Skip to content

Commit 1085db4

Browse files
committed
Merge tag 'f2fs-for-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs update from Jaegeuk Kim: "[Major bug fixes] o Store device file information correctly o Fix -EIO handling with respect to power-off-recovery o Allocate blocks with global locks o Fix wrong calculation of the SSR cost [Cleanups] o Get rid of fake on-stack dentries [Enhancement] o Support (un)freeze_fs o Enhance the f2fs_gc flow o Support 32-bit binary execution on 64-bit kernel" * tag 'f2fs-for-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (29 commits) f2fs: avoid build warning f2fs: add compat_ioctl to provide backward compatability f2fs: fix calculation of max. gc cost in the SSR case f2fs: clarify and enhance the f2fs_gc flow f2fs: optimize the return condition for has_not_enough_free_secs f2fs: make an accessor to get sections for particular block type f2fs: mark gc_thread as NULL when thread creation is failed f2fs: name gc task as per the block device f2fs: remove unnecessary gc option check and balance_fs f2fs: remove repeated F2FS_SET_SB_DIRT call f2fs: when check superblock failed, try to check another superblock f2fs: use F2FS_BLKSIZE to judge bloksize and page_cache_size f2fs: add device name in debugfs f2fs: stop repeated checking if cp is needed f2fs: avoid balanc_fs during evict_inode f2fs: remove the use of page_cache_release f2fs: fix typo mistake for data_version description f2fs: reorganize code for ra_node_page f2fs: avoid redundant call to has_not_enough_free_secs in f2fs_gc f2fs: add un/freeze_fs into super_operations ...
2 parents 3c834b6 + 7dd690c commit 1085db4

13 files changed

Lines changed: 292 additions & 261 deletions

File tree

