From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AF84C3DA49 for ; Thu, 25 Jul 2024 16:53:34 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sX1ie-0007bu-Uu; Thu, 25 Jul 2024 16:53:32 +0000 Received: from [172.30.29.67] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sX1id-0007bn-46 for linux-f2fs-devel@lists.sourceforge.net; Thu, 25 Jul 2024 16:53:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TuUZaTOyPRZX5ZrT+PYS/qA8lns1mnbr1m8XbgdPpSg=; b=AMdktBVtfnYBZpOubEaQpKjBIQ YBB6hS+gZ+ypyjagDHY6+BaRmtuK1M2VgW8uyujHFp/7WaX86qXqZk4qpmhP5JhPaFa2aCkE3TvpE WdTn9cFv0w07Vtb1gcgRN6AGDHPaPgYAW5G60myrgIuGdsSF8YxXLeDM57Bk0HNVF8QI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=TuUZaTOyPRZX5ZrT+PYS/qA8lns1mnbr1m8XbgdPpSg=; b=i6ncdGj4GcFMjtizkM+RbZFf7r j1/iuxcV3V+cjr5H5yrcIdD1jeQNxk2qVTSusZoyKoMQ4Qyd9B5cNbr4LrV+FKeybdCMMxn/m1dZ1 XwdUxM066DqSRlj4xTEjYmtpGHfA1AdgBn2sSDBuqaUoHlr7RWGEXZkcPFu9BIvwoBMI=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sX1ib-0005Ws-EN for linux-f2fs-devel@lists.sourceforge.net; Thu, 25 Jul 2024 16:53:30 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 399A3CE136B; Thu, 25 Jul 2024 16:53:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC589C116B1; Thu, 25 Jul 2024 16:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721926401; bh=+4LlKYDTgAhPZmYC0SMXOXNTQ6Qeoe1ZKAUx/gCLEp8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bh+dgbAvSjID/AhQ1jSSZiMZO6mGq8NpoZ/91FphQd9ok/ugXlvEV8SAXRvILTBWh ztVRAk+37960TOTmWMU/Z4cGgguWJnDhxlqmrUzYaScWGB3LoDDf1S1MrAlGM1qKD7 MKoxHjqQneX2R4RaUqkFsYAULPI0ETl9VqvhijU5WlgmFhW5eOuzf9fuwny0oAqtXz 7ohPizIk0PoneOeXGgcKPhh6+u3kn1z4H1qCGwIp1dMxx6iQAi7PnBgmxQ7QHqauOA nbLWCzg44pPUBiUPr6cwLK9cV711YbCGupsDd554bBehWo09bmogxIjelHWMBTDp0S cTsGKK43lQruQ== Date: Thu, 25 Jul 2024 16:53:19 +0000 From: Jaegeuk Kim To: Zhiguo Niu Message-ID: References: <1721295366-21008-1-git-send-email-zhiguo.niu@unisoc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1721295366-21008-1-git-send-email-zhiguo.niu@unisoc.com> X-Headers-End: 1sX1ib-0005Ws-EN Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to use per-inode maxbytes and cleanup X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ke.wang@unisoc.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Hao_hao.Wang@unisoc.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 07/18, Zhiguo Niu wrote: > This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes") > for some missed cases, also cleanup redundant code in f2fs_llseek. > > Cc: Chengguang Xu > Signed-off-by: Zhiguo Niu > --- > fs/f2fs/data.c | 2 +- > fs/f2fs/file.c | 7 ++----- > fs/f2fs/verity.c | 5 +++-- > 3 files changed, 6 insertions(+), 8 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 6457e5b..1d41d99 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -2064,7 +2064,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > static inline loff_t f2fs_readpage_limit(struct inode *inode) > { > if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode)) > - return inode->i_sb->s_maxbytes; > + return max_file_blocks(inode) << F2FS_BLKSIZE_BITS; F2FS_BLK_TO_BYTES(max_file_blocks(inode))? > > return i_size_read(inode); > } > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index effbaa6..e6411d5 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -431,7 +431,7 @@ static bool __found_offset(struct address_space *mapping, > static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence) > { > struct inode *inode = file->f_mapping->host; > - loff_t maxbytes = inode->i_sb->s_maxbytes; > + loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; > struct dnode_of_data dn; > pgoff_t pgofs, end_offset; > loff_t data_ofs = offset; > @@ -513,10 +513,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence) > static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence) > { > struct inode *inode = file->f_mapping->host; > - loff_t maxbytes = inode->i_sb->s_maxbytes; > - > - if (f2fs_compressed_file(inode)) > - maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; > + loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; > > switch (whence) { > case SEEK_SET: > diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c > index f7bb0c5..7fc787c 100644 > --- a/fs/f2fs/verity.c > +++ b/fs/f2fs/verity.c > @@ -74,7 +74,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count, > struct address_space *mapping = inode->i_mapping; > const struct address_space_operations *aops = mapping->a_ops; > > - if (pos + count > inode->i_sb->s_maxbytes) > + if (pos + count > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS)) > return -EFBIG; > > while (count) { > @@ -237,7 +237,8 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf, > pos = le64_to_cpu(dloc.pos); > > /* Get the descriptor */ > - if (pos + size < pos || pos + size > inode->i_sb->s_maxbytes || > + if (pos + size < pos || > + pos + size > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS) || > pos < f2fs_verity_metadata_pos(inode) || size > INT_MAX) { > f2fs_warn(F2FS_I_SB(inode), "invalid verity xattr"); > f2fs_handle_error(F2FS_I_SB(inode), > -- > 1.9.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0EB21D545 for ; Thu, 25 Jul 2024 16:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721926401; cv=none; b=PDenMv1VyJeDFiliYVKviddTyIZefmr/5ih0esQqiamqpvZFYicsaupB5CbrwIoT40WEUdjrvSoWTdCF973/jz4uWavFfA4BICkNIygxeNGTT0U+e/qUiQSM9n8EKATJKLwhQNzkvtYg8eseyCVe1YXGh6gn5QZN3oayqWF/4iY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721926401; c=relaxed/simple; bh=+4LlKYDTgAhPZmYC0SMXOXNTQ6Qeoe1ZKAUx/gCLEp8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LhrKdmor4lXMKKOiI/LNvXajJpr0o1V6LbUN11tL0dDiJH7Bn+DRdzqu0TtoNBa7nHmZPpx3JI9A72ay3WYl3RBhUhXjD6EelzEzxxEYjZviMUyrOQQppD41bchQ93oZgAzg/jTK1MwHn6+iA/Ux1Cg45MdVhI+0pPBZ7EIriTs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bh+dgbAv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bh+dgbAv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC589C116B1; Thu, 25 Jul 2024 16:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721926401; bh=+4LlKYDTgAhPZmYC0SMXOXNTQ6Qeoe1ZKAUx/gCLEp8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bh+dgbAvSjID/AhQ1jSSZiMZO6mGq8NpoZ/91FphQd9ok/ugXlvEV8SAXRvILTBWh ztVRAk+37960TOTmWMU/Z4cGgguWJnDhxlqmrUzYaScWGB3LoDDf1S1MrAlGM1qKD7 MKoxHjqQneX2R4RaUqkFsYAULPI0ETl9VqvhijU5WlgmFhW5eOuzf9fuwny0oAqtXz 7ohPizIk0PoneOeXGgcKPhh6+u3kn1z4H1qCGwIp1dMxx6iQAi7PnBgmxQ7QHqauOA nbLWCzg44pPUBiUPr6cwLK9cV711YbCGupsDd554bBehWo09bmogxIjelHWMBTDp0S cTsGKK43lQruQ== Date: Thu, 25 Jul 2024 16:53:19 +0000 From: Jaegeuk Kim To: Zhiguo Niu Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, niuzhiguo84@gmail.com, ke.wang@unisoc.com, Hao_hao.Wang@unisoc.com Subject: Re: [PATCH] f2fs: fix to use per-inode maxbytes and cleanup Message-ID: References: <1721295366-21008-1-git-send-email-zhiguo.niu@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1721295366-21008-1-git-send-email-zhiguo.niu@unisoc.com> On 07/18, Zhiguo Niu wrote: > This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes") > for some missed cases, also cleanup redundant code in f2fs_llseek. > > Cc: Chengguang Xu > Signed-off-by: Zhiguo Niu > --- > fs/f2fs/data.c | 2 +- > fs/f2fs/file.c | 7 ++----- > fs/f2fs/verity.c | 5 +++-- > 3 files changed, 6 insertions(+), 8 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 6457e5b..1d41d99 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -2064,7 +2064,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > static inline loff_t f2fs_readpage_limit(struct inode *inode) > { > if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode)) > - return inode->i_sb->s_maxbytes; > + return max_file_blocks(inode) << F2FS_BLKSIZE_BITS; F2FS_BLK_TO_BYTES(max_file_blocks(inode))? > > return i_size_read(inode); > } > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index effbaa6..e6411d5 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -431,7 +431,7 @@ static bool __found_offset(struct address_space *mapping, > static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence) > { > struct inode *inode = file->f_mapping->host; > - loff_t maxbytes = inode->i_sb->s_maxbytes; > + loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; > struct dnode_of_data dn; > pgoff_t pgofs, end_offset; > loff_t data_ofs = offset; > @@ -513,10 +513,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence) > static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence) > { > struct inode *inode = file->f_mapping->host; > - loff_t maxbytes = inode->i_sb->s_maxbytes; > - > - if (f2fs_compressed_file(inode)) > - maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; > + loff_t maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; > > switch (whence) { > case SEEK_SET: > diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c > index f7bb0c5..7fc787c 100644 > --- a/fs/f2fs/verity.c > +++ b/fs/f2fs/verity.c > @@ -74,7 +74,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count, > struct address_space *mapping = inode->i_mapping; > const struct address_space_operations *aops = mapping->a_ops; > > - if (pos + count > inode->i_sb->s_maxbytes) > + if (pos + count > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS)) > return -EFBIG; > > while (count) { > @@ -237,7 +237,8 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf, > pos = le64_to_cpu(dloc.pos); > > /* Get the descriptor */ > - if (pos + size < pos || pos + size > inode->i_sb->s_maxbytes || > + if (pos + size < pos || > + pos + size > (max_file_blocks(inode) << F2FS_BLKSIZE_BITS) || > pos < f2fs_verity_metadata_pos(inode) || size > INT_MAX) { > f2fs_warn(F2FS_I_SB(inode), "invalid verity xattr"); > f2fs_handle_error(F2FS_I_SB(inode), > -- > 1.9.1