From: OGAWA Hirofumi Subject: Re: [PATCH v7 1/4] fat: add fat_fallocate operation Date: Thu, 27 Nov 2014 00:18:01 +0900 Message-ID: <877fyixa6u.fsf@devron.myhome.or.jp> References: <000101cffed2$1511d070$3f357150$@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]:54802 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753175AbaKZPSE (ORCPT ); Wed, 26 Nov 2014 10:18:04 -0500 In-Reply-To: <000101cffed2$1511d070$3f357150$@samsung.com> (Namjae Jeon's message of "Thu, 13 Nov 2014 08:40:46 +0900") Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Namjae Jeon writes: > +static int __fat_write_inode(struct inode *inode, int wait); > static void fat_evict_inode(struct inode *inode) > { > truncate_inode_pages_final(&inode->i_data); > if (!inode->i_nlink) { > inode->i_size = 0; > fat_truncate_blocks(inode, 0); > + } else { > + /* Release unwritten fallocated blocks on inode eviction. */ > + if ((inode->i_blocks << 9) > > + round_up(MSDOS_I(inode)->mmu_private, > + inode->i_sb->s_blocksize)) { Don't we need to check alignment of cluster size here, not blocksize? Otherwise, looks like we call write_inode() without actual truncate. (BTW, IMHO, Adding own static function for this, would be easier to read.) > + int err; > + > + fat_truncate_blocks(inode, MSDOS_I(inode)->mmu_private); > + /* Fallocate results in updating the i_start/iogstart > + * for the zero byte file. So, make it return to > + * original state during evict and commit it to avoid > + * any corruption on the next access to the cluster > + * chain for the file. > + */ > + err = __fat_write_inode(inode, inode_needs_sync(inode)); > + if (err) { > + fat_msg(inode->i_sb, KERN_WARNING, "Failed to " > + "update on disk inode for unused fallocated " > + "blocks, inode could be corrupted. Please run " > + "fsck"); > + } > + } -- OGAWA Hirofumi