public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: steve@digidescorp.com
To: hirofumi@mail.parknet.co.jp, linux-kernel@vger.kernel.org
Cc: "Steven J. Magnani" <steve@digidescorp.com>
Subject: [PATCH] FAT: optimize FSINFO writeback
Date: Tue, 30 Jun 2009 15:02:10 -0500	[thread overview]
Message-ID: <1246392130-4261-1-git-send-email-steve@digidescorp.com> (raw)

Only write the FSINFO block back to disk when its contents change.
This optimization can be important when the underlying physical media
can wear out, i.e. Flash.

Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
---
diff -uprN a/fs/fat/misc.c b/fs/fat/misc.c
--- a/fs/fat/misc.c	2009-06-29 11:12:40.000000000 -0500
+++ b/fs/fat/misc.c	2009-06-29 11:46:45.000000000 -0500
@@ -61,11 +61,25 @@ void fat_clusters_flush(struct super_blo
 		       le32_to_cpu(fsinfo->signature2),
 		       sbi->fsinfo_sector);
 	} else {
-		if (sbi->free_clusters != -1)
-			fsinfo->free_clusters = cpu_to_le32(sbi->free_clusters);
-		if (sbi->prev_free != -1)
-			fsinfo->next_cluster = cpu_to_le32(sbi->prev_free);
-		mark_buffer_dirty(bh);
+		char write_needed = 0;
+		__le32 le_value;
+
+		if (sbi->free_clusters != -1) {
+			le_value = cpu_to_le32(sbi->free_clusters);
+			if (fsinfo->free_clusters != le_value) {
+				fsinfo->free_clusters = le_value;
+				write_needed = 1;
+			}
+		}
+		if (sbi->prev_free != -1) {
+			le_value = cpu_to_le32(sbi->prev_free);
+			if (fsinfo->next_cluster != le_value) {
+				fsinfo->next_cluster = le_value;
+				write_needed = 1;
+			}
+		}
+		if (write_needed)
+			mark_buffer_dirty(bh);
 	}
 	brelse(bh);
 }


             reply	other threads:[~2009-06-30 20:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-30 20:02 steve [this message]
2009-06-30 20:57 ` [PATCH] FAT: optimize FSINFO writeback OGAWA Hirofumi
2009-06-30 22:19   ` Steven J. Magnani
2009-07-01  0:28     ` OGAWA Hirofumi
2009-07-01 13:07       ` Steven J. Magnani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1246392130-4261-1-git-send-email-steve@digidescorp.com \
    --to=steve@digidescorp.com \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox