2013/1/10, Jaegeuk Kim <jaegeuk.kim@xxxxxxxxxxx>: > The f2fs_balance_fs() is to check the number of free sections and decide > whether > it needs to conduct cleaning or not. If there are not enough free sections, > the > cleaning job should be started. > > In order to control an amount of free sections even under high utilization, > f2fs > should call f2fs_balance_fs at all the VFS interfaces that are able to > produce > dirty pages. > This patch adds the function calls in the missing interfaces as follows. > > 1. f2fs_setxattr() > The f2fs_setxattr() produces dirty node pages so that we should call > f2fs_balance_fs() either likewise doing in other VFS interfaces such as > f2fs_lookup(), f2fs_mkdir(), and so on. > > 2. f2fs_sync_file() > We should guarantee serving free sections for syncing metadata during > fsync. > Previously, there is no space check before triggering checkpoint and > sync_node_pages. > Therefore, if a bunch of fsync calls are triggered under 100% of FS > utilization, > f2fs is able to be faced with no free sections, resulting in BUG_ON(). > > 3. f2fs_sync_fs() > Before calling write_checkpoint(), we should guarantee that there are > minimum > free sections. Hi Jaegeuk. There is no need to add f2fs_balance_fs in f2fs_fallocate also ? Thanks. > > Signed-off-by: Jaegeuk Kim <jaegeuk.kim@xxxxxxxxxxx> > --- > fs/f2fs/file.c | 3 +++ > fs/f2fs/super.c | 2 ++ > fs/f2fs/xattr.c | 2 ++ > 3 files changed, 7 insertions(+) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 88593c5..7354c2d 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -137,6 +137,9 @@ int f2fs_sync_file(struct file *file, loff_t start, > loff_t end, int datasync) > if (ret) > return ret; > > + /* guarantee free sections for fsync */ > + f2fs_balance_fs(sbi); > + > mutex_lock(&inode->i_mutex); > > if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index afa7ef0..0f2b2eb 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -137,6 +137,8 @@ int f2fs_sync_fs(struct super_block *sb, int sync) > > if (sync) > write_checkpoint(sbi, false, false); > + else > + f2fs_balance_fs(sbi); > > return 0; > } > diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c > index 940136a..8038c04 100644 > --- a/fs/f2fs/xattr.c > +++ b/fs/f2fs/xattr.c > @@ -318,6 +318,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, > const char *name, > if (name_len > 255 || value_len > MAX_VALUE_LEN) > return -ERANGE; > > + f2fs_balance_fs(sbi); > + > mutex_lock_op(sbi, NODE_NEW); > if (!fi->i_xattr_nid) { > /* Allocate new attribute block */ > -- > 1.8.0.1.250.gb7973fb > > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html