‎fs/f2fs/checkpoint.c‎

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,22 @@ static int f2fs_write_meta_page(struct page *page,
7272
{
7373
struct inode *inode = page->mapping->host;
7474
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
75-
int err;
7675

77-
wait_on_page_writeback(page);
78-
79-
err = write_meta_page(sbi, page, wbc);
80-
if (err) {
76+
/* Should not write any meta pages, if any IO error was occurred */
77+
if (wbc->for_reclaim ||
78+
is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)) {
79+
dec_page_count(sbi, F2FS_DIRTY_META);
8180
wbc->pages_skipped++;
8281
set_page_dirty(page);
82+
return AOP_WRITEPAGE_ACTIVATE;
8383
}
8484

85-
dec_page_count(sbi, F2FS_DIRTY_META);
85+
wait_on_page_writeback(page);
8686

87-
/* In this case, we should not unlock this page */
88-
if (err != AOP_WRITEPAGE_ACTIVATE)
89-
unlock_page(page);
90-
return err;
87+
write_meta_page(sbi, page);
88+
dec_page_count(sbi, F2FS_DIRTY_META);
89+
unlock_page(page);
90+
return 0;
9191
}
9292

9393
static int f2fs_write_meta_pages(struct address_space *mapping,
@@ -138,7 +138,10 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
138138
BUG_ON(page->mapping != mapping);
139139
BUG_ON(!PageDirty(page));
140140
clear_page_dirty_for_io(page);
141-
f2fs_write_meta_page(page, &wbc);
141+
if (f2fs_write_meta_page(page, &wbc)) {
142+
unlock_page(page);
143+
break;
144+
}
142145
if (nwritten++ >= nr_to_write)
143146
break;
144147
}
@@ -161,7 +164,6 @@ static int f2fs_set_meta_page_dirty(struct page *page)
161164
if (!PageDirty(page)) {
162165
__set_page_dirty_nobuffers(page);
163166
inc_page_count(sbi, F2FS_DIRTY_META);
164-
F2FS_SET_SB_DIRT(sbi);
165167
return 1;
166168
}
167169
return 0;
@@ -216,19 +218,11 @@ void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
216218
new->ino = ino;
217219

218220
/* add new_oentry into list which is sorted by inode number */
219-
if (orphan) {
220-
struct orphan_inode_entry *prev;
221-
222-
/* get previous entry */
223-
prev = list_entry(orphan->list.prev, typeof(*prev), list);
224-
if (&prev->list != head)
225-
/* insert new orphan inode entry */
226-
list_add(&new->list, &prev->list);
227-
else
228-
list_add(&new->list, head);
229-
} else {
221+
if (orphan)
222+
list_add(&new->list, this->prev);
223+
else
230224
list_add_tail(&new->list, head);
231-
}
225+
232226
sbi->n_orphans++;
233227
out:
234228
mutex_unlock(&sbi->orphan_inode_mutex);
@@ -545,7 +539,7 @@ void sync_dirty_dir_inodes(struct f2fs_sb_info *sbi)
545539
/*
546540
* Freeze all the FS-operations for checkpoint.
547541
*/
548-
void block_operations(struct f2fs_sb_info *sbi)
542+
static void block_operations(struct f2fs_sb_info *sbi)
549543
{
550544
int t;
551545
struct writeback_control wbc = {
@@ -717,27 +711,24 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
717711
sbi->alloc_valid_block_count = 0;
718712

719713
/* Here, we only have one bio having CP pack */
720-
if (is_set_ckpt_flags(ckpt, CP_ERROR_FLAG))
721-
sbi->sb->s_flags |= MS_RDONLY;
722-
else
723-
sync_meta_pages(sbi, META_FLUSH, LONG_MAX);
714+
sync_meta_pages(sbi, META_FLUSH, LONG_MAX);
724715

725-
clear_prefree_segments(sbi);
726-
F2FS_RESET_SB_DIRT(sbi);
716+
if (!is_set_ckpt_flags(ckpt, CP_ERROR_FLAG)) {
717+
clear_prefree_segments(sbi);
718+
F2FS_RESET_SB_DIRT(sbi);
719+
}
727720
}
728721

729722
/*
730723
* We guarantee that this checkpoint procedure should not fail.
731724
*/
732-
void write_checkpoint(struct f2fs_sb_info *sbi, bool blocked, bool is_umount)
725+
void write_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
733726
{
734727
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
735728
unsigned long long ckpt_ver;
736729

737-
if (!blocked) {
738-
mutex_lock(&sbi->cp_mutex);
739-
block_operations(sbi);
740-
}
730+
mutex_lock(&sbi->cp_mutex);
731+
block_operations(sbi);
741732

742733
f2fs_submit_bio(sbi, DATA, true);
743734
f2fs_submit_bio(sbi, NODE, true);

‎fs/f2fs/debug.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@ static int stat_show(struct seq_file *s, void *v)
183183

184184
mutex_lock(&f2fs_stat_mutex);
185185
list_for_each_entry_safe(si, next, &f2fs_stat_list, stat_list) {
186+
char devname[BDEVNAME_SIZE];
186187

187188
update_general_status(si->sbi);
188189

189-
seq_printf(s, "\n=====[ partition info. #%d ]=====\n", i++);
190+
seq_printf(s, "\n=====[ partition info(%s). #%d ]=====\n",
191+
bdevname(si->sbi->sb->s_bdev, devname), i++);
190192
seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ",
191193
si->sit_area_segs, si->nat_area_segs);
192194
seq_printf(s, "[SSA: %d] [MAIN: %d",

‎fs/f2fs/dir.c‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
265265
mutex_unlock_op(sbi, DENTRY_OPS);
266266
}
267267

268-
void init_dent_inode(struct dentry *dentry, struct page *ipage)
268+
void init_dent_inode(const struct qstr *name, struct page *ipage)
269269
{
270270
struct f2fs_node *rn;
271271

@@ -274,20 +274,19 @@ void init_dent_inode(struct dentry *dentry, struct page *ipage)
274274

275275
wait_on_page_writeback(ipage);
276276

277-
/* copy dentry info. to this inode page */
277+
/* copy name info. to this inode page */
278278
rn = (struct f2fs_node *)page_address(ipage);
279-
rn->i.i_namelen = cpu_to_le32(dentry->d_name.len);
280-
memcpy(rn->i.i_name, dentry->d_name.name, dentry->d_name.len);
279+
rn->i.i_namelen = cpu_to_le32(name->len);
280+
memcpy(rn->i.i_name, name->name, name->len);
281281
set_page_dirty(ipage);
282282
}
283283

284-
static int init_inode_metadata(struct inode *inode, struct dentry *dentry)
284+
static int init_inode_metadata(struct inode *inode,
285+
struct inode *dir, const struct qstr *name)
285286
{
286-
struct inode *dir = dentry->d_parent->d_inode;
287-
288287
if (is_inode_flag_set(F2FS_I(inode), FI_NEW_INODE)) {
289288
int err;
290-
err = new_inode_page(inode, dentry);
289+
err = new_inode_page(inode, name);
291290
if (err)
292291
return err;
293292

@@ -310,7 +309,7 @@ static int init_inode_metadata(struct inode *inode, struct dentry *dentry)
310309
if (IS_ERR(ipage))
311310
return PTR_ERR(ipage);
312311
set_cold_node(inode, ipage);
313-
init_dent_inode(dentry, ipage);
312+
init_dent_inode(name, ipage);
314313
f2fs_put_page(ipage, 1);
315314
}
316315
if (is_inode_flag_set(F2FS_I(inode), FI_INC_LINK)) {
@@ -371,7 +370,7 @@ static int room_for_filename(struct f2fs_dentry_block *dentry_blk, int slots)
371370
goto next;
372371
}
373372

374-
int f2fs_add_link(struct dentry *dentry, struct inode *inode)
373+
int __f2fs_add_link(struct inode *dir, const struct qstr *name, struct inode *inode)
375374
{
376375
unsigned int bit_pos;
377376
unsigned int level;
@@ -380,17 +379,15 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
380379
f2fs_hash_t dentry_hash;
381380
struct f2fs_dir_entry *de;
382381
unsigned int nbucket, nblock;
383-
struct inode *dir = dentry->d_parent->d_inode;
384382
struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
385-
const char *name = dentry->d_name.name;
386-
size_t namelen = dentry->d_name.len;
383+
size_t namelen = name->len;
387384
struct page *dentry_page = NULL;
388385
struct f2fs_dentry_block *dentry_blk = NULL;
389386
int slots = GET_DENTRY_SLOTS(namelen);
390387
int err = 0;
391388
int i;
392389

393-
dentry_hash = f2fs_dentry_hash(name, dentry->d_name.len);
390+
dentry_hash = f2fs_dentry_hash(name->name, name->len);
394391
level = 0;
395392
current_depth = F2FS_I(dir)->i_current_depth;
396393
if (F2FS_I(dir)->chash == dentry_hash) {
@@ -433,7 +430,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
433430
++level;
434431
goto start;
435432
add_dentry:
436-
err = init_inode_metadata(inode, dentry);
433+
err = init_inode_metadata(inode, dir, name);
437434
if (err)
438435
goto fail;
439436

@@ -442,7 +439,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
442439
de = &dentry_blk->dentry[bit_pos];
443440
de->hash_code = dentry_hash;
444441
de->name_len = cpu_to_le16(namelen);
445-
memcpy(dentry_blk->filename[bit_pos], name, namelen);
442+
memcpy(dentry_blk->filename[bit_pos], name->name, name->len);
446443
de->ino = cpu_to_le32(inode->i_ino);
447444
set_de_type(de, inode);
448445
for (i = 0; i < slots; i++)

‎fs/f2fs/f2fs.h‎

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i)
103103
return before;
104104
}
105105

106+
/*
107+
* ioctl commands
108+
*/
109+
#define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS
110+
#define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS
111+
112+
#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
113+
/*
114+
* ioctl commands in 32 bit emulation
115+
*/
116+
#define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS
117+
#define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS
118+
#endif
119+
106120
/*
107121
* For INODE and NODE manager
108122
*/
@@ -141,7 +155,7 @@ struct f2fs_inode_info {
141155

142156
/* Use below internally in f2fs*/
143157
unsigned long flags; /* use to pass per-file flags */
144-
unsigned long long data_version;/* lastes version of data for fsync */
158+
unsigned long long data_version;/* latest version of data for fsync */
145159
atomic_t dirty_dents; /* # of dirty dentry pages */
146160
f2fs_hash_t chash; /* hash value of given file name */
147161
unsigned int clevel; /* maximum level of given file name */
@@ -573,6 +587,14 @@ static inline int get_pages(struct f2fs_sb_info *sbi, int count_type)
573587
return atomic_read(&sbi->nr_pages[count_type]);
574588
}
575589

590+
static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
591+
{
592+
unsigned int pages_per_sec = sbi->segs_per_sec *
593+
(1 << sbi->log_blocks_per_seg);
594+
return ((get_pages(sbi, block_type) + pages_per_sec - 1)
595+
>> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
596+
}
597+
576598
static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi)
577599
{
578600
block_t ret;
@@ -842,12 +864,12 @@ void f2fs_truncate(struct inode *);
842864
int f2fs_setattr(struct dentry *, struct iattr *);
843865
int truncate_hole(struct inode *, pgoff_t, pgoff_t);
844866
long f2fs_ioctl(struct file *, unsigned int, unsigned long);
867+
long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
845868

846869
/*
847870
* inode.c
848871
*/
849872
void f2fs_set_inode_flags(struct inode *);
850-
struct inode *f2fs_iget_nowait(struct super_block *, unsigned long);
851873
struct inode *f2fs_iget(struct super_block *, unsigned long);
852874
void update_inode(struct inode *, struct page *);
853875
int f2fs_write_inode(struct inode *, struct writeback_control *);
@@ -867,12 +889,18 @@ struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
867889
ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
868890
void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
869891
struct page *, struct inode *);
870-
void init_dent_inode(struct dentry *, struct page *);
871-
int f2fs_add_link(struct dentry *, struct inode *);
892+
void init_dent_inode(const struct qstr *, struct page *);
893+
int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
872894
void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *);
873895
int f2fs_make_empty(struct inode *, struct inode *);
874896
bool f2fs_empty_dir(struct inode *);
875897

898+
static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
899+
{
900+
return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name,
901+
inode);
902+
}
903+
876904
/*
877905
* super.c
878906
*/
@@ -896,7 +924,7 @@ void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
896924
int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int);
897925
int truncate_inode_blocks(struct inode *, pgoff_t);
898926
int remove_inode_page(struct inode *);
899-
int new_inode_page(struct inode *, struct dentry *);
927+
int new_inode_page(struct inode *, const struct qstr *);
900928
struct page *new_node_page(struct dnode_of_data *, unsigned int);
901929
void ra_node_page(struct f2fs_sb_info *, nid_t);
902930
struct page *get_node_page(struct f2fs_sb_info *, pgoff_t);
@@ -929,8 +957,7 @@ void allocate_new_segments(struct f2fs_sb_info *);
929957
struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
930958
struct bio *f2fs_bio_alloc(struct block_device *, int);
931959
void f2fs_submit_bio(struct f2fs_sb_info *, enum page_type, bool sync);
932-
int write_meta_page(struct f2fs_sb_info *, struct page *,
933-
struct writeback_control *);
960+
void write_meta_page(struct f2fs_sb_info *, struct page *);
934961
void write_node_page(struct f2fs_sb_info *, struct page *, unsigned int,
935962
block_t, block_t *);
936963
void write_data_page(struct inode *, struct page *, struct dnode_of_data*,
@@ -963,8 +990,7 @@ int get_valid_checkpoint(struct f2fs_sb_info *);
963990
void set_dirty_dir_page(struct inode *, struct page *);
964991
void remove_dirty_dir_inode(struct inode *);
965992
void sync_dirty_dir_inodes(struct f2fs_sb_info *);
966-
void block_operations(struct f2fs_sb_info *);
967-
void write_checkpoint(struct f2fs_sb_info *, bool, bool);
993+
void write_checkpoint(struct f2fs_sb_info *, bool);
968994
void init_orphan_info(struct f2fs_sb_info *);
969995
int __init create_checkpoint_caches(void);
970996
void destroy_checkpoint_caches(void);

0 commit comments

Comments
 (0)