]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
fat: Fix fat_ent_update_ptr() for FAT12
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Thu, 6 Nov 2008 20:53:49 +0000 (12:53 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Nov 2008 23:41:20 +0000 (15:41 -0800)
This fixes the missing update for bhs/nr_bhs in case the caller
accessed from block boundary to first block of boundary.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/fat/fatent.c

index 5b5f49061b7c7ccbfe76eea416475fc691936346..13513992da3cce40de0afa6a281f66b27e260a3d 100644 (file)
@@ -317,10 +317,20 @@ static inline int fat_ent_update_ptr(struct super_block *sb,
        /* Is this fatent's blocks including this entry? */
        if (!fatent->nr_bhs || bhs[0]->b_blocknr != blocknr)
                return 0;
-       /* Does this entry need the next block? */
-       if (sbi->fat_bits == 12 && (offset + 1) >= sb->s_blocksize) {
-               if (fatent->nr_bhs != 2 || bhs[1]->b_blocknr != (blocknr + 1))
-                       return 0;
+       if (sbi->fat_bits == 12) {
+               if ((offset + 1) < sb->s_blocksize) {
+                       /* This entry is on bhs[0]. */
+                       if (fatent->nr_bhs == 2) {
+                               brelse(bhs[1]);
+                               fatent->nr_bhs = 1;
+                       }
+               } else {
+                       /* This entry needs the next block. */
+                       if (fatent->nr_bhs != 2)
+                               return 0;
+                       if (bhs[1]->b_blocknr != (blocknr + 1))
+                               return 0;
+               }
        }
        ops->ent_set_ptr(fatent, offset);
        return 1;