diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2012-12-19 02:25:21 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2012-12-25 20:39:52 -0500 |
commit | 1efef832020ef392deb2cd3d74e0c316711245be (patch) | |
tree | f9b777202cb0cca945c42aa4aec0ffe0743776ab /fs | |
parent | 30f0c75858c46a0273ccb838de401b1f5fdebe6f (diff) |
f2fs: do f2fs_balance_fs in front of dir operations
In order to conserve free sections to deal with the worst-case scenarios, f2fs
should be able to freeze all the directory operations especially when there are
not enough free sections. The f2fs_balance_fs() is for this use.
When FS utilization becomes almost 100%, directory operations can be failed due
to -ENOSPC frequently, which produces some dirty node pages occasionally.
Previously, in such a case, f2fs_balance_fs() is not able to be triggered since
it is triggered only if the directory operation ends up with success.
So, this patch triggers f2fs_balance_fs() at first before handling directory
operations.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/f2fs/namei.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 89b7675dc377..b42389f80011 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c | |||
@@ -123,6 +123,8 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, | |||
123 | nid_t ino = 0; | 123 | nid_t ino = 0; |
124 | int err; | 124 | int err; |
125 | 125 | ||
126 | f2fs_balance_fs(sbi); | ||
127 | |||
126 | inode = f2fs_new_inode(dir, mode); | 128 | inode = f2fs_new_inode(dir, mode); |
127 | if (IS_ERR(inode)) | 129 | if (IS_ERR(inode)) |
128 | return PTR_ERR(inode); | 130 | return PTR_ERR(inode); |
@@ -144,8 +146,6 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, | |||
144 | if (!sbi->por_doing) | 146 | if (!sbi->por_doing) |
145 | d_instantiate(dentry, inode); | 147 | d_instantiate(dentry, inode); |
146 | unlock_new_inode(inode); | 148 | unlock_new_inode(inode); |
147 | |||
148 | f2fs_balance_fs(sbi); | ||
149 | return 0; | 149 | return 0; |
150 | out: | 150 | out: |
151 | clear_nlink(inode); | 151 | clear_nlink(inode); |
@@ -163,6 +163,8 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir, | |||
163 | struct f2fs_sb_info *sbi = F2FS_SB(sb); | 163 | struct f2fs_sb_info *sbi = F2FS_SB(sb); |
164 | int err; | 164 | int err; |
165 | 165 | ||
166 | f2fs_balance_fs(sbi); | ||
167 | |||
166 | inode->i_ctime = CURRENT_TIME; | 168 | inode->i_ctime = CURRENT_TIME; |
167 | atomic_inc(&inode->i_count); | 169 | atomic_inc(&inode->i_count); |
168 | 170 | ||
@@ -172,8 +174,6 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir, | |||
172 | goto out; | 174 | goto out; |
173 | 175 | ||
174 | d_instantiate(dentry, inode); | 176 | d_instantiate(dentry, inode); |
175 | |||
176 | f2fs_balance_fs(sbi); | ||
177 | return 0; | 177 | return 0; |
178 | out: | 178 | out: |
179 | clear_inode_flag(F2FS_I(inode), FI_INC_LINK); | 179 | clear_inode_flag(F2FS_I(inode), FI_INC_LINK); |
@@ -223,6 +223,8 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) | |||
223 | struct page *page; | 223 | struct page *page; |
224 | int err = -ENOENT; | 224 | int err = -ENOENT; |
225 | 225 | ||
226 | f2fs_balance_fs(sbi); | ||
227 | |||
226 | de = f2fs_find_entry(dir, &dentry->d_name, &page); | 228 | de = f2fs_find_entry(dir, &dentry->d_name, &page); |
227 | if (!de) | 229 | if (!de) |
228 | goto fail; | 230 | goto fail; |
@@ -238,7 +240,6 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) | |||
238 | 240 | ||
239 | /* In order to evict this inode, we set it dirty */ | 241 | /* In order to evict this inode, we set it dirty */ |
240 | mark_inode_dirty(inode); | 242 | mark_inode_dirty(inode); |
241 | f2fs_balance_fs(sbi); | ||
242 | fail: | 243 | fail: |
243 | return err; | 244 | return err; |
244 | } | 245 | } |
@@ -252,6 +253,8 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, | |||
252 | unsigned symlen = strlen(symname) + 1; | 253 | unsigned symlen = strlen(symname) + 1; |
253 | int err; | 254 | int err; |
254 | 255 | ||
256 | f2fs_balance_fs(sbi); | ||
257 | |||
255 | inode = f2fs_new_inode(dir, S_IFLNK | S_IRWXUGO); | 258 | inode = f2fs_new_inode(dir, S_IFLNK | S_IRWXUGO); |
256 | if (IS_ERR(inode)) | 259 | if (IS_ERR(inode)) |
257 | return PTR_ERR(inode); | 260 | return PTR_ERR(inode); |
@@ -268,9 +271,6 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, | |||
268 | 271 | ||
269 | d_instantiate(dentry, inode); | 272 | d_instantiate(dentry, inode); |
270 | unlock_new_inode(inode); | 273 | unlock_new_inode(inode); |
271 | |||
272 | f2fs_balance_fs(sbi); | ||
273 | |||
274 | return err; | 274 | return err; |
275 | out: | 275 | out: |
276 | clear_nlink(inode); | 276 | clear_nlink(inode); |
@@ -286,6 +286,8 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
286 | struct inode *inode; | 286 | struct inode *inode; |
287 | int err; | 287 | int err; |
288 | 288 | ||
289 | f2fs_balance_fs(sbi); | ||
290 | |||
289 | inode = f2fs_new_inode(dir, S_IFDIR | mode); | 291 | inode = f2fs_new_inode(dir, S_IFDIR | mode); |
290 | if (IS_ERR(inode)) | 292 | if (IS_ERR(inode)) |
291 | return PTR_ERR(inode); | 293 | return PTR_ERR(inode); |
@@ -305,7 +307,6 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
305 | d_instantiate(dentry, inode); | 307 | d_instantiate(dentry, inode); |
306 | unlock_new_inode(inode); | 308 | unlock_new_inode(inode); |
307 | 309 | ||
308 | f2fs_balance_fs(sbi); | ||
309 | return 0; | 310 | return 0; |
310 | 311 | ||
311 | out_fail: | 312 | out_fail: |
@@ -336,6 +337,8 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry, | |||
336 | if (!new_valid_dev(rdev)) | 337 | if (!new_valid_dev(rdev)) |
337 | return -EINVAL; | 338 | return -EINVAL; |
338 | 339 | ||
340 | f2fs_balance_fs(sbi); | ||
341 | |||
339 | inode = f2fs_new_inode(dir, mode); | 342 | inode = f2fs_new_inode(dir, mode); |
340 | if (IS_ERR(inode)) | 343 | if (IS_ERR(inode)) |
341 | return PTR_ERR(inode); | 344 | return PTR_ERR(inode); |
@@ -350,9 +353,6 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry, | |||
350 | alloc_nid_done(sbi, inode->i_ino); | 353 | alloc_nid_done(sbi, inode->i_ino); |
351 | d_instantiate(dentry, inode); | 354 | d_instantiate(dentry, inode); |
352 | unlock_new_inode(inode); | 355 | unlock_new_inode(inode); |
353 | |||
354 | f2fs_balance_fs(sbi); | ||
355 | |||
356 | return 0; | 356 | return 0; |
357 | out: | 357 | out: |
358 | clear_nlink(inode); | 358 | clear_nlink(inode); |
@@ -376,6 +376,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
376 | struct f2fs_dir_entry *new_entry; | 376 | struct f2fs_dir_entry *new_entry; |
377 | int err = -ENOENT; | 377 | int err = -ENOENT; |
378 | 378 | ||
379 | f2fs_balance_fs(sbi); | ||
380 | |||
379 | old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page); | 381 | old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page); |
380 | if (!old_entry) | 382 | if (!old_entry) |
381 | goto out; | 383 | goto out; |
@@ -441,8 +443,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
441 | } | 443 | } |
442 | 444 | ||
443 | mutex_unlock_op(sbi, RENAME); | 445 | mutex_unlock_op(sbi, RENAME); |
444 | |||
445 | f2fs_balance_fs(sbi); | ||
446 | return 0; | 446 | return 0; |
447 | 447 | ||
448 | out_dir: | 448 | out_dir: |