From: OGAWA Hirofumi Subject: Re: [PATCH v7 3/4] fat: permit to return phy block number by fibmap in fallocated region Date: Thu, 27 Nov 2014 00:11:19 +0900 Message-ID: <87bnnuxai0.fsf@devron.myhome.or.jp> References: <000301cffed2$1fad92d0$5f08b870$@samsung.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Andrew Morton , linux-fsdevel@vger.kernel.org To: Namjae Jeon Return-path: Received: from mail.parknet.co.jp ([210.171.160.6]:54800 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbaKZPLZ (ORCPT ); Wed, 26 Nov 2014 10:11:25 -0500 In-Reply-To: <000301cffed2$1fad92d0$5f08b870$@samsung.com> (Namjae Jeon's message of "Thu, 13 Nov 2014 08:41:04 +0900") Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Namjae Jeon writes: Hi, Sorry for long delay. > +static int fat_get_block_bmap(struct inode *inode, sector_t iblock, > + struct buffer_head *bh_result, int create) > +{ > + struct super_block *sb = inode->i_sb; > + unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; > + int err; > + sector_t bmap, last_block; > + unsigned long mapped_blocks; > + > + BUG_ON(create != 0); > + > + last_block = inode->i_blocks >> (sb->s_blocksize_bits - 9); > + > + if (iblock >= last_block) > + return 0; > + > + err = fat_get_mapped_cluster(inode, iblock, last_block, &mapped_blocks, > + &bmap); > + if (err) > + return err; Probably, we are missing rootdir check here? If it is fat12/fat16, rootdir has to treat as special, because it doesn't have cluster chain. So, how about to pass flags to fat_bmap()? For example, /* Check EOF for excluding bmap() ioctl path */ static int is_exceed_eof() { ... } fat_bmap(..., from_bmap) { ... if (!from_bmap && is_exceed_eof(inode, sector, create)) return 0; ... } or such. Thanks. -- OGAWA Hirofumi