diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-05-31 19:26:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-31 20:49:28 -0400 |
commit | 330fe3c4c6509e0418c434b5bcf80e65cffab477 (patch) | |
tree | f170e47fa9fd25bad3a5ce6996fdfbd86daa3706 /fs/fat | |
parent | 90b436657efb1a6d73bf0677fedee8a8c77032f6 (diff) |
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>
Diffstat (limited to 'fs/fat')
-rw-r--r-- | fs/fat/fatent.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index e49d27463b67..81815487e04d 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c | |||
@@ -503,7 +503,6 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) | |||
503 | sbi->prev_free = entry; | 503 | sbi->prev_free = entry; |
504 | if (sbi->free_clusters != -1) | 504 | if (sbi->free_clusters != -1) |
505 | sbi->free_clusters--; | 505 | sbi->free_clusters--; |
506 | mark_fsinfo_dirty(sb); | ||
507 | 506 | ||
508 | cluster[idx_clus] = entry; | 507 | cluster[idx_clus] = entry; |
509 | idx_clus++; | 508 | idx_clus++; |
@@ -525,11 +524,11 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) | |||
525 | /* Couldn't allocate the free entries */ | 524 | /* Couldn't allocate the free entries */ |
526 | sbi->free_clusters = 0; | 525 | sbi->free_clusters = 0; |
527 | sbi->free_clus_valid = 1; | 526 | sbi->free_clus_valid = 1; |
528 | mark_fsinfo_dirty(sb); | ||
529 | err = -ENOSPC; | 527 | err = -ENOSPC; |
530 | 528 | ||
531 | out: | 529 | out: |
532 | unlock_fat(sbi); | 530 | unlock_fat(sbi); |
531 | mark_fsinfo_dirty(sb); | ||
533 | fatent_brelse(&fatent); | 532 | fatent_brelse(&fatent); |
534 | if (!err) { | 533 | if (!err) { |
535 | if (inode_needs_sync(inode)) | 534 | if (inode_needs_sync(inode)) |
@@ -554,7 +553,7 @@ int fat_free_clusters(struct inode *inode, int cluster) | |||
554 | struct fat_entry fatent; | 553 | struct fat_entry fatent; |
555 | struct buffer_head *bhs[MAX_BUF_PER_PAGE]; | 554 | struct buffer_head *bhs[MAX_BUF_PER_PAGE]; |
556 | int i, err, nr_bhs; | 555 | int i, err, nr_bhs; |
557 | int first_cl = cluster; | 556 | int first_cl = cluster, dirty_fsinfo = 0; |
558 | 557 | ||
559 | nr_bhs = 0; | 558 | nr_bhs = 0; |
560 | fatent_init(&fatent); | 559 | fatent_init(&fatent); |
@@ -592,7 +591,7 @@ int fat_free_clusters(struct inode *inode, int cluster) | |||
592 | ops->ent_put(&fatent, FAT_ENT_FREE); | 591 | ops->ent_put(&fatent, FAT_ENT_FREE); |
593 | if (sbi->free_clusters != -1) { | 592 | if (sbi->free_clusters != -1) { |
594 | sbi->free_clusters++; | 593 | sbi->free_clusters++; |
595 | mark_fsinfo_dirty(sb); | 594 | dirty_fsinfo = 1; |
596 | } | 595 | } |
597 | 596 | ||
598 | if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) { | 597 | if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) { |
@@ -622,6 +621,8 @@ error: | |||
622 | for (i = 0; i < nr_bhs; i++) | 621 | for (i = 0; i < nr_bhs; i++) |
623 | brelse(bhs[i]); | 622 | brelse(bhs[i]); |
624 | unlock_fat(sbi); | 623 | unlock_fat(sbi); |
624 | if (dirty_fsinfo) | ||
625 | mark_fsinfo_dirty(sb); | ||
625 | 626 | ||
626 | return err; | 627 | return err; |
627 | } | 628 | } |