From patchwork Wed Aug 7 18:29:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756613 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2020313E02E for ; Wed, 7 Aug 2024 18:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; cv=none; b=CI6VXvTYmYH5XdSrFXHA+82IuC0G1vNcmLjlQhqFYXI9H57ni2rLSwuDO1pjju1Ip1lTxuEeVSR6zQBic80ypD9NJqhsSP90RKRwtgDKmvd40B/v38MVZc0TDYd1hRgq3yH6Y0kWfPxO9gP2Vv1qUhbdtlDZiTAz/UhrvPx0Cj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; c=relaxed/simple; bh=NLbcVKvoZUnAjBOjxoi6Qb73AMZJY/JT/HFFKPHAeoI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r0OpYEqSq8E3w7vwiYyYjUjYDkyTB9jindY46bTdG5N8sz2prDxCdNDtZD90lj+9eWfrS2+pfvbw4m4VbrjEson+0DbWNFoSIlC6fzHVI4sGmbWpXsS9HGLZ+9UtGzOzTwthx7JBSXOVYGWoKEXbz2xVcyRRE7KnewwonLa1e5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=QEv2/WA0; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=kDgWZ+MC; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=W+zS8Szm; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=Ho95xB0D; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="QEv2/WA0"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="kDgWZ+MC"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="W+zS8Szm"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Ho95xB0D" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 12F4A21C09; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q2m+YEtDH4Y6yWo4pxzfKf/t1yicZeM+HgMLdn3QS2Q=; b=QEv2/WA0oWddAdux7iScEWG1hrtUtWRjwmyDyXceQi2scxi97irsxCYmhhUMHZbNq9EcnM 93h6ifC9J2SSKs8zt5SXSLKhoEZmR+2TwA1ZmZlBTRbATh/uQvCCaRmq1B7gAEiOEYvGqI i6RtFm+4sQk30PZWTUY7VC21Lodpr8E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q2m+YEtDH4Y6yWo4pxzfKf/t1yicZeM+HgMLdn3QS2Q=; b=kDgWZ+MCDB2DqiI5dv3XqL8XQUQ0eExeqMG6XLSTWN9XDO8uc87ZRIlrumBbwcucGIvG2O mQR1HwnAH7/J6JDA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q2m+YEtDH4Y6yWo4pxzfKf/t1yicZeM+HgMLdn3QS2Q=; b=W+zS8Szm4RtgKo2+hS5GtIhJDVK9fkOcdZ1VSxGmTvdjzGxGKZ1SxOCDGOmPmEVSWXUr5I sP3n3XCDSmvxZTh9WOFs4xm1G6WJ/mZ1K7BmfonXzgD60y/WfYBwb7T/2aLhjyq0r04U6g /56w6nJ0cYgppsUcpqvQVP09oG1n+A0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q2m+YEtDH4Y6yWo4pxzfKf/t1yicZeM+HgMLdn3QS2Q=; b=Ho95xB0DXem6cAaiF66ImQXhGoEnPBtC23ByJHiGeh/3Pkq+1NJUrVneE21yC2hZ1kTRf7 frw8axAuY4DRNeAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0173A13B03; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id G6AFACy9s2ZjNAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:03 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 978B3A083F; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 01/13] fs: Define bit numbers for SB_I_ flags Date: Wed, 7 Aug 2024 20:29:46 +0200 Message-Id: <20240807183003.23562-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2618; i=jack@suse.cz; h=from:subject; bh=NLbcVKvoZUnAjBOjxoi6Qb73AMZJY/JT/HFFKPHAeoI=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70afo9cS29RY9ZnlVQR44SRDWP8Jh6kMj3mSZ7l w8hGs+eJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9GgAKCRCcnaoHP2RA2RtMCA CG/Qz7t7j1RDHC978+XmKcLXuCSSGbMBTe9bETd5veCuWb3KomqgHIH8i9t6gLZ1wQNUnJgJwT+Ou/ fr6WF+mWvi6dgwOcrTq9k+iDIlV3okTd6vVO1kTNL+XY28+aSzHxYOwIWXuaqdAUul3huzj4Op2qaG Oi5RtNMDckz7OMClw7F5gIpESTAOsK2mmPRpfR+Ht+iwbB0xRjSl9Zhv7TBWlACvjXrBAnWPBA21KI Y37hgyRFuTeUm/49XEly6sFl1Kxxln3jNg7qdTQTz6rIy+MbvQtYIiZ7D1mCGWceEPQkf9vORIE2Da QCTV82wXeAKeRPP+nqUQuyEkPuw/Y6 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email] X-Spam-Score: -2.80 X-Spam-Flag: NO X-Spam-Level: sb->s_iflags has unclear locking rules. Some users modify it under sb_lock, some under sb->s_umount rwsem, some without any lock. Readers are generally not holding any locks either. The flags are rarely modified so this does not lead to any practical problems but it is a mess. To reconcile the situation, handle sb->i_flags without any locks by using atomic bit operations. Since the flags are rarely modified, this does not introduce any noticeable performance overhead and resolves all possible issues when different users of sb->s_iflags could possibly stomp on each other's toes. Define new constants using bit numbers and functions to tests, set and clear the flags. Signed-off-by: Jan Kara --- include/linux/fs.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index fd34b5755c0b..ff45a97b39cb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1190,6 +1190,25 @@ extern int send_sigurg(struct fown_struct *fown); #define SB_I_RETIRED 0x00000800 /* superblock shouldn't be reused */ #define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */ +enum { + _SB_I_CGROUPWB, /* cgroup-aware writeback enabled */ + _SB_I_NOEXEC, /* Ignore executables on this fs */ + _SB_I_NODEV, /* Ignore devices on this fs */ + _SB_I_STABLE_WRITES, /* don't modify blks until WB is done */ + + /* sb->s_iflags to limit user namespace mounts */ + _SB_I_USERNS_VISIBLE, /* fstype already mounted */ + _SB_I_IMA_UNVERIFIABLE_SIGNATURE, + _SB_I_UNTRUSTED_MOUNTER, + _SB_I_EVM_HMAC_UNSUPPORTED, + + _SB_I_SKIP_SYNC, /* Skip superblock at global sync */ + _SB_I_PERSB_BDI, /* has a per-sb bdi */ + _SB_I_TS_EXPIRY_WARNED, /* warned about timestamp range expiry */ + _SB_I_RETIRED, /* superblock shouldn't be reused */ + _SB_I_NOUMASK, /* VFS does not apply umask */ +}; + /* Possible states of 'frozen' field */ enum { SB_UNFROZEN = 0, /* FS is unfrozen */ @@ -1351,6 +1370,21 @@ struct super_block { struct list_head s_inodes_wb; /* writeback inodes */ } __randomize_layout; +static inline bool sb_test_iflag(const struct super_block *sb, int flag) +{ + return test_bit(flag, &sb->s_iflags); +} + +static inline void sb_set_iflag(struct super_block *sb, int flag) +{ + set_bit(flag, &sb->s_iflags); +} + +static inline void sb_clear_iflag(struct super_block *sb, int flag) +{ + clear_bit(flag, &sb->s_iflags); +} + static inline struct user_namespace *i_user_ns(const struct inode *inode) { return inode->i_sb->s_user_ns; From patchwork Wed Aug 7 18:29:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756621 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A4BD13FD86 for ; Wed, 7 Aug 2024 18:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055410; cv=none; b=FyRu9P6r9zhJlQdprpdNrOoaGCazbi/1VWMdnBxakrfIdo97Czi3oXl/xdkO3IbnyhRgpoRy+L7ZS+6mqHvosvGnzg/cPCCCGVbSMGUSxtu2E5KGhvynTsv5msJ8QTM8AJiA3ofS2AIGQlWlpAR5oyJB0dFy9JQpKX3Rzwxcot0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055410; c=relaxed/simple; bh=vnTivuYbvkOsdMt+eymjyBgi3CWQtuVU4gGetco1x1s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o9J9K141haB7aLUucYkZSMAAMIfmUVNDVI1v1JrdWbw7kShRf2/U64uPrGxsidcfGXm/p1a35VGpmP1Kx57aRW+9o1mo+JX49+glzczW5u4UGyFCkpxKx6MsXqOaoX0cG+CxNj4cwQwAuMQMuYZHbitKBivB86KKLioMEDOQveI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=y6suBkP9; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=FqWmWCTr; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=WyZQmRVj; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=qL9AIGV3; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="y6suBkP9"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="FqWmWCTr"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="WyZQmRVj"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="qL9AIGV3" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 189071FB9A; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f29OTYnCgSYfzrpoPjh3jY3P4l0tMkF/OXMZ05VfvBI=; b=y6suBkP9SpAV54+5HTNEITlZOLe7Xuz1WqMta16zS5P57arSvTi9AOrFSUFyohAw51Tz13 lz2w2BbifSvbE9YVoH9aEbE/5TYBPcLPKCHI49KBeqlG3aZjcZGz/ZAOjl1JXhDdJUJ9z7 St35+qLReSOD85JnMHPWr7EdFruJ7mQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f29OTYnCgSYfzrpoPjh3jY3P4l0tMkF/OXMZ05VfvBI=; b=FqWmWCTr6TehxkCnfptVKtwx2SlheBF7FQYsqicgp8oNS4MEKC3eo//C3c/+QrTI3qG9+d 3/HORceXxGUKH2DQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=WyZQmRVj; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=qL9AIGV3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f29OTYnCgSYfzrpoPjh3jY3P4l0tMkF/OXMZ05VfvBI=; b=WyZQmRVjqIKZlaBVoZAH9l9oPsRP2rI3z57JY+ztKFUHVuOI/gyGaHsA++d6eQiVg0o9Wz 9BwzrmJq+47zNBXTZLoptVEncM5DPSK26q5R7Yr+4wYQasCl0tGyJ6xK3HW2Pwem+4MlM2 ruSh9knSZQ8zSY6LPpWQfQMpEze227c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f29OTYnCgSYfzrpoPjh3jY3P4l0tMkF/OXMZ05VfvBI=; b=qL9AIGV38xi6MtEfpX0IEt32bGZlGVVltJe8GlbMgT+mokRy20egP6vPTgqFnoQbgo3JxX 1SQAUFYLHl1YY9DA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0919213B05; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 4pk3Aiy9s2ZoNAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 9E116A0851; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 02/13] fs: Convert fs_context use of SB_I_ flags to new constants Date: Wed, 7 Aug 2024 20:29:47 +0200 Message-Id: <20240807183003.23562-2-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1526; i=jack@suse.cz; h=from:subject; bh=vnTivuYbvkOsdMt+eymjyBgi3CWQtuVU4gGetco1x1s=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70b+DxOvVMTSkPz+/cJWzQihyLlOohnwIG3SORq o7sQ56aJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9GwAKCRCcnaoHP2RA2QQ0B/ wNMYKTyXVaZ/taNdcDr97HtuOF43wbrVlg7Noeo9CBnDkNZA8WgN5cEYV8hI6ArLnX9F41Ce3s0ZVt EJofLJGAimVQkosXLDkmPqjeyQPbbD69cgUTqPUZ5m3AN/RSj+zFGivT3kRlU0y/WEiq3TYGkdx5gN 3kixK2zYgQ/KsIj6VssmR4j4RIm9f+DIFBxPtyqzJWwpqPCOASXop42gU/OUodBgVokqmifKYP8dep 5mSxDnYOmhRqbm6a0LhIffUZOJ0HGHlACooUqm+nX+tFrwTbkvpzr+tjY9wbcpmN8nfD8ZsLmVIabb pLF6wEcH94KIgQWuosOOhPIwPOgb4T X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-0.01 / 50.00]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_TLS_LAST(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.cz:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.cz:+] X-Spamd-Bar: / X-Rspamd-Queue-Id: 189071FB9A X-Spam-Level: X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -0.01 Convert uses of SB_I_ constants in fc->s_iflags to the new bit constants. No functional changes. Signed-off-by: Jan Kara --- block/bdev.c | 2 +- fs/aio.c | 2 +- fs/nfs/fs_context.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index c5507b6f63b8..c1ea2aeb93dd 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -373,7 +373,7 @@ static int bd_init_fs_context(struct fs_context *fc) struct pseudo_fs_context *ctx = init_pseudo(fc, BDEVFS_MAGIC); if (!ctx) return -ENOMEM; - fc->s_iflags |= SB_I_CGROUPWB; + fc->s_iflags |= 1 << _SB_I_CGROUPWB; ctx->ops = &bdev_sops; return 0; } diff --git a/fs/aio.c b/fs/aio.c index 6066f64967b3..63ce0736c3a3 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -279,7 +279,7 @@ static int aio_init_fs_context(struct fs_context *fc) { if (!init_pseudo(fc, AIO_RING_MAGIC)) return -ENOMEM; - fc->s_iflags |= SB_I_NOEXEC; + fc->s_iflags |= 1 << _SB_I_NOEXEC; return 0; } diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 6c9f3f6645dd..2fbae7e2b6ce 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1643,7 +1643,7 @@ static int nfs_init_fs_context(struct fs_context *fc) ctx->xprtsec.cert_serial = TLS_NO_CERT; ctx->xprtsec.privkey_serial = TLS_NO_PRIVKEY; - fc->s_iflags |= SB_I_STABLE_WRITES; + fc->s_iflags |= 1 << _SB_I_STABLE_WRITES; } fc->fs_private = ctx; fc->ops = &nfs_fs_context_ops; From patchwork Wed Aug 7 18:29:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756620 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2016E13CFA3 for ; Wed, 7 Aug 2024 18:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055410; cv=none; b=qaeyrbdc9ulVZWRP76MIMcQWCdZvqN22bi9OreMrIfClHXOickb2lJEQJ8BVWQsNBCskETsajWEQM4KrIV8SniLVUTjBWN4OY1kUQ4rFUMPXnEdjKX+1RazISPbv8tN88xi5PB9ei4KhWqzdOJKsEbfVbotKjrar6PdhIx/Dl4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055410; c=relaxed/simple; bh=K832h4ryVz+4yV7IucFzPLYGb+qGK8QI2p+mXEAWgCU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Sd7poqOjUD8JqdDaCn/9SO//MHgHiC96482Z9jxlJYyWnHI3P3OaUcyvymrC7KWLD9qKDSHqO+dnFWRSEv5MjGTYYRlatAXAoKUTyN9CuTwZvb1SnNOh/vSDxQmzn5TlQaJpxIa91S4M4Y9pZGd50Y7dWTkuS7vOlRWQ1pQ/WwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=vyhgFbx7; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=F34hjzrQ; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=emaJVXh4; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=WP9BL+1E; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="vyhgFbx7"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="F34hjzrQ"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="emaJVXh4"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="WP9BL+1E" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1C3E421C46; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+MeDJ1VqQPReP+MdvN1Ue94VZEOCQEN5UAxnZWI5lRE=; b=vyhgFbx7q/0Rodzykh72pinyiXrOHOVTqDPtKb3F16oXgAR2iEDE95fj+YTt7y7cyyC2d0 fLauzTOJFE0EUcGM3mHxts4cQYxPkaU5Wc8qeiyPU2zAsRclbOAPqztms56ByW5yiVTiVJ EzLQuTmNAc97l8ex/bhjZ3kDLuGbXS8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+MeDJ1VqQPReP+MdvN1Ue94VZEOCQEN5UAxnZWI5lRE=; b=F34hjzrQTjzNMUHx120i/xgUu3aWaHtn724mxADkbQnX7GTt94PUV8/lWuWL4YFE8m//Q/ OweZPQavywXh3+Cg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+MeDJ1VqQPReP+MdvN1Ue94VZEOCQEN5UAxnZWI5lRE=; b=emaJVXh4UPlmoYcFKGSKTKgoFh0D/pl8KFZqmVtQaT162QU4mK37EFhS7V+FRucj3vw6Yi 03b5pJqRXBG3Mv6GVNiubufThqByrSNz2El3vEGOzDx/9va7vuwdZsq/HiMHihZHGHIVwL dtJQslR+B0ZZoq08wZhCHQD1j84NaT0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+MeDJ1VqQPReP+MdvN1Ue94VZEOCQEN5UAxnZWI5lRE=; b=WP9BL+1EsAogfKTp3kHXBu/EWarsIoieWCckmnyuSykQ93tkyBnTaoZ4uJPxguKc8AxTG1 2FguB06N/Ko4I4DA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0C28813B06; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id PQXyAiy9s2ZpNAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id A7777A0853; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 03/13] fs: Convert mount_too_revealing() to new s_iflags handling functions Date: Wed, 7 Aug 2024 20:29:48 +0200 Message-Id: <20240807183003.23562-3-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1287; i=jack@suse.cz; h=from:subject; bh=K832h4ryVz+4yV7IucFzPLYGb+qGK8QI2p+mXEAWgCU=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70ctlWwsjzJ7w8sEny5iKEvPCtcFB7x5PJTgULW bpkt/TuJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9HAAKCRCcnaoHP2RA2W23CA DAjJR2iHxbn65VUs+wNkK4w2DjwBA3s+jrEHyG8NjDKnq67AtRRAPrHTabdODLrimNBlvq5yK8v+7X nDDoeP1iqEfHsahnOHdmTZWwKjJf6GvGgr1LEA7a39iE6bu5RX4oz2lK6JKBZx72HACnoVIlVSHb3p kQ0RyR3VzJZxLSuGikAKBPH4FMikSMnY8l4UjVLR1aQCUs5PDPCdxupIpsRrNz51b5Z3h/keap4XSP 4eu00fkryUBlATTT6y3S+qiRqWbQK13E0xAqux6RmKwhiRNZAE/SGBrprLNBS4IrNFTAqwW6GSXxSd bXbFF4FO/x+sAwOHR4my+IRBBIrA6G X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email] X-Spam-Flag: NO X-Spam-Score: -2.80 Convert mount_too_revealing() to use the new functions for handling sb->s_iflags and new bit constants. Signed-off-by: Jan Kara --- fs/namespace.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 328087a4df8a..75153f61a908 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -5623,21 +5623,18 @@ static bool mnt_already_visible(struct mnt_namespace *ns, static bool mount_too_revealing(const struct super_block *sb, int *new_mnt_flags) { - const unsigned long required_iflags = SB_I_NOEXEC | SB_I_NODEV; struct mnt_namespace *ns = current->nsproxy->mnt_ns; - unsigned long s_iflags; if (ns->user_ns == &init_user_ns) return false; /* Can this filesystem be too revealing? */ - s_iflags = sb->s_iflags; - if (!(s_iflags & SB_I_USERNS_VISIBLE)) + if (!sb_test_iflag(sb, _SB_I_USERNS_VISIBLE)) return false; - if ((s_iflags & required_iflags) != required_iflags) { - WARN_ONCE(1, "Expected s_iflags to contain 0x%lx\n", - required_iflags); + if (!sb_test_iflag(sb, _SB_I_NOEXEC) || !sb_test_iflag(sb, _SB_I_NODEV)) { + WARN_ONCE(1, "Expected s_iflags to contain SB_I_NOEXEC and " + "SB_I_NODEV\n"); return true; } From patchwork Wed Aug 7 18:29:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756618 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27AA713F012 for ; Wed, 7 Aug 2024 18:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; cv=none; b=FMyzsUUM9HZIx4qJAGnEzpUfd+fYv2G4RkV0aWymhE7j7BJsZ9hT3V10I1EBA9h8OTocWvqUUM5c6MSEQu5qZ+zr535JjMg9R5pz4VAf4ycHsK9LSSmwSvLyvPHtq+bwTrpU1ZhMYIXMHoy+vf9FjG8FZZOD1bnqYp4KuVfDHYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; c=relaxed/simple; bh=pmU00GFGhFqdo9dFtgioCWIx18MNwL+VWzn/H84Q9Ms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JJl3Oy7kQXG26SKwXXmrSEnruKw8uB7yCc3UK5q4MiAgvNN1FD7/Ctr8TELi44SWRemoAsDAAxjQvZvxB2uOYEWOmKxrt58SHjV2B+XY+r0KVxfrFVe4x94WKqY25ItbyLnW5XQAETvlmgcNH7clT44Ps0kLSCW+HjPbv+wL04c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=USCom/6A; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=5Hg2+No6; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=L+xbd6eM; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=IEwqLGf/; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="USCom/6A"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="5Hg2+No6"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="L+xbd6eM"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="IEwqLGf/" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2B0391FB9B; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2hJSnrQLpQHBgUjNMT0pcZBC3s0BXvP07ddUXbWSWF4=; b=USCom/6AVT/l0lKqTiYNQOBObwPqm652fjGNrF/TCbcYYlviVQVP6dkksLFZGME9gFRzhL xYznfTIzSUnIJqG0w5aMQusEnNIOSamFVuN8KUbxrBvs/GaPonBxGsNUhohKrkMp/c7Asu ApPJ3GGl/VD2jiYguwtcFS9TBFU9jeI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2hJSnrQLpQHBgUjNMT0pcZBC3s0BXvP07ddUXbWSWF4=; b=5Hg2+No6iNVhw9ask8tTBhuGpuh5XWH4udjaOMYhKd/D3g6LHeBDYZSWS0Vfp/x+pYOWQs RL5FLsdHvwtQiKBg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2hJSnrQLpQHBgUjNMT0pcZBC3s0BXvP07ddUXbWSWF4=; b=L+xbd6eMDzvb8rcVV8HS6LQEVbHyNwE1rFszssyzvhh86kJCV+/n8L6zYua1VrhJZgxKH1 WnTe7bRMHdOcULMpPb4G57g+x47yujVpJVqKeOc+gpt9s4JCh6uXPPrs1Rojy73Zjvt820 rNlM9Ppl0/Vj2wYQADrwQkywNYzC68o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2hJSnrQLpQHBgUjNMT0pcZBC3s0BXvP07ddUXbWSWF4=; b=IEwqLGf/Iy0j/pFaPWC0dZ4nrWoksmQaVP1ZfEdce/AuVT4DxrDaw/YxVD/WkV3RZnkJ/n Fmd2HaNDJ6JZ4UAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 14DC413B08; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 6DMWBSy9s2ZvNAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id B03B1A0857; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 04/13] fs: Convert remaining usage of SB_I_ flags Date: Wed, 7 Aug 2024 20:29:49 +0200 Message-Id: <20240807183003.23562-4-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=17335; i=jack@suse.cz; h=from:subject; bh=pmU00GFGhFqdo9dFtgioCWIx18MNwL+VWzn/H84Q9Ms=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70dKt3VaUomAJhmhnz2xQwQAlcIzTEWepN647of u03Pr6KJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9HQAKCRCcnaoHP2RA2bnZB/ 9QovmThPaJC9WPlyZTuC2HXfkh3j/3VXSDBmfLNGtjUafTNcjTj/eq2lG3dkGxuEPN3+n32JqkfL9y C27dZTEmMxuIa2wIeielhqAnrm4Nu65XIaVvE0sI0wxBpAepAdnwOJaF1uCSy9f0SW1HaXBes9yBVd azaZcGVJjDRZvEljzaLwMzO/fbpXEu+NV83dH80LFfB4/CjCdJ4OGoxmIwBn16Me1otD9xnlJO55zR v8yBdnULCjPn7TARBaKSUKhGPR7MsPrT7HgeCf1eteSKC8cp5fxZvgwYnuFoKuAL81tTYPjMLUSGb9 M/Bh1AGyOf5Lseynpj47o6P8duIKB2 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email] X-Spam-Score: -2.80 X-Spam-Flag: NO X-Spam-Level: Convert remaining handling of sb->s_iflags to use the new helper functions and new bit constants. The patch was generated using coccinelle with a few manual fixups to improve code style. Signed-off-by: Jan Kara --- drivers/android/binderfs.c | 4 ++-- fs/btrfs/super.c | 2 +- fs/devpts/inode.c | 2 +- fs/exec.c | 2 +- fs/ext2/super.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fuse/inode.c | 4 ++-- fs/inode.c | 2 +- fs/kernfs/mount.c | 3 ++- fs/namei.c | 2 +- fs/namespace.c | 4 ++-- fs/nfs/super.c | 2 +- fs/overlayfs/super.c | 6 +++--- fs/proc/root.c | 4 +++- fs/super.c | 18 +++++++++--------- fs/sync.c | 2 +- fs/sysfs/mount.c | 2 +- fs/xfs/xfs_super.c | 2 +- include/linux/backing-dev.h | 2 +- include/linux/namei.h | 2 +- ipc/mqueue.c | 3 ++- security/integrity/evm/evm_main.c | 2 +- security/integrity/ima/ima_appraise.c | 4 ++-- security/integrity/ima/ima_main.c | 4 ++-- 25 files changed, 44 insertions(+), 40 deletions(-) diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c index 3001d754ac36..f9454b93c2f7 100644 --- a/drivers/android/binderfs.c +++ b/drivers/android/binderfs.c @@ -672,8 +672,8 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc) * allowed to do. So removing the SB_I_NODEV flag from s_iflags is both * necessary and safe. */ - sb->s_iflags &= ~SB_I_NODEV; - sb->s_iflags |= SB_I_NOEXEC; + sb_clear_iflag(sb, _SB_I_NODEV); + sb_set_iflag(sb, _SB_I_NOEXEC); sb->s_magic = BINDERFS_SUPER_MAGIC; sb->s_op = &binderfs_super_ops; sb->s_time_gran = 1; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 08d33cb372fb..321696697279 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -950,7 +950,7 @@ static int btrfs_fill_super(struct super_block *sb, #endif sb->s_xattr = btrfs_xattr_handlers; sb->s_time_gran = 1; - sb->s_iflags |= SB_I_CGROUPWB; + sb_set_iflag(sb, _SB_I_CGROUPWB); err = super_setup_bdi(sb); if (err) { diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index b20e565b9c5e..d473156d2791 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -428,7 +428,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent) struct inode *inode; int error; - s->s_iflags &= ~SB_I_NODEV; + sb_clear_iflag(s, _SB_I_NODEV); s->s_blocksize = 1024; s->s_blocksize_bits = 10; s->s_magic = DEVPTS_SUPER_MAGIC; diff --git a/fs/exec.c b/fs/exec.c index a126e3d1cacb..b62b67bea10b 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -112,7 +112,7 @@ static inline void put_binfmt(struct linux_binfmt * fmt) bool path_noexec(const struct path *path) { return (path->mnt->mnt_flags & MNT_NOEXEC) || - (path->mnt->mnt_sb->s_iflags & SB_I_NOEXEC); + sb_test_iflag(path->mnt->mnt_sb, _SB_I_NOEXEC); } #ifdef CONFIG_USELIB diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 37f7ce56adce..9da8652c10c5 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -916,7 +916,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); - sb->s_iflags |= SB_I_CGROUPWB; + sb_set_iflag(sb, _SB_I_CGROUPWB); if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 93c016b186c0..a776d4e7ec66 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4972,7 +4972,7 @@ static int ext4_check_journal_data_mode(struct super_block *sb) if (test_opt(sb, DELALLOC)) clear_opt(sb, DELALLOC); } else { - sb->s_iflags |= SB_I_CGROUPWB; + sb_set_iflag(sb, _SB_I_CGROUPWB); } return 0; diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 3959fd137cc9..041b7b7b0810 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4472,7 +4472,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0); super_set_uuid(sb, (void *) raw_super->uuid, sizeof(raw_super->uuid)); super_set_sysfs_name_bdev(sb); - sb->s_iflags |= SB_I_CGROUPWB; + sb_set_iflag(sb, _SB_I_CGROUPWB); /* init f2fs-specific super block info */ sbi->valid_super_block = valid_super_block; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index d8ab4e93916f..3602a578b7b3 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1566,9 +1566,9 @@ static void fuse_sb_defaults(struct super_block *sb) sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_time_gran = 1; sb->s_export_op = &fuse_export_operations; - sb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE; + sb_set_iflag(sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE); if (sb->s_user_ns != &init_user_ns) - sb->s_iflags |= SB_I_UNTRUSTED_MOUNTER; + sb_set_iflag(sb, _SB_I_UNTRUSTED_MOUNTER); sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION); } diff --git a/fs/inode.c b/fs/inode.c index 86670941884b..a8598a968940 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -216,7 +216,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode) lockdep_set_class_and_name(&mapping->invalidate_lock, &sb->s_type->invalidate_lock_key, "mapping.invalidate_lock"); - if (sb->s_iflags & SB_I_STABLE_WRITES) + if (sb_test_iflag(sb, _SB_I_STABLE_WRITES)) mapping_set_stable_writes(mapping); inode->i_private = NULL; inode->i_mapping = mapping; diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index 1358c21837f1..762edcf5387e 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -252,7 +252,8 @@ static int kernfs_fill_super(struct super_block *sb, struct kernfs_fs_context *k info->sb = sb; /* Userspace would break if executables or devices appear on sysfs */ - sb->s_iflags |= SB_I_NOEXEC | SB_I_NODEV; + sb_set_iflag(sb, _SB_I_NOEXEC); + sb_set_iflag(sb, _SB_I_NODEV); sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; sb->s_magic = kfc->magic; diff --git a/fs/namei.c b/fs/namei.c index 5512cb10fa89..de6936564298 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3308,7 +3308,7 @@ EXPORT_SYMBOL(vfs_mkobj); bool may_open_dev(const struct path *path) { return !(path->mnt->mnt_flags & MNT_NODEV) && - !(path->mnt->mnt_sb->s_iflags & SB_I_NODEV); + !sb_test_iflag(path->mnt->mnt_sb, _SB_I_NODEV); } static int may_open(struct mnt_idmap *idmap, const struct path *path, diff --git a/fs/namespace.c b/fs/namespace.c index 75153f61a908..17126569b3c4 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2919,7 +2919,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * struct super_block *sb = mnt->mnt_sb; if (!__mnt_is_readonly(mnt) && - (!(sb->s_iflags & SB_I_TS_EXPIRY_WARNED)) && + !sb_test_iflag(sb, _SB_I_TS_EXPIRY_WARNED) && (ktime_get_real_seconds() + TIME_UPTIME_SEC_MAX > sb->s_time_max)) { char *buf = (char *)__get_free_page(GFP_KERNEL); char *mntpath = buf ? d_path(mountpoint, buf, PAGE_SIZE) : ERR_PTR(-ENOMEM); @@ -2931,7 +2931,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * (unsigned long long)sb->s_time_max); free_page((unsigned long)buf); - sb->s_iflags |= SB_I_TS_EXPIRY_WARNED; + sb_set_iflag(sb, _SB_I_TS_EXPIRY_WARNED); } } diff --git a/fs/nfs/super.c b/fs/nfs/super.c index cbbd4866b0b7..b6b806fb6286 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -1094,7 +1094,7 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx) sb->s_export_op = &nfs_export_ops; break; case 4: - sb->s_iflags |= SB_I_NOUMASK; + sb_set_iflag(sb, _SB_I_NOUMASK); sb->s_time_gran = 1; sb->s_time_min = S64_MIN; sb->s_time_max = S64_MAX; diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 06a231970cb5..afa5263ff016 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1453,14 +1453,14 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc) #ifdef CONFIG_FS_POSIX_ACL sb->s_flags |= SB_POSIXACL; #endif - sb->s_iflags |= SB_I_SKIP_SYNC; + sb_set_iflag(sb, _SB_I_SKIP_SYNC); /* * Ensure that umask handling is done by the filesystems used * for the the upper layer instead of overlayfs as that would * lead to unexpected results. */ - sb->s_iflags |= SB_I_NOUMASK; - sb->s_iflags |= SB_I_EVM_HMAC_UNSUPPORTED; + sb_set_iflag(sb, _SB_I_NOUMASK); + sb_set_iflag(sb, _SB_I_EVM_HMAC_UNSUPPORTED); err = -ENOMEM; root_dentry = ovl_get_root(sb, ctx->upper.dentry, oe); diff --git a/fs/proc/root.c b/fs/proc/root.c index 06a297a27ba3..ac78ec69dde9 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -171,7 +171,9 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc) proc_apply_options(fs_info, fc, current_user_ns()); /* User space would break if executables or devices appear on proc */ - s->s_iflags |= SB_I_USERNS_VISIBLE | SB_I_NOEXEC | SB_I_NODEV; + sb_set_iflag(s, _SB_I_USERNS_VISIBLE); + sb_set_iflag(s, _SB_I_NOEXEC); + sb_set_iflag(s, _SB_I_NODEV); s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC; s->s_blocksize = 1024; s->s_blocksize_bits = 10; diff --git a/fs/super.c b/fs/super.c index 38d72a3cf6fc..e3020b3db4f0 100644 --- a/fs/super.c +++ b/fs/super.c @@ -355,7 +355,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_bdi = &noop_backing_dev_info; s->s_flags = flags; if (s->s_user_ns != &init_user_ns) - s->s_iflags |= SB_I_NODEV; + sb_set_iflag(s, _SB_I_NODEV); INIT_HLIST_NODE(&s->s_instances); INIT_HLIST_BL_HEAD(&s->s_roots); mutex_init(&s->s_sync_lock); @@ -589,11 +589,11 @@ void retire_super(struct super_block *sb) { WARN_ON(!sb->s_bdev); __super_lock_excl(sb); - if (sb->s_iflags & SB_I_PERSB_BDI) { + if (sb_test_iflag(sb, _SB_I_PERSB_BDI)) { bdi_unregister(sb->s_bdi); - sb->s_iflags &= ~SB_I_PERSB_BDI; + sb_clear_iflag(sb, _SB_I_PERSB_BDI); } - sb->s_iflags |= SB_I_RETIRED; + sb_set_iflag(sb, _SB_I_RETIRED); super_unlock_excl(sb); } EXPORT_SYMBOL(retire_super); @@ -678,7 +678,7 @@ void generic_shutdown_super(struct super_block *sb) super_wake(sb, SB_DYING); super_unlock_excl(sb); if (sb->s_bdi != &noop_backing_dev_info) { - if (sb->s_iflags & SB_I_PERSB_BDI) + if (sb_test_iflag(sb, _SB_I_PERSB_BDI)) bdi_unregister(sb->s_bdi); bdi_put(sb->s_bdi); sb->s_bdi = &noop_backing_dev_info; @@ -1331,7 +1331,7 @@ static int super_s_dev_set(struct super_block *s, struct fs_context *fc) static int super_s_dev_test(struct super_block *s, struct fs_context *fc) { - return !(s->s_iflags & SB_I_RETIRED) && + return !sb_test_iflag(s, _SB_I_RETIRED) && s->s_dev == *(dev_t *)fc->sget_key; } @@ -1584,7 +1584,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, sb->s_bdev = bdev; sb->s_bdi = bdi_get(bdev->bd_disk->bdi); if (bdev_stable_writes(bdev)) - sb->s_iflags |= SB_I_STABLE_WRITES; + sb_set_iflag(sb, _SB_I_STABLE_WRITES); spin_unlock(&sb_lock); snprintf(sb->s_id, sizeof(sb->s_id), "%pg", bdev); @@ -1648,7 +1648,7 @@ EXPORT_SYMBOL(get_tree_bdev); static int test_bdev_super(struct super_block *s, void *data) { - return !(s->s_iflags & SB_I_RETIRED) && s->s_dev == *(dev_t *)data; + return !sb_test_iflag(s, _SB_I_RETIRED) && s->s_dev == *(dev_t *)data; } struct dentry *mount_bdev(struct file_system_type *fs_type, @@ -1864,7 +1864,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) } WARN_ON(sb->s_bdi != &noop_backing_dev_info); sb->s_bdi = bdi; - sb->s_iflags |= SB_I_PERSB_BDI; + sb_set_iflag(sb, _SB_I_PERSB_BDI); return 0; } diff --git a/fs/sync.c b/fs/sync.c index dc725914e1ed..4e5ad48316be 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -79,7 +79,7 @@ static void sync_inodes_one_sb(struct super_block *sb, void *arg) static void sync_fs_one_sb(struct super_block *sb, void *arg) { - if (!sb_rdonly(sb) && !(sb->s_iflags & SB_I_SKIP_SYNC) && + if (!sb_rdonly(sb) && !sb_test_iflag(sb, _SB_I_SKIP_SYNC) && sb->s_op->sync_fs) sb->s_op->sync_fs(sb, *(int *)arg); } diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 98467bb76737..124385961da7 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c @@ -33,7 +33,7 @@ static int sysfs_get_tree(struct fs_context *fc) return ret; if (kfc->new_sb_created) - fc->root->d_sb->s_iflags |= SB_I_USERNS_VISIBLE; + sb_set_iflag(fc->root->d_sb, _SB_I_USERNS_VISIBLE); return 0; } diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 27e9f749c4c7..7707f2a1a836 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1701,7 +1701,7 @@ xfs_fs_fill_super( sb->s_time_max = XFS_LEGACY_TIME_MAX; } trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max); - sb->s_iflags |= SB_I_CGROUPWB; + sb_set_iflag(sb, _SB_I_CGROUPWB); set_posix_acl_flag(sb); diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 8e7af9a03b41..54fdae7b1be4 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -176,7 +176,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode) return cgroup_subsys_on_dfl(memory_cgrp_subsys) && cgroup_subsys_on_dfl(io_cgrp_subsys) && (bdi->capabilities & BDI_CAP_WRITEBACK) && - (inode->i_sb->s_iflags & SB_I_CGROUPWB); + sb_test_iflag(inode->i_sb, _SB_I_CGROUPWB); } /** diff --git a/include/linux/namei.h b/include/linux/namei.h index 8ec8fed3bce8..3fbf340dac1a 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -107,7 +107,7 @@ extern void unlock_rename(struct dentry *, struct dentry *); */ static inline umode_t __must_check mode_strip_umask(const struct inode *dir, umode_t mode) { - if (!IS_POSIXACL(dir) && !(dir->i_sb->s_iflags & SB_I_NOUMASK)) + if (!IS_POSIXACL(dir) && !sb_test_iflag(dir->i_sb, _SB_I_NOUMASK)) mode &= ~current_umask(); return mode; } diff --git a/ipc/mqueue.c b/ipc/mqueue.c index a7cbd69efbef..e73fff4c2f12 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -406,7 +406,8 @@ static int mqueue_fill_super(struct super_block *sb, struct fs_context *fc) struct inode *inode; struct ipc_namespace *ns = sb->s_fs_info; - sb->s_iflags |= SB_I_NOEXEC | SB_I_NODEV; + sb_set_iflag(sb, _SB_I_NOEXEC); + sb_set_iflag(sb, _SB_I_NODEV); sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; sb->s_magic = MQUEUE_MAGIC; diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 62fe66dd53ce..3ff29bf73f04 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -155,7 +155,7 @@ static int is_unsupported_hmac_fs(struct dentry *dentry) { struct inode *inode = d_backing_inode(dentry); - if (inode->i_sb->s_iflags & SB_I_EVM_HMAC_UNSUPPORTED) { + if (sb_test_iflag(inode->i_sb, _SB_I_EVM_HMAC_UNSUPPORTED)) { pr_info_once("%s not supported\n", inode->i_sb->s_type->name); return 1; } diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index 656c709b974f..9c290dd8a4ac 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c @@ -564,8 +564,8 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint, * system not willing to accept such a risk, fail the file signature * verification. */ - if ((inode->i_sb->s_iflags & SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - ((inode->i_sb->s_iflags & SB_I_UNTRUSTED_MOUNTER) || + if (sb_test_iflag(inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && + (sb_test_iflag(inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) || (iint->flags & IMA_FAIL_UNVERIFIABLE_SIGS))) { status = INTEGRITY_FAIL; cause = "unverifiable-signature"; diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index f04f43af651c..b04eaa33eca4 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -280,8 +280,8 @@ static int process_measurement(struct file *file, const struct cred *cred, * (Limited to privileged mounted filesystems.) */ if (test_and_clear_bit(IMA_CHANGE_XATTR, &iint->atomic_flags) || - ((inode->i_sb->s_iflags & SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - !(inode->i_sb->s_iflags & SB_I_UNTRUSTED_MOUNTER) && + (sb_test_iflag(inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && + !sb_test_iflag(inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) && !(action & IMA_FAIL_UNVERIFIABLE_SIGS))) { iint->flags &= ~IMA_DONE_MASK; iint->measured_pcrs = 0; From patchwork Wed Aug 7 18:29:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756616 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2659F13E41F for ; Wed, 7 Aug 2024 18:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; cv=none; b=eRbF3gCjiv0utgVNHt6ml4kyyD9p/x46EG3mwHgwcm7JlHcM4+I7Ju93DoxtidcFmllq5nFshYmOa8EzbVpFOkjVFcCukrIMq+fSUi6kkDutuEFNleqjVhk3s8Slf1xN7aLmS47xNMGHtButbE3IP54S/8bIZow1QQyhGJZ0wjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; c=relaxed/simple; bh=DenUDpj3WqoI+B4EOpl4Crt9s0SwJCelBY3MVGTT8u8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pmMCcokL7WmumtJmeqCeUVYL6qAv7yVE2lIalPuio9uCGmNbnH6tLthcNL1dsZPw2P80WbqynzC0G5obj9cQx+oTg2WaZQcSvAzkcQx3UtqOMNDXHntV2qgCw98WjeRpozB2RGrnv7ao3/pXwW0ulLeALz2ADQm27eYbibzmCDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=OlIHY11o; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=d2RbIBSV; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=OlIHY11o; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=d2RbIBSV; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="OlIHY11o"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="d2RbIBSV"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="OlIHY11o"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="d2RbIBSV" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 869FD1FB9D; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QCURvdHGtOg2D85NSVbPrAOjn4jDG7r8Kn9996m3dEE=; b=OlIHY11o6GrrUPX9Huj+n8G246yqmGYPnEuLWBDm3NsyBBjlC7avl+xPwsbMwqoTfCBCSI Neqrs0ZRyhD8t42N4ptoDkCubl8UzFQlPNULFjYL9nAohg4TGubTbLhIPGLYfaa0P5+3bx x7DQ/jQn3NDq2vz+ylDlsnZZ83bAj1c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QCURvdHGtOg2D85NSVbPrAOjn4jDG7r8Kn9996m3dEE=; b=d2RbIBSVV8RYbRFk4Ya52yHqF29rOtmASPFBlIsg8mCPe9Cjzqf4eBx/NdkDs4VIo4MSqS Pd/xP26w5R7HIiBQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QCURvdHGtOg2D85NSVbPrAOjn4jDG7r8Kn9996m3dEE=; b=OlIHY11o6GrrUPX9Huj+n8G246yqmGYPnEuLWBDm3NsyBBjlC7avl+xPwsbMwqoTfCBCSI Neqrs0ZRyhD8t42N4ptoDkCubl8UzFQlPNULFjYL9nAohg4TGubTbLhIPGLYfaa0P5+3bx x7DQ/jQn3NDq2vz+ylDlsnZZ83bAj1c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QCURvdHGtOg2D85NSVbPrAOjn4jDG7r8Kn9996m3dEE=; b=d2RbIBSVV8RYbRFk4Ya52yHqF29rOtmASPFBlIsg8mCPe9Cjzqf4eBx/NdkDs4VIo4MSqS Pd/xP26w5R7HIiBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6C10C13B0C; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Qh6rGSy9s2Z5NAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id B7402A086C; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 05/13] fs: Drop old SB_I_ constants Date: Wed, 7 Aug 2024 20:29:50 +0200 Message-Id: <20240807183003.23562-5-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1555; i=jack@suse.cz; h=from:subject; bh=DenUDpj3WqoI+B4EOpl4Crt9s0SwJCelBY3MVGTT8u8=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70ecNm9L336fzN53aq0+RButYd43MhRyoYgUsIu QXNdXjuJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9HgAKCRCcnaoHP2RA2ffwB/ 4+mBEo6BlsbvpLv3ZPib91EFBXMxYw2bJ+z6ozXve7/g6jPbp3omH1/9BrRYxss+dmkX7x7vklgyFv efU+Z0wB9SU4c5vtG9aHgMiNHCXfKWw62lujt8wDaLTmyk8xNfLN7oOMerbDMcnjl3ESOFxGSe2a1y BIxO/HIZdl6HLuqLUJF7mdoe4J8NNngaxvggnA/A9AVTFNmHoZrHrqm8dRrEcg5lZ2Ufk7dZPZy774 K7rkxbJ1tB3KIO1g7iqsFLWW4C9K/DxE60IXsBwxpiQZGoTzDzWPv0dS/wn+pUSTv91ILJcCdU6nK4 wDn5D9f09hg18jUtJn8/tQViEj71u5 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Level: X-Spamd-Result: default: False [0.20 / 50.00]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email] X-Spam-Flag: NO X-Spam-Score: 0.20 Nothing is using the old SB_I_ constants anymore. Remove them. Signed-off-by: Jan Kara --- include/linux/fs.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index ff45a97b39cb..65e70ceb335e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1173,23 +1173,6 @@ extern int send_sigurg(struct fown_struct *fown); #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ /* sb->s_iflags */ -#define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */ -#define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */ -#define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */ -#define SB_I_STABLE_WRITES 0x00000008 /* don't modify blks until WB is done */ - -/* sb->s_iflags to limit user namespace mounts */ -#define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ -#define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020 -#define SB_I_UNTRUSTED_MOUNTER 0x00000040 -#define SB_I_EVM_HMAC_UNSUPPORTED 0x00000080 - -#define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */ -#define SB_I_PERSB_BDI 0x00000200 /* has a per-sb bdi */ -#define SB_I_TS_EXPIRY_WARNED 0x00000400 /* warned about timestamp range expiry */ -#define SB_I_RETIRED 0x00000800 /* superblock shouldn't be reused */ -#define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */ - enum { _SB_I_CGROUPWB, /* cgroup-aware writeback enabled */ _SB_I_NOEXEC, /* Ignore executables on this fs */ From patchwork Wed Aug 7 18:29:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756624 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7DC214374C for ; Wed, 7 Aug 2024 18:30:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055413; cv=none; b=txjCxXaCFsK85m+5ChgP2SYyNkpJjS8mwFXn13+Pc0lKIkF+rS+3J+nNUn1NMw3TXJ0K//2E4Fo2qTxf4RoaFEaV7TrclFZkbcQq7/S3lKrBhmAjS0hkGUoXy7qLiCxY4BK9h0024aIebVl85/8uDwOymvyQuV4XtmyJvp3Lt7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055413; c=relaxed/simple; bh=xdVKxLuhh7kQ4pi7CNuIs5KuDljkW9yy7R1YP6bnphA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E+UGbijeQTQA1jrmP23EPm59r6kEOA7OzFa2WWg60DR+uQ8KpNITJqSHjPwTDuGnlfqhhKHPxYYy0DncDigggRykac0fbJJLLzyncOSygoVPO4vas34ozg8unlEjJSCkJTe4xGxTyohTDsZFMLmT0ky5REGJagfmxh2W9KDr1Pg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=m0oqXG60; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=Q0oVhd0w; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=m0oqXG60; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=Q0oVhd0w; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="m0oqXG60"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Q0oVhd0w"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="m0oqXG60"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Q0oVhd0w" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8207C21CEF; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VwczmGJuzBlAGThCZWPl+ZsYNhfyPWCCY1cAKUTf6Bs=; b=m0oqXG60Uat7Auh7EdhjKna6lH9keceM50szKWnU7uSCAro2N2Y/mfwY+aruEaS+SqA7ZD /WYUzfroge5/KKZatD++yzH6rvbxb5TBwWTUEkavhKAUoRFfhfS+XxROpQPsr/gRCBg3lL peZ6Mul91186Fec3KpAMnjg0GHIRtJE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VwczmGJuzBlAGThCZWPl+ZsYNhfyPWCCY1cAKUTf6Bs=; b=Q0oVhd0waOXRRkPo5QUqFlRU5tFWGpGwdvUuh9xkrxSG4lzFENO95eKlEDlo8vl081dFwF vE4Fee2rnjojdwDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VwczmGJuzBlAGThCZWPl+ZsYNhfyPWCCY1cAKUTf6Bs=; b=m0oqXG60Uat7Auh7EdhjKna6lH9keceM50szKWnU7uSCAro2N2Y/mfwY+aruEaS+SqA7ZD /WYUzfroge5/KKZatD++yzH6rvbxb5TBwWTUEkavhKAUoRFfhfS+XxROpQPsr/gRCBg3lL peZ6Mul91186Fec3KpAMnjg0GHIRtJE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VwczmGJuzBlAGThCZWPl+ZsYNhfyPWCCY1cAKUTf6Bs=; b=Q0oVhd0waOXRRkPo5QUqFlRU5tFWGpGwdvUuh9xkrxSG4lzFENO95eKlEDlo8vl081dFwF vE4Fee2rnjojdwDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 636AE13B09; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id PZpDGCy9s2Z1NAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C0151A0873; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 06/13] fs: Drop unnecessary underscore from _SB_I_ constants Date: Wed, 7 Aug 2024 20:29:51 +0200 Message-Id: <20240807183003.23562-6-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=21137; i=jack@suse.cz; h=from:subject; bh=xdVKxLuhh7kQ4pi7CNuIs5KuDljkW9yy7R1YP6bnphA=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70fN/jLNwNyk51iZVXXCj6pEJVRT/2kJfWv0Z2O qqDlMMCJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9HwAKCRCcnaoHP2RA2ZZZB/ 9azu+5TA2B5dO2rStjybow6FrVV6woijRJyjpGse5BwIUva0Pz1QxXSGSzbmhhQDZrdmIUJXoNi4P+ 9G0Qb922fTD2Z6h/b2vCklXsqtpKOfpQaTMP7HFubQwvoxQEeHmIRM4DZhhmzwRwBYURJnmKZ3grMS Ogjl8gACdD7aGZ6bhAgGjtmwFe9nvZWDnBltFdW0SeNkB10a/MC7fMwlBp8DI8CvcEvPxZ93aHJivf 0LSMpgxUgsZAfcvqxGGbircXGL7T1s8ur76VmzH10pEZn9Qc6LoTGQjuLU3Tn2We/ucdRJVM+OM7Rl gTLwOWHpDb+4LEW0Lf+yCXv5bB/i0A X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -2.80 X-Spam-Flag: NO X-Spam-Level: Now that old constants are gone, remove the unnecessary underscore from the new _SB_I_ constants. Pure mechanical replacement, no functional changes. Signed-off-by: Jan Kara --- block/bdev.c | 2 +- drivers/android/binderfs.c | 4 ++-- fs/aio.c | 2 +- fs/btrfs/super.c | 2 +- fs/devpts/inode.c | 2 +- fs/exec.c | 2 +- fs/ext2/super.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fuse/inode.c | 4 ++-- fs/inode.c | 2 +- fs/kernfs/mount.c | 4 ++-- fs/namei.c | 2 +- fs/namespace.c | 8 ++++---- fs/nfs/fs_context.c | 2 +- fs/nfs/super.c | 2 +- fs/overlayfs/super.c | 6 +++--- fs/proc/root.c | 6 +++--- fs/super.c | 18 ++++++++--------- fs/sync.c | 2 +- fs/sysfs/mount.c | 2 +- fs/xfs/xfs_super.c | 2 +- include/linux/backing-dev.h | 2 +- include/linux/fs.h | 28 +++++++++++++-------------- include/linux/namei.h | 2 +- ipc/mqueue.c | 4 ++-- security/integrity/evm/evm_main.c | 2 +- security/integrity/ima/ima_appraise.c | 4 ++-- security/integrity/ima/ima_main.c | 4 ++-- 29 files changed, 63 insertions(+), 63 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index c1ea2aeb93dd..6c13ba60c0b1 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -373,7 +373,7 @@ static int bd_init_fs_context(struct fs_context *fc) struct pseudo_fs_context *ctx = init_pseudo(fc, BDEVFS_MAGIC); if (!ctx) return -ENOMEM; - fc->s_iflags |= 1 << _SB_I_CGROUPWB; + fc->s_iflags |= 1 << SB_I_CGROUPWB; ctx->ops = &bdev_sops; return 0; } diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c index f9454b93c2f7..6070923fbfbd 100644 --- a/drivers/android/binderfs.c +++ b/drivers/android/binderfs.c @@ -672,8 +672,8 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc) * allowed to do. So removing the SB_I_NODEV flag from s_iflags is both * necessary and safe. */ - sb_clear_iflag(sb, _SB_I_NODEV); - sb_set_iflag(sb, _SB_I_NOEXEC); + sb_clear_iflag(sb, SB_I_NODEV); + sb_set_iflag(sb, SB_I_NOEXEC); sb->s_magic = BINDERFS_SUPER_MAGIC; sb->s_op = &binderfs_super_ops; sb->s_time_gran = 1; diff --git a/fs/aio.c b/fs/aio.c index 63ce0736c3a3..48d99221ff57 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -279,7 +279,7 @@ static int aio_init_fs_context(struct fs_context *fc) { if (!init_pseudo(fc, AIO_RING_MAGIC)) return -ENOMEM; - fc->s_iflags |= 1 << _SB_I_NOEXEC; + fc->s_iflags |= 1 << SB_I_NOEXEC; return 0; } diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 321696697279..fb3938ec127c 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -950,7 +950,7 @@ static int btrfs_fill_super(struct super_block *sb, #endif sb->s_xattr = btrfs_xattr_handlers; sb->s_time_gran = 1; - sb_set_iflag(sb, _SB_I_CGROUPWB); + sb_set_iflag(sb, SB_I_CGROUPWB); err = super_setup_bdi(sb); if (err) { diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index d473156d2791..6094cb7e1a16 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -428,7 +428,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent) struct inode *inode; int error; - sb_clear_iflag(s, _SB_I_NODEV); + sb_clear_iflag(s, SB_I_NODEV); s->s_blocksize = 1024; s->s_blocksize_bits = 10; s->s_magic = DEVPTS_SUPER_MAGIC; diff --git a/fs/exec.c b/fs/exec.c index b62b67bea10b..a8bd15aa6bd8 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -112,7 +112,7 @@ static inline void put_binfmt(struct linux_binfmt * fmt) bool path_noexec(const struct path *path) { return (path->mnt->mnt_flags & MNT_NOEXEC) || - sb_test_iflag(path->mnt->mnt_sb, _SB_I_NOEXEC); + sb_test_iflag(path->mnt->mnt_sb, SB_I_NOEXEC); } #ifdef CONFIG_USELIB diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 9da8652c10c5..cbe79fb7ac35 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -916,7 +916,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); - sb_set_iflag(sb, _SB_I_CGROUPWB); + sb_set_iflag(sb, SB_I_CGROUPWB); if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || diff --git a/fs/ext4/super.c b/fs/ext4/super.c index a776d4e7ec66..b5b2f17f1b65 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4972,7 +4972,7 @@ static int ext4_check_journal_data_mode(struct super_block *sb) if (test_opt(sb, DELALLOC)) clear_opt(sb, DELALLOC); } else { - sb_set_iflag(sb, _SB_I_CGROUPWB); + sb_set_iflag(sb, SB_I_CGROUPWB); } return 0; diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 041b7b7b0810..8437612bf64b 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4472,7 +4472,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0); super_set_uuid(sb, (void *) raw_super->uuid, sizeof(raw_super->uuid)); super_set_sysfs_name_bdev(sb); - sb_set_iflag(sb, _SB_I_CGROUPWB); + sb_set_iflag(sb, SB_I_CGROUPWB); /* init f2fs-specific super block info */ sbi->valid_super_block = valid_super_block; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 3602a578b7b3..5b6254481d5c 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1566,9 +1566,9 @@ static void fuse_sb_defaults(struct super_block *sb) sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_time_gran = 1; sb->s_export_op = &fuse_export_operations; - sb_set_iflag(sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE); + sb_set_iflag(sb, SB_I_IMA_UNVERIFIABLE_SIGNATURE); if (sb->s_user_ns != &init_user_ns) - sb_set_iflag(sb, _SB_I_UNTRUSTED_MOUNTER); + sb_set_iflag(sb, SB_I_UNTRUSTED_MOUNTER); sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION); } diff --git a/fs/inode.c b/fs/inode.c index a8598a968940..3091385a4de1 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -216,7 +216,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode) lockdep_set_class_and_name(&mapping->invalidate_lock, &sb->s_type->invalidate_lock_key, "mapping.invalidate_lock"); - if (sb_test_iflag(sb, _SB_I_STABLE_WRITES)) + if (sb_test_iflag(sb, SB_I_STABLE_WRITES)) mapping_set_stable_writes(mapping); inode->i_private = NULL; inode->i_mapping = mapping; diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index 762edcf5387e..f5331f2e0b2d 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -252,8 +252,8 @@ static int kernfs_fill_super(struct super_block *sb, struct kernfs_fs_context *k info->sb = sb; /* Userspace would break if executables or devices appear on sysfs */ - sb_set_iflag(sb, _SB_I_NOEXEC); - sb_set_iflag(sb, _SB_I_NODEV); + sb_set_iflag(sb, SB_I_NOEXEC); + sb_set_iflag(sb, SB_I_NODEV); sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; sb->s_magic = kfc->magic; diff --git a/fs/namei.c b/fs/namei.c index de6936564298..9e9bca0566e9 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3308,7 +3308,7 @@ EXPORT_SYMBOL(vfs_mkobj); bool may_open_dev(const struct path *path) { return !(path->mnt->mnt_flags & MNT_NODEV) && - !sb_test_iflag(path->mnt->mnt_sb, _SB_I_NODEV); + !sb_test_iflag(path->mnt->mnt_sb, SB_I_NODEV); } static int may_open(struct mnt_idmap *idmap, const struct path *path, diff --git a/fs/namespace.c b/fs/namespace.c index 17126569b3c4..1c5591673f96 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2919,7 +2919,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * struct super_block *sb = mnt->mnt_sb; if (!__mnt_is_readonly(mnt) && - !sb_test_iflag(sb, _SB_I_TS_EXPIRY_WARNED) && + !sb_test_iflag(sb, SB_I_TS_EXPIRY_WARNED) && (ktime_get_real_seconds() + TIME_UPTIME_SEC_MAX > sb->s_time_max)) { char *buf = (char *)__get_free_page(GFP_KERNEL); char *mntpath = buf ? d_path(mountpoint, buf, PAGE_SIZE) : ERR_PTR(-ENOMEM); @@ -2931,7 +2931,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * (unsigned long long)sb->s_time_max); free_page((unsigned long)buf); - sb_set_iflag(sb, _SB_I_TS_EXPIRY_WARNED); + sb_set_iflag(sb, SB_I_TS_EXPIRY_WARNED); } } @@ -5629,10 +5629,10 @@ static bool mount_too_revealing(const struct super_block *sb, int *new_mnt_flags return false; /* Can this filesystem be too revealing? */ - if (!sb_test_iflag(sb, _SB_I_USERNS_VISIBLE)) + if (!sb_test_iflag(sb, SB_I_USERNS_VISIBLE)) return false; - if (!sb_test_iflag(sb, _SB_I_NOEXEC) || !sb_test_iflag(sb, _SB_I_NODEV)) { + if (!sb_test_iflag(sb, SB_I_NOEXEC) || !sb_test_iflag(sb, SB_I_NODEV)) { WARN_ONCE(1, "Expected s_iflags to contain SB_I_NOEXEC and " "SB_I_NODEV\n"); return true; diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 2fbae7e2b6ce..52fc52b6350f 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1643,7 +1643,7 @@ static int nfs_init_fs_context(struct fs_context *fc) ctx->xprtsec.cert_serial = TLS_NO_CERT; ctx->xprtsec.privkey_serial = TLS_NO_PRIVKEY; - fc->s_iflags |= 1 << _SB_I_STABLE_WRITES; + fc->s_iflags |= 1 << SB_I_STABLE_WRITES; } fc->fs_private = ctx; fc->ops = &nfs_fs_context_ops; diff --git a/fs/nfs/super.c b/fs/nfs/super.c index b6b806fb6286..246ecceda7c8 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -1094,7 +1094,7 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx) sb->s_export_op = &nfs_export_ops; break; case 4: - sb_set_iflag(sb, _SB_I_NOUMASK); + sb_set_iflag(sb, SB_I_NOUMASK); sb->s_time_gran = 1; sb->s_time_min = S64_MIN; sb->s_time_max = S64_MAX; diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index afa5263ff016..f5a60d0bcb1c 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1453,14 +1453,14 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc) #ifdef CONFIG_FS_POSIX_ACL sb->s_flags |= SB_POSIXACL; #endif - sb_set_iflag(sb, _SB_I_SKIP_SYNC); + sb_set_iflag(sb, SB_I_SKIP_SYNC); /* * Ensure that umask handling is done by the filesystems used * for the the upper layer instead of overlayfs as that would * lead to unexpected results. */ - sb_set_iflag(sb, _SB_I_NOUMASK); - sb_set_iflag(sb, _SB_I_EVM_HMAC_UNSUPPORTED); + sb_set_iflag(sb, SB_I_NOUMASK); + sb_set_iflag(sb, SB_I_EVM_HMAC_UNSUPPORTED); err = -ENOMEM; root_dentry = ovl_get_root(sb, ctx->upper.dentry, oe); diff --git a/fs/proc/root.c b/fs/proc/root.c index ac78ec69dde9..7acfa535b925 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -171,9 +171,9 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc) proc_apply_options(fs_info, fc, current_user_ns()); /* User space would break if executables or devices appear on proc */ - sb_set_iflag(s, _SB_I_USERNS_VISIBLE); - sb_set_iflag(s, _SB_I_NOEXEC); - sb_set_iflag(s, _SB_I_NODEV); + sb_set_iflag(s, SB_I_USERNS_VISIBLE); + sb_set_iflag(s, SB_I_NOEXEC); + sb_set_iflag(s, SB_I_NODEV); s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC; s->s_blocksize = 1024; s->s_blocksize_bits = 10; diff --git a/fs/super.c b/fs/super.c index e3020b3db4f0..873808245d54 100644 --- a/fs/super.c +++ b/fs/super.c @@ -355,7 +355,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_bdi = &noop_backing_dev_info; s->s_flags = flags; if (s->s_user_ns != &init_user_ns) - sb_set_iflag(s, _SB_I_NODEV); + sb_set_iflag(s, SB_I_NODEV); INIT_HLIST_NODE(&s->s_instances); INIT_HLIST_BL_HEAD(&s->s_roots); mutex_init(&s->s_sync_lock); @@ -589,11 +589,11 @@ void retire_super(struct super_block *sb) { WARN_ON(!sb->s_bdev); __super_lock_excl(sb); - if (sb_test_iflag(sb, _SB_I_PERSB_BDI)) { + if (sb_test_iflag(sb, SB_I_PERSB_BDI)) { bdi_unregister(sb->s_bdi); - sb_clear_iflag(sb, _SB_I_PERSB_BDI); + sb_clear_iflag(sb, SB_I_PERSB_BDI); } - sb_set_iflag(sb, _SB_I_RETIRED); + sb_set_iflag(sb, SB_I_RETIRED); super_unlock_excl(sb); } EXPORT_SYMBOL(retire_super); @@ -678,7 +678,7 @@ void generic_shutdown_super(struct super_block *sb) super_wake(sb, SB_DYING); super_unlock_excl(sb); if (sb->s_bdi != &noop_backing_dev_info) { - if (sb_test_iflag(sb, _SB_I_PERSB_BDI)) + if (sb_test_iflag(sb, SB_I_PERSB_BDI)) bdi_unregister(sb->s_bdi); bdi_put(sb->s_bdi); sb->s_bdi = &noop_backing_dev_info; @@ -1331,7 +1331,7 @@ static int super_s_dev_set(struct super_block *s, struct fs_context *fc) static int super_s_dev_test(struct super_block *s, struct fs_context *fc) { - return !sb_test_iflag(s, _SB_I_RETIRED) && + return !sb_test_iflag(s, SB_I_RETIRED) && s->s_dev == *(dev_t *)fc->sget_key; } @@ -1584,7 +1584,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, sb->s_bdev = bdev; sb->s_bdi = bdi_get(bdev->bd_disk->bdi); if (bdev_stable_writes(bdev)) - sb_set_iflag(sb, _SB_I_STABLE_WRITES); + sb_set_iflag(sb, SB_I_STABLE_WRITES); spin_unlock(&sb_lock); snprintf(sb->s_id, sizeof(sb->s_id), "%pg", bdev); @@ -1648,7 +1648,7 @@ EXPORT_SYMBOL(get_tree_bdev); static int test_bdev_super(struct super_block *s, void *data) { - return !sb_test_iflag(s, _SB_I_RETIRED) && s->s_dev == *(dev_t *)data; + return !sb_test_iflag(s, SB_I_RETIRED) && s->s_dev == *(dev_t *)data; } struct dentry *mount_bdev(struct file_system_type *fs_type, @@ -1864,7 +1864,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) } WARN_ON(sb->s_bdi != &noop_backing_dev_info); sb->s_bdi = bdi; - sb_set_iflag(sb, _SB_I_PERSB_BDI); + sb_set_iflag(sb, SB_I_PERSB_BDI); return 0; } diff --git a/fs/sync.c b/fs/sync.c index 4e5ad48316be..a7c0645aa9dc 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -79,7 +79,7 @@ static void sync_inodes_one_sb(struct super_block *sb, void *arg) static void sync_fs_one_sb(struct super_block *sb, void *arg) { - if (!sb_rdonly(sb) && !sb_test_iflag(sb, _SB_I_SKIP_SYNC) && + if (!sb_rdonly(sb) && !sb_test_iflag(sb, SB_I_SKIP_SYNC) && sb->s_op->sync_fs) sb->s_op->sync_fs(sb, *(int *)arg); } diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 124385961da7..b461c216731a 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c @@ -33,7 +33,7 @@ static int sysfs_get_tree(struct fs_context *fc) return ret; if (kfc->new_sb_created) - sb_set_iflag(fc->root->d_sb, _SB_I_USERNS_VISIBLE); + sb_set_iflag(fc->root->d_sb, SB_I_USERNS_VISIBLE); return 0; } diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 7707f2a1a836..0020724e3b0a 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1701,7 +1701,7 @@ xfs_fs_fill_super( sb->s_time_max = XFS_LEGACY_TIME_MAX; } trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max); - sb_set_iflag(sb, _SB_I_CGROUPWB); + sb_set_iflag(sb, SB_I_CGROUPWB); set_posix_acl_flag(sb); diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 54fdae7b1be4..bc5f96ba499e 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -176,7 +176,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode) return cgroup_subsys_on_dfl(memory_cgrp_subsys) && cgroup_subsys_on_dfl(io_cgrp_subsys) && (bdi->capabilities & BDI_CAP_WRITEBACK) && - sb_test_iflag(inode->i_sb, _SB_I_CGROUPWB); + sb_test_iflag(inode->i_sb, SB_I_CGROUPWB); } /** diff --git a/include/linux/fs.h b/include/linux/fs.h index 65e70ceb335e..52841aab13fb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1174,22 +1174,22 @@ extern int send_sigurg(struct fown_struct *fown); /* sb->s_iflags */ enum { - _SB_I_CGROUPWB, /* cgroup-aware writeback enabled */ - _SB_I_NOEXEC, /* Ignore executables on this fs */ - _SB_I_NODEV, /* Ignore devices on this fs */ - _SB_I_STABLE_WRITES, /* don't modify blks until WB is done */ + SB_I_CGROUPWB, /* cgroup-aware writeback enabled */ + SB_I_NOEXEC, /* Ignore executables on this fs */ + SB_I_NODEV, /* Ignore devices on this fs */ + SB_I_STABLE_WRITES, /* don't modify blks until WB is done */ /* sb->s_iflags to limit user namespace mounts */ - _SB_I_USERNS_VISIBLE, /* fstype already mounted */ - _SB_I_IMA_UNVERIFIABLE_SIGNATURE, - _SB_I_UNTRUSTED_MOUNTER, - _SB_I_EVM_HMAC_UNSUPPORTED, - - _SB_I_SKIP_SYNC, /* Skip superblock at global sync */ - _SB_I_PERSB_BDI, /* has a per-sb bdi */ - _SB_I_TS_EXPIRY_WARNED, /* warned about timestamp range expiry */ - _SB_I_RETIRED, /* superblock shouldn't be reused */ - _SB_I_NOUMASK, /* VFS does not apply umask */ + SB_I_USERNS_VISIBLE, /* fstype already mounted */ + SB_I_IMA_UNVERIFIABLE_SIGNATURE, + SB_I_UNTRUSTED_MOUNTER, + SB_I_EVM_HMAC_UNSUPPORTED, + + SB_I_SKIP_SYNC, /* Skip superblock at global sync */ + SB_I_PERSB_BDI, /* has a per-sb bdi */ + SB_I_TS_EXPIRY_WARNED, /* warned about timestamp range expiry */ + SB_I_RETIRED, /* superblock shouldn't be reused */ + SB_I_NOUMASK, /* VFS does not apply umask */ }; /* Possible states of 'frozen' field */ diff --git a/include/linux/namei.h b/include/linux/namei.h index 3fbf340dac1a..0bd6db9adb7f 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -107,7 +107,7 @@ extern void unlock_rename(struct dentry *, struct dentry *); */ static inline umode_t __must_check mode_strip_umask(const struct inode *dir, umode_t mode) { - if (!IS_POSIXACL(dir) && !sb_test_iflag(dir->i_sb, _SB_I_NOUMASK)) + if (!IS_POSIXACL(dir) && !sb_test_iflag(dir->i_sb, SB_I_NOUMASK)) mode &= ~current_umask(); return mode; } diff --git a/ipc/mqueue.c b/ipc/mqueue.c index e73fff4c2f12..abe4dfe4374c 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -406,8 +406,8 @@ static int mqueue_fill_super(struct super_block *sb, struct fs_context *fc) struct inode *inode; struct ipc_namespace *ns = sb->s_fs_info; - sb_set_iflag(sb, _SB_I_NOEXEC); - sb_set_iflag(sb, _SB_I_NODEV); + sb_set_iflag(sb, SB_I_NOEXEC); + sb_set_iflag(sb, SB_I_NODEV); sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; sb->s_magic = MQUEUE_MAGIC; diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 3ff29bf73f04..a15a87250d55 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -155,7 +155,7 @@ static int is_unsupported_hmac_fs(struct dentry *dentry) { struct inode *inode = d_backing_inode(dentry); - if (sb_test_iflag(inode->i_sb, _SB_I_EVM_HMAC_UNSUPPORTED)) { + if (sb_test_iflag(inode->i_sb, SB_I_EVM_HMAC_UNSUPPORTED)) { pr_info_once("%s not supported\n", inode->i_sb->s_type->name); return 1; } diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index 9c290dd8a4ac..dfa16dba5d89 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c @@ -564,8 +564,8 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint, * system not willing to accept such a risk, fail the file signature * verification. */ - if (sb_test_iflag(inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - (sb_test_iflag(inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) || + if (sb_test_iflag(inode->i_sb, SB_I_IMA_UNVERIFIABLE_SIGNATURE) && + (sb_test_iflag(inode->i_sb, SB_I_UNTRUSTED_MOUNTER) || (iint->flags & IMA_FAIL_UNVERIFIABLE_SIGS))) { status = INTEGRITY_FAIL; cause = "unverifiable-signature"; diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index b04eaa33eca4..27d446136c4f 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -280,8 +280,8 @@ static int process_measurement(struct file *file, const struct cred *cred, * (Limited to privileged mounted filesystems.) */ if (test_and_clear_bit(IMA_CHANGE_XATTR, &iint->atomic_flags) || - (sb_test_iflag(inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - !sb_test_iflag(inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) && + (sb_test_iflag(inode->i_sb, SB_I_IMA_UNVERIFIABLE_SIGNATURE) && + !sb_test_iflag(inode->i_sb, SB_I_UNTRUSTED_MOUNTER) && !(action & IMA_FAIL_UNVERIFIABLE_SIGS))) { iint->flags &= ~IMA_DONE_MASK; iint->measured_pcrs = 0; From patchwork Wed Aug 7 18:29:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756617 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 201C813DDDF for ; Wed, 7 Aug 2024 18:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; cv=none; b=Q0JKurY5KdST+xKdYd78C/XTck07iP7EUnZMQXpzEuZr/qg7kzPQxblNJo3Gv3cpcaCkekU+9v1Hb2pfFrBXnoN4xbdxRUn6u1OnPAnIHZGoHkwPCih9cQcZdL6rJYmtyEv0mY/2QS6dLroHL4OaDVG2SaraZAXm9H63hbYGHPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; c=relaxed/simple; bh=aelp7K/w47cwgXXwilgnQVd3tgLB6rycTPPQJCXhfB8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bHgqztRkpmDbZmibkvD+sa4RmdqysQ8fZcujJv9/wXnCmwsQF+DNLSI9w2VhLawPDap4yzatd1g6wUqyUHrRaxteEe2ANsxw/E77zyoeWPg9URtEWi868r5s93T+o70RlJkFaTCMKqjYMQx4cXjKbZCumoz0yjxZHHDGZWFzNGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Irkx4usb; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=LMDhWOSN; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Irkx4usb; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=LMDhWOSN; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Irkx4usb"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="LMDhWOSN"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Irkx4usb"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="LMDhWOSN" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7AE2021CA3; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DhYhOhTuekMwxl0QM9IpRdA8iIOSD8F0EEqUAlIvfOs=; b=Irkx4usbJzwFv+VC+kxGOBFPgcPhT9qA4PfFkJ61+EHaR7K+Z/IedfkARN3YkunGmGIQq1 5Y6BQSJgTvErfkNHH64iO45FQtBBkoJOaHpV6PaQ41NhM5jUZ6Dc6BT8DO77hdneYIK6Jx Ciou3bAcWWoFWUcpVdsBZSN6C08Rx0c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DhYhOhTuekMwxl0QM9IpRdA8iIOSD8F0EEqUAlIvfOs=; b=LMDhWOSN8zY3BoB+T4j0F0m2LN7gB5gsGuVcRa3mGHGhBGUEkYQsCwQea4iILm7tfT9Xwa 8795UNLood5H28Cw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DhYhOhTuekMwxl0QM9IpRdA8iIOSD8F0EEqUAlIvfOs=; b=Irkx4usbJzwFv+VC+kxGOBFPgcPhT9qA4PfFkJ61+EHaR7K+Z/IedfkARN3YkunGmGIQq1 5Y6BQSJgTvErfkNHH64iO45FQtBBkoJOaHpV6PaQ41NhM5jUZ6Dc6BT8DO77hdneYIK6Jx Ciou3bAcWWoFWUcpVdsBZSN6C08Rx0c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DhYhOhTuekMwxl0QM9IpRdA8iIOSD8F0EEqUAlIvfOs=; b=LMDhWOSN8zY3BoB+T4j0F0m2LN7gB5gsGuVcRa3mGHGhBGUEkYQsCwQea4iILm7tfT9Xwa 8795UNLood5H28Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 64CEA13B0B; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +lGbGCy9s2Z4NAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C8DE9A0886; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 07/13] overlayfs: Make ovl_start_write() return error Date: Wed, 7 Aug 2024 20:29:52 +0200 Message-Id: <20240807183003.23562-7-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5325; i=jack@suse.cz; h=from:subject; bh=aelp7K/w47cwgXXwilgnQVd3tgLB6rycTPPQJCXhfB8=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70fAqNbLgNhRBnSPyC873ZT8T9z9kf+hon3SAc9 hWtFZsWJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9HwAKCRCcnaoHP2RA2TCDCA C/3riMQkfkSx4uaPIumjJBFD2ZmYc0k6psO08YR6Pnhp2EvunK+6RQapjwEbm6QT0tvM1p5ibL7p4c BHIaVU+Lp8SXM2Ey0CVQ7lpQebW27xvqjUxrX8wyGCbfIbyUppE1e5jZatrVFkKCehbG2icSsh7IDQ eV83sr0OBpe/7ybBPz+yjWvN5WblOUHEGPhOOoRpzewFN+GSB9GuyVuky+C38p5CLz+PYbCjU5ii+e 1fh9e5FFHq+fH8TSHk4ncPX3QLV70hy1P/6umppbSuBAXiAnI6WtIEYV1SmszMYl2EUWCgONsIec0n 5QiHKzr9Ooqf7AsCz98S2M+0lJ4vt9 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Flag: NO X-Spam-Score: -2.80 sb_start_write() will be returning error for a shutdown filesystem. Teach all ovl_start_write() to handle the error and bail out. Signed-off-by: Jan Kara --- fs/overlayfs/copy_up.c | 42 +++++++++++++++++++++++++++++++--------- fs/overlayfs/overlayfs.h | 2 +- fs/overlayfs/util.c | 3 ++- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index a5ef2005a2cc..6ebfd9c7b260 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -584,7 +584,9 @@ static int ovl_link_up(struct ovl_copy_up_ctx *c) struct ovl_fs *ofs = OVL_FS(c->dentry->d_sb); struct inode *udir = d_inode(upperdir); - ovl_start_write(c->dentry); + err = ovl_start_write(c->dentry); + if (err) + return err; /* Mark parent "impure" because it may now contain non-pure upper */ err = ovl_set_impure(c->parent, upperdir); @@ -744,6 +746,7 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) struct path path = { .mnt = ovl_upper_mnt(ofs) }; struct dentry *temp, *upper, *trap; struct ovl_cu_creds cc; + bool frozen = false; int err; struct ovl_cattr cattr = { /* Can't properly set mode on creation because of the umask */ @@ -756,7 +759,11 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) if (err) return err; - ovl_start_write(c->dentry); + err = ovl_start_write(c->dentry); + if (err) { + ovl_revert_cu_creds(&cc); + return err; + } inode_lock(wdir); temp = ovl_create_temp(ofs, c->workdir, &cattr); inode_unlock(wdir); @@ -778,7 +785,10 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) * ovl_copy_up_data(), so lock workdir and destdir and make sure that * temp wasn't moved before copy up completion or cleanup. */ - ovl_start_write(c->dentry); + if (!err) { + err = ovl_start_write(c->dentry); + frozen = !err; + } trap = lock_rename(c->workdir, c->destdir); if (trap || temp->d_parent != c->workdir) { /* temp or workdir moved underneath us? abort without cleanup */ @@ -827,7 +837,8 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) unlock: unlock_rename(c->workdir, c->destdir); out: - ovl_end_write(c->dentry); + if (frozen) + ovl_end_write(c->dentry); return err; @@ -851,7 +862,11 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) if (err) return err; - ovl_start_write(c->dentry); + err = ovl_start_write(c->dentry); + if (err) { + ovl_revert_cu_creds(&cc); + return err; + } tmpfile = ovl_do_tmpfile(ofs, c->workdir, c->stat.mode); ovl_end_write(c->dentry); ovl_revert_cu_creds(&cc); @@ -865,7 +880,9 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) goto out_fput; } - ovl_start_write(c->dentry); + err = ovl_start_write(c->dentry); + if (err) + goto out_fput; err = ovl_copy_up_metadata(c, temp); if (err) @@ -964,7 +981,9 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c) * Mark parent "impure" because it may now contain non-pure * upper */ - ovl_start_write(c->dentry); + err = ovl_start_write(c->dentry); + if (err) + goto out_free_fh; err = ovl_set_impure(c->parent, c->destdir); ovl_end_write(c->dentry); if (err) @@ -982,7 +1001,9 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c) if (c->indexed) ovl_set_flag(OVL_INDEX, d_inode(c->dentry)); - ovl_start_write(c->dentry); + err = ovl_start_write(c->dentry); + if (err) + goto out; if (to_index) { /* Initialize nlink for copy up of disconnected dentry */ err = ovl_set_nlink_upper(c->dentry); @@ -1088,7 +1109,10 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c) * Writing to upper file will clear security.capability xattr. We * don't want that to happen for normal copy-up operation. */ - ovl_start_write(c->dentry); + err = ovl_start_write(c->dentry); + if (err) + goto out_free; + if (capability) { err = ovl_do_setxattr(ofs, upperpath.dentry, XATTR_NAME_CAPS, capability, cap_size, 0); diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 0bfe35da4b7b..ee8f2b28159a 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -423,7 +423,7 @@ static inline int ovl_do_getattr(const struct path *path, struct kstat *stat, /* util.c */ int ovl_get_write_access(struct dentry *dentry); void ovl_put_write_access(struct dentry *dentry); -void ovl_start_write(struct dentry *dentry); +int __must_check ovl_start_write(struct dentry *dentry); void ovl_end_write(struct dentry *dentry); int ovl_want_write(struct dentry *dentry); void ovl_drop_write(struct dentry *dentry); diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index edc9216f6e27..b53fa14506a9 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -25,10 +25,11 @@ int ovl_get_write_access(struct dentry *dentry) } /* Get write access to upper sb - may block if upper sb is frozen */ -void ovl_start_write(struct dentry *dentry) +int __must_check ovl_start_write(struct dentry *dentry) { struct ovl_fs *ofs = OVL_FS(dentry->d_sb); sb_start_write(ovl_upper_mnt(ofs)->mnt_sb); + return 0; } int ovl_want_write(struct dentry *dentry) From patchwork Wed Aug 7 18:29:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756614 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F95B13F458 for ; Wed, 7 Aug 2024 18:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; cv=none; b=DfxPNYTwrefrepUFE7DW3vhdDHsDB4v/wXpOFpwSajYrVMwtYk+xBL2gYZOX16ymDXjWyH1ssogArDQVWPVhxXAcl95K/ZT+2VaYxH5YxeV++WaQdiP+kdLTAsFOXK3gs313pxAn+cm+34+t2wtLB+rTLh2GpL6x/vltHGY4yFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; c=relaxed/simple; bh=CVmyFXa3mb/HAQvnjdCtzo9LMs7/0fXP7KEN+Td57dg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jFvDC976kKh12yYjwZxbyOr8F2TezbPADSeVLXOrXKwsOLMnDEefUbW/vx9P0WZY476uk2KiARd4PLzvxHmgpKfexdLkZlLQfK9/0TozLjjttDcgbrKBAS1YUDXW8PylPGLb6rZLLn3cNUnFNP7oj/fDZZkzZ++rRF8AQPAGe20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=d25azNXp; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=WnJOsDNJ; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=d25azNXp; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=WnJOsDNJ; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="d25azNXp"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="WnJOsDNJ"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="d25azNXp"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="WnJOsDNJ" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 90CEC1FB61; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/9Vk7nIgsN2Hc4EVTYl3Ul+GBLt9+dT+yI/YCVuNRFQ=; b=d25azNXpYkPNToYSDS3GaHbQUzCRj1LDsEJ2JLDeiXQWEvZ9bCYOEbYYj4ZFpn0tl9ypi+ RmNhcQi+Je5naL4rcb521+l1N2ivZqYSQqt3F8r5jWZqjBSfks11RfJSdJ8ks6Lklf7ZSM saVOILU0kKrOET74F5LpC/KvMgL5FgM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/9Vk7nIgsN2Hc4EVTYl3Ul+GBLt9+dT+yI/YCVuNRFQ=; b=WnJOsDNJoIPkQ/MY1+xH9fdMGuMAT3kl9+e3rWLCFlGrw8yBhXzHfw3dWzNxxzzKWnHuGv qEdW5AB3f+luExAA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=d25azNXp; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=WnJOsDNJ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/9Vk7nIgsN2Hc4EVTYl3Ul+GBLt9+dT+yI/YCVuNRFQ=; b=d25azNXpYkPNToYSDS3GaHbQUzCRj1LDsEJ2JLDeiXQWEvZ9bCYOEbYYj4ZFpn0tl9ypi+ RmNhcQi+Je5naL4rcb521+l1N2ivZqYSQqt3F8r5jWZqjBSfks11RfJSdJ8ks6Lklf7ZSM saVOILU0kKrOET74F5LpC/KvMgL5FgM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/9Vk7nIgsN2Hc4EVTYl3Ul+GBLt9+dT+yI/YCVuNRFQ=; b=WnJOsDNJoIPkQ/MY1+xH9fdMGuMAT3kl9+e3rWLCFlGrw8yBhXzHfw3dWzNxxzzKWnHuGv qEdW5AB3f+luExAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6D78D13B0D; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id LhjRGiy9s2Z6NAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id D11F0A0892; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 08/13] fs: Teach callers of kiocb_start_write() to handle errors Date: Wed, 7 Aug 2024 20:29:53 +0200 Message-Id: <20240807183003.23562-8-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2894; i=jack@suse.cz; h=from:subject; bh=CVmyFXa3mb/HAQvnjdCtzo9LMs7/0fXP7KEN+Td57dg=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70gHzo/iL1pbikz3ytt/Rx4eZSmvGiz5e6JAtSx 6twVihCJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9IAAKCRCcnaoHP2RA2TjlB/ 9lX7eLdx+D/KzlbTmf2tM3jS89tKUDXtK7PlRlzmW8lFyqm7+3RSn1TZXHE5RdO7EOzvPBaWnadZ3a lD71962qFzkbzbYoX8U9oj0otSoM0hbhM+2SPKFStbr6HLo07UKGn4wu63vWkiMQHxqcgsKrik1h9C eWffm8C8H9r9plrEWUKct12JECPaO46lBYxfAn99MiWqWGwK7ZOC2rGzrTD/JPLzttVmHC1F56x6D7 kHM0d4Gn5v9Ubi3BjAIs2B38l2VHu/wHsx3Z2bcSHU5OqXLEfR6wwz23mTvztIsXpp8nVmuO8F6TUP CmydI/bpwngCmtIyYbSMVItEg9iVis X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.cz:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 90CEC1FB61 sb_start_write() will be returning error on shutdown filesystem. Teach callers of kiocb_start_write() to handle the error. Signed-off-by: Jan Kara --- fs/aio.c | 14 +++++++++----- fs/read_write.c | 4 +++- include/linux/fs.h | 3 ++- io_uring/rw.c | 7 +++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 48d99221ff57..3b94081118bc 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1626,12 +1626,16 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb, if (ret < 0) return ret; ret = rw_verify_area(WRITE, file, &req->ki_pos, iov_iter_count(&iter)); - if (!ret) { - if (S_ISREG(file_inode(file)->i_mode)) - kiocb_start_write(req); - req->ki_flags |= IOCB_WRITE; - aio_rw_done(req, file->f_op->write_iter(req, &iter)); + if (unlikely(ret)) + goto out; + if (S_ISREG(file_inode(file)->i_mode)) { + ret = kiocb_start_write(req); + if (unlikely(ret)) + goto out; } + req->ki_flags |= IOCB_WRITE; + aio_rw_done(req, file->f_op->write_iter(req, &iter)); +out: kfree(iovec); return ret; } diff --git a/fs/read_write.c b/fs/read_write.c index 90e283b31ca1..12996892bb1d 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -859,7 +859,9 @@ ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb, if (ret < 0) return ret; - kiocb_start_write(iocb); + ret = kiocb_start_write(iocb); + if (ret < 0) + return ret; ret = file->f_op->write_iter(iocb, iter); if (ret != -EIOCBQUEUED) kiocb_end_write(iocb); diff --git a/include/linux/fs.h b/include/linux/fs.h index 52841aab13fb..3ac37d9884f5 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2920,7 +2920,7 @@ static inline void file_end_write(struct file *file) * This is a variant of sb_start_write() for async io submission. * Should be matched with a call to kiocb_end_write(). */ -static inline void kiocb_start_write(struct kiocb *iocb) +static inline int __must_check kiocb_start_write(struct kiocb *iocb) { struct inode *inode = file_inode(iocb->ki_filp); @@ -2930,6 +2930,7 @@ static inline void kiocb_start_write(struct kiocb *iocb) * doesn't complain about the held lock when we return to userspace. */ __sb_writers_release(inode->i_sb, SB_FREEZE_WRITE); + return 0; } /** diff --git a/io_uring/rw.c b/io_uring/rw.c index c004d21e2f12..a9dc9f84fb60 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -1040,8 +1040,11 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) if (unlikely(ret)) return ret; - if (req->flags & REQ_F_ISREG) - kiocb_start_write(kiocb); + if (req->flags & REQ_F_ISREG) { + ret = kiocb_start_write(kiocb); + if (unlikely(ret)) + return ret; + } kiocb->ki_flags |= IOCB_WRITE; if (likely(req->file->f_op->write_iter)) From patchwork Wed Aug 7 18:29:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756622 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1364314388F for ; Wed, 7 Aug 2024 18:30:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055412; cv=none; b=EGriPiRGKgN7kWRv2BsOeeCEoSpT0k8jQaRZnhJCGVJBbsb0PLqNpyG6Kig1mgPOB4jr6vj9yTasWgQ9kWbXFm0Lp6HaX5LnDN1MjmR4u7Xz83ozRn4Jj/o3SAFbpqNmRwXcjrMWjzWIxSVlijnXCq9s/4f5I+Qz5PlJCDkTuMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055412; c=relaxed/simple; bh=LcL3BHzsZSUskp27VS2JLcjy7YZAv2wBS/LrWsqpkpM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O3NG9Hhq6leBIN+PCT9UP4k5DPWAHzhQ2YoiJ+CXLRe3tAXM3FUMKyY6j4qKyI7bIKc0DPAtlDJhxiyHV5H5w1uYMyrY8WcZAgMKvuYDh5mruguCttwQ5RT3SGtajhcTAmHPMVEBqOLwvrqCLjWpgcamd6b6CxBOVJWa62vxj/Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=i9154zgf; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=aP2LkDHv; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=i9154zgf; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=aP2LkDHv; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="i9154zgf"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="aP2LkDHv"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="i9154zgf"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="aP2LkDHv" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 868FC21CF8; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OdXwsqLXfONFWUtMvQutXzXRdGwYALr88CknhQRoGfM=; b=i9154zgf+KTffLJGuSMnIrEvFdDmhyQJ9wYNCq6qSFrsyfcjcmW1B6RmtXU42P1kPOHvSB DBiHI8vQzMN9A3tt5gSjZHttTurKvloXs1eoFohTTUUs8fo0F2kUBfyVgGIOFmHjf0pwkz iWZ/TNbbjUgY5e6KN8fwwKdtFvS03HA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OdXwsqLXfONFWUtMvQutXzXRdGwYALr88CknhQRoGfM=; b=aP2LkDHvp+la3qCX8lzuHSzGaXz2GZcbSykcNfMxgmPfwVpE3D69gsZmkNEDQJePS02xTc L9ZC+0bP6c2Z+LAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OdXwsqLXfONFWUtMvQutXzXRdGwYALr88CknhQRoGfM=; b=i9154zgf+KTffLJGuSMnIrEvFdDmhyQJ9wYNCq6qSFrsyfcjcmW1B6RmtXU42P1kPOHvSB DBiHI8vQzMN9A3tt5gSjZHttTurKvloXs1eoFohTTUUs8fo0F2kUBfyVgGIOFmHjf0pwkz iWZ/TNbbjUgY5e6KN8fwwKdtFvS03HA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OdXwsqLXfONFWUtMvQutXzXRdGwYALr88CknhQRoGfM=; b=aP2LkDHvp+la3qCX8lzuHSzGaXz2GZcbSykcNfMxgmPfwVpE3D69gsZmkNEDQJePS02xTc L9ZC+0bP6c2Z+LAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 784B913B15; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MXVeHSy9s2Z/NAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id D8560A0893; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 09/13] fs: Teach callers of file_start_write() to handle errors Date: Wed, 7 Aug 2024 20:29:54 +0200 Message-Id: <20240807183003.23562-9-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6709; i=jack@suse.cz; h=from:subject; bh=LcL3BHzsZSUskp27VS2JLcjy7YZAv2wBS/LrWsqpkpM=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70hfABh09Hl32zEhViYc5oJcWa/zlUoDMStc2wE 9AsRNkOJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9IQAKCRCcnaoHP2RA2S2UB/ 4tR/9vNEhr7XkTb74UcQ0tvnSthx2OzTamK6/ZmWEIg1gLVJ52IBaelusMwBsmnws5wdyqI/anK9oA dtYNL4oHD9zLvvQjgcTqUP8mkFW6NWvuHb0z6QKQ3archZmEoDDrdSLOWyezrj6Y6b1JdvaI1rVADE PmMAj6c/2+wg6wJGtr5CeARMuAKgCiFePLHgjsZ206IOZX8lqj7TqJXjWVtw//RMJz8lmod9+2vmR+ 3zYaFxkyENCxZWr+9vff76YBlBAJnZJtDFIWHYhhfSDe9mF/ePEEgdJpH8I3AYvfxD8PQrKhwubTIK wr9VkIiDmWAQJdWEadQ+QdqHy/WWga X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email] X-Spam-Flag: NO X-Spam-Score: -2.80 sb_start_write() will be returning error on shutdown filesystem. Teach callers of file_start_write() to handle the error. Signed-off-by: Jan Kara --- fs/backing-file.c | 4 +++- fs/btrfs/ioctl.c | 4 +++- fs/coredump.c | 4 +++- fs/open.c | 4 +++- fs/read_write.c | 20 +++++++++++++++----- fs/remap_range.c | 4 +++- fs/splice.c | 8 ++++++-- fs/xfs/xfs_exchrange.c | 4 +++- include/linux/fs.h | 5 +++-- 9 files changed, 42 insertions(+), 15 deletions(-) diff --git a/fs/backing-file.c b/fs/backing-file.c index afb557446c27..3df3fb48cb42 100644 --- a/fs/backing-file.c +++ b/fs/backing-file.c @@ -308,7 +308,9 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe, return ret; old_cred = override_creds(ctx->cred); - file_start_write(out); + ret = file_start_write(out); + if (ret) + return ret; ret = iter_file_splice_write(pipe, out, ppos, len, flags); file_end_write(out); revert_creds(old_cred); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e0a664b8a46a..4cadba17a5a3 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4676,7 +4676,9 @@ static int btrfs_ioctl_encoded_write(struct file *file, void __user *argp, bool goto out_iov; kiocb.ki_pos = pos; - file_start_write(file); + ret = file_start_write(file); + if (ret < 0) + goto out_iov; ret = btrfs_do_write_iter(&kiocb, &iter, &args); if (ret > 0) diff --git a/fs/coredump.c b/fs/coredump.c index 7f12ff6ad1d3..aa24964dc1e4 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -763,7 +763,9 @@ void do_coredump(const kernel_siginfo_t *siginfo) if (!dump_vma_snapshot(&cprm)) goto close_fail; - file_start_write(cprm.file); + retval = file_start_write(cprm.file); + if (retval) + goto close_fail; core_dumped = binfmt->core_dump(&cprm); /* * Ensures that file size is big enough to contain the current diff --git a/fs/open.c b/fs/open.c index 22adbef7ecc2..4bce4ba776ab 100644 --- a/fs/open.c +++ b/fs/open.c @@ -330,7 +330,9 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) if (!file->f_op->fallocate) return -EOPNOTSUPP; - file_start_write(file); + ret = file_start_write(file); + if (ret) + return ret; ret = file->f_op->fallocate(file, mode, offset, len); /* diff --git a/fs/read_write.c b/fs/read_write.c index 12996892bb1d..4d2831891e84 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -560,7 +560,9 @@ ssize_t kernel_write(struct file *file, const void *buf, size_t count, if (ret) return ret; - file_start_write(file); + ret = file_start_write(file); + if (ret) + return ret; ret = __kernel_write(file, buf, count, pos); file_end_write(file); return ret; @@ -583,7 +585,9 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_ return ret; if (count > MAX_RW_COUNT) count = MAX_RW_COUNT; - file_start_write(file); + ret = file_start_write(file); + if (ret) + return ret; if (file->f_op->write) ret = file->f_op->write(file, buf, count, pos); else if (file->f_op->write_iter) @@ -893,7 +897,9 @@ ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos, if (ret < 0) return ret; - file_start_write(file); + ret = file_start_write(file); + if (ret) + return ret; ret = do_iter_readv_writev(file, iter, ppos, WRITE, flags); if (ret > 0) fsnotify_modify(file); @@ -968,7 +974,9 @@ static ssize_t vfs_writev(struct file *file, const struct iovec __user *vec, if (ret < 0) goto out; - file_start_write(file); + ret = file_start_write(file); + if (ret < 0) + goto out; if (file->f_op->write_iter) ret = do_iter_readv_writev(file, &iter, pos, WRITE, flags); else @@ -1509,7 +1517,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, if (len == 0) return 0; - file_start_write(file_out); + ret = file_start_write(file_out); + if (unlikely(ret)) + return ret; /* * Cloning is supported by more file systems, so we implement copy on diff --git a/fs/remap_range.c b/fs/remap_range.c index 28246dfc8485..d1aa23c16f15 100644 --- a/fs/remap_range.c +++ b/fs/remap_range.c @@ -399,7 +399,9 @@ loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, if (ret) return ret; - file_start_write(file_out); + ret = file_start_write(file_out); + if (ret) + return ret; ret = file_in->f_op->remap_file_range(file_in, pos_in, file_out, pos_out, len, remap_flags); file_end_write(file_out); diff --git a/fs/splice.c b/fs/splice.c index 60aed8de21f8..5d66a4dc93fc 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1160,7 +1160,9 @@ static int direct_splice_actor(struct pipe_inode_info *pipe, struct file *file = sd->u.file; long ret; - file_start_write(file); + ret = file_start_write(file); + if (ret) + return ret; ret = do_splice_from(pipe, file, sd->opos, sd->total_len, sd->flags); file_end_write(file); return ret; @@ -1350,7 +1352,9 @@ ssize_t do_splice(struct file *in, loff_t *off_in, struct file *out, if (in->f_flags & O_NONBLOCK) flags |= SPLICE_F_NONBLOCK; - file_start_write(out); + ret = file_start_write(out); + if (unlikely(ret)) + return ret; ret = do_splice_from(ipipe, out, &offset, len, flags); file_end_write(out); diff --git a/fs/xfs/xfs_exchrange.c b/fs/xfs/xfs_exchrange.c index c8a655c92c92..e4840cbbe276 100644 --- a/fs/xfs/xfs_exchrange.c +++ b/fs/xfs/xfs_exchrange.c @@ -756,7 +756,9 @@ xfs_exchange_range( if (!(fxr->file2->f_mode & FMODE_NOCMTIME) && !IS_NOCMTIME(inode2)) fxr->flags |= __XFS_EXCHANGE_RANGE_UPD_CMTIME2; - file_start_write(fxr->file2); + ret = file_start_write(fxr->file2); + if (ret) + return ret; ret = xfs_exchrange_contents(fxr); file_end_write(fxr->file2); if (ret) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3ac37d9884f5..952f11170296 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2886,11 +2886,12 @@ static inline bool inode_wrong_type(const struct inode *inode, umode_t mode) * This is a variant of sb_start_write() which is a noop on non-regualr file. * Should be matched with a call to file_end_write(). */ -static inline void file_start_write(struct file *file) +static inline int __must_check file_start_write(struct file *file) { if (!S_ISREG(file_inode(file)->i_mode)) - return; + return 0; sb_start_write(file_inode(file)->i_sb); + return 0; } static inline bool file_start_write_trylock(struct file *file) From patchwork Wed Aug 7 18:29:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756615 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2246A13E409 for ; Wed, 7 Aug 2024 18:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; cv=none; b=OwDSflcEN5QPGcx8dQaY9W3eX8O0JahY0VL8uNAEbDG2+zfwWlZLOaBMZg4BkC8eyAtIzOHoR1YAUlqjbiTdAe/ezxCiIy5n78jIavZe/liJpsGQRsxqNPb07qBAC1z+dPkF9AhFkHtF99O7TT6rblx+xNH1iNM4QjrwBsFKEtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055409; c=relaxed/simple; bh=HOKhGw7DbSaMYcuyuRIgbMmniRdO/9MZVJ+cfyWXltQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WcRrktlYZFYHno6NZosuCmTav6g6n3/8pP0IfeSE2PYWW0Ek2wD1WclGOofLD25h3QvZa8U5blqkTye7iZLHzuUiQDA2rmgMLGLPGfQwfkqfMW9rbw9z9YSzt2Pvy6p//t3flis/MWxkURd1nwSkFgvOFmg2iy6bk+SGGHl5p/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=g6B36gbt; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=lpCMzDHn; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=g6B36gbt; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=lpCMzDHn; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="g6B36gbt"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="lpCMzDHn"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="g6B36gbt"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="lpCMzDHn" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8800521CF9; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XuZxlJ5CLM+kZvC3aVZwUhGn9HRKek4wGQ8oh/oAzK8=; b=g6B36gbtdC3mHFa3mb1fPdQB1LxB4g5lDw9u097hp9gs/+JmDrYfRTaj5kym6/R9MElA3j +8AH8HjgsJzFeMyi5Q24KYVxP3m5+tKkYHMKyL08jeCI1ste1jUa6M9TlGbQUoHSYK72p/ cKlAdq4zIAS3RTWX66db2A+3fZyVqmw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XuZxlJ5CLM+kZvC3aVZwUhGn9HRKek4wGQ8oh/oAzK8=; b=lpCMzDHnLLTlkfuBxE13mijSyFOzatsqZ0lTQAFQwXDtNbygZPmbdYn9YKG/4i6zXDABYA Njt/oOgi8dWvQNCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XuZxlJ5CLM+kZvC3aVZwUhGn9HRKek4wGQ8oh/oAzK8=; b=g6B36gbtdC3mHFa3mb1fPdQB1LxB4g5lDw9u097hp9gs/+JmDrYfRTaj5kym6/R9MElA3j +8AH8HjgsJzFeMyi5Q24KYVxP3m5+tKkYHMKyL08jeCI1ste1jUa6M9TlGbQUoHSYK72p/ cKlAdq4zIAS3RTWX66db2A+3fZyVqmw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XuZxlJ5CLM+kZvC3aVZwUhGn9HRKek4wGQ8oh/oAzK8=; b=lpCMzDHnLLTlkfuBxE13mijSyFOzatsqZ0lTQAFQwXDtNbygZPmbdYn9YKG/4i6zXDABYA Njt/oOgi8dWvQNCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 781BD13B14; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +8lRHSy9s2aANAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id E072CA0894; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 10/13] fs: Add __must_check annotations to sb_start_write_trylock() and similar Date: Wed, 7 Aug 2024 20:29:55 +0200 Message-Id: <20240807183003.23562-10-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1609; i=jack@suse.cz; h=from:subject; bh=HOKhGw7DbSaMYcuyuRIgbMmniRdO/9MZVJ+cfyWXltQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70icVtioNbWtGj4yW6SpWJjT3RyFHjgBANQgHoT fJcUHVuJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9IgAKCRCcnaoHP2RA2b6eCA C2XvrQWBz4W+GVErx8fCD8EVekwye4AYQPXcNohifAqM4XdFCfg+80MV315SLhnmCOrNvfugi/B3BQ TW7P78dw+uVXG5EUifEryqD3hJoeJjnlW3h6v3e7hanymWgG36jisk6zT9WwIBLE3olM5IQvu2Fhgy cVFeaUYn/lWsfSrHtmcmAQw5zmBzmsT6T/xoeGyO6BYExfs8H6lhdniVWjI+FTvrg6/wv6x86yaGkp qIqhkCa0eJHbmwVxqDrj7f93iiGKgVTEMP/YwYmu6TrdLN01BPkONlpQUXpoLkBCBvp+Pxp2ZHQk6Q 6cJ+0E63NctEIEnS0x2bl5rRQ9h885 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email] X-Spam-Score: -2.80 X-Spam-Flag: NO X-Spam-Level: The callers of sb_start_write_trylock(), sb_start_intwrite_trylock(), file_start_write_trylock() must check the return value to figure out whether the protection has been acquired (and thus must be dropped) or not. Add __must_check annotation to these functions to catch forgotten checks early. Signed-off-by: Jan Kara --- include/linux/fs.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 952f11170296..755a4c83a2bf 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1828,7 +1828,7 @@ static inline void sb_start_write(struct super_block *sb) __sb_start_write(sb, SB_FREEZE_WRITE); } -static inline bool sb_start_write_trylock(struct super_block *sb) +static inline bool __must_check sb_start_write_trylock(struct super_block *sb) { return __sb_start_write_trylock(sb, SB_FREEZE_WRITE); } @@ -1875,7 +1875,8 @@ static inline void sb_start_intwrite(struct super_block *sb) __sb_start_write(sb, SB_FREEZE_FS); } -static inline bool sb_start_intwrite_trylock(struct super_block *sb) +static inline bool __must_check sb_start_intwrite_trylock( + struct super_block *sb) { return __sb_start_write_trylock(sb, SB_FREEZE_FS); } @@ -2894,7 +2895,7 @@ static inline int __must_check file_start_write(struct file *file) return 0; } -static inline bool file_start_write_trylock(struct file *file) +static inline bool __must_check file_start_write_trylock(struct file *file) { if (!S_ISREG(file_inode(file)->i_mode)) return true; From patchwork Wed Aug 7 18:29:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756623 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 362DC143C60 for ; Wed, 7 Aug 2024 18:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055413; cv=none; b=HbQygmn2uGZlln80BtBuK0e6JQ4DleXQvm4Fl7hBMyeRmswezdefiVvwTvpvfiCa8TkjYfJWQi7xYh3dXnWIT1iEcdzozn3e+bQ1IEbx5GVLHrZXN5aZ+/qvE7k7YbVbaQP8/VnqKDI4bdtB0yaW0alVf0YAQY9PujKU5o6tJU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055413; c=relaxed/simple; bh=Nh7+Gohd80CafAf6rSUlx70GGjPImuDki53aSiRfl7w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FWeSMHS+m1bIFVbBhY3BqLAEvmNpoJlIYjaAUMPAYq9CFMBo1xC2WbLsosRhN5rr77E4M+ngbUbG9tUoXl9nPJVhxpruifudV1oOBmCv0wt7eWFaZpWflDeJnHZFZWflbLeQraLmw2+9v6n7Rk7SiCWS12P71PzIdGHbg4jV2LY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=b+8PUH2v; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=tvKtDZqP; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=b+8PUH2v; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=tvKtDZqP; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="b+8PUH2v"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="tvKtDZqP"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="b+8PUH2v"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="tvKtDZqP" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 94D6B21D18; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Czxq/KORa09Eh7tdfV7rQVGIZDivar8+/WAku5tZaY=; b=b+8PUH2vsXvrL3UmEgblTCncsjDs8ARjWu4fnJ4/mAk3vrLdiJ7lOJU/hQ6RwEGlJOq6uc jH/Wq3m2uArdTcGTEfc/C4U0+o0prAEGrhuB1FLkBgHjxtg8GPuIZuno5Ub/3E12Jx0WJu VqkXMysIJw0e2WRmOktTaTHcHBAbsXc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Czxq/KORa09Eh7tdfV7rQVGIZDivar8+/WAku5tZaY=; b=tvKtDZqPpVrQhk8iuI0TBxuPi5rFadAt5/1sHIlEUu9tWRrXa01G3Zb9kD+xJ1qs0ZZApX k0qEa05EztYyeJCQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Czxq/KORa09Eh7tdfV7rQVGIZDivar8+/WAku5tZaY=; b=b+8PUH2vsXvrL3UmEgblTCncsjDs8ARjWu4fnJ4/mAk3vrLdiJ7lOJU/hQ6RwEGlJOq6uc jH/Wq3m2uArdTcGTEfc/C4U0+o0prAEGrhuB1FLkBgHjxtg8GPuIZuno5Ub/3E12Jx0WJu VqkXMysIJw0e2WRmOktTaTHcHBAbsXc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Czxq/KORa09Eh7tdfV7rQVGIZDivar8+/WAku5tZaY=; b=tvKtDZqPpVrQhk8iuI0TBxuPi5rFadAt5/1sHIlEUu9tWRrXa01G3Zb9kD+xJ1qs0ZZApX k0qEa05EztYyeJCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 867D313B16; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id EancICy9s2aFNAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id E81ACA0896; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 11/13] fs: Make sb_start_write() return error on shutdown filesystem Date: Wed, 7 Aug 2024 20:29:56 +0200 Message-Id: <20240807183003.23562-11-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7957; i=jack@suse.cz; h=from:subject; bh=Nh7+Gohd80CafAf6rSUlx70GGjPImuDki53aSiRfl7w=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70jN/pdziElOlGS00zJqyOkRF0b9SOLoDJYLwm2 rbD2OfOJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9IwAKCRCcnaoHP2RA2XV5B/ 40OS/OkLJmOGdjXx7Ni+dtp/d/aealGn2D9jwfLzF/q+BzAWoRdYFL4sryshNHj9rOhy9la3Vk78lI aUns5u1zSn+HVkHJDiT0hAZmKfYvXtSYQXzs5BvBLzG7J/1C0snnPw2AgTAXi8zu0PvRLKWnFfH1xU DBNqWsStC9Wldrr784nBrXVLn8l37BTjPkJiZDa/LCnhcWlxz7egMJC5tlGQ6MuJuwmGhaHIH0Wbnw RSKgCExhMAasH6eyyahpJ+Pfj+PrtuWszQx7yMylBNLtvjmcr0ADRRP66Tq2kCVYea7Km/RVAUw7Ih 2WLrkUM112XFIIIo+VII9v1kjHKi8s X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Flag: NO X-Spam-Score: -2.80 Introduce new SB_I_SHUTDOWN flag that a filesystem can set when it is forcefully shutting down (usually due to errors). Make sb_start_write() return errors for such superblocks to avoid modifications to it which reduces noise in the error logs and generally makes life somewhat easier for filesystems. We teach all sb_start_write() callers to handle the error. Signed-off-by: Jan Kara --- fs/btrfs/block-group.c | 3 ++- fs/btrfs/defrag.c | 6 +++++- fs/btrfs/volumes.c | 13 +++++++++---- fs/ext4/mmp.c | 4 +++- fs/namespace.c | 8 ++++++-- fs/open.c | 4 +++- fs/overlayfs/util.c | 3 +-- fs/quota/quota.c | 4 ++-- fs/xfs/xfs_ioctl.c | 4 +++- include/linux/fs.h | 16 ++++++++++++---- 10 files changed, 46 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 498442d0c216..fdd833f1f7df 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1800,7 +1800,8 @@ void btrfs_reclaim_bgs_work(struct work_struct *work) if (!btrfs_should_reclaim(fs_info)) return; - sb_start_write(fs_info->sb); + if (sb_start_write(fs_info->sb) < 0) + return; if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE)) { sb_end_write(fs_info->sb); diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c index f6dbda37a361..6d14c9be4060 100644 --- a/fs/btrfs/defrag.c +++ b/fs/btrfs/defrag.c @@ -274,7 +274,11 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, range.start = cur; range.extent_thresh = defrag->extent_thresh; - sb_start_write(fs_info->sb); + ret = sb_start_write(fs_info->sb); + if (ret < 0) { + iput(inode); + goto cleanup; + } ret = btrfs_defrag_file(inode, NULL, &range, defrag->transid, BTRFS_DEFRAG_BATCH); sb_end_write(fs_info->sb); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index fcedc43ef291..f7b6b307c4bf 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4589,9 +4589,11 @@ int btrfs_balance(struct btrfs_fs_info *fs_info, static int balance_kthread(void *data) { struct btrfs_fs_info *fs_info = data; - int ret = 0; + int ret; - sb_start_write(fs_info->sb); + ret = sb_start_write(fs_info->sb); + if (ret < 0) + return ret; mutex_lock(&fs_info->balance_mutex); if (fs_info->balance_ctl) ret = btrfs_balance(fs_info, fs_info->balance_ctl, NULL); @@ -8231,12 +8233,15 @@ static int relocating_repair_kthread(void *data) struct btrfs_block_group *cache = data; struct btrfs_fs_info *fs_info = cache->fs_info; u64 target; - int ret = 0; + int ret; target = cache->start; btrfs_put_block_group(cache); - sb_start_write(fs_info->sb); + ret = sb_start_write(fs_info->sb); + if (ret < 0) + return ret; + if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE)) { btrfs_info(fs_info, "zoned: skip relocating block group %llu to repair: EBUSY", diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index bd946d0c71b7..96f69b6835f9 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -63,7 +63,9 @@ static int write_mmp_block(struct super_block *sb, struct buffer_head *bh) * We protect against freezing so that we don't create dirty buffers * on frozen filesystem. */ - sb_start_write(sb); + err = sb_start_write(sb); + if (err < 0) + return err; err = write_mmp_block_thawed(sb, bh); sb_end_write(sb); return err; diff --git a/fs/namespace.c b/fs/namespace.c index 1c5591673f96..43fad685531e 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -512,7 +512,9 @@ int mnt_want_write(struct vfsmount *m) { int ret; - sb_start_write(m->mnt_sb); + ret = sb_start_write(m->mnt_sb); + if (ret) + return ret; ret = mnt_get_write_access(m); if (ret) sb_end_write(m->mnt_sb); @@ -556,7 +558,9 @@ int mnt_want_write_file(struct file *file) { int ret; - sb_start_write(file_inode(file)->i_sb); + ret = sb_start_write(file_inode(file)->i_sb); + if (ret) + return ret; ret = mnt_get_write_access_file(file); if (ret) sb_end_write(file_inode(file)->i_sb); diff --git a/fs/open.c b/fs/open.c index 4bce4ba776ab..8fe9f4968969 100644 --- a/fs/open.c +++ b/fs/open.c @@ -175,7 +175,9 @@ long do_ftruncate(struct file *file, loff_t length, int small) /* Check IS_APPEND on real upper inode */ if (IS_APPEND(file_inode(file))) return -EPERM; - sb_start_write(inode->i_sb); + error = sb_start_write(inode->i_sb); + if (error) + return error; error = security_file_truncate(file); if (!error) error = do_truncate(file_mnt_idmap(file), dentry, length, diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index b53fa14506a9..f97bf2458c66 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -28,8 +28,7 @@ int ovl_get_write_access(struct dentry *dentry) int __must_check ovl_start_write(struct dentry *dentry) { struct ovl_fs *ofs = OVL_FS(dentry->d_sb); - sb_start_write(ovl_upper_mnt(ofs)->mnt_sb); - return 0; + return sb_start_write(ovl_upper_mnt(ofs)->mnt_sb); } int ovl_want_write(struct dentry *dentry) diff --git a/fs/quota/quota.c b/fs/quota/quota.c index 0e41fb84060f..df9c4d08f135 100644 --- a/fs/quota/quota.c +++ b/fs/quota/quota.c @@ -896,8 +896,8 @@ static struct super_block *quotactl_block(const char __user *special, int cmd) else up_read(&sb->s_umount); /* Wait for sb to unfreeze */ - sb_start_write(sb); - sb_end_write(sb); + if (sb_start_write(sb) == 0) + sb_end_write(sb); put_super(sb); goto retry; } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 4e933db75b12..5cf9e568324a 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1499,7 +1499,9 @@ xfs_file_ioctl( trace_xfs_ioc_free_eofblocks(mp, &icw, _RET_IP_); - sb_start_write(mp->m_super); + error = sb_start_write(mp->m_super); + if (error) + return error; error = xfs_blockgc_free_space(mp, &icw); sb_end_write(mp->m_super); return error; diff --git a/include/linux/fs.h b/include/linux/fs.h index 755a4c83a2bf..44ae86f46b12 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1190,6 +1190,9 @@ enum { SB_I_TS_EXPIRY_WARNED, /* warned about timestamp range expiry */ SB_I_RETIRED, /* superblock shouldn't be reused */ SB_I_NOUMASK, /* VFS does not apply umask */ + SB_I_SHUTDOWN, /* The filesystem has shutdown. Refuse + * modification attempts with error as they are + * a futile exercise. */ }; /* Possible states of 'frozen' field */ @@ -1823,9 +1826,12 @@ static inline void sb_end_intwrite(struct super_block *sb) * -> i_mutex (write path, truncate, directory ops, ...) * -> s_umount (freeze_super, thaw_super) */ -static inline void sb_start_write(struct super_block *sb) +static inline int __must_check sb_start_write(struct super_block *sb) { + if (sb_test_iflag(sb, SB_I_SHUTDOWN)) + return -EROFS; __sb_start_write(sb, SB_FREEZE_WRITE); + return 0; } static inline bool __must_check sb_start_write_trylock(struct super_block *sb) @@ -2891,8 +2897,7 @@ static inline int __must_check file_start_write(struct file *file) { if (!S_ISREG(file_inode(file)->i_mode)) return 0; - sb_start_write(file_inode(file)->i_sb); - return 0; + return sb_start_write(file_inode(file)->i_sb); } static inline bool __must_check file_start_write_trylock(struct file *file) @@ -2925,8 +2930,11 @@ static inline void file_end_write(struct file *file) static inline int __must_check kiocb_start_write(struct kiocb *iocb) { struct inode *inode = file_inode(iocb->ki_filp); + int err; - sb_start_write(inode->i_sb); + err = sb_start_write(inode->i_sb); + if (err) + return err; /* * Fool lockdep by telling it the lock got released so that it * doesn't complain about the held lock when we return to userspace. From patchwork Wed Aug 7 18:29:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756625 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B8EC143C70 for ; Wed, 7 Aug 2024 18:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055413; cv=none; b=WPX9DXgrek0rgJbxmmv8Epd2lbQrzWM4EBOfT3+QU27hrKGcdE9VDKx1idyMKHzwbmCyZIIoMPk3mgbUjHQuCnj8aeUmFroamJi1TBGXbV3ahDxyrwIN6Fm91YZIQProD3IQt9yHcMvx3Cn0ZzgJEuOkC+XqM70H19ZJGvamqtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055413; c=relaxed/simple; bh=8KmJ0x0UPIu10TnEpoxvWsrKnC2A+3Bc4jqRyuanl7Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DkbVyHxN7n2OESH89XkFmj01NVN7l2xZtmh6cy28ifeaxr8Ukb2t7O4j3xmBsC6sm5XqSq8ZO7zcOcUiDd6w3eTp4ctybzc/JhyU7hclvKUks21SZh/qfc+Ufyr38DMZCVY1oGRJ98ZwMgG91kTDCqmQyU7E6+p+D8UPtxX6OHY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=mz+S7s4d; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=zNom4Umh; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=mz+S7s4d; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=zNom4Umh; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="mz+S7s4d"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="zNom4Umh"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="mz+S7s4d"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="zNom4Umh" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9200621D12; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gzqniTAIHeQnvY5cBsiNDIpvQxfh/HqTK3A2lIErejI=; b=mz+S7s4dTv/H0GtrfOk2DYO1DGClA+rNyENRLNTuZwMGO4+Ndjm1j8/nnjHBf1Zw8zhno3 hEDeS9j9SNjTF/s1QSnM2I54cXznLMtsPLdTCUjacd/zhCJuoMIdCpqra0mpGAKxsG0HwX hfLnsOEDygRMfR8A2KsTmVYYI+NP4Zg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gzqniTAIHeQnvY5cBsiNDIpvQxfh/HqTK3A2lIErejI=; b=zNom4UmhKrzQ82DoCHJtUmbmbH4eOwNKt9xSmOM74omp8XfrZsWk/gTbwI0YYmIXcO8b08 kzveboVDw0Sg24Bg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=mz+S7s4d; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=zNom4Umh DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gzqniTAIHeQnvY5cBsiNDIpvQxfh/HqTK3A2lIErejI=; b=mz+S7s4dTv/H0GtrfOk2DYO1DGClA+rNyENRLNTuZwMGO4+Ndjm1j8/nnjHBf1Zw8zhno3 hEDeS9j9SNjTF/s1QSnM2I54cXznLMtsPLdTCUjacd/zhCJuoMIdCpqra0mpGAKxsG0HwX hfLnsOEDygRMfR8A2KsTmVYYI+NP4Zg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gzqniTAIHeQnvY5cBsiNDIpvQxfh/HqTK3A2lIErejI=; b=zNom4UmhKrzQ82DoCHJtUmbmbH4eOwNKt9xSmOM74omp8XfrZsWk/gTbwI0YYmIXcO8b08 kzveboVDw0Sg24Bg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 87D6813B18; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id VEHvICy9s2aGNAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id EF8F4A089C; Wed, 7 Aug 2024 20:30:03 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 12/13] fs: Make sb_start_pagefault() return error on shutdown filesystem Date: Wed, 7 Aug 2024 20:29:57 +0200 Message-Id: <20240807183003.23562-12-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=10931; i=jack@suse.cz; h=from:subject; bh=8KmJ0x0UPIu10TnEpoxvWsrKnC2A+3Bc4jqRyuanl7Y=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70ksc3ySHKfAltYxeulBlWyqyiOrwze+R68+LMW Hp0ihjiJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9JAAKCRCcnaoHP2RA2SaWB/ 9IExF5d8A7QrttGvftjZnv0TWTMuMB0kjpW2vLOxm93r6fJ2cMCGhvmhjwVhY6lElXv4kgNFV4EDtX 7h4D7dWoCpt4D3TF55TMy2NkHjnG45CTbQXPcuUlrCgOuBYmxS2+iT/qza6X3A8kfoL0qTHwEXelwc nDrherotqfaFbri9k7ReXnFUs3qCdGjDFS3KeHjbpaxryTcVeAIkD6/GMq+VF/zBhwIaYhzb8pGqdC uhqahvcKMdEi8S6OC09FCuZ0DQvaiPgMpM0WxibkrxIerXpbaWaMrkNJgQvnkjuF/FU+9txLM+C/6V jla+wB6hSQI7KeBMqFI1dw8FNtmI/w X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Level: X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO X-Rspamd-Queue-Id: 9200621D12 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.cz:dkim,suse.cz:email]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Similarly to sb_start_write(), make sb_start_pagefault() return errors for superblocks which are marked as shutdown to avoid modifications to it which reduces noise in the error logs and generally makes life somewhat easier for filesystems. We teach all sb_start_pagefault() callers to handle the error. Signed-off-by: Jan Kara --- fs/bcachefs/fs-io-pagecache.c | 3 ++- fs/btrfs/file.c | 3 ++- fs/ceph/addr.c | 9 ++++++--- fs/ext2/file.c | 3 ++- fs/ext4/file.c | 3 ++- fs/ext4/inode.c | 3 ++- fs/f2fs/file.c | 4 +++- fs/fuse/dax.c | 3 ++- fs/gfs2/file.c | 3 ++- fs/netfs/buffered_write.c | 3 ++- fs/nfs/file.c | 3 ++- fs/nilfs2/file.c | 3 ++- fs/ocfs2/mmap.c | 3 ++- fs/orangefs/inode.c | 3 ++- fs/udf/file.c | 3 ++- fs/xfs/xfs_file.c | 3 ++- fs/zonefs/file.c | 3 ++- include/linux/fs.h | 5 ++++- mm/filemap.c | 3 ++- 19 files changed, 45 insertions(+), 21 deletions(-) diff --git a/fs/bcachefs/fs-io-pagecache.c b/fs/bcachefs/fs-io-pagecache.c index a9cc5cad9cc9..a4efa1b76035 100644 --- a/fs/bcachefs/fs-io-pagecache.c +++ b/fs/bcachefs/fs-io-pagecache.c @@ -611,7 +611,8 @@ vm_fault_t bch2_page_mkwrite(struct vm_fault *vmf) bch2_folio_reservation_init(c, inode, &res); - sb_start_pagefault(inode->v.i_sb); + if (sb_start_pagefault(inode->v.i_sb) < 0) + return VM_FAULT_SIGBUS; file_update_time(file); /* diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 21381de906f6..481d355c66ee 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1900,7 +1900,8 @@ static vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) reserved_space = PAGE_SIZE; - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; page_start = page_offset(page); page_end = page_start + PAGE_SIZE - 1; end = page_end; diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 8c16bc5250ef..60ddddce4ec1 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1686,7 +1686,9 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf) if (!prealloc_cf) return VM_FAULT_OOM; - sb_start_pagefault(inode->i_sb); + err = sb_start_pagefault(inode->i_sb); + if (err) + goto out_free; ceph_block_sigs(&oldset); if (off + thp_size(page) <= size) @@ -1704,7 +1706,7 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf) got = 0; err = ceph_get_caps(vma->vm_file, CEPH_CAP_FILE_WR, want, off + len, &got); if (err < 0) - goto out_free; + goto out_sigs; doutc(cl, "%llx.%llx %llu~%zd got cap refs on %s\n", ceph_vinop(inode), off, len, ceph_cap_string(got)); @@ -1758,9 +1760,10 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf) doutc(cl, "%llx.%llx %llu~%zd dropping cap refs on %s ret %x\n", ceph_vinop(inode), off, len, ceph_cap_string(got), ret); ceph_put_cap_refs_async(ci, got); -out_free: +out_sigs: ceph_restore_sigs(&oldset); sb_end_pagefault(inode->i_sb); +out_free: ceph_free_cap_flush(prealloc_cf); if (err < 0) ret = vmf_error(err); diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 10b061ac5bc0..b57197007b28 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -98,7 +98,8 @@ static vm_fault_t ext2_dax_fault(struct vm_fault *vmf) (vmf->vma->vm_flags & VM_SHARED); if (write) { - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; file_update_time(vmf->vma->vm_file); } filemap_invalidate_lock_shared(inode->i_mapping); diff --git a/fs/ext4/file.c b/fs/ext4/file.c index c89e434db6b7..37623d4624c0 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -725,7 +725,8 @@ static vm_fault_t ext4_dax_huge_fault(struct vm_fault *vmf, unsigned int order) pfn_t pfn; if (write) { - sb_start_pagefault(sb); + if (sb_start_pagefault(sb) < 0) + return VM_FAULT_SIGBUS; file_update_time(vmf->vma->vm_file); filemap_invalidate_lock_shared(mapping); retry: diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 941c1c0d5c6e..195fcbb5c083 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6128,7 +6128,8 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) if (unlikely(IS_IMMUTABLE(inode))) return VM_FAULT_SIGBUS; - sb_start_pagefault(inode->i_sb); + if (unlikely(sb_start_pagefault(inode->i_sb) < 0)) + return VM_FAULT_SIGBUS; file_update_time(vma->vm_file); filemap_invalidate_lock_shared(mapping); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 168f08507004..67ee66ff75a7 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -100,7 +100,9 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) if (need_alloc) f2fs_balance_fs(sbi, true); - sb_start_pagefault(inode->i_sb); + err = sb_start_pagefault(inode->i_sb); + if (err) + goto out; f2fs_bug_on(sbi, f2fs_has_inline_data(inode)); diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 12ef91d170bb..d42d0aaa1bd9 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -797,7 +797,8 @@ static vm_fault_t __fuse_dax_fault(struct vm_fault *vmf, unsigned int order, bool retry = false; if (write) - sb_start_pagefault(sb); + if (sb_start_pagefault(sb) < 0) + return VM_FAULT_SIGBUS; retry: if (retry && !(fcd->nr_free_ranges > 0)) wait_event(fcd->range_waitq, (fcd->nr_free_ranges > 0)); diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 08982937b5df..774203da5262 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -427,7 +427,8 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) loff_t size; int err; - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); err = gfs2_glock_nq(&gh); diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 4726c315453c..e46fcd387be6 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -531,7 +531,8 @@ vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_gr _enter("%lx", folio->index); - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; if (folio_lock_killable(folio) < 0) goto out; diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 61a8cdb9f1e1..ae0791c67ab8 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -593,7 +593,8 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf) filp, filp->f_mapping->host->i_ino, (long long)folio_pos(folio)); - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; /* make sure the cache has finished storing the page */ if (folio_test_private_2(folio) && /* [DEPRECATED] */ diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index 0e3fc5ba33c7..6e80377250d1 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -54,7 +54,8 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info))) return VM_FAULT_SIGBUS; /* -ENOSPC */ - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; folio_lock(folio); if (folio->mapping != inode->i_mapping || folio_pos(folio) >= i_size_read(inode) || diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index 1834f26522ed..a56465a3a515 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c @@ -119,7 +119,8 @@ static vm_fault_t ocfs2_page_mkwrite(struct vm_fault *vmf) int err; vm_fault_t ret; - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; ocfs2_block_signals(&oldset); /* diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index fdb9b65db1de..170ef9456ff1 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -632,7 +632,8 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf) vm_fault_t ret; struct orangefs_write_range *wr; - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; if (wait_on_bit(bitlock, 1, TASK_KILLABLE)) { ret = VM_FAULT_RETRY; diff --git a/fs/udf/file.c b/fs/udf/file.c index 3a4179de316b..d97ba972f1f3 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -45,7 +45,8 @@ static vm_fault_t udf_page_mkwrite(struct vm_fault *vmf) vm_fault_t ret = VM_FAULT_LOCKED; int err; - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; file_update_time(vma->vm_file); filemap_invalidate_lock_shared(mapping); folio_lock(folio); diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 4cdc54dc9686..7e2c9bd70bc2 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1283,7 +1283,8 @@ xfs_write_fault( unsigned int lock_mode = XFS_MMAPLOCK_SHARED; vm_fault_t ret; - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; file_update_time(vmf->vma->vm_file); /* diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c index 3b103715acc9..0b100d48056a 100644 --- a/fs/zonefs/file.c +++ b/fs/zonefs/file.c @@ -294,7 +294,8 @@ static vm_fault_t zonefs_filemap_page_mkwrite(struct vm_fault *vmf) if (zonefs_inode_is_seq(inode)) return VM_FAULT_NOPAGE; - sb_start_pagefault(inode->i_sb); + if (sb_start_pagefault(inode->i_sb) < 0) + return VM_FAULT_SIGBUS; file_update_time(vmf->vma->vm_file); /* Serialize against truncates */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 44ae86f46b12..a082777eac6a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1858,9 +1858,12 @@ static inline bool __must_check sb_start_write_trylock(struct super_block *sb) * mmap_lock * -> sb_start_pagefault */ -static inline void sb_start_pagefault(struct super_block *sb) +static inline int __must_check sb_start_pagefault(struct super_block *sb) { + if (sb_test_iflag(sb, SB_I_SHUTDOWN)) + return -EROFS; __sb_start_write(sb, SB_FREEZE_PAGEFAULT); + return 0; } /** diff --git a/mm/filemap.c b/mm/filemap.c index d62150418b91..97efc8a62c21 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3672,7 +3672,8 @@ vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf) struct folio *folio = page_folio(vmf->page); vm_fault_t ret = VM_FAULT_LOCKED; - sb_start_pagefault(mapping->host->i_sb); + if (sb_start_pagefault(mapping->host->i_sb) < 0) + return VM_FAULT_SIGBUS; file_update_time(vmf->vma->vm_file); folio_lock(folio); if (folio->mapping != mapping) { From patchwork Wed Aug 7 18:29:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13756619 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2012313A25F for ; Wed, 7 Aug 2024 18:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055410; cv=none; b=kzz+UUZSAmlPOjhxrKk4Dt83a05+sifgaKcf5UTEMSGMoHhj1ttBU4jLBsWCR7d2+CjFFMs6cFMCnqI9xHhNQADAPyNcpKWRZhhOJHdrc6CtXRUJ+kUqNst+uPjOtGdNBSRHliHrp3jGCZH9ZRhMTLL38eKhyn670zuS9+MJlwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723055410; c=relaxed/simple; bh=ZxNDo9aPYuap3mVBwDH3tYSQoLhuYnF5doB8nHtl+JA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RL7u2UZ5FodTL79yfSfEqj2qmgL2WmNk1j8X/1xHLk4uL1+pMgD56Mo4cJW2oPkRkVpjMiMvHLZNang2Upx9AU8oAmABmIRV6NGk2mEx3Lt0MzJYzEP//qo7olnOYehNYQQ2JvgTObCL3TwRMMqi67zHjTve7T+Cb2PWysJgLvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=PFucV6ho; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=L0ENRQgi; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=PFucV6ho; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=L0ENRQgi; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="PFucV6ho"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="L0ENRQgi"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="PFucV6ho"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="L0ENRQgi" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8B35A21D0A; Wed, 7 Aug 2024 18:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jW2UxCUvrHl1YGAPkqecYDBFUh/CQI21/j3ziGvYNDg=; b=PFucV6hoTnlAXOby9AtXtQ4ZI9pLI/G476xTV6hWrQ18ipZHYjuO36Fi8gtf9RRaV9EW2t 69fEnQKSRxaTE3pKNzMJ8cXjpxB6uNRipF3rQIUJ0DZIu1asffcjdHhRo3njL3nL5m5tGA CvzuhHNeLLuNzcnDJt9OxCT0xJIozW8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jW2UxCUvrHl1YGAPkqecYDBFUh/CQI21/j3ziGvYNDg=; b=L0ENRQgi6fKJ/XLgDqJ/hU+Dk2htxYbHxEdaIvbeXi7Od+ik4PgOUD4F0mxp6KsJ7UrBKW QkX+HhH8SvCWiVAQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=PFucV6ho; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=L0ENRQgi DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jW2UxCUvrHl1YGAPkqecYDBFUh/CQI21/j3ziGvYNDg=; b=PFucV6hoTnlAXOby9AtXtQ4ZI9pLI/G476xTV6hWrQ18ipZHYjuO36Fi8gtf9RRaV9EW2t 69fEnQKSRxaTE3pKNzMJ8cXjpxB6uNRipF3rQIUJ0DZIu1asffcjdHhRo3njL3nL5m5tGA CvzuhHNeLLuNzcnDJt9OxCT0xJIozW8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723055405; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jW2UxCUvrHl1YGAPkqecYDBFUh/CQI21/j3ziGvYNDg=; b=L0ENRQgi6fKJ/XLgDqJ/hU+Dk2htxYbHxEdaIvbeXi7Od+ik4PgOUD4F0mxp6KsJ7UrBKW QkX+HhH8SvCWiVAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 87ACD13B17; Wed, 7 Aug 2024 18:30:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Wo/rICy9s2aHNAAAD6G6ig (envelope-from ); Wed, 07 Aug 2024 18:30:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 045B9A08AF; Wed, 7 Aug 2024 20:30:04 +0200 (CEST) From: Jan Kara To: Cc: Dave Chinner , Christian Brauner , Jan Kara Subject: [PATCH 13/13] ext4: Replace EXT4_FLAGS_SHUTDOWN flag with a generic SB_I_SHUTDOWN Date: Wed, 7 Aug 2024 20:29:58 +0200 Message-Id: <20240807183003.23562-13-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240807180706.30713-1-jack@suse.cz> References: <20240807180706.30713-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3143; i=jack@suse.cz; h=from:subject; bh=ZxNDo9aPYuap3mVBwDH3tYSQoLhuYnF5doB8nHtl+JA=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBms70lzOwmwCWccOu1v76WslcFyhi1SbCUW/tC6peM YF+ERPmJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZrO9JQAKCRCcnaoHP2RA2ev5B/ 9r8kEBeEQDB0os5i6BQ3HtJIHQx2eqQStJwRMLVhBa94sorP2BUXlX765VkaUuvTwrYUVT4BpFHimY MOWD59MWrdqi7c21KnS8p2KVA6uiILp1eT5olh5L+3Rfvyy3os1Sfr67pq44UvJ6XhglWWHQ2d70+M boS1cxPyRB2qXyNhu6KVLUZl0O8MSlmGqesI1HRmUW2GQ5K+aHCIE0CA4m7AhHhcDwwRSDCpa7yQIj baqjkBrdE8JoSJRU3FKT3948NKAm6DvXA2eoDZhnj3GPwNfZStTWXQY8ih2Dv18Cg0axlVATxusnEm 58bbAcC869lQ/IQFaq7uoYEawNkRIY X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Level: X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO X-Rspamd-Queue-Id: 8B35A21D0A X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:dkim,suse.cz:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Instead of using private ext4 EXT4_FLAGS_SHUTDOWN flag, use a generic variant SB_I_SHUTDOWN. As a bonus VFS will now refuse modification attempts for the filesystem when the flag is set. Signed-off-by: Jan Kara --- fs/ext4/ext4.h | 3 +-- fs/ext4/ioctl.c | 6 +++--- fs/ext4/super.c | 11 +++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 08acd152261e..7a3ea125ec86 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2240,12 +2240,11 @@ extern int ext4_feature_set_ok(struct super_block *sb, int readonly); * Superblock flags */ #define EXT4_FLAGS_RESIZING 0 -#define EXT4_FLAGS_SHUTDOWN 1 #define EXT4_FLAGS_BDEV_IS_DAX 2 static inline int ext4_forced_shutdown(struct super_block *sb) { - return test_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags); + return sb_test_iflag(sb, SB_I_SHUTDOWN); } /* diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index e8bf5972dd47..086bc239ff33 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -822,18 +822,18 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags) ret = bdev_freeze(sb->s_bdev); if (ret) return ret; - set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); + sb_set_iflag(sb, SB_I_SHUTDOWN); bdev_thaw(sb->s_bdev); break; case EXT4_GOING_FLAGS_LOGFLUSH: - set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); + sb_set_iflag(sb, SB_I_SHUTDOWN); if (sbi->s_journal && !is_journal_aborted(sbi->s_journal)) { (void) ext4_force_commit(sb); jbd2_journal_abort(sbi->s_journal, -ESHUTDOWN); } break; case EXT4_GOING_FLAGS_NOLOGFLUSH: - set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); + sb_set_iflag(sb, SB_I_SHUTDOWN); if (sbi->s_journal && !is_journal_aborted(sbi->s_journal)) jbd2_journal_abort(sbi->s_journal, -ESHUTDOWN); break; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index b5b2f17f1b65..928d8eb266f0 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -701,7 +701,7 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error, WARN_ON_ONCE(1); if (!continue_fs && !sb_rdonly(sb)) { - set_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags); + sb_set_iflag(sb, SB_I_SHUTDOWN); if (journal) jbd2_journal_abort(journal, -EIO); } @@ -735,11 +735,10 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error, ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); /* - * EXT4_FLAGS_SHUTDOWN was set which stops all filesystem - * modifications. We don't set SB_RDONLY because that requires - * sb->s_umount semaphore and setting it without proper remount - * procedure is confusing code such as freeze_super() leading to - * deadlocks and other problems. + * SB_I_SHUTDOWN was set which stops all filesystem modifications. We + * don't set SB_RDONLY because that requires sb->s_umount semaphore and + * setting it without proper remount procedure is confusing code such + * as freeze_super() leading to deadlocks and other problems. */ }