aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2013-04-29 19:21:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:40 -0400
commite22a444275d1e7c80db5d8bec08fb8d0d79617ad (patch)
treeb69291b4b24a733f6d5ec6178e1cc9059e5dc5bf /fs/fat
parentf21735d5873ad6c0d71fc15ebbbeda9ef445009b (diff)
fat: introduce a helper fat_get_blknr_offset()
Introduce helper function to get the block number and offset for a given i_pos value. Use it in __fat_write_inode() now and later on in nfs.c Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Ravishankar N <ravi.n1@samsung.com> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com> Acked-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>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/fat.h7
-rw-r--r--fs/fat/inode.c9
2 files changed, 12 insertions, 4 deletions
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index f16948ed5bf8..980c0346c168 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -218,6 +218,13 @@ static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus)
218 + sbi->data_start; 218 + sbi->data_start;
219} 219}
220 220
221static inline void fat_get_blknr_offset(struct msdos_sb_info *sbi,
222 loff_t i_pos, sector_t *blknr, int *offset)
223{
224 *blknr = i_pos >> sbi->dir_per_block_bits;
225 *offset = i_pos & (sbi->dir_per_block - 1);
226}
227
221static inline loff_t fat_i_pos_read(struct msdos_sb_info *sbi, 228static inline loff_t fat_i_pos_read(struct msdos_sb_info *sbi,
222 struct inode *inode) 229 struct inode *inode)
223{ 230{
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 78e363c844cb..68cb5a6eb539 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -662,7 +662,8 @@ static int __fat_write_inode(struct inode *inode, int wait)
662 struct buffer_head *bh; 662 struct buffer_head *bh;
663 struct msdos_dir_entry *raw_entry; 663 struct msdos_dir_entry *raw_entry;
664 loff_t i_pos; 664 loff_t i_pos;
665 int err; 665 sector_t blocknr;
666 int err, offset;
666 667
667 if (inode->i_ino == MSDOS_ROOT_INO) 668 if (inode->i_ino == MSDOS_ROOT_INO)
668 return 0; 669 return 0;
@@ -672,7 +673,8 @@ retry:
672 if (!i_pos) 673 if (!i_pos)
673 return 0; 674 return 0;
674 675
675 bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); 676 fat_get_blknr_offset(sbi, i_pos, &blocknr, &offset);
677 bh = sb_bread(sb, blocknr);
676 if (!bh) { 678 if (!bh) {
677 fat_msg(sb, KERN_ERR, "unable to read inode block " 679 fat_msg(sb, KERN_ERR, "unable to read inode block "
678 "for updating (i_pos %lld)", i_pos); 680 "for updating (i_pos %lld)", i_pos);
@@ -685,8 +687,7 @@ retry:
685 goto retry; 687 goto retry;
686 } 688 }
687 689
688 raw_entry = &((struct msdos_dir_entry *) (bh->b_data)) 690 raw_entry = &((struct msdos_dir_entry *) (bh->b_data))[offset];
689 [i_pos & (sbi->dir_per_block - 1)];
690 if (S_ISDIR(inode->i_mode)) 691 if (S_ISDIR(inode->i_mode))
691 raw_entry->size = 0; 692 raw_entry->size = 0;
692 else 693 else