aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs/balloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ufs/balloc.c')
-rw-r--r--fs/ufs/balloc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index b82381475779..2e0021e8f366 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -275,6 +275,25 @@ static void ufs_change_blocknr(struct inode *inode, unsigned int baseblk,
275 UFSD("EXIT\n"); 275 UFSD("EXIT\n");
276} 276}
277 277
278static void ufs_clear_frags(struct inode *inode, sector_t beg, unsigned int n,
279 int sync)
280{
281 struct buffer_head *bh;
282 sector_t end = beg + n;
283
284 for (; beg < end; ++beg) {
285 bh = sb_getblk(inode->i_sb, beg);
286 lock_buffer(bh);
287 memset(bh->b_data, 0, inode->i_sb->s_blocksize);
288 set_buffer_uptodate(bh);
289 mark_buffer_dirty(bh);
290 unlock_buffer(bh);
291 if (IS_SYNC(inode) || sync)
292 sync_dirty_buffer(bh);
293 brelse(bh);
294 }
295}
296
278unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, 297unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
279 unsigned goal, unsigned count, int * err, struct page *locked_page) 298 unsigned goal, unsigned count, int * err, struct page *locked_page)
280{ 299{
@@ -350,6 +369,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
350 *p = cpu_to_fs32(sb, result); 369 *p = cpu_to_fs32(sb, result);
351 *err = 0; 370 *err = 0;
352 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 371 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
372 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
373 locked_page != NULL);
353 } 374 }
354 unlock_super(sb); 375 unlock_super(sb);
355 UFSD("EXIT, result %u\n", result); 376 UFSD("EXIT, result %u\n", result);
@@ -363,6 +384,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
363 if (result) { 384 if (result) {
364 *err = 0; 385 *err = 0;
365 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 386 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
387 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
388 locked_page != NULL);
366 unlock_super(sb); 389 unlock_super(sb);
367 UFSD("EXIT, result %u\n", result); 390 UFSD("EXIT, result %u\n", result);
368 return result; 391 return result;
@@ -398,6 +421,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
398 *p = cpu_to_fs32(sb, result); 421 *p = cpu_to_fs32(sb, result);
399 *err = 0; 422 *err = 0;
400 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 423 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
424 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
425 locked_page != NULL);
401 unlock_super(sb); 426 unlock_super(sb);
402 if (newcount < request) 427 if (newcount < request)
403 ufs_free_fragments (inode, result + newcount, request - newcount); 428 ufs_free_fragments (inode, result + newcount, request - newcount);