Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fat: mark superblock as dirty less often

Preparation for further changes. It touches few functions in fatent.c and
prevents them from marking the superblock as dirty unnecessarily often.
Namely, instead of marking it as dirty in the internal tight loops - do it
only once at the end of the functions. And instead of marking it as dirty
while holding the FAT table lock, do it outside the lock.

The reason for this patch is that marking the superblock as dirty will
soon become a little bit heavier operation, so it is cleaner to do this
only when it is necessary.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Artem Bityutskiy and committed by
Linus Torvalds
330fe3c4 90b43665

+5 -4
+5 -4
fs/fat/fatent.c
··· 503 503 sbi->prev_free = entry; 504 504 if (sbi->free_clusters != -1) 505 505 sbi->free_clusters--; 506 - mark_fsinfo_dirty(sb); 507 506 508 507 cluster[idx_clus] = entry; 509 508 idx_clus++; ··· 524 525 /* Couldn't allocate the free entries */ 525 526 sbi->free_clusters = 0; 526 527 sbi->free_clus_valid = 1; 527 - mark_fsinfo_dirty(sb); 528 528 err = -ENOSPC; 529 529 530 530 out: 531 531 unlock_fat(sbi); 532 + mark_fsinfo_dirty(sb); 532 533 fatent_brelse(&fatent); 533 534 if (!err) { 534 535 if (inode_needs_sync(inode)) ··· 553 554 struct fat_entry fatent; 554 555 struct buffer_head *bhs[MAX_BUF_PER_PAGE]; 555 556 int i, err, nr_bhs; 556 - int first_cl = cluster; 557 + int first_cl = cluster, dirty_fsinfo = 0; 557 558 558 559 nr_bhs = 0; 559 560 fatent_init(&fatent); ··· 591 592 ops->ent_put(&fatent, FAT_ENT_FREE); 592 593 if (sbi->free_clusters != -1) { 593 594 sbi->free_clusters++; 594 - mark_fsinfo_dirty(sb); 595 + dirty_fsinfo = 1; 595 596 } 596 597 597 598 if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) { ··· 621 622 for (i = 0; i < nr_bhs; i++) 622 623 brelse(bhs[i]); 623 624 unlock_fat(sbi); 625 + if (dirty_fsinfo) 626 + mark_fsinfo_dirty(sb); 624 627 625 628 return err; 626 629 }