Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6217782ybf; Thu, 5 Mar 2020 15:50:04 -0800 (PST) X-Google-Smtp-Source: ADFU+vsmaHSBkHXuCCcL5lNwhKh3X/B7wwCfyd2k+7szjAh6YCfR4KYGOwzqLvUX/T2TRm9PV/SJ X-Received: by 2002:aca:af44:: with SMTP id y65mr679303oie.35.1583452204284; Thu, 05 Mar 2020 15:50:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583452204; cv=none; d=google.com; s=arc-20160816; b=XXFm5ROvN+XP0RIyubO9b3NI5CAG5u8dkDSWkobhZxPTaoaYkhLLMPPiLHOCwvk7E6 kxCPa+gju5x6xYJlUw3EzEitCEa7bjJZJOcryYnncZnsyvC6pbyskusf+3v+ndAL5698 xw49VpQUIac0GIpr20qUBtjxt5CGLk0JvppxMIeqAn0+iPbpZphAmynuxBt8QhVfta9y MKo0wYqDkCAtaslURLEMhHcEau4kYFP6F6SbNaHxcLxZZsW3v0GpeVMN/t//ijb7a20A 0DKKo6Ze4npJkgPBRyeXihYQEWWv0VzFkNk/eVkP3dmg/gnVyRX273MJEhjxLrmEzxoa ERlA== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=wntQB8RheADAmL7MIPzkrAFyo4pv0NyUMAwgrix1UT8=; b=fONrG6iZdmUJRtJZHqZy2vJULTz9VNDyhsExKqBhYwmaJ0xXOeg0TzS5tqLX+cxMWn ErhLhoXF5FdumngvknZ61dStJCT73kPvWkLKDs3LTaTVSq7qhJbZscsjSjnfmzrDq5qj FK9fgsXB8uqJCiKzwxDz4egVNrK04Qoq5hOs8weYiE9y2Xa4xymZJpZrYj4UznHZBBgQ iOhRhR2oQ0IwdqdqAugefFDN5a3pv/ZQ7NgsbR2/0rUUnUDoeEZcKc9ad8nU7t3bMj+W DppR4yNcG1JXKwZ7P+BjIwG4ZCom7OekxVUNtEmdIUPVWcvZiLg49YxPGAtMTk+FuVwu tdVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wH8SH9C9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e26si271361otk.251.2020.03.05.15.49.44; Thu, 05 Mar 2020 15:50:04 -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; dkim=pass header.i=@kernel.org header.s=default header.b=wH8SH9C9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbgCEXsY (ORCPT + 99 others); Thu, 5 Mar 2020 18:48:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:40776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbgCEXsY (ORCPT ); Thu, 5 Mar 2020 18:48:24 -0500 Received: from localhost (unknown [104.132.1.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B6DF520717; Thu, 5 Mar 2020 23:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583452103; bh=Y8k9h7kxv3IqWsza/9KnsqFOgRnXjD8bfknBAcC9/r0=; h=From:To:Cc:Subject:Date:From; b=wH8SH9C9ro8FdneBLDrrJ9SUXN2tdQghLktAMkrilfz1+rzpfUrw4lqDYaesj5Ca0 m8DCIKEmQrBXBoFYP8hEPOgYZUrOUQMeYOkApWlw3JCa9cf0zI3LbAUatrnc/5Q8Af TsavOfgjoF0U0sMouWvpP2kureiblQOZM9PxOX/c= From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim , Daniel Rosenberg Subject: [PATCH] f2fs: fix wrong check on F2FS_IOC_FSSETXATTR Date: Thu, 5 Mar 2020 15:48:22 -0800 Message-Id: <20200305234822.178708-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)); - if (fi->i_flags & F2FS_PROJINHERIT_FL) + if (masked_flags & F2FS_PROJINHERIT_FL) set_inode_flag(inode, FI_PROJ_INHERIT); else clear_inode_flag(inode, FI_PROJ_INHERIT); -- 2.25.1.481.gfbce0eb801-goog