Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6302347ybf; Thu, 5 Mar 2020 17:39:41 -0800 (PST) X-Google-Smtp-Source: ADFU+vslERTuXlwCX86oMaXjspJswWYSl1az1NC5fi7mctG/5uLW/X1+Qayek7dTfmC1OoGKgx4W X-Received: by 2002:a9d:3f4b:: with SMTP id m69mr600455otc.146.1583458781166; Thu, 05 Mar 2020 17:39:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583458781; cv=none; d=google.com; s=arc-20160816; b=ymojQCYS+HiBsAEjY6cjIeEuheCnjvghBcq6GME5sNvrGsp/jHkGhhdn/cqZQgw03N KkpQ6ChjTcD6yH31PAA3GpsG2j44QMa4k+ptFbMuCx7bYTvNbSZfeH5pBzs/7XxhgwZF WPdHbjSu2foLNjEnj70ihgAT9oFpAyAOvHDlMoqdTK3ynzActSfv4eA4bcX6/R7ifcnC 6w5e9vha4YbaEdCKGA9JSfZQrma19Db+koYfjzUgJ7BHhgurTK8nZblfxW+9qXQwBe05 d2mH4QBCm5hnxvEipXublJhfN7+evbybfn0BhqoFQ5TxG3RFj43+7epgLvbOP5Xrq3rU U+nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=enWO7ZdqKDunipiE6KYyxoMigaSFs51tIz5SiYrvzdU=; b=w0uKseOQKRRdG2Nl2xRALMlGwV1+nijzp/9LK5PfGrC48pyVjGi6Sbl4PhC6BvxnzQ C8tXZYlir5qeyqvxxlXY1whEHVmPuHbiyCMfCH8A3BuExxk8C9eJcRoMEVD6XL/WSCow hXbyvxszXGi0td0wnqR6FtNuFvPFigQQ/ZR8WnbwHwiTr/s6Nni0ZsDZxl7mT+pzxkNL 6Icndw9ns90pbcodGQUrtRt2cUYWg8XQ7xPEvZ1jb587H8+g+U8hY5n5BHWOWG3aldR8 f4KPtPtADsalI07GQU7z1MJKt/cqmKeNzi1Gd8j3cUw6vEUibKbcGuOV/GVW/DmON5KM EaFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e206si468302oib.210.2020.03.05.17.39.29; Thu, 05 Mar 2020 17:39:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbgCFBjH (ORCPT + 99 others); Thu, 5 Mar 2020 20:39:07 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11158 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726162AbgCFBjH (ORCPT ); Thu, 5 Mar 2020 20:39:07 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0297F88034623412B26A; Fri, 6 Mar 2020 09:39:06 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 6 Mar 2020 09:39:04 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: fix wrong check on F2FS_IOC_FSSETXATTR To: Jaegeuk Kim , , CC: Daniel Rosenberg References: <20200305234822.178708-1-jaegeuk@kernel.org> From: Chao Yu Message-ID: <1e8389fb-2416-d191-cdb3-cd4714ed7756@huawei.com> Date: Fri, 6 Mar 2020 09:39:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200305234822.178708-1-jaegeuk@kernel.org> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/3/6 7:48, Jaegeuk Kim wrote: > This fixes the incorrect failure when enabling project quota on casefold-enabled > file. > > Cc: Daniel Rosenberg > Signed-off-by: Jaegeuk Kim > --- > fs/f2fs/file.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index fb070816a8a5..8a41afac0346 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -1789,12 +1789,15 @@ static int f2fs_file_flush(struct file *file, fl_owner_t id) > static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) > { > struct f2fs_inode_info *fi = F2FS_I(inode); > + u32 masked_flags = fi->i_flags & mask; > + > + f2fs_bug_on(F2FS_I_SB(inode), (iflags & ~mask)); > > /* Is it quota file? Do not allow user to mess with it */ > if (IS_NOQUOTA(inode)) > return -EPERM; > > - if ((iflags ^ fi->i_flags) & F2FS_CASEFOLD_FL) { > + if ((iflags ^ masked_flags) & F2FS_CASEFOLD_FL) { > if (!f2fs_sb_has_casefold(F2FS_I_SB(inode))) > return -EOPNOTSUPP; > if (!f2fs_empty_dir(inode)) > @@ -1808,9 +1811,9 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) > return -EINVAL; > } > > - if ((iflags ^ fi->i_flags) & F2FS_COMPR_FL) { > + if ((iflags ^ masked_flags) & F2FS_COMPR_FL) { > if (S_ISREG(inode->i_mode) && > - (fi->i_flags & F2FS_COMPR_FL || i_size_read(inode) || > + (masked_flags & F2FS_COMPR_FL || i_size_read(inode) || > F2FS_HAS_BLOCKS(inode))) > return -EINVAL; > if (iflags & F2FS_NOCOMP_FL) > @@ -1827,16 +1830,16 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) > set_compress_context(inode); > } > } > - if ((iflags ^ fi->i_flags) & F2FS_NOCOMP_FL) { > - if (fi->i_flags & F2FS_COMPR_FL) > + if ((iflags ^ masked_flags) & F2FS_NOCOMP_FL) { > + if (masked_flags & F2FS_COMPR_FL) > return -EINVAL; > } > > fi->i_flags = iflags | (fi->i_flags & ~mask); > - f2fs_bug_on(F2FS_I_SB(inode), (fi->i_flags & F2FS_COMPR_FL) && > - (fi->i_flags & F2FS_NOCOMP_FL)); > + f2fs_bug_on(F2FS_I_SB(inode), (masked_flags & F2FS_COMPR_FL) && > + (masked_flags & F2FS_NOCOMP_FL)); We don't need to change here due to we should check final status in fi->i_flags rather than checking previous status in masked_flags? > > - if (fi->i_flags & F2FS_PROJINHERIT_FL) > + if (masked_flags & F2FS_PROJINHERIT_FL) Ditto. Thanks, > set_inode_flag(inode, FI_PROJ_INHERIT); > else > clear_inode_flag(inode, FI_PROJ_INHERIT); >