From nobody Thu Oct 2 20:38:43 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 899AB248F72; Thu, 11 Sep 2025 04:56:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757566574; cv=none; b=e+WSfQQP3aLCNU6k364TBq4Cn8eWsbr8vX0fsFi9GyYk86hyt8xibVT0SFfDxfUKIExbK7IN/vQ9tfVynje8+6EOpwUZS4T540XCOA4Y3cXuuye00ZGUewvIt3NZ+GXf0VtQRl4JSkfE2bzMHLF5Hi7OUv0Cd2FsTb3WmBVskGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757566574; c=relaxed/simple; bh=CP3LXTksQglwFNpnXr0hPsTeP7YFtJ0DHIn/IRdimlo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VCjhnnzKeIHzaJEuh2A5y5++1u5d6HKVpjtRiMuUlzfkxbKBPkY1U/Fc/ME1cXI3KqceAAOeTjDo3z7E6L6H3xkGFdLAdCWqiDMHkamth/WZVoOke/XR7KGPKDmg2gDO9GvnomVajQDy+gOyM/gzaf2PRmGgKY5fXcp+Q+evIpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WTb2Cf4P; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WTb2Cf4P" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-45cb6180b60so1667845e9.0; Wed, 10 Sep 2025 21:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757566571; x=1758171371; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/znQVoqdYnguqmx5WBg8gphSRKbnjv7YqaJ0uXheApk=; b=WTb2Cf4PmWTbVkQoUzX0+Uef3EKEBv88yQpHVXuAqPz5qYmIXWQOtUgm8Eh9CvUkHP 8wFPfrgQ/i35W5FAf7+SVcqKRTHmlp+VJI+Ek/RCbzL1x9LGBNsoo5RuleXd+Le01Acq 3XifXX9x6/jfub+9mtbeWf8fLWEKgA7wHj3gRTulzOIMXFZFgrMQJ+6UU3u+mX7+17yD dpkuBfY2bxQqpv5yPf7opnyVpp9FNE2eNbSbnEmIv++zvZLFk+kWNCA3KNTAkKRSBAxA rhSKzkGhXIR3Yxx7EcfY28igevFqvcRGmTR0VzEqfd1vbefjLrBY36AH4c305EBp16iS yNRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757566571; x=1758171371; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/znQVoqdYnguqmx5WBg8gphSRKbnjv7YqaJ0uXheApk=; b=MK9/f+62PIcWMgf7z3nkBEh/xcZ53oDamUVHTnT2KWJUm6vxIWmQe4Jw9pqCxqQvgs 71gRE9H4lkdP6ezsbIeebAlx7tFQtHLylIrYzwSz42T5mf2pyA0kjdQw0StHiXj0gYYL CbMMp0miAxYwbyKNQVfhWzCm5PsGzpNIIwBCz9ugP+bmxVYD/itYr5af+F8pFthS1uuh 6nHYftgqzkm4IDfHHB8bi6IIyOr49Kafp06dHhQtj4YU+kRdq7E/Z8vcA8bdRZ/umaeY T+ZrVpzdIS0AUngm1CUW45ON8CyY8cyCjiQRfOdZkAzR1t5tVuOVT5vywNKZmIBrR1hz Qs1Q== X-Forwarded-Encrypted: i=1; AJvYcCUS4w6e5aje1jt/9zEQkaFgSCLo6pCiG7/eCm2F1TGIVQcmOG8JgE5RqEa80AHEuQ0ESzb2Hsz/un1j2w==@vger.kernel.org, AJvYcCV8jXa2g4BT+KVsZ39TRDCXv8EWjz6HWzgOC6CU10aHqWo4mMbJHmj/GcvzwJiX40qCjZnBEmUkRrZhNxky7g==@vger.kernel.org, AJvYcCV9V+LfDMSB4bmWUWIpO9MV9UG/wpNHyTR5ZqT21iGN+wOi3zlvbbkBqyaUS/SQmMcbcP+NXj20kZ7QiQ==@vger.kernel.org, AJvYcCVU3PfbADvBIffriit8H02qTIMTxMw1+px8hOp35BJ4oi0I5Ej6Z8s62NKwS7HejgDTMk7xUDVwCmWl@vger.kernel.org, AJvYcCWDtHxZ9+dymG9nyS8l0H/+i6BCNKs/tf/h4sUxepurEF0Rpa0Fqy0M7CQJd9EIyFBFOEA5lzM6DJ4d/nGY@vger.kernel.org X-Gm-Message-State: AOJu0Yy6zM3WiYXzk9JHYtQp1uQGHCtkusEslaQ532YkhGUfwk3qKeje BwTkEjp7J62KukCDAx18kOKnk1YRqTHKK4DIlbWBSdgmVIQO7q1dwdzT X-Gm-Gg: ASbGnctySV8ojlqFNMpCw+q/y1mDRorS0pdy4HcV9rglRkZ+FvAaz3X50Tlxuifw0GX PGGwcYKCvfSjH9WkdFgJokyGLa90X1zXBxDy4Qa8jN9C/Mbuhb0N7w9Uf62XsWHe8p/ig4VA/h5 PQh9GZYCnMqZXPgGCOXYdDm5Zqgkvb4LVDCx/8k02PVfwPhwjHrOMOm7QoKL8k/LtshswsF47BS rM0UgAzRytAzXsMHhRXfoK3p/MMcBeIeufnGD8rH9fzujt7oECVpY7JHAau5pet0ZBlGqJZ2W8l rsxXrmxL46WaSkctGG9aftR/e5ZkNgY3T5abZ79ktGUGuKcemODcQumvfS1/mOdbw3f9Sc6vM4G QSHuZgKmxO8L1P3WxsC2mw45IoMAmqpmzTJlVfF4t X-Google-Smtp-Source: AGHT+IE+08c9X5HobyMLxXhZ3NFl5GxQuz/7iatm7LXGN82shDvsjXSG1iJZArieNMj/KCrR4Zsqig== X-Received: by 2002:a05:600c:1f91:b0:45d:d5df:ab2d with SMTP id 5b1f17b1804b1-45dddeef92cmr155477075e9.26.1757566570508; Wed, 10 Sep 2025 21:56:10 -0700 (PDT) Received: from f.. (cst-prg-67-222.cust.vodafone.cz. [46.135.67.222]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607e9e6asm889419f8f.62.2025.09.10.21.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Sep 2025 21:56:09 -0700 (PDT) From: Mateusz Guzik To: brauner@kernel.org Cc: viro@zeniv.linux.org.uk, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, josef@toxicpanda.com, kernel-team@fb.com, amir73il@gmail.com, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, Mateusz Guzik Subject: [PATCH v3 1/4] fs: expand dump_inode() Date: Thu, 11 Sep 2025 06:55:54 +0200 Message-ID: <20250911045557.1552002-2-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911045557.1552002-1-mjguzik@gmail.com> References: <20250911045557.1552002-1-mjguzik@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This adds fs name and few fields from struct inode: i_mode, i_opflags, i_flags and i_state. All values printed raw, no attempt to pretty-print anything. Compile tested on for i386 and runtime tested on amd64. Sample output: [ 31.450263] VFS_WARN_ON_INODE("crap") encountered for inode ffff9b10837a= 3240 fs sockfs mode 140777 opflags c flags 0 state 100 Signed-off-by: Mateusz Guzik --- fs/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 833de5457a06..e8c712211822 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2935,10 +2935,18 @@ EXPORT_SYMBOL(mode_strip_sgid); * * TODO: add a proper inode dumping routine, this is a stub to get debug o= ff the * ground. + * + * TODO: handle getting to fs type with get_kernel_nofault()? + * See dump_mapping() above. */ void dump_inode(struct inode *inode, const char *reason) { - pr_warn("%s encountered for inode %px", reason, inode); + struct super_block *sb =3D inode->i_sb; + + pr_warn("%s encountered for inode %px\n" + "fs %s mode %ho opflags %hx flags %u state %x\n", + reason, inode, sb->s_type->name, inode->i_mode, inode->i_opflags, + inode->i_flags, inode->i_state); } =20 EXPORT_SYMBOL(dump_inode); --=20 2.43.0 From nobody Thu Oct 2 20:38:43 2025 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 DA5E82580CA for ; Thu, 11 Sep 2025 04:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757566580; cv=none; b=JxCNOs/ePaxu1g/lFseszaiiz2l/y0aX0w7BU/c0YnJaWNiU3ZjcxttNjtzCdS4XE7IwPmvtbOnUujYU12G/0Vo6mwO4NKKfIOVlN++LmNC972MqHHXBrmYycuObg3h5YyDwZQPCtf4ejCxQ1dRGiL6MXs1r5p1MH1NwWmeFtWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757566580; c=relaxed/simple; bh=OEjnifHjPxvs5mIcEbiq8E0EsMzTidAt0c3PZm6jgKc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Aax3aOX07CBDA0U7fcfnjPzZQPYlbJ4o7Flc4E3ppkHrn6+MC+SUMpToj2VbQzjmzFUCsds+4jAnNxgf8tZdxm+nFMitlRLmukIBFkGZPtw1ylA031rD3tYl33rdcWVElK9qakamQm+6CCXuBwmf2LHlrOfEUqZWZRwbYpb0gPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NVkY7sxK; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NVkY7sxK" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3dae49b1293so137876f8f.1 for ; Wed, 10 Sep 2025 21:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757566575; x=1758171375; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ygVJ+Bkkxh/1T6kHxseAxJmJu6kAgrkkBFGhbPiHl28=; b=NVkY7sxKj/XTYwQIFjFvxDfHYGCqhaNvOF2+WgZEvOLacNrdv8/0hM/hw+asQp/tXd G1UcVlqh7DOnQC0mo8zIwGeWKx56XrGWrYzoOvdpyGjqBJc5wdvhi8YmiREBYG360lM/ esWm6Lnp/O1O0HRIdOnWOix9UnWbdVndl3NJtpLfOho6Vb0iB6cIB3XwwNtlsSS0O49J RZh6+T9K0C9kHEcr6J9XrG4YA1zzJ87QrbF4+Wqj0826Tx7r6ojsCstTk1gMC+RfBv5u RaKr1ysN1s8E5ta1XLQM8mtTg5pI99U3vuHCBTKZKnaZn9XG81OGuUefGRTAUirHj3Ph lD9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757566575; x=1758171375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ygVJ+Bkkxh/1T6kHxseAxJmJu6kAgrkkBFGhbPiHl28=; b=plM6d9D6WforeaRfi2httEHmfljO4FXFOELsSDEYwZZK3Q0sbhxpoEMv9d4v6vBsm5 yhM6ZIGy+BYH+mn/Y8O+vJTxgcd2yDpDg5Rujai2bRIZ4rPhnucR9fd4kqJ1PHkDz4Qo 182PNFg9CbPq4bKo1pDM27AXzpxT8xOyJeaulirV2+VSsksvXQcgDIhKY/aMIxLPAM9G 8GiaV41QU4SoY2+qQXUnohQopQSgu1S2flc3Dz54+hEqRl6HUFEN1PHSFanbgrCR7Hi3 JpAL7QdQXgev/Wgpgj2z0muf1ONFwKoR01pxuA8HrbginO8em+xPEPOylr/2wQ9uxR6O EyHQ== X-Forwarded-Encrypted: i=1; AJvYcCUNYlkGKYb1M6eX3gZIX8ovC1R1yhVeWKmt14cimrqYAqTciSoxjgBC1ejjZwAYmCLPn+k9IDebdTAjXz8=@vger.kernel.org X-Gm-Message-State: AOJu0YwpmU0jhSRNd5KFxMHftaUgS6WjRubUuXbpfJxGucAwPfRux8Vg 4Cy3C4+2hTAOjVWhTgjYcoY3XewuPHVPNWtngUxkap0OzAPvF56GBd/7 X-Gm-Gg: ASbGncsodlzr8PD5BcCGK+QhUf9kqQesy9XyP6qcWD+78j/T0qjn+ff/rxg0AefwS6Q gUAn55De1ewfUksNItSlB7Oh33fC5wSPzE6oBiWM5S9PJBetyKEkEZqioekMZlEuBdi3sb4VbZB YoEUTqKJwRShK7WsjlHdhMeZLiBchi7d+khJeWzQgMKGPOJADG1tOg47vPS6NWmMcdMtAnNREWK POj6qlzxeTIoYkkUkjmPu/MYbEAjDJUNXS99BZ330coffaMFnDm17C79hjwk4zIF7TLuzU2bttS KMO6dpXY5Fm1H5G1Knz3uuxbV3tFZekzIwdl0X7oY3h51RSzXxv+c64u+3EDsDbVB0qOJYG7jW+ dEZmxoqRd8dqo83seVjc2og1MFvrXLCSuCaXpbqVux/p8djld0ZSyEhD0ZFdF9Q== X-Google-Smtp-Source: AGHT+IG5keQ1YIH7GVlPEXazCgqsjLSAwbkA2jMtok90kSRccCP3RkIcMHCJ3NZYKHYIlAKgyKqOYQ== X-Received: by 2002:a5d:5d05:0:b0:3ce:f0a5:d581 with SMTP id ffacd0b85a97d-3e636d8ff6dmr13265651f8f.7.1757566574765; Wed, 10 Sep 2025 21:56:14 -0700 (PDT) Received: from f.. (cst-prg-67-222.cust.vodafone.cz. [46.135.67.222]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607e9e6asm889419f8f.62.2025.09.10.21.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Sep 2025 21:56:14 -0700 (PDT) From: Mateusz Guzik To: brauner@kernel.org Cc: viro@zeniv.linux.org.uk, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, josef@toxicpanda.com, kernel-team@fb.com, amir73il@gmail.com, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, Mateusz Guzik Subject: [PATCH v3 2/4] fs: hide ->i_state handling behind accessors Date: Thu, 11 Sep 2025 06:55:55 +0200 Message-ID: <20250911045557.1552002-3-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911045557.1552002-1-mjguzik@gmail.com> References: <20250911045557.1552002-1-mjguzik@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Mateusz Guzik --- block/bdev.c | 4 +- drivers/dax/super.c | 2 +- fs/buffer.c | 4 +- fs/crypto/keyring.c | 2 +- fs/crypto/keysetup.c | 2 +- fs/dcache.c | 8 +- fs/drop_caches.c | 2 +- fs/fs-writeback.c | 123 ++++++++++++++++--------------- fs/inode.c | 103 +++++++++++++------------- fs/libfs.c | 6 +- fs/namei.c | 8 +- fs/notify/fsnotify.c | 2 +- fs/pipe.c | 2 +- fs/quota/dquot.c | 2 +- fs/sync.c | 2 +- include/linux/backing-dev.h | 5 +- include/linux/fs.h | 55 +++++++++++++- include/linux/writeback.h | 4 +- include/trace/events/writeback.h | 8 +- mm/backing-dev.c | 2 +- security/landlock/fs.c | 2 +- 21 files changed, 198 insertions(+), 150 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index b77ddd12dc06..77f04042ac67 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -67,7 +67,7 @@ static void bdev_write_inode(struct block_device *bdev) int ret; =20 spin_lock(&inode->i_lock); - while (inode->i_state & I_DIRTY) { + while (inode_state_read(inode) & I_DIRTY) { spin_unlock(&inode->i_lock); ret =3D write_inode_now(inode, true); if (ret) @@ -1265,7 +1265,7 @@ void sync_bdevs(bool wait) struct block_device *bdev; =20 spin_lock(&inode->i_lock); - if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW) || + if (inode_state_read(inode) & (I_FREEING|I_WILL_FREE|I_NEW) || mapping->nrpages =3D=3D 0) { spin_unlock(&inode->i_lock); continue; diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 54c480e874cb..900e488105d3 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -433,7 +433,7 @@ static struct dax_device *dax_dev_get(dev_t devt) return NULL; =20 dax_dev =3D to_dax_dev(inode); - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { set_bit(DAXDEV_ALIVE, &dax_dev->flags); inode->i_cdev =3D &dax_dev->cdev; inode->i_mode =3D S_IFCHR; diff --git a/fs/buffer.c b/fs/buffer.c index ead4dc85debd..b732842fb060 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -611,9 +611,9 @@ int generic_buffers_fsync_noflush(struct file *file, lo= ff_t start, loff_t end, return err; =20 ret =3D sync_mapping_buffers(inode->i_mapping); - if (!(inode->i_state & I_DIRTY_ALL)) + if (!(inode_state_read_unstable(inode) & I_DIRTY_ALL)) goto out; - if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) + if (datasync && !(inode_state_read_unstable(inode) & I_DIRTY_DATASYNC)) goto out; =20 err =3D sync_inode_metadata(inode, 1); diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c index 7557f6a88b8f..34beb60bc24e 100644 --- a/fs/crypto/keyring.c +++ b/fs/crypto/keyring.c @@ -957,7 +957,7 @@ static void evict_dentries_for_decrypted_inodes(struct = fscrypt_master_key *mk) list_for_each_entry(ci, &mk->mk_decrypted_inodes, ci_master_key_link) { inode =3D ci->ci_inode; spin_lock(&inode->i_lock); - if (inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW)) { + if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) { spin_unlock(&inode->i_lock); continue; } diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index c1f85715c276..b801c47f5699 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -859,7 +859,7 @@ int fscrypt_drop_inode(struct inode *inode) * userspace is still using the files, inodes can be dirtied between * then and now. We mustn't lose any writes, so skip dirty inodes here. */ - if (inode->i_state & I_DIRTY_ALL) + if (inode_state_read(inode) & I_DIRTY_ALL) return 0; =20 /* diff --git a/fs/dcache.c b/fs/dcache.c index 60046ae23d51..e01c8b678a6f 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -794,7 +794,7 @@ void d_mark_dontcache(struct inode *inode) de->d_flags |=3D DCACHE_DONTCACHE; spin_unlock(&de->d_lock); } - inode->i_state |=3D I_DONTCACHE; + inode_state_add(inode, I_DONTCACHE); spin_unlock(&inode->i_lock); } EXPORT_SYMBOL(d_mark_dontcache); @@ -1073,7 +1073,7 @@ struct dentry *d_find_alias_rcu(struct inode *inode) spin_lock(&inode->i_lock); // ->i_dentry and ->i_rcu are colocated, but the latter won't be // used without having I_FREEING set, which means no aliases left - if (likely(!(inode->i_state & I_FREEING) && !hlist_empty(l))) { + if (likely(!(inode_state_read(inode) & I_FREEING) && !hlist_empty(l))) { if (S_ISDIR(inode->i_mode)) { de =3D hlist_entry(l->first, struct dentry, d_u.d_alias); } else { @@ -1980,8 +1980,8 @@ void d_instantiate_new(struct dentry *entry, struct i= node *inode) security_d_instantiate(entry, inode); spin_lock(&inode->i_lock); __d_instantiate(entry, inode); - WARN_ON(!(inode->i_state & I_NEW)); - inode->i_state &=3D ~I_NEW & ~I_CREATING; + WARN_ON(!(inode_state_read(inode) & I_NEW)); + inode_state_del(inode, I_NEW | I_CREATING); /* * Pairs with the barrier in prepare_to_wait_event() to make sure * ___wait_var_event() either sees the bit cleared or diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 019a8b4eaaf9..73175ac2fe92 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -28,7 +28,7 @@ static void drop_pagecache_sb(struct super_block *sb, voi= d *unused) * inodes without pages but we deliberately won't in case * we need to reschedule to avoid softlockups. */ - if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || + if ((inode_state_read(inode) & (I_FREEING|I_WILL_FREE|I_NEW)) || (mapping_empty(inode->i_mapping) && !need_resched())) { spin_unlock(&inode->i_lock); continue; diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 6088a67b2aae..3ce3a636c061 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -121,7 +121,7 @@ static bool inode_io_list_move_locked(struct inode *ino= de, { assert_spin_locked(&wb->list_lock); assert_spin_locked(&inode->i_lock); - WARN_ON_ONCE(inode->i_state & I_FREEING); + WARN_ON_ONCE(inode_state_read(inode) & I_FREEING); =20 list_move(&inode->i_io_list, head); =20 @@ -304,9 +304,9 @@ static void inode_cgwb_move_to_attached(struct inode *i= node, { assert_spin_locked(&wb->list_lock); assert_spin_locked(&inode->i_lock); - WARN_ON_ONCE(inode->i_state & I_FREEING); + WARN_ON_ONCE(inode_state_read(inode) & I_FREEING); =20 - inode->i_state &=3D ~I_SYNC_QUEUED; + inode_state_del(inode, I_SYNC_QUEUED); if (wb !=3D &wb->bdi->wb) list_move(&inode->i_io_list, &wb->b_attached); else @@ -408,7 +408,7 @@ static bool inode_do_switch_wbs(struct inode *inode, * Once I_FREEING or I_WILL_FREE are visible under i_lock, the eviction * path owns the inode and we shouldn't modify ->i_io_list. */ - if (unlikely(inode->i_state & (I_FREEING | I_WILL_FREE))) + if (unlikely(inode_state_read(inode) & (I_FREEING | I_WILL_FREE))) goto skip_switch; =20 trace_inode_switch_wbs(inode, old_wb, new_wb); @@ -452,7 +452,7 @@ static bool inode_do_switch_wbs(struct inode *inode, if (!list_empty(&inode->i_io_list)) { inode->i_wb =3D new_wb; =20 - if (inode->i_state & I_DIRTY_ALL) { + if (inode_state_read(inode) & I_DIRTY_ALL) { struct inode *pos; =20 list_for_each_entry(pos, &new_wb->b_dirty, i_io_list) @@ -475,10 +475,11 @@ static bool inode_do_switch_wbs(struct inode *inode, switched =3D true; skip_switch: /* - * Paired with load_acquire in unlocked_inode_to_wb_begin() and + * Paired with an acquire fence in unlocked_inode_to_wb_begin() and * ensures that the new wb is visible if they see !I_WB_SWITCH. */ - smp_store_release(&inode->i_state, inode->i_state & ~I_WB_SWITCH); + smp_wmb(); + inode_state_del(inode, I_WB_SWITCH); =20 xa_unlock_irq(&mapping->i_pages); spin_unlock(&inode->i_lock); @@ -560,12 +561,12 @@ static bool inode_prepare_wbs_switch(struct inode *in= ode, /* while holding I_WB_SWITCH, no one else can update the association */ spin_lock(&inode->i_lock); if (!(inode->i_sb->s_flags & SB_ACTIVE) || - inode->i_state & (I_WB_SWITCH | I_FREEING | I_WILL_FREE) || + inode_state_read(inode) & (I_WB_SWITCH | I_FREEING | I_WILL_FREE) || inode_to_wb(inode) =3D=3D new_wb) { spin_unlock(&inode->i_lock); return false; } - inode->i_state |=3D I_WB_SWITCH; + inode_state_add(inode, I_WB_SWITCH); __iget(inode); spin_unlock(&inode->i_lock); =20 @@ -587,7 +588,7 @@ static void inode_switch_wbs(struct inode *inode, int n= ew_wb_id) struct inode_switch_wbs_context *isw; =20 /* noop if seems to be already in progress */ - if (inode->i_state & I_WB_SWITCH) + if (inode_state_read_unstable(inode) & I_WB_SWITCH) return; =20 /* avoid queueing a new switch if too many are already in flight */ @@ -1197,9 +1198,9 @@ static void inode_cgwb_move_to_attached(struct inode = *inode, { assert_spin_locked(&wb->list_lock); assert_spin_locked(&inode->i_lock); - WARN_ON_ONCE(inode->i_state & I_FREEING); + WARN_ON_ONCE(inode_state_read(inode) & I_FREEING); =20 - inode->i_state &=3D ~I_SYNC_QUEUED; + inode_state_del(inode, I_SYNC_QUEUED); list_del_init(&inode->i_io_list); wb_io_lists_depopulated(wb); } @@ -1312,7 +1313,7 @@ void inode_io_list_del(struct inode *inode) wb =3D inode_to_wb_and_lock_list(inode); spin_lock(&inode->i_lock); =20 - inode->i_state &=3D ~I_SYNC_QUEUED; + inode_state_del(inode, I_SYNC_QUEUED); list_del_init(&inode->i_io_list); wb_io_lists_depopulated(wb); =20 @@ -1370,13 +1371,13 @@ static void redirty_tail_locked(struct inode *inode= , struct bdi_writeback *wb) { assert_spin_locked(&inode->i_lock); =20 - inode->i_state &=3D ~I_SYNC_QUEUED; + inode_state_del(inode, I_SYNC_QUEUED); /* * When the inode is being freed just don't bother with dirty list * tracking. Flush worker will ignore this inode anyway and it will * trigger assertions in inode_io_list_move_locked(). */ - if (inode->i_state & I_FREEING) { + if (inode_state_read(inode) & I_FREEING) { list_del_init(&inode->i_io_list); wb_io_lists_depopulated(wb); return; @@ -1410,7 +1411,7 @@ static void inode_sync_complete(struct inode *inode) { assert_spin_locked(&inode->i_lock); =20 - inode->i_state &=3D ~I_SYNC; + inode_state_del(inode, I_SYNC); /* If inode is clean an unused, put it into LRU now... */ inode_add_lru(inode); /* Called with inode->i_lock which ensures memory ordering. */ @@ -1454,7 +1455,7 @@ static int move_expired_inodes(struct list_head *dela= ying_queue, spin_lock(&inode->i_lock); list_move(&inode->i_io_list, &tmp); moved++; - inode->i_state |=3D I_SYNC_QUEUED; + inode_state_add(inode, I_SYNC_QUEUED); spin_unlock(&inode->i_lock); if (sb_is_blkdev_sb(inode->i_sb)) continue; @@ -1540,14 +1541,14 @@ void inode_wait_for_writeback(struct inode *inode) =20 assert_spin_locked(&inode->i_lock); =20 - if (!(inode->i_state & I_SYNC)) + if (!(inode_state_read(inode) & I_SYNC)) return; =20 wq_head =3D inode_bit_waitqueue(&wqe, inode, __I_SYNC); for (;;) { prepare_to_wait_event(wq_head, &wqe.wq_entry, TASK_UNINTERRUPTIBLE); /* Checking I_SYNC with inode->i_lock guarantees memory ordering. */ - if (!(inode->i_state & I_SYNC)) + if (!(inode_state_read(inode) & I_SYNC)) break; spin_unlock(&inode->i_lock); schedule(); @@ -1573,7 +1574,7 @@ static void inode_sleep_on_writeback(struct inode *in= ode) wq_head =3D inode_bit_waitqueue(&wqe, inode, __I_SYNC); prepare_to_wait_event(wq_head, &wqe.wq_entry, TASK_UNINTERRUPTIBLE); /* Checking I_SYNC with inode->i_lock guarantees memory ordering. */ - sleep =3D !!(inode->i_state & I_SYNC); + sleep =3D !!(inode_state_read(inode) & I_SYNC); spin_unlock(&inode->i_lock); if (sleep) schedule(); @@ -1592,7 +1593,7 @@ static void requeue_inode(struct inode *inode, struct= bdi_writeback *wb, struct writeback_control *wbc, unsigned long dirtied_before) { - if (inode->i_state & I_FREEING) + if (inode_state_read(inode) & I_FREEING) return; =20 /* @@ -1600,7 +1601,7 @@ static void requeue_inode(struct inode *inode, struct= bdi_writeback *wb, * shot. If still dirty, it will be redirty_tail()'ed below. Update * the dirty time to prevent enqueue and sync it again. */ - if ((inode->i_state & I_DIRTY) && + if ((inode_state_read(inode) & I_DIRTY) && (wbc->sync_mode =3D=3D WB_SYNC_ALL || wbc->tagged_writepages)) inode->dirtied_when =3D jiffies; =20 @@ -1611,7 +1612,7 @@ static void requeue_inode(struct inode *inode, struct= bdi_writeback *wb, * is odd for clean inodes, it can happen for some * filesystems so handle that gracefully. */ - if (inode->i_state & I_DIRTY_ALL) + if (inode_state_read(inode) & I_DIRTY_ALL) redirty_tail_locked(inode, wb); else inode_cgwb_move_to_attached(inode, wb); @@ -1637,17 +1638,17 @@ static void requeue_inode(struct inode *inode, stru= ct bdi_writeback *wb, */ redirty_tail_locked(inode, wb); } - } else if (inode->i_state & I_DIRTY) { + } else if (inode_state_read(inode) & I_DIRTY) { /* * Filesystems can dirty the inode during writeback operations, * such as delayed allocation during submission or metadata * updates after data IO completion. */ redirty_tail_locked(inode, wb); - } else if (inode->i_state & I_DIRTY_TIME) { + } else if (inode_state_read(inode) & I_DIRTY_TIME) { inode->dirtied_when =3D jiffies; inode_io_list_move_locked(inode, wb, &wb->b_dirty_time); - inode->i_state &=3D ~I_SYNC_QUEUED; + inode_state_del(inode, I_SYNC_QUEUED); } else { /* The inode is clean. Remove from writeback lists. */ inode_cgwb_move_to_attached(inode, wb); @@ -1673,7 +1674,7 @@ __writeback_single_inode(struct inode *inode, struct = writeback_control *wbc) unsigned dirty; int ret; =20 - WARN_ON(!(inode->i_state & I_SYNC)); + WARN_ON(!(inode_state_read_unstable(inode) & I_SYNC)); =20 trace_writeback_single_inode_start(inode, wbc, nr_to_write); =20 @@ -1697,7 +1698,7 @@ __writeback_single_inode(struct inode *inode, struct = writeback_control *wbc) * mark_inode_dirty_sync() to notify the filesystem about it and to * change I_DIRTY_TIME into I_DIRTY_SYNC. */ - if ((inode->i_state & I_DIRTY_TIME) && + if ((inode_state_read_unstable(inode) & I_DIRTY_TIME) && (wbc->sync_mode =3D=3D WB_SYNC_ALL || time_after(jiffies, inode->dirtied_time_when + dirtytime_expire_interval * HZ))) { @@ -1712,8 +1713,8 @@ __writeback_single_inode(struct inode *inode, struct = writeback_control *wbc) * after handling timestamp expiration, as that may dirty the inode too. */ spin_lock(&inode->i_lock); - dirty =3D inode->i_state & I_DIRTY; - inode->i_state &=3D ~dirty; + dirty =3D inode_state_read(inode) & I_DIRTY; + inode_state_del(inode, dirty); =20 /* * Paired with smp_mb() in __mark_inode_dirty(). This allows @@ -1729,10 +1730,10 @@ __writeback_single_inode(struct inode *inode, struc= t writeback_control *wbc) smp_mb(); =20 if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) - inode->i_state |=3D I_DIRTY_PAGES; - else if (unlikely(inode->i_state & I_PINNING_NETFS_WB)) { - if (!(inode->i_state & I_DIRTY_PAGES)) { - inode->i_state &=3D ~I_PINNING_NETFS_WB; + inode_state_add(inode, I_DIRTY_PAGES); + else if (unlikely(inode_state_read(inode) & I_PINNING_NETFS_WB)) { + if (!(inode_state_read(inode) & I_DIRTY_PAGES)) { + inode_state_del(inode, I_PINNING_NETFS_WB); wbc->unpinned_netfs_wb =3D true; dirty |=3D I_PINNING_NETFS_WB; /* Cause write_inode */ } @@ -1768,11 +1769,11 @@ static int writeback_single_inode(struct inode *ino= de, =20 spin_lock(&inode->i_lock); if (!icount_read(inode)) - WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING))); + WARN_ON(!(inode_state_read(inode) & (I_WILL_FREE|I_FREEING))); else - WARN_ON(inode->i_state & I_WILL_FREE); + WARN_ON(inode_state_read(inode) & I_WILL_FREE); =20 - if (inode->i_state & I_SYNC) { + if (inode_state_read(inode) & I_SYNC) { /* * Writeback is already running on the inode. For WB_SYNC_NONE, * that's enough and we can just return. For WB_SYNC_ALL, we @@ -1783,7 +1784,7 @@ static int writeback_single_inode(struct inode *inode, goto out; inode_wait_for_writeback(inode); } - WARN_ON(inode->i_state & I_SYNC); + WARN_ON(inode_state_read(inode) & I_SYNC); /* * If the inode is already fully clean, then there's nothing to do. * @@ -1791,11 +1792,11 @@ static int writeback_single_inode(struct inode *ino= de, * still under writeback, e.g. due to prior WB_SYNC_NONE writeback. If * there are any such pages, we'll need to wait for them. */ - if (!(inode->i_state & I_DIRTY_ALL) && + if (!(inode_state_read(inode) & I_DIRTY_ALL) && (wbc->sync_mode !=3D WB_SYNC_ALL || !mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK))) goto out; - inode->i_state |=3D I_SYNC; + inode_state_add(inode, I_SYNC); wbc_attach_and_unlock_inode(wbc, inode); =20 ret =3D __writeback_single_inode(inode, wbc); @@ -1808,18 +1809,18 @@ static int writeback_single_inode(struct inode *ino= de, * If the inode is freeing, its i_io_list shoudn't be updated * as it can be finally deleted at this moment. */ - if (!(inode->i_state & I_FREEING)) { + if (!(inode_state_read(inode) & I_FREEING)) { /* * If the inode is now fully clean, then it can be safely * removed from its writeback list (if any). Otherwise the * flusher threads are responsible for the writeback lists. */ - if (!(inode->i_state & I_DIRTY_ALL)) + if (!(inode_state_read(inode) & I_DIRTY_ALL)) inode_cgwb_move_to_attached(inode, wb); - else if (!(inode->i_state & I_SYNC_QUEUED)) { - if ((inode->i_state & I_DIRTY)) + else if (!(inode_state_read(inode) & I_SYNC_QUEUED)) { + if ((inode_state_read(inode) & I_DIRTY)) redirty_tail_locked(inode, wb); - else if (inode->i_state & I_DIRTY_TIME) { + else if (inode_state_read(inode) & I_DIRTY_TIME) { inode->dirtied_when =3D jiffies; inode_io_list_move_locked(inode, wb, @@ -1928,12 +1929,12 @@ static long writeback_sb_inodes(struct super_block = *sb, * kind writeout is handled by the freer. */ spin_lock(&inode->i_lock); - if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { + if (inode_state_read(inode) & (I_NEW | I_FREEING | I_WILL_FREE)) { redirty_tail_locked(inode, wb); spin_unlock(&inode->i_lock); continue; } - if ((inode->i_state & I_SYNC) && wbc.sync_mode !=3D WB_SYNC_ALL) { + if ((inode_state_read(inode) & I_SYNC) && wbc.sync_mode !=3D WB_SYNC_ALL= ) { /* * If this inode is locked for writeback and we are not * doing writeback-for-data-integrity, move it to @@ -1955,14 +1956,14 @@ static long writeback_sb_inodes(struct super_block = *sb, * are doing WB_SYNC_NONE writeback. So this catches only the * WB_SYNC_ALL case. */ - if (inode->i_state & I_SYNC) { + if (inode_state_read(inode) & I_SYNC) { /* Wait for I_SYNC. This function drops i_lock... */ inode_sleep_on_writeback(inode); /* Inode may be gone, start again */ spin_lock(&wb->list_lock); continue; } - inode->i_state |=3D I_SYNC; + inode_state_add(inode, I_SYNC); wbc_attach_and_unlock_inode(&wbc, inode); =20 write_chunk =3D writeback_chunk_size(wb, work); @@ -2000,7 +2001,7 @@ static long writeback_sb_inodes(struct super_block *s= b, */ tmp_wb =3D inode_to_wb_and_lock_list(inode); spin_lock(&inode->i_lock); - if (!(inode->i_state & I_DIRTY_ALL)) + if (!(inode_state_read(inode) & I_DIRTY_ALL)) total_wrote++; requeue_inode(inode, tmp_wb, &wbc, dirtied_before); inode_sync_complete(inode); @@ -2506,10 +2507,10 @@ void __mark_inode_dirty(struct inode *inode, int fl= ags) * We tell ->dirty_inode callback that timestamps need to * be updated by setting I_DIRTY_TIME in flags. */ - if (inode->i_state & I_DIRTY_TIME) { + if (inode_state_read_unstable(inode) & I_DIRTY_TIME) { spin_lock(&inode->i_lock); - if (inode->i_state & I_DIRTY_TIME) { - inode->i_state &=3D ~I_DIRTY_TIME; + if (inode_state_read(inode) & I_DIRTY_TIME) { + inode_state_del(inode, I_DIRTY_TIME); flags |=3D I_DIRTY_TIME; } spin_unlock(&inode->i_lock); @@ -2546,16 +2547,16 @@ void __mark_inode_dirty(struct inode *inode, int fl= ags) */ smp_mb(); =20 - if ((inode->i_state & flags) =3D=3D flags) + if ((inode_state_read_unstable(inode) & flags) =3D=3D flags) return; =20 spin_lock(&inode->i_lock); - if ((inode->i_state & flags) !=3D flags) { - const int was_dirty =3D inode->i_state & I_DIRTY; + if ((inode_state_read(inode) & flags) !=3D flags) { + const int was_dirty =3D inode_state_read(inode) & I_DIRTY; =20 inode_attach_wb(inode, NULL); =20 - inode->i_state |=3D flags; + inode_state_add(inode, flags); =20 /* * Grab inode's wb early because it requires dropping i_lock and we @@ -2574,7 +2575,7 @@ void __mark_inode_dirty(struct inode *inode, int flag= s) * the inode it will place it on the appropriate superblock * list, based upon its state. */ - if (inode->i_state & I_SYNC_QUEUED) + if (inode_state_read(inode) & I_SYNC_QUEUED) goto out_unlock; =20 /* @@ -2585,7 +2586,7 @@ void __mark_inode_dirty(struct inode *inode, int flag= s) if (inode_unhashed(inode)) goto out_unlock; } - if (inode->i_state & I_FREEING) + if (inode_state_read(inode) & I_FREEING) goto out_unlock; =20 /* @@ -2600,7 +2601,7 @@ void __mark_inode_dirty(struct inode *inode, int flag= s) if (dirtytime) inode->dirtied_time_when =3D jiffies; =20 - if (inode->i_state & I_DIRTY) + if (inode_state_read(inode) & I_DIRTY) dirty_list =3D &wb->b_dirty; else dirty_list =3D &wb->b_dirty_time; @@ -2696,7 +2697,7 @@ static void wait_sb_inodes(struct super_block *sb) spin_unlock_irq(&sb->s_inode_wblist_lock); =20 spin_lock(&inode->i_lock); - if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) { + if (inode_state_read(inode) & (I_FREEING|I_WILL_FREE|I_NEW)) { spin_unlock(&inode->i_lock); =20 spin_lock_irq(&sb->s_inode_wblist_lock); diff --git a/fs/inode.c b/fs/inode.c index e8c712211822..af9b7cf784d2 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -233,7 +233,7 @@ int inode_init_always_gfp(struct super_block *sb, struc= t inode *inode, gfp_t gfp inode->i_sb =3D sb; inode->i_blkbits =3D sb->s_blocksize_bits; inode->i_flags =3D 0; - inode->i_state =3D 0; + inode_state_set_unchecked(inode, 0); atomic64_set(&inode->i_sequence, 0); atomic_set(&inode->i_count, 1); inode->i_op =3D &empty_iops; @@ -471,7 +471,7 @@ EXPORT_SYMBOL(set_nlink); void inc_nlink(struct inode *inode) { if (unlikely(inode->i_nlink =3D=3D 0)) { - WARN_ON(!(inode->i_state & I_LINKABLE)); + WARN_ON(!(inode_state_read_unstable(inode) & I_LINKABLE)); atomic_long_dec(&inode->i_sb->s_remove_count); } =20 @@ -532,7 +532,7 @@ EXPORT_SYMBOL(ihold); =20 static void __inode_add_lru(struct inode *inode, bool rotate) { - if (inode->i_state & (I_DIRTY_ALL | I_SYNC | I_FREEING | I_WILL_FREE)) + if (inode_state_read(inode) & (I_DIRTY_ALL | I_SYNC | I_FREEING | I_WILL_= FREE)) return; if (icount_read(inode)) return; @@ -544,7 +544,7 @@ static void __inode_add_lru(struct inode *inode, bool r= otate) if (list_lru_add_obj(&inode->i_sb->s_inode_lru, &inode->i_lru)) this_cpu_inc(nr_unused); else if (rotate) - inode->i_state |=3D I_REFERENCED; + inode_state_add(inode, I_REFERENCED); } =20 struct wait_queue_head *inode_bit_waitqueue(struct wait_bit_queue_entry *w= qe, @@ -577,15 +577,15 @@ static void inode_lru_list_del(struct inode *inode) static void inode_pin_lru_isolating(struct inode *inode) { lockdep_assert_held(&inode->i_lock); - WARN_ON(inode->i_state & (I_LRU_ISOLATING | I_FREEING | I_WILL_FREE)); - inode->i_state |=3D I_LRU_ISOLATING; + WARN_ON(inode_state_read(inode) & (I_LRU_ISOLATING | I_FREEING | I_WILL_F= REE)); + inode_state_add(inode, I_LRU_ISOLATING); } =20 static void inode_unpin_lru_isolating(struct inode *inode) { spin_lock(&inode->i_lock); - WARN_ON(!(inode->i_state & I_LRU_ISOLATING)); - inode->i_state &=3D ~I_LRU_ISOLATING; + WARN_ON(!(inode_state_read(inode) & I_LRU_ISOLATING)); + inode_state_del(inode, I_LRU_ISOLATING); /* Called with inode->i_lock which ensures memory ordering. */ inode_wake_up_bit(inode, __I_LRU_ISOLATING); spin_unlock(&inode->i_lock); @@ -597,7 +597,7 @@ static void inode_wait_for_lru_isolating(struct inode *= inode) struct wait_queue_head *wq_head; =20 lockdep_assert_held(&inode->i_lock); - if (!(inode->i_state & I_LRU_ISOLATING)) + if (!(inode_state_read(inode) & I_LRU_ISOLATING)) return; =20 wq_head =3D inode_bit_waitqueue(&wqe, inode, __I_LRU_ISOLATING); @@ -607,14 +607,14 @@ static void inode_wait_for_lru_isolating(struct inode= *inode) * Checking I_LRU_ISOLATING with inode->i_lock guarantees * memory ordering. */ - if (!(inode->i_state & I_LRU_ISOLATING)) + if (!(inode_state_read(inode) & I_LRU_ISOLATING)) break; spin_unlock(&inode->i_lock); schedule(); spin_lock(&inode->i_lock); } finish_wait(wq_head, &wqe.wq_entry); - WARN_ON(inode->i_state & I_LRU_ISOLATING); + WARN_ON(inode_state_read(inode) & I_LRU_ISOLATING); } =20 /** @@ -761,11 +761,11 @@ void clear_inode(struct inode *inode) */ xa_unlock_irq(&inode->i_data.i_pages); BUG_ON(!list_empty(&inode->i_data.i_private_list)); - BUG_ON(!(inode->i_state & I_FREEING)); - BUG_ON(inode->i_state & I_CLEAR); + BUG_ON(!(inode_state_read_unstable(inode) & I_FREEING)); + BUG_ON(inode_state_read_unstable(inode) & I_CLEAR); BUG_ON(!list_empty(&inode->i_wb_list)); /* don't need i_lock here, no concurrent mods to i_state */ - inode->i_state =3D I_FREEING | I_CLEAR; + inode_state_set_unchecked(inode, I_FREEING | I_CLEAR); } EXPORT_SYMBOL(clear_inode); =20 @@ -786,7 +786,7 @@ static void evict(struct inode *inode) { const struct super_operations *op =3D inode->i_sb->s_op; =20 - BUG_ON(!(inode->i_state & I_FREEING)); + BUG_ON(!(inode_state_read_unstable(inode) & I_FREEING)); BUG_ON(!list_empty(&inode->i_lru)); =20 if (!list_empty(&inode->i_io_list)) @@ -829,7 +829,7 @@ static void evict(struct inode *inode) * This also means we don't need any fences for the call below. */ inode_wake_up_bit(inode, __I_NEW); - BUG_ON(inode->i_state !=3D (I_FREEING | I_CLEAR)); + BUG_ON(inode_state_read_unstable(inode) !=3D (I_FREEING | I_CLEAR)); =20 destroy_inode(inode); } @@ -879,12 +879,12 @@ void evict_inodes(struct super_block *sb) spin_unlock(&inode->i_lock); continue; } - if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { + if (inode_state_read(inode) & (I_NEW | I_FREEING | I_WILL_FREE)) { spin_unlock(&inode->i_lock); continue; } =20 - inode->i_state |=3D I_FREEING; + inode_state_add(inode, I_FREEING); inode_lru_list_del(inode); spin_unlock(&inode->i_lock); list_add(&inode->i_lru, &dispose); @@ -938,7 +938,7 @@ static enum lru_status inode_lru_isolate(struct list_he= ad *item, * sync, or the last page cache deletion will requeue them. */ if (icount_read(inode) || - (inode->i_state & ~I_REFERENCED) || + (inode_state_read(inode) & ~I_REFERENCED) || !mapping_shrinkable(&inode->i_data)) { list_lru_isolate(lru, &inode->i_lru); spin_unlock(&inode->i_lock); @@ -947,8 +947,8 @@ static enum lru_status inode_lru_isolate(struct list_he= ad *item, } =20 /* Recently referenced inodes get one more pass */ - if (inode->i_state & I_REFERENCED) { - inode->i_state &=3D ~I_REFERENCED; + if (inode_state_read(inode) & I_REFERENCED) { + inode_state_del(inode, I_REFERENCED); spin_unlock(&inode->i_lock); return LRU_ROTATE; } @@ -975,8 +975,8 @@ static enum lru_status inode_lru_isolate(struct list_he= ad *item, return LRU_RETRY; } =20 - WARN_ON(inode->i_state & I_NEW); - inode->i_state |=3D I_FREEING; + WARN_ON(inode_state_read(inode) & I_NEW); + inode_state_add(inode, I_FREEING); list_lru_isolate_move(lru, &inode->i_lru, freeable); spin_unlock(&inode->i_lock); =20 @@ -1025,11 +1025,11 @@ static struct inode *find_inode(struct super_block = *sb, if (!test(inode, data)) continue; spin_lock(&inode->i_lock); - if (inode->i_state & (I_FREEING|I_WILL_FREE)) { + if (inode_state_read(inode) & (I_FREEING|I_WILL_FREE)) { __wait_on_freeing_inode(inode, is_inode_hash_locked); goto repeat; } - if (unlikely(inode->i_state & I_CREATING)) { + if (unlikely(inode_state_read(inode) & I_CREATING)) { spin_unlock(&inode->i_lock); rcu_read_unlock(); return ERR_PTR(-ESTALE); @@ -1066,11 +1066,11 @@ static struct inode *find_inode_fast(struct super_b= lock *sb, if (inode->i_sb !=3D sb) continue; spin_lock(&inode->i_lock); - if (inode->i_state & (I_FREEING|I_WILL_FREE)) { + if (inode_state_read(inode) & (I_FREEING|I_WILL_FREE)) { __wait_on_freeing_inode(inode, is_inode_hash_locked); goto repeat; } - if (unlikely(inode->i_state & I_CREATING)) { + if (unlikely(inode_state_read(inode) & I_CREATING)) { spin_unlock(&inode->i_lock); rcu_read_unlock(); return ERR_PTR(-ESTALE); @@ -1180,8 +1180,8 @@ void unlock_new_inode(struct inode *inode) { lockdep_annotate_inode_mutex_key(inode); spin_lock(&inode->i_lock); - WARN_ON(!(inode->i_state & I_NEW)); - inode->i_state &=3D ~I_NEW & ~I_CREATING; + WARN_ON(!(inode_state_read(inode) & I_NEW)); + inode_state_del(inode, I_NEW | I_CREATING); /* * Pairs with the barrier in prepare_to_wait_event() to make sure * ___wait_var_event() either sees the bit cleared or @@ -1197,8 +1197,8 @@ void discard_new_inode(struct inode *inode) { lockdep_annotate_inode_mutex_key(inode); spin_lock(&inode->i_lock); - WARN_ON(!(inode->i_state & I_NEW)); - inode->i_state &=3D ~I_NEW; + WARN_ON(!(inode_state_read(inode) & I_NEW)); + inode_state_del(inode, I_NEW); /* * Pairs with the barrier in prepare_to_wait_event() to make sure * ___wait_var_event() either sees the bit cleared or @@ -1308,7 +1308,7 @@ struct inode *inode_insert5(struct inode *inode, unsi= gned long hashval, * caller is responsible for filling in the contents */ spin_lock(&inode->i_lock); - inode->i_state |=3D I_NEW; + inode_state_add(inode, I_NEW); hlist_add_head_rcu(&inode->i_hash, head); spin_unlock(&inode->i_lock); =20 @@ -1445,7 +1445,7 @@ struct inode *iget_locked(struct super_block *sb, uns= igned long ino) if (!old) { inode->i_ino =3D ino; spin_lock(&inode->i_lock); - inode->i_state =3D I_NEW; + inode_state_add(inode, I_NEW); hlist_add_head_rcu(&inode->i_hash, head); spin_unlock(&inode->i_lock); spin_unlock(&inode_hash_lock); @@ -1538,7 +1538,7 @@ EXPORT_SYMBOL(iunique); struct inode *igrab(struct inode *inode) { spin_lock(&inode->i_lock); - if (!(inode->i_state & (I_FREEING|I_WILL_FREE))) { + if (!(inode_state_read(inode) & (I_FREEING|I_WILL_FREE))) { __iget(inode); spin_unlock(&inode->i_lock); } else { @@ -1728,7 +1728,7 @@ struct inode *find_inode_rcu(struct super_block *sb, = unsigned long hashval, =20 hlist_for_each_entry_rcu(inode, head, i_hash) { if (inode->i_sb =3D=3D sb && - !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE)) && + !(inode_state_read_unstable(inode) & (I_FREEING | I_WILL_FREE)) && test(inode, data)) return inode; } @@ -1767,7 +1767,7 @@ struct inode *find_inode_by_ino_rcu(struct super_bloc= k *sb, hlist_for_each_entry_rcu(inode, head, i_hash) { if (inode->i_ino =3D=3D ino && inode->i_sb =3D=3D sb && - !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE))) + !(inode_state_read_unstable(inode) & (I_FREEING | I_WILL_FREE))) return inode; } return NULL; @@ -1789,7 +1789,7 @@ int insert_inode_locked(struct inode *inode) if (old->i_sb !=3D sb) continue; spin_lock(&old->i_lock); - if (old->i_state & (I_FREEING|I_WILL_FREE)) { + if (inode_state_read(old) & (I_FREEING|I_WILL_FREE)) { spin_unlock(&old->i_lock); continue; } @@ -1797,13 +1797,13 @@ int insert_inode_locked(struct inode *inode) } if (likely(!old)) { spin_lock(&inode->i_lock); - inode->i_state |=3D I_NEW | I_CREATING; + inode_state_add(inode, I_NEW | I_CREATING); hlist_add_head_rcu(&inode->i_hash, head); spin_unlock(&inode->i_lock); spin_unlock(&inode_hash_lock); return 0; } - if (unlikely(old->i_state & I_CREATING)) { + if (unlikely(inode_state_read(old) & I_CREATING)) { spin_unlock(&old->i_lock); spin_unlock(&inode_hash_lock); return -EBUSY; @@ -1826,7 +1826,7 @@ int insert_inode_locked4(struct inode *inode, unsigne= d long hashval, { struct inode *old; =20 - inode->i_state |=3D I_CREATING; + inode_state_add_unchecked(inode, I_CREATING); old =3D inode_insert5(inode, hashval, test, NULL, data); =20 if (old !=3D inode) { @@ -1858,10 +1858,9 @@ static void iput_final(struct inode *inode) { struct super_block *sb =3D inode->i_sb; const struct super_operations *op =3D inode->i_sb->s_op; - unsigned long state; int drop; =20 - WARN_ON(inode->i_state & I_NEW); + WARN_ON(inode_state_read(inode) & I_NEW); =20 if (op->drop_inode) drop =3D op->drop_inode(inode); @@ -1869,27 +1868,25 @@ static void iput_final(struct inode *inode) drop =3D generic_drop_inode(inode); =20 if (!drop && - !(inode->i_state & I_DONTCACHE) && + !(inode_state_read(inode) & I_DONTCACHE) && (sb->s_flags & SB_ACTIVE)) { __inode_add_lru(inode, true); spin_unlock(&inode->i_lock); return; } =20 - state =3D inode->i_state; if (!drop) { - WRITE_ONCE(inode->i_state, state | I_WILL_FREE); + inode_state_add(inode, I_WILL_FREE); spin_unlock(&inode->i_lock); =20 write_inode_now(inode, 1); =20 spin_lock(&inode->i_lock); - state =3D inode->i_state; - WARN_ON(state & I_NEW); - state &=3D ~I_WILL_FREE; + inode_state_del(inode, I_WILL_FREE); + WARN_ON(inode_state_read(inode) & I_NEW); } =20 - WRITE_ONCE(inode->i_state, state | I_FREEING); + inode_state_add(inode, I_FREEING); if (!list_empty(&inode->i_lru)) inode_lru_list_del(inode); spin_unlock(&inode->i_lock); @@ -1913,7 +1910,7 @@ void iput(struct inode *inode) =20 retry: lockdep_assert_not_held(&inode->i_lock); - VFS_BUG_ON_INODE(inode->i_state & I_CLEAR, inode); + VFS_BUG_ON_INODE(inode_state_read_unstable(inode) & I_CLEAR, inode); /* * Note this assert is technically racy as if the count is bogusly * equal to one, then two CPUs racing to further drop it can both @@ -1924,14 +1921,14 @@ void iput(struct inode *inode) if (atomic_add_unless(&inode->i_count, -1, 1)) return; =20 - if ((inode->i_state & I_DIRTY_TIME) && inode->i_nlink) { + if ((inode_state_read_unstable(inode) & I_DIRTY_TIME) && inode->i_nlink) { trace_writeback_lazytime_iput(inode); mark_inode_dirty_sync(inode); goto retry; } =20 spin_lock(&inode->i_lock); - if (unlikely((inode->i_state & I_DIRTY_TIME) && inode->i_nlink)) { + if (unlikely((inode_state_read(inode) & I_DIRTY_TIME) && inode->i_nlink))= { spin_unlock(&inode->i_lock); goto retry; } @@ -2946,7 +2943,7 @@ void dump_inode(struct inode *inode, const char *reas= on) pr_warn("%s encountered for inode %px\n" "fs %s mode %ho opflags %hx flags %u state %x\n", reason, inode, sb->s_type->name, inode->i_mode, inode->i_opflags, - inode->i_flags, inode->i_state); + inode->i_flags, inode_state_read_unstable(inode)); } =20 EXPORT_SYMBOL(dump_inode); diff --git a/fs/libfs.c b/fs/libfs.c index ce8c496a6940..469ca3314889 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1542,9 +1542,9 @@ int __generic_file_fsync(struct file *file, loff_t st= art, loff_t end, =20 inode_lock(inode); ret =3D sync_mapping_buffers(inode->i_mapping); - if (!(inode->i_state & I_DIRTY_ALL)) + if (!(inode_state_read_unstable(inode) & I_DIRTY_ALL)) goto out; - if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) + if (datasync && !(inode_state_read_unstable(inode) & I_DIRTY_DATASYNC)) goto out; =20 err =3D sync_inode_metadata(inode, 1); @@ -1664,7 +1664,7 @@ struct inode *alloc_anon_inode(struct super_block *s) * list because mark_inode_dirty() will think * that it already _is_ on the dirty list. */ - inode->i_state =3D I_DIRTY; + inode_state_set_unchecked(inode, I_DIRTY); /* * Historically anonymous inodes don't have a type at all and * userspace has come to rely on this. diff --git a/fs/namei.c b/fs/namei.c index cd43ff89fbaa..b0742d7376d5 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3948,7 +3948,7 @@ int vfs_tmpfile(struct mnt_idmap *idmap, inode =3D file_inode(file); if (!(open_flag & O_EXCL)) { spin_lock(&inode->i_lock); - inode->i_state |=3D I_LINKABLE; + inode_state_add(inode, I_LINKABLE); spin_unlock(&inode->i_lock); } security_inode_post_create_tmpfile(idmap, inode); @@ -4844,7 +4844,7 @@ int vfs_link(struct dentry *old_dentry, struct mnt_id= map *idmap, =20 inode_lock(inode); /* Make sure we don't allow creating hardlink to an unlinked file */ - if (inode->i_nlink =3D=3D 0 && !(inode->i_state & I_LINKABLE)) + if (inode->i_nlink =3D=3D 0 && !(inode_state_read_unstable(inode) & I_LIN= KABLE)) error =3D -ENOENT; else if (max_links && inode->i_nlink >=3D max_links) error =3D -EMLINK; @@ -4854,9 +4854,9 @@ int vfs_link(struct dentry *old_dentry, struct mnt_id= map *idmap, error =3D dir->i_op->link(old_dentry, dir, new_dentry); } =20 - if (!error && (inode->i_state & I_LINKABLE)) { + if (!error && (inode_state_read_unstable(inode) & I_LINKABLE)) { spin_lock(&inode->i_lock); - inode->i_state &=3D ~I_LINKABLE; + inode_state_del(inode, I_LINKABLE); spin_unlock(&inode->i_lock); } inode_unlock(inode); diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 46bfc543f946..8e504b40fb39 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -52,7 +52,7 @@ static void fsnotify_unmount_inodes(struct super_block *s= b) * the inode cannot have any associated watches. */ spin_lock(&inode->i_lock); - if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) { + if (inode_state_read(inode) & (I_FREEING|I_WILL_FREE|I_NEW)) { spin_unlock(&inode->i_lock); continue; } diff --git a/fs/pipe.c b/fs/pipe.c index 731622d0738d..81ad740af963 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -906,7 +906,7 @@ static struct inode * get_pipe_inode(void) * list because "mark_inode_dirty()" will think * that it already _is_ on the dirty list. */ - inode->i_state =3D I_DIRTY; + inode_state_set_unchecked(inode, I_DIRTY); inode->i_mode =3D S_IFIFO | S_IRUSR | S_IWUSR; inode->i_uid =3D current_fsuid(); inode->i_gid =3D current_fsgid(); diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index df4a9b348769..beb3d82a2915 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1030,7 +1030,7 @@ static int add_dquot_ref(struct super_block *sb, int = type) spin_lock(&sb->s_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { spin_lock(&inode->i_lock); - if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || + if ((inode_state_read(inode) & (I_FREEING|I_WILL_FREE|I_NEW)) || !atomic_read(&inode->i_writecount) || !dqinit_needed(inode, type)) { spin_unlock(&inode->i_lock); diff --git a/fs/sync.c b/fs/sync.c index 2955cd4c77a3..def938b28c2a 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -182,7 +182,7 @@ int vfs_fsync_range(struct file *file, loff_t start, lo= ff_t end, int datasync) =20 if (!file->f_op->fsync) return -EINVAL; - if (!datasync && (inode->i_state & I_DIRTY_TIME)) + if (!datasync && (inode_state_read_unstable(inode) & I_DIRTY_TIME)) mark_inode_dirty_sync(inode); return file->f_op->fsync(file, start, end, datasync); } diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index e721148c95d0..4f461eb4232a 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -289,10 +289,11 @@ unlocked_inode_to_wb_begin(struct inode *inode, struc= t wb_lock_cookie *cookie) rcu_read_lock(); =20 /* - * Paired with store_release in inode_switch_wbs_work_fn() and + * Paired with a release fence in inode_do_switch_wbs() and * ensures that we see the new wb if we see cleared I_WB_SWITCH. */ - cookie->locked =3D smp_load_acquire(&inode->i_state) & I_WB_SWITCH; + cookie->locked =3D inode_state_read_unstable(inode) & I_WB_SWITCH; + smp_rmb(); =20 if (unlikely(cookie->locked)) xa_lock_irqsave(&inode->i_mapping->i_pages, cookie->flags); diff --git a/include/linux/fs.h b/include/linux/fs.h index c4fd010cf5bf..ed482e5d14a6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -756,7 +756,7 @@ enum inode_state_bits { /* reserved wait address bit 3 */ }; =20 -enum inode_state_flags_t { +enum inode_state_flags_enum { I_NEW =3D (1U << __I_NEW), I_SYNC =3D (1U << __I_SYNC), I_LRU_ISOLATING =3D (1U << __I_LRU_ISOLATING), @@ -840,7 +840,7 @@ struct inode { #endif =20 /* Misc */ - enum inode_state_flags_t i_state; + enum inode_state_flags_enum i_state; /* 32-bit hole */ struct rw_semaphore i_rwsem; =20 @@ -899,6 +899,55 @@ struct inode { void *i_private; /* fs or device private pointer */ } __randomize_layout; =20 + +/* + * i_state handling + * + * We hide all of it behind helpers so that we can validate consumers. + */ +static inline enum inode_state_flags_enum inode_state_read(struct inode *i= node) +{ + lockdep_assert_held(&inode->i_lock); + return inode->i_state; +} + +static inline enum inode_state_flags_enum inode_state_read_unstable(struct= inode *inode) +{ + return READ_ONCE(inode->i_state); +} + +static inline void inode_state_add(struct inode *inode, + enum inode_state_flags_enum newflags) +{ + lockdep_assert_held(&inode->i_lock); + WRITE_ONCE(inode->i_state, inode->i_state | newflags); +} + +static inline void inode_state_add_unchecked(struct inode *inode, + enum inode_state_flags_enum newflags) +{ + WRITE_ONCE(inode->i_state, inode->i_state | newflags); +} + +static inline void inode_state_del(struct inode *inode, + enum inode_state_flags_enum rmflags) +{ + lockdep_assert_held(&inode->i_lock); + WRITE_ONCE(inode->i_state, inode->i_state & ~rmflags); +} + +static inline void inode_state_del_unchecked(struct inode *inode, + enum inode_state_flags_enum rmflags) +{ + WRITE_ONCE(inode->i_state, inode->i_state & ~rmflags); +} + +static inline void inode_state_set_unchecked(struct inode *inode, + enum inode_state_flags_enum newflags) +{ + WRITE_ONCE(inode->i_state, newflags); +} + static inline void inode_set_cached_link(struct inode *inode, char *link, = int linklen) { VFS_WARN_ON_INODE(strlen(link) !=3D linklen, inode); @@ -2627,7 +2676,7 @@ static inline int icount_read(const struct inode *ino= de) */ static inline bool inode_is_dirtytime_only(struct inode *inode) { - return (inode->i_state & (I_DIRTY_TIME | I_NEW | + return (inode_state_read_unstable(inode) & (I_DIRTY_TIME | I_NEW | I_FREEING | I_WILL_FREE)) =3D=3D I_DIRTY_TIME; } =20 diff --git a/include/linux/writeback.h b/include/linux/writeback.h index a2848d731a46..c24b581ed61f 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -193,7 +193,7 @@ void inode_io_list_del(struct inode *inode); static inline void wait_on_inode(struct inode *inode) { wait_var_event(inode_state_wait_address(inode, __I_NEW), - !(READ_ONCE(inode->i_state) & I_NEW)); + !(inode_state_read_unstable(inode) & I_NEW)); } =20 #ifdef CONFIG_CGROUP_WRITEBACK @@ -234,7 +234,7 @@ static inline void inode_attach_wb(struct inode *inode,= struct folio *folio) static inline void inode_detach_wb(struct inode *inode) { if (inode->i_wb) { - WARN_ON_ONCE(!(inode->i_state & I_CLEAR)); + WARN_ON_ONCE(!(inode_state_read_unstable(inode) & I_CLEAR)); wb_put(inode->i_wb); inode->i_wb =3D NULL; } diff --git a/include/trace/events/writeback.h b/include/trace/events/writeb= ack.h index 1e23919c0da9..a6efa3ad37a9 100644 --- a/include/trace/events/writeback.h +++ b/include/trace/events/writeback.h @@ -120,7 +120,7 @@ DECLARE_EVENT_CLASS(writeback_dirty_inode_template, /* may be called for files on pseudo FSes w/ unregistered bdi */ strscpy_pad(__entry->name, bdi_dev_name(bdi), 32); __entry->ino =3D inode->i_ino; - __entry->state =3D inode->i_state; + __entry->state =3D inode_state_read_unstable(inode); __entry->flags =3D flags; ), =20 @@ -719,7 +719,7 @@ TRACE_EVENT(writeback_sb_inodes_requeue, strscpy_pad(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32); __entry->ino =3D inode->i_ino; - __entry->state =3D inode->i_state; + __entry->state =3D inode_state_read_unstable(inode); __entry->dirtied_when =3D inode->dirtied_when; __entry->cgroup_ino =3D __trace_wb_assign_cgroup(inode_to_wb(inode)); ), @@ -758,7 +758,7 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template, strscpy_pad(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32); __entry->ino =3D inode->i_ino; - __entry->state =3D inode->i_state; + __entry->state =3D inode_state_read_unstable(inode); __entry->dirtied_when =3D inode->dirtied_when; __entry->writeback_index =3D inode->i_mapping->writeback_index; __entry->nr_to_write =3D nr_to_write; @@ -810,7 +810,7 @@ DECLARE_EVENT_CLASS(writeback_inode_template, TP_fast_assign( __entry->dev =3D inode->i_sb->s_dev; __entry->ino =3D inode->i_ino; - __entry->state =3D inode->i_state; + __entry->state =3D inode_state_read_unstable(inode); __entry->mode =3D inode->i_mode; __entry->dirtied_when =3D inode->dirtied_when; ), diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 783904d8c5ef..0636abae1c5c 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -72,7 +72,7 @@ static void collect_wb_stats(struct wb_stats *stats, list_for_each_entry(inode, &wb->b_more_io, i_io_list) stats->nr_more_io++; list_for_each_entry(inode, &wb->b_dirty_time, i_io_list) - if (inode->i_state & I_DIRTY_TIME) + if (inode_state_read_unstable(inode) & I_DIRTY_TIME) stats->nr_dirty_time++; spin_unlock(&wb->list_lock); =20 diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 0bade2c5aa1d..d4d72f406d58 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -1296,7 +1296,7 @@ static void hook_sb_delete(struct super_block *const = sb) * second call to iput() for the same Landlock object. Also * checks I_NEW because such inode cannot be tied to an object. */ - if (inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW)) { + if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) { spin_unlock(&inode->i_lock); continue; } --=20 2.43.0 From nobody Thu Oct 2 20:38:43 2025 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 418D8241667; Thu, 11 Sep 2025 04:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757566584; cv=none; b=EieDSvYHc2zncc7OCn54ogsIBfmeGLsl9ID9yVgy7PSA+DUPRwFhnO6UZlgxGQ/kWryl0EilLb4OoYFQzjijgwhnKtDmLmeYj2s/JfsPygXBeyQu7BupqUp0vt66a9gbQvIl0lMrKigW14M7xho/05oNfEof9i15xCvdQkXIHdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757566584; c=relaxed/simple; bh=JO5giDKBppn8ILM5ZWrjc0lbAskJpJIP9qCd4xFFN7c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n61HNLCmBL/YaupUXMazLsZqSxKal6xCRJZ2Qkn+nEFmUuGwAClKcQwHK1ao0Be907n4s47a5Ddt972cqvyxJQ3N4rJXB8YqKMTUckxLCIRdGjsCWQwjS1mLZR/96lzChmIeKpu3OZBPg2cO2saFgd4Wi3NV0C9EwgMwzWmuCkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XpoWkJsS; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XpoWkJsS" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-45b9a856dc2so1396285e9.0; Wed, 10 Sep 2025 21:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757566578; x=1758171378; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rjq2LJVJwKrWUziF/OxOScoVsYSkB66pSBu/byH8I3U=; b=XpoWkJsSHRCTd/ntBhlR2TGzfWVe2rVmygJSpqlbhPLv6PMEERG9HlvbgPJTs7d2jr w0plYbASpSGD1764QxvPXM4D2zkblGEprYR45xSt6B18NOIjS5/YBRFkZPt6o5y34DFp DHKvnSFD9++WTupNscCJUbBBIqOe6VEOym1Z4UIHzwam+DbAEfryXMo79XKoJzIZTd7K gUFhrhpGPq6AX/OdYywA+aCZ7WKOU3PSoYFaGEr1JKJyXALBrF77Tet8+aYK2eWzcqG4 pQu8Z+d6VeM/ggCzwoP+LupHb7UDmFNrET0pI6yh5/JYiljQkwOSO/DYGjxsMhLhmH3j pkuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757566578; x=1758171378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rjq2LJVJwKrWUziF/OxOScoVsYSkB66pSBu/byH8I3U=; b=t22pjdlNix9srOXrhhsYGH3EU239rNqMHlubYwkbcc2QmyUf1zIUwtCko5htIvD6xt Q76gh8FlGolZvrBk8U3z8lOnnB6bf0z88d7g7TRovKLT+uFEglu9Q/RBDEHAmJsmA0vU Dfgxlo46nOZCFo0CZp73y33r5x75kGQt+cjohGBES3kSZrunaYx7v8EBY+sxtt+sXujG OCknvgoWTo0lC49xqd3WdRPsTOCBHVFr2xjAZkJiN7QbvNkPRPPzPblXaMrEh2DOhWyj GFv4m0Pd88c2Aju8vED0DqNnww6duQUDDdpLzh4Bur06Vz8mc7BLmt9Vh2HzWnLUyjwT dRbw== X-Forwarded-Encrypted: i=1; AJvYcCVBJAq/i/0zU0wFmZEzLIB1ijrJfPK5paBTbbgawojOW/UTTqtQHJdd0APVfvEur+zuU2QC6GwpyWSQdrMzJg==@vger.kernel.org, AJvYcCVwkZOduoW9G2CMFGVlcWj77aCYRYa8XuXkb9RNx44g7K3bHKOHwTwHCvi5ED3aAqotgPk86owCuSZYNxsy@vger.kernel.org, AJvYcCWI4FVg8s7UQlz7iEM6NOp19tTMzm3yXN7ItRhRnXZK7rlN8ubvQxZ2p6cMsPuTI6DwJkVyOrcnQcO10Q==@vger.kernel.org, AJvYcCWNsuJZWv9TE2JhdQWztURduy8nQ6p/BdMaZnIo/RGVdBsiUswE3lnhkBUepwW9cG0G7gzr0LPlLv6WSg==@vger.kernel.org, AJvYcCWbVjKitaNIDMreoIGjdbs3dndAlFlg1b5MOTDd2DLawAXkVt3HACRjq+VsIA74WXm7Uyt5BEP0dgZl@vger.kernel.org X-Gm-Message-State: AOJu0Yy273421dZ2XWaxmDAbpnYRxkeICeVD6+MCXoqoU1qMrY6CVRZ9 ZsI69w8aN7juHtZ1MGUiMgEASQto03vMPepKpm64tVg60qgyxwfuhIiy X-Gm-Gg: ASbGncuUSs6QPq0SxuRFyCbvzpvdE+FpdIs9fNkQp5SkCGADfuL2c5YD1VaQ36vX6Tb 04i1vDfwVhGUjmFHMkyP8jYljdh2111t9XBsZtD7Z2pIDx9BmqbD8SOYSxe9FcNEfq39FFvm9cW WdSIVgevOP2nPKVbWe48Hm48sYz1SgydZ/1uqGpuB6GPeg2sD0s2YIyBTLZTO45KXrrsV7FiOO6 sxH9RuTf+cSx5yUiEl16UqpPoO+2Cb4ctaLEwscq91fQ1uodW3NMBtFgo/++LVXl6ZgvssXN0YZ iDuHYRgZ9vp4/lispUnXBwzTwNbR4Bgsbo7AffHDFK0x8b7SMbFWatbOruigFbgFRXHmsFTpue+ 5qM4+LdLXoTERYOh6wMYc4yUs4GkXvxv/uQl/OpIO X-Google-Smtp-Source: AGHT+IHthNQc/EOPDTuhX9KOz0bcRC4rLwVFnJG9gf4eVDly6EZaTwDP4ODwBYRXG4WQ7J922CNEig== X-Received: by 2002:a05:600c:45d4:b0:45b:9a76:ebea with SMTP id 5b1f17b1804b1-45dddeeee4cmr165080575e9.20.1757566577056; Wed, 10 Sep 2025 21:56:17 -0700 (PDT) Received: from f.. (cst-prg-67-222.cust.vodafone.cz. [46.135.67.222]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607e9e6asm889419f8f.62.2025.09.10.21.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Sep 2025 21:56:16 -0700 (PDT) From: Mateusz Guzik To: brauner@kernel.org Cc: viro@zeniv.linux.org.uk, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, josef@toxicpanda.com, kernel-team@fb.com, amir73il@gmail.com, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, Mateusz Guzik Subject: [PATCH v3 3/4] convert all filesystems to use the new ->i_state accessors Date: Thu, 11 Sep 2025 06:55:56 +0200 Message-ID: <20250911045557.1552002-4-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911045557.1552002-1-mjguzik@gmail.com> References: <20250911045557.1552002-1-mjguzik@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" this will be one patch per fs in the actual submission commits: bcachefs: use the new ->i_state accessors Signed-off-by: Mateusz Guzik 9p: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik affs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik afs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik befs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik bfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik btrfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik ceph: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik coda: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik cramfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik ecryptfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik efs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik erofs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik ext2: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik ext4: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik f2fs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik freevxfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik fuse: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik gfs2: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik hfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik hfsplus: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik hostfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik hpfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik isofs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik jffs2: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik jfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik kernfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik minix: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik netfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik nfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik nfsd: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik nilfs2: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik ntfs3: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik ocfs2: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik omfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik openpromfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik orangefs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik overlayfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik qnx4: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik qnx6: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik romfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik smb: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik squashfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik ubifs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik udf: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik ufs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik xfs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik zonefs: use the new ->i_state accessors Change generated with coccinelle and fixed up by hand as appropriate. Signed-off-by: Mateusz Guzik --- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 2 +- fs/affs/inode.c | 2 +- fs/afs/dynroot.c | 6 +++--- fs/afs/inode.c | 8 ++++---- fs/bcachefs/fs.c | 7 +++---- fs/befs/linuxvfs.c | 2 +- fs/bfs/inode.c | 2 +- fs/btrfs/inode.c | 10 +++++----- fs/ceph/cache.c | 2 +- fs/ceph/crypto.c | 4 ++-- fs/ceph/file.c | 4 ++-- fs/ceph/inode.c | 28 ++++++++++++++-------------- fs/coda/cnode.c | 4 ++-- fs/cramfs/inode.c | 2 +- fs/ecryptfs/inode.c | 6 +++--- fs/efs/inode.c | 2 +- fs/erofs/inode.c | 2 +- fs/ext2/inode.c | 2 +- fs/ext4/inode.c | 10 +++++----- fs/ext4/orphan.c | 4 ++-- fs/f2fs/data.c | 2 +- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 4 ++-- fs/f2fs/super.c | 2 +- fs/freevxfs/vxfs_inode.c | 2 +- fs/fuse/inode.c | 4 ++-- fs/gfs2/file.c | 2 +- fs/gfs2/glops.c | 2 +- fs/gfs2/inode.c | 4 ++-- fs/gfs2/ops_fstype.c | 2 +- fs/hfs/btree.c | 2 +- fs/hfs/inode.c | 2 +- fs/hfsplus/super.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/dir.c | 2 +- fs/hpfs/inode.c | 2 +- fs/isofs/inode.c | 2 +- fs/jffs2/fs.c | 4 ++-- fs/jfs/file.c | 4 ++-- fs/jfs/inode.c | 2 +- fs/jfs/jfs_txnmgr.c | 2 +- fs/kernfs/inode.c | 2 +- fs/minix/inode.c | 2 +- fs/netfs/misc.c | 8 ++++---- fs/netfs/read_single.c | 6 +++--- fs/nfs/inode.c | 2 +- fs/nfs/pnfs.c | 2 +- fs/nfsd/vfs.c | 2 +- fs/nilfs2/cpfile.c | 2 +- fs/nilfs2/dat.c | 2 +- fs/nilfs2/ifile.c | 2 +- fs/nilfs2/inode.c | 10 +++++----- fs/nilfs2/sufile.c | 2 +- fs/ntfs3/inode.c | 2 +- fs/ocfs2/dlmglue.c | 2 +- fs/ocfs2/inode.c | 10 +++++----- fs/omfs/inode.c | 2 +- fs/openpromfs/inode.c | 2 +- fs/orangefs/inode.c | 2 +- fs/orangefs/orangefs-utils.c | 6 +++--- fs/overlayfs/dir.c | 2 +- fs/overlayfs/inode.c | 6 +++--- fs/overlayfs/util.c | 10 +++++----- fs/qnx4/inode.c | 2 +- fs/qnx6/inode.c | 2 +- fs/romfs/super.c | 2 +- fs/smb/client/cifsfs.c | 2 +- fs/smb/client/inode.c | 14 +++++++------- fs/squashfs/inode.c | 2 +- fs/ubifs/file.c | 2 +- fs/ubifs/super.c | 2 +- fs/udf/inode.c | 2 +- fs/ufs/inode.c | 2 +- fs/xfs/scrub/common.c | 2 +- fs/xfs/scrub/inode_repair.c | 2 +- fs/xfs/scrub/parent.c | 2 +- fs/xfs/xfs_bmap_util.c | 2 +- fs/xfs/xfs_health.c | 4 ++-- fs/xfs/xfs_icache.c | 6 +++--- fs/xfs/xfs_inode.c | 6 +++--- fs/xfs/xfs_inode_item.c | 4 ++-- fs/xfs/xfs_iops.c | 2 +- fs/xfs/xfs_reflink.h | 2 +- fs/zonefs/super.c | 4 ++-- 85 files changed, 158 insertions(+), 159 deletions(-) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 399d455d50d6..1af7d6518e19 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -422,7 +422,7 @@ static struct inode *v9fs_qid_iget(struct super_block *= sb, inode =3D iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode, st); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; /* * initialize the inode with the stat info diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 5b5fda617b80..d08a7f5ae4b0 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -112,7 +112,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_bl= ock *sb, inode =3D iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode_dotl, st); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; /* * initialize the inode with the stat info diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 0210df8d3500..6dfe02bac56c 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -29,7 +29,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned = long ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 pr_debug("affs_iget(%lu)\n", inode->i_ino); diff --git a/fs/afs/dynroot.c b/fs/afs/dynroot.c index 8c6130789fde..3b9594b568a4 100644 --- a/fs/afs/dynroot.c +++ b/fs/afs/dynroot.c @@ -64,7 +64,7 @@ static struct inode *afs_iget_pseudo_dir(struct super_blo= ck *sb, ino_t ino) =20 vnode =3D AFS_FS_I(inode); =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { netfs_inode_init(&vnode->netfs, NULL, false); simple_inode_init_ts(inode); set_nlink(inode, 2); @@ -258,7 +258,7 @@ static struct dentry *afs_lookup_atcell(struct inode *d= ir, struct dentry *dentry =20 vnode =3D AFS_FS_I(inode); =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { netfs_inode_init(&vnode->netfs, NULL, false); simple_inode_init_ts(inode); set_nlink(inode, 1); @@ -383,7 +383,7 @@ struct inode *afs_dynroot_iget_root(struct super_block = *sb) vnode =3D AFS_FS_I(inode); =20 /* there shouldn't be an existing inode */ - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { netfs_inode_init(&vnode->netfs, NULL, false); simple_inode_init_ts(inode); set_nlink(inode, 2); diff --git a/fs/afs/inode.c b/fs/afs/inode.c index e9538e91f848..65b04f0ad06c 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -427,7 +427,7 @@ static void afs_fetch_status_success(struct afs_operati= on *op) struct afs_vnode *vnode =3D vp->vnode; int ret; =20 - if (vnode->netfs.inode.i_state & I_NEW) { + if (inode_state_read_unstable(&vnode->netfs.inode) & I_NEW) { ret =3D afs_inode_init_from_status(op, vp, vnode); afs_op_set_error(op, ret); if (ret =3D=3D 0) @@ -579,7 +579,7 @@ struct inode *afs_iget(struct afs_operation *op, struct= afs_vnode_param *vp) inode, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique); =20 /* deal with an existing inode */ - if (!(inode->i_state & I_NEW)) { + if (!(inode_state_read_unstable(inode) & I_NEW)) { _leave(" =3D %p", inode); return inode; } @@ -639,7 +639,7 @@ struct inode *afs_root_iget(struct super_block *sb, str= uct key *key) =20 _debug("GOT ROOT INODE %p { vl=3D%llx }", inode, as->volume->vid); =20 - BUG_ON(!(inode->i_state & I_NEW)); + BUG_ON(!(inode_state_read_unstable(inode) & I_NEW)); =20 vnode =3D AFS_FS_I(inode); vnode->cb_v_check =3D atomic_read(&as->volume->cb_v_break); @@ -748,7 +748,7 @@ void afs_evict_inode(struct inode *inode) =20 if ((S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && - (inode->i_state & I_DIRTY) && + (inode_state_read_unstable(inode) & I_DIRTY) && !sbi->dyn_root) { struct writeback_control wbc =3D { .sync_mode =3D WB_SYNC_ALL, diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 687af0eea0c2..c3477dd334a1 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -347,7 +347,7 @@ static struct bch_inode_info *bch2_inode_hash_find(stru= ct bch_fs *c, struct btre spin_unlock(&inode->v.i_lock); return NULL; } - if ((inode->v.i_state & (I_FREEING|I_WILL_FREE))) { + if ((inode_state_read(&inode->v) & (I_FREEING|I_WILL_FREE))) { if (!trans) { __wait_on_freeing_inode(c, inode, inum); } else { @@ -411,7 +411,7 @@ static struct bch_inode_info *bch2_inode_hash_insert(st= ruct bch_fs *c, * only insert fully created inodes in the inode hash table. But * discard_new_inode() expects it to be set... */ - inode->v.i_state |=3D I_NEW; + inode_state_add_unchecked(&inode->v, I_NEW); /* * We don't want bch2_evict_inode() to delete the inode on disk, * we just raced and had another inode in cache. Normally new @@ -2224,8 +2224,7 @@ void bch2_evict_subvolume_inodes(struct bch_fs *c, sn= apshot_id_list *s) if (!snapshot_list_has_id(s, inode->ei_inum.subvol)) continue; =20 - if (!(inode->v.i_state & I_DONTCACHE) && - !(inode->v.i_state & I_FREEING) && + if (!(inode_state_read_unstable(&inode->v) & (I_DONTCACHE | I_FREEING)) = && igrab(&inode->v)) { this_pass_clean =3D false; =20 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 8f430ff8e445..9b556f7e7b1c 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -307,7 +307,7 @@ static struct inode *befs_iget(struct super_block *sb, = unsigned long ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 befs_ino =3D BEFS_I(inode); diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 1d41ce477df5..3d1fc8387764 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c @@ -42,7 +42,7 @@ struct inode *bfs_iget(struct super_block *sb, unsigned l= ong ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) { diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5bcd8e25fa78..c61ab26f4d2c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3856,7 +3856,7 @@ static int btrfs_add_inode_to_root(struct btrfs_inode= *inode, bool prealloc) ASSERT(ret !=3D -ENOMEM); return ret; } else if (existing) { - WARN_ON(!(existing->vfs_inode.i_state & (I_WILL_FREE | I_FREEING))); + WARN_ON(!(inode_state_read_unstable(&existing->vfs_inode) & (I_WILL_FREE= | I_FREEING))); } =20 return 0; @@ -5317,7 +5317,7 @@ static void evict_inode_truncate_pages(struct inode *= inode) struct extent_io_tree *io_tree =3D &BTRFS_I(inode)->io_tree; struct rb_node *node; =20 - ASSERT(inode->i_state & I_FREEING); + ASSERT(inode_state_read_unstable(inode) & I_FREEING); truncate_inode_pages_final(&inode->i_data); =20 btrfs_drop_extent_map_range(BTRFS_I(inode), 0, (u64)-1, false); @@ -5745,7 +5745,7 @@ struct btrfs_inode *btrfs_iget_path(u64 ino, struct b= trfs_root *root, if (!inode) return ERR_PTR(-ENOMEM); =20 - if (!(inode->vfs_inode.i_state & I_NEW)) + if (!(inode_state_read_unstable(&inode->vfs_inode) & I_NEW)) return inode; =20 ret =3D btrfs_read_locked_inode(inode, path); @@ -5769,7 +5769,7 @@ struct btrfs_inode *btrfs_iget(u64 ino, struct btrfs_= root *root) if (!inode) return ERR_PTR(-ENOMEM); =20 - if (!(inode->vfs_inode.i_state & I_NEW)) + if (!(inode_state_read_unstable(&inode->vfs_inode) & I_NEW)) return inode; =20 path =3D btrfs_alloc_path(); @@ -7435,7 +7435,7 @@ static void btrfs_invalidate_folio(struct folio *foli= o, size_t offset, u64 page_start =3D folio_pos(folio); u64 page_end =3D page_start + folio_size(folio) - 1; u64 cur; - int inode_evicting =3D inode->vfs_inode.i_state & I_FREEING; + int inode_evicting =3D inode_state_read_unstable(&inode->vfs_inode) & I_F= REEING; =20 /* * We have folio locked so no new ordered extent can be created on this diff --git a/fs/ceph/cache.c b/fs/ceph/cache.c index 930fbd54d2c8..ed3b12f7752b 100644 --- a/fs/ceph/cache.c +++ b/fs/ceph/cache.c @@ -26,7 +26,7 @@ void ceph_fscache_register_inode_cookie(struct inode *ino= de) return; =20 /* Only new inodes! */ - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return; =20 WARN_ON_ONCE(ci->netfs.cache); diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c index 7026e794813c..cbedf4b5a746 100644 --- a/fs/ceph/crypto.c +++ b/fs/ceph/crypto.c @@ -329,7 +329,7 @@ int ceph_encode_encrypted_dname(struct inode *parent, c= har *buf, int elen) out: kfree(cryptbuf); if (dir !=3D parent) { - if ((dir->i_state & I_NEW)) + if ((inode_state_read_unstable(dir) & I_NEW)) discard_new_inode(dir); else iput(dir); @@ -438,7 +438,7 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, s= truct fscrypt_str *tname, fscrypt_fname_free_buffer(&_tname); out_inode: if (dir !=3D fname->dir) { - if ((dir->i_state & I_NEW)) + if ((inode_state_read_unstable(dir) & I_NEW)) discard_new_inode(dir); else iput(dir); diff --git a/fs/ceph/file.c b/fs/ceph/file.c index c02f100f8552..e42e0a92e94f 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -744,7 +744,7 @@ static int ceph_finish_async_create(struct inode *dir, = struct inode *inode, vino.ino, ceph_ino(dir), dentry->d_name.name); ceph_dir_clear_ordered(dir); ceph_init_inode_acls(inode, as_ctx); - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { /* * If it's not I_NEW, then someone created this before * we got here. Assume the server is aware of it at @@ -907,7 +907,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *= dentry, new_inode =3D NULL; goto out_req; } - WARN_ON_ONCE(!(new_inode->i_state & I_NEW)); + WARN_ON_ONCE(!(inode_state_read_unstable(new_inode) & I_NEW)); =20 spin_lock(&dentry->d_lock); di->flags |=3D CEPH_DENTRY_ASYNC_CREATE; diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 480cb3a1d639..55df06186b27 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -86,7 +86,7 @@ struct inode *ceph_new_inode(struct inode *dir, struct de= ntry *dentry, goto out_err; } =20 - inode->i_state =3D 0; + inode_state_set_unchecked(inode, 0); inode->i_mode =3D *mode; =20 err =3D ceph_security_init_secctx(dentry, *mode, as_ctx); @@ -155,7 +155,7 @@ struct inode *ceph_get_inode(struct super_block *sb, st= ruct ceph_vino vino, =20 doutc(cl, "on %llx=3D%llx.%llx got %p new %d\n", ceph_present_inode(inode), ceph_vinop(inode), inode, - !!(inode->i_state & I_NEW)); + !!(inode_state_read_unstable(inode) & I_NEW)); return inode; } =20 @@ -182,7 +182,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) goto err; } =20 - if (!(inode->i_state & I_NEW) && !S_ISDIR(inode->i_mode)) { + if (!(inode_state_read_unstable(inode) & I_NEW) && !S_ISDIR(inode->i_mode= )) { pr_warn_once_client(cl, "bad snapdir inode type (mode=3D0%o)\n", inode->i_mode); goto err; @@ -215,7 +215,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) } } #endif - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { inode->i_op =3D &ceph_snapdir_iops; inode->i_fop =3D &ceph_snapdir_fops; ci->i_snap_caps =3D CEPH_CAP_PIN; /* so we can open */ @@ -224,7 +224,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) =20 return inode; err: - if ((inode->i_state & I_NEW)) + if ((inode_state_read_unstable(inode) & I_NEW)) discard_new_inode(inode); else iput(inode); @@ -698,7 +698,7 @@ void ceph_evict_inode(struct inode *inode) =20 netfs_wait_for_outstanding_io(inode); truncate_inode_pages_final(&inode->i_data); - if (inode->i_state & I_PINNING_NETFS_WB) + if (inode_state_read_unstable(inode) & I_PINNING_NETFS_WB) ceph_fscache_unuse_cookie(inode, true); clear_inode(inode); =20 @@ -967,7 +967,7 @@ int ceph_fill_inode(struct inode *inode, struct page *l= ocked_page, le64_to_cpu(info->version), ci->i_version); =20 /* Once I_NEW is cleared, we can't change type or dev numbers */ - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { inode->i_mode =3D mode; } else { if (inode_wrong_type(inode, mode)) { @@ -1044,7 +1044,7 @@ int ceph_fill_inode(struct inode *inode, struct page = *locked_page, =20 #ifdef CONFIG_FS_ENCRYPTION if (iinfo->fscrypt_auth_len && - ((inode->i_state & I_NEW) || (ci->fscrypt_auth_len =3D=3D 0))) { + ((inode_state_read_unstable(inode) & I_NEW) || (ci->fscrypt_auth_len = =3D=3D 0))) { kfree(ci->fscrypt_auth); ci->fscrypt_auth_len =3D iinfo->fscrypt_auth_len; ci->fscrypt_auth =3D iinfo->fscrypt_auth; @@ -1638,13 +1638,13 @@ int ceph_fill_trace(struct super_block *sb, struct = ceph_mds_request *req) pr_err_client(cl, "badness %p %llx.%llx\n", in, ceph_vinop(in)); req->r_target_inode =3D NULL; - if (in->i_state & I_NEW) + if (inode_state_read_unstable(in) & I_NEW) discard_new_inode(in); else iput(in); goto done; } - if (in->i_state & I_NEW) + if (inode_state_read_unstable(in) & I_NEW) unlock_new_inode(in); } =20 @@ -1830,11 +1830,11 @@ static int readdir_prepopulate_inodes_only(struct c= eph_mds_request *req, pr_err_client(cl, "inode badness on %p got %d\n", in, rc); err =3D rc; - if (in->i_state & I_NEW) { + if (inode_state_read_unstable(in) & I_NEW) { ihold(in); discard_new_inode(in); } - } else if (in->i_state & I_NEW) { + } else if (inode_state_read_unstable(in) & I_NEW) { unlock_new_inode(in); } =20 @@ -2046,7 +2046,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request = *req, pr_err_client(cl, "badness on %p %llx.%llx\n", in, ceph_vinop(in)); if (d_really_is_negative(dn)) { - if (in->i_state & I_NEW) { + if (inode_state_read_unstable(in) & I_NEW) { ihold(in); discard_new_inode(in); } @@ -2056,7 +2056,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request = *req, err =3D ret; goto next_item; } - if (in->i_state & I_NEW) + if (inode_state_read_unstable(in) & I_NEW) unlock_new_inode(in); =20 if (d_really_is_negative(dn)) { diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c index 62a3d2565c26..6fc0d072cbd0 100644 --- a/fs/coda/cnode.c +++ b/fs/coda/cnode.c @@ -70,7 +70,7 @@ struct inode * coda_iget(struct super_block * sb, struct = CodaFid * fid, if (!inode) return ERR_PTR(-ENOMEM); =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { cii =3D ITOC(inode); /* we still need to set i_ino for things like stat(2) */ inode->i_ino =3D hash; @@ -148,7 +148,7 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, st= ruct super_block *sb) =20 /* we should never see newly created inodes because we intentionally * fail in the initialization callback */ - BUG_ON(inode->i_state & I_NEW); + BUG_ON(inode_state_read_unstable(inode) & I_NEW); =20 return inode; } diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index b002e9b734f9..0397754dc852 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -95,7 +95,7 @@ static struct inode *get_cramfs_inode(struct super_block = *sb, inode =3D iget_locked(sb, cramino(cramfs_inode, offset)); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 switch (cramfs_inode->mode & S_IFMT) { diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 72fbe1316ab8..5699ef841d4d 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -95,7 +95,7 @@ static struct inode *__ecryptfs_get_inode(struct inode *l= ower_inode, iput(lower_inode); return ERR_PTR(-EACCES); } - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) iput(lower_inode); =20 return inode; @@ -106,7 +106,7 @@ struct inode *ecryptfs_get_inode(struct inode *lower_in= ode, { struct inode *inode =3D __ecryptfs_get_inode(lower_inode, sb); =20 - if (!IS_ERR(inode) && (inode->i_state & I_NEW)) + if (!IS_ERR(inode) && (inode_state_read_unstable(inode) & I_NEW)) unlock_new_inode(inode); =20 return inode; @@ -373,7 +373,7 @@ static struct dentry *ecryptfs_lookup_interpose(struct = dentry *dentry, } } =20 - if (inode->i_state & I_NEW) + if (inode_state_read_unstable(inode) & I_NEW) unlock_new_inode(inode); return d_splice_alias(inode, dentry); } diff --git a/fs/efs/inode.c b/fs/efs/inode.c index 462619e59766..095ab7388edf 100644 --- a/fs/efs/inode.c +++ b/fs/efs/inode.c @@ -62,7 +62,7 @@ struct inode *efs_iget(struct super_block *super, unsigne= d long ino) inode =3D iget_locked(super, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 in =3D INODE_INFO(inode); diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index 9a2f59721522..456f59099cc4 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -297,7 +297,7 @@ struct inode *erofs_iget(struct super_block *sb, erofs_= nid_t nid) if (!inode) return ERR_PTR(-ENOMEM); =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { int err =3D erofs_fill_inode(inode); =20 if (err) { diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index e10c376843d7..5355008eb5bc 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1398,7 +1398,7 @@ struct inode *ext2_iget (struct super_block *sb, unsi= gned long ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 ei =3D EXT2_I(inode); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ed54c4d0f2f9..b3373b1c1596 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -425,7 +425,7 @@ void ext4_check_map_extents_env(struct inode *inode) if (!S_ISREG(inode->i_mode) || IS_NOQUOTA(inode) || IS_VERITY(inode) || is_special_ino(inode->i_sb, inode->i_ino) || - (inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW)) || + (inode_state_read_unstable(inode) & (I_FREEING | I_WILL_FREE | I_NEW)= ) || ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE) || ext4_verity_in_progress(inode)) return; @@ -3473,7 +3473,7 @@ static bool ext4_inode_datasync_dirty(struct inode *i= node) /* Any metadata buffers to write? */ if (!list_empty(&inode->i_mapping->i_private_list)) return true; - return inode->i_state & I_DIRTY_DATASYNC; + return inode_state_read_unstable(inode) & I_DIRTY_DATASYNC; } =20 static void ext4_set_iomap(struct inode *inode, struct iomap *iomap, @@ -4581,7 +4581,7 @@ int ext4_truncate(struct inode *inode) * or it's a completely new inode. In those cases we might not * have i_rwsem locked because it's not necessary. */ - if (!(inode->i_state & (I_NEW|I_FREEING))) + if (!(inode_state_read_unstable(inode) & (I_NEW | I_FREEING))) WARN_ON(!inode_is_locked(inode)); trace_ext4_truncate_enter(inode); =20 @@ -5239,7 +5239,7 @@ struct inode *__ext4_iget(struct super_block *sb, uns= igned long ino, inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) { + if (!(inode_state_read_unstable(inode) & I_NEW)) { ret =3D check_igot_inode(inode, flags, function, line); if (ret) { iput(inode); @@ -5570,7 +5570,7 @@ static void __ext4_update_other_inode_time(struct sup= er_block *sb, if (inode_is_dirtytime_only(inode)) { struct ext4_inode_info *ei =3D EXT4_I(inode); =20 - inode->i_state &=3D ~I_DIRTY_TIME; + inode_state_del(inode, I_DIRTY_TIME); spin_unlock(&inode->i_lock); =20 spin_lock(&ei->i_raw_lock); diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c index 7c7f792ad6ab..2fdaaca613ba 100644 --- a/fs/ext4/orphan.c +++ b/fs/ext4/orphan.c @@ -107,7 +107,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *ino= de) if (!sbi->s_journal || is_bad_inode(inode)) return 0; =20 - WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) && + WARN_ON_ONCE(!(inode_state_read_unstable(inode) & (I_NEW | I_FREEING)) && !inode_is_locked(inode)); /* * Inode orphaned in orphan file or in orphan list? @@ -236,7 +236,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *ino= de) if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS)) return 0; =20 - WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) && + WARN_ON_ONCE(!(inode_state_read_unstable(inode) & (I_NEW | I_FREEING)) && !inode_is_locked(inode)); if (ext4_test_inode_state(inode, EXT4_STATE_ORPHAN_FILE)) return ext4_orphan_file_del(handle, inode); diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 7961e0ddfca3..da6d366583f4 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -4241,7 +4241,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff= _t offset, loff_t length, =20 if (map.m_flags & F2FS_MAP_NEW) iomap->flags |=3D IOMAP_F_NEW; - if ((inode->i_state & I_DIRTY_DATASYNC) || + if ((inode_state_read_unstable(inode) & I_DIRTY_DATASYNC) || offset + length > i_size_read(inode)) iomap->flags |=3D IOMAP_F_DIRTY; =20 diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 8c4eafe9ffac..ffb79c976755 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -569,7 +569,7 @@ struct inode *f2fs_iget(struct super_block *sb, unsigne= d long ino) if (!inode) return ERR_PTR(-ENOMEM); =20 - if (!(inode->i_state & I_NEW)) { + if (!(inode_state_read_unstable(inode) & I_NEW)) { if (is_meta_ino(sbi, ino)) { f2fs_err(sbi, "inaccessible inode: %lu, run fsck to repair", ino); set_sbi_flag(sbi, SBI_NEED_FSCK); diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index b882771e4699..7d977b80bae5 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -844,7 +844,7 @@ static int __f2fs_tmpfile(struct mnt_idmap *idmap, stru= ct inode *dir, f2fs_i_links_write(inode, false); =20 spin_lock(&inode->i_lock); - inode->i_state |=3D I_LINKABLE; + inode_state_add(inode, I_LINKABLE); spin_unlock(&inode->i_lock); } else { if (file) @@ -1057,7 +1057,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struc= t inode *old_dir, goto put_out_dir; =20 spin_lock(&whiteout->i_lock); - whiteout->i_state &=3D ~I_LINKABLE; + inode_state_del(whiteout, I_LINKABLE); spin_unlock(&whiteout->i_lock); =20 iput(whiteout); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 2045642cfe3b..d8db9a4084fa 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1747,7 +1747,7 @@ static int f2fs_drop_inode(struct inode *inode) * - f2fs_gc -> iput -> evict * - inode_wait_for_writeback(inode) */ - if ((!inode_unhashed(inode) && inode->i_state & I_SYNC)) { + if ((!inode_unhashed(inode) && inode_state_read(inode) & I_SYNC)) { if (!inode->i_nlink && !is_bad_inode(inode)) { /* to avoid evict_inode call simultaneously */ __iget(inode); diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c index 20600e9ea202..f522ff2b2d12 100644 --- a/fs/freevxfs/vxfs_inode.c +++ b/fs/freevxfs/vxfs_inode.c @@ -258,7 +258,7 @@ vxfs_iget(struct super_block *sbp, ino_t ino) ip =3D iget_locked(sbp, ino); if (!ip) return ERR_PTR(-ENOMEM); - if (!(ip->i_state & I_NEW)) + if (!(inode_state_read_unstable(ip) & I_NEW)) return ip; =20 vip =3D VXFS_INO(ip); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index ecb869e895ab..5d1676766dab 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -161,7 +161,7 @@ static void fuse_evict_inode(struct inode *inode) struct fuse_inode *fi =3D get_fuse_inode(inode); =20 /* Will write inode on close/munmap and in all other dirtiers */ - WARN_ON(inode->i_state & I_DIRTY_INODE); + WARN_ON(inode_state_read_unstable(inode) & I_DIRTY_INODE); =20 if (FUSE_IS_DAX(inode)) dax_break_layout_final(inode); @@ -506,7 +506,7 @@ struct inode *fuse_iget(struct super_block *sb, u64 nod= eid, if (!inode) return NULL; =20 - if ((inode->i_state & I_NEW)) { + if ((inode_state_read_unstable(inode) & I_NEW)) { inode->i_flags |=3D S_NOATIME; if (!fc->writeback_cache || !S_ISREG(attr->mode)) inode->i_flags |=3D S_NOCMTIME; diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 72d95185a39f..712cf618a372 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -744,7 +744,7 @@ static int gfs2_fsync(struct file *file, loff_t start, = loff_t end, { struct address_space *mapping =3D file->f_mapping; struct inode *inode =3D mapping->host; - int sync_state =3D inode->i_state & I_DIRTY; + int sync_state =3D inode_state_read_unstable(inode) & I_DIRTY; struct gfs2_inode *ip =3D GFS2_I(inode); int ret =3D 0, ret1 =3D 0; =20 diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index fe0faad4892f..0aaa5dec57d2 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -394,7 +394,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const = void *buf) u16 height, depth; umode_t mode =3D be32_to_cpu(str->di_mode); struct inode *inode =3D &ip->i_inode; - bool is_new =3D inode->i_state & I_NEW; + bool is_new =3D inode_state_read_unstable(inode) & I_NEW; =20 if (unlikely(ip->i_no_addr !=3D be64_to_cpu(str->di_num.no_addr))) { gfs2_consist_inode(ip); diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 8760e7e20c9d..daa10f8b0f34 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -127,7 +127,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb,= unsigned int type, =20 ip =3D GFS2_I(inode); =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { struct gfs2_sbd *sdp =3D GFS2_SB(inode); struct gfs2_glock *io_gl; int extra_flags =3D 0; @@ -924,7 +924,7 @@ static int gfs2_create_inode(struct inode *dir, struct = dentry *dentry, gfs2_dir_no_add(&da); gfs2_glock_dq_uninit(&d_gh); if (!IS_ERR_OR_NULL(inode)) { - if (inode->i_state & I_NEW) + if (inode_state_read_unstable(inode) & I_NEW) iget_failed(inode); else iput(inode); diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index c770006f8889..2572ff9753b8 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -1749,7 +1749,7 @@ static void gfs2_evict_inodes(struct super_block *sb) spin_lock(&sb->s_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { spin_lock(&inode->i_lock); - if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) && + if ((inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) && !need_resched()) { spin_unlock(&inode->i_lock); continue; diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c index e86e1e235658..22c286762035 100644 --- a/fs/hfs/btree.c +++ b/fs/hfs/btree.c @@ -42,7 +42,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, = u32 id, btree_keycmp ke tree->inode =3D iget_locked(sb, id); if (!tree->inode) goto free_tree; - BUG_ON(!(tree->inode->i_state & I_NEW)); + BUG_ON(!(inode_state_read_unstable(tree->inode) & I_NEW)); { struct hfs_mdb *mdb =3D HFS_SB(sb)->mdb; HFS_I(tree->inode)->flags =3D 0; diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index bf4cb7e78396..b47374d0a518 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c @@ -401,7 +401,7 @@ struct inode *hfs_iget(struct super_block *sb, struct h= fs_cat_key *key, hfs_cat_ return NULL; } inode =3D iget5_locked(sb, cnid, hfs_test_inode, hfs_read_inode, &data); - if (inode && (inode->i_state & I_NEW)) + if (inode && (inode_state_read_unstable(inode) & I_NEW)) unlock_new_inode(inode); return inode; } diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 86351bdc8985..f41b35612d94 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c @@ -65,7 +65,7 @@ struct inode *hfsplus_iget(struct super_block *sb, unsign= ed long ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 INIT_LIST_HEAD(&HFSPLUS_I(inode)->open_dir_list); diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 01e516175bcd..c29d229d4eb7 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -581,7 +581,7 @@ static struct inode *hostfs_iget(struct super_block *sb= , char *name) if (!inode) return ERR_PTR(-ENOMEM); =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { unlock_new_inode(inode); } else { spin_lock(&inode->i_lock); diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index 49dd585c2b17..4452cea2edf9 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c @@ -247,7 +247,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct de= ntry *dentry, unsigned in result =3D ERR_PTR(-ENOMEM); goto bail1; } - if (result->i_state & I_NEW) { + if (inode_state_read_unstable(result) & I_NEW) { hpfs_init_inode(result); if (de->directory) hpfs_read_inode(result); diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index 34008442ee26..e95b1b6e3799 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c @@ -196,7 +196,7 @@ void hpfs_write_inode(struct inode *i) parent =3D iget_locked(i->i_sb, hpfs_inode->i_parent_dir); if (parent) { hpfs_inode->i_dirty =3D 0; - if (parent->i_state & I_NEW) { + if (inode_state_read_unstable(parent) & I_NEW) { hpfs_init_inode(parent); hpfs_read_inode(parent); unlock_new_inode(parent); diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 6f0e6b19383c..eecdcb0aeb58 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -1515,7 +1515,7 @@ struct inode *__isofs_iget(struct super_block *sb, if (!inode) return ERR_PTR(-ENOMEM); =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { ret =3D isofs_read_inode(inode, relocated); if (ret < 0) { iget_failed(inode); diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index d175cccb7c55..0f57b5675ce2 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -265,7 +265,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsign= ed long ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 f =3D JFFS2_INODE_INFO(inode); @@ -373,7 +373,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags) { struct iattr iattr; =20 - if (!(inode->i_state & I_DIRTY_DATASYNC)) { + if (!(inode_state_read_unstable(inode) & I_DIRTY_DATASYNC)) { jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n", __func__, inode->i_ino); return; diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 2a4a288b821c..1d216764cec4 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c @@ -26,8 +26,8 @@ int jfs_fsync(struct file *file, loff_t start, loff_t end= , int datasync) return rc; =20 inode_lock(inode); - if (!(inode->i_state & I_DIRTY_ALL) || - (datasync && !(inode->i_state & I_DIRTY_DATASYNC))) { + if (!(inode_state_read_unstable(inode) & I_DIRTY_ALL) || + (datasync && !(inode_state_read_unstable(inode) & I_DIRTY_DATASYNC)))= { /* Make sure committed changes hit the disk */ jfs_flush_journal(JFS_SBI(inode->i_sb)->log, 1); inode_unlock(inode); diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index fcedeb514e14..2986168a2ef3 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c @@ -29,7 +29,7 @@ struct inode *jfs_iget(struct super_block *sb, unsigned l= ong ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 ret =3D diRead(inode); diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index be17e3c43582..4a5a7a032269 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c @@ -1286,7 +1286,7 @@ int txCommit(tid_t tid, /* transaction identifier */ * to verify this, only a trivial s/I_LOCK/I_SYNC/ was done. * Joern */ - if (tblk->u.ip->i_state & I_SYNC) + if (inode_state_read_unstable(tblk->u.ip) & I_SYNC) tblk->xflag &=3D ~COMMIT_LAZY; } =20 diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c index 3c293a5a21b1..4be78ff5ab6c 100644 --- a/fs/kernfs/inode.c +++ b/fs/kernfs/inode.c @@ -251,7 +251,7 @@ struct inode *kernfs_get_inode(struct super_block *sb, = struct kernfs_node *kn) struct inode *inode; =20 inode =3D iget_locked(sb, kernfs_ino(kn)); - if (inode && (inode->i_state & I_NEW)) + if (inode && (inode_state_read_unstable(inode) & I_NEW)) kernfs_init_inode(kn, inode); =20 return inode; diff --git a/fs/minix/inode.c b/fs/minix/inode.c index df9d11479caf..50b81fd292fd 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c @@ -583,7 +583,7 @@ struct inode *minix_iget(struct super_block *sb, unsign= ed long ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 if (INODE_VERSION(inode) =3D=3D MINIX_V1) diff --git a/fs/netfs/misc.c b/fs/netfs/misc.c index 20748bcfbf59..358edd97b40e 100644 --- a/fs/netfs/misc.c +++ b/fs/netfs/misc.c @@ -147,10 +147,10 @@ bool netfs_dirty_folio(struct address_space *mapping,= struct folio *folio) if (!fscache_cookie_valid(cookie)) return true; =20 - if (!(inode->i_state & I_PINNING_NETFS_WB)) { + if (!(inode_state_read_unstable(inode) & I_PINNING_NETFS_WB)) { spin_lock(&inode->i_lock); - if (!(inode->i_state & I_PINNING_NETFS_WB)) { - inode->i_state |=3D I_PINNING_NETFS_WB; + if (!(inode_state_read(inode) & I_PINNING_NETFS_WB)) { + inode_state_add(inode, I_PINNING_NETFS_WB); need_use =3D true; } spin_unlock(&inode->i_lock); @@ -192,7 +192,7 @@ void netfs_clear_inode_writeback(struct inode *inode, c= onst void *aux) { struct fscache_cookie *cookie =3D netfs_i_cookie(netfs_inode(inode)); =20 - if (inode->i_state & I_PINNING_NETFS_WB) { + if (inode_state_read_unstable(inode) & I_PINNING_NETFS_WB) { loff_t i_size =3D i_size_read(inode); fscache_unuse_cookie(cookie, aux, &i_size); } diff --git a/fs/netfs/read_single.c b/fs/netfs/read_single.c index fa622a6cd56d..d3894cece633 100644 --- a/fs/netfs/read_single.c +++ b/fs/netfs/read_single.c @@ -36,12 +36,12 @@ void netfs_single_mark_inode_dirty(struct inode *inode) =20 mark_inode_dirty(inode); =20 - if (caching && !(inode->i_state & I_PINNING_NETFS_WB)) { + if (caching && !(inode_state_read_unstable(inode) & I_PINNING_NETFS_WB)) { bool need_use =3D false; =20 spin_lock(&inode->i_lock); - if (!(inode->i_state & I_PINNING_NETFS_WB)) { - inode->i_state |=3D I_PINNING_NETFS_WB; + if (!(inode_state_read(inode) & I_PINNING_NETFS_WB)) { + inode_state_add(inode, I_PINNING_NETFS_WB); need_use =3D true; } spin_unlock(&inode->i_lock); diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index b52805951856..eb1c5c764110 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -475,7 +475,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, st= ruct nfs_fattr *fattr) goto out_no_inode; } =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { struct nfs_inode *nfsi =3D NFS_I(inode); unsigned long now =3D jiffies; =20 diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index a3135b5af7ee..f157d43d1312 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -317,7 +317,7 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n"); pnfs_detach_layout_hdr(lo); /* Notify pnfs_destroy_layout_final() that we're done */ - if (inode->i_state & (I_FREEING | I_CLEAR)) + if (inode_state_read(inode) & (I_FREEING | I_CLEAR)) wake_up_var_locked(lo, &inode->i_lock); spin_unlock(&inode->i_lock); pnfs_free_layout_hdr(lo); diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 98ab55ba3ced..d207ca1d76bb 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1139,7 +1139,7 @@ static int wait_for_concurrent_writes(struct file *fi= le) dprintk("nfsd: write resume %d\n", task_pid_nr(current)); } =20 - if (inode->i_state & I_DIRTY) { + if (inode_state_read_unstable(inode) & I_DIRTY) { dprintk("nfsd: write sync %d\n", task_pid_nr(current)); err =3D vfs_fsync(file, 0); } diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c index bcc7d76269ac..9eda63f0462e 100644 --- a/fs/nilfs2/cpfile.c +++ b/fs/nilfs2/cpfile.c @@ -1148,7 +1148,7 @@ int nilfs_cpfile_read(struct super_block *sb, size_t = cpsize, cpfile =3D nilfs_iget_locked(sb, NULL, NILFS_CPFILE_INO); if (unlikely(!cpfile)) return -ENOMEM; - if (!(cpfile->i_state & I_NEW)) + if (!(inode_state_read_unstable(cpfile) & I_NEW)) goto out; =20 err =3D nilfs_mdt_init(cpfile, NILFS_MDT_GFP, 0); diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c index c664daba56ae..6e057627261c 100644 --- a/fs/nilfs2/dat.c +++ b/fs/nilfs2/dat.c @@ -506,7 +506,7 @@ int nilfs_dat_read(struct super_block *sb, size_t entry= _size, dat =3D nilfs_iget_locked(sb, NULL, NILFS_DAT_INO); if (unlikely(!dat)) return -ENOMEM; - if (!(dat->i_state & I_NEW)) + if (!(inode_state_read_unstable(dat) & I_NEW)) goto out; =20 err =3D nilfs_mdt_init(dat, NILFS_MDT_GFP, sizeof(*di)); diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c index c4cd4a4dedd0..58494b1d4477 100644 --- a/fs/nilfs2/ifile.c +++ b/fs/nilfs2/ifile.c @@ -188,7 +188,7 @@ int nilfs_ifile_read(struct super_block *sb, struct nil= fs_root *root, ifile =3D nilfs_iget_locked(sb, root, NILFS_IFILE_INO); if (unlikely(!ifile)) return -ENOMEM; - if (!(ifile->i_state & I_NEW)) + if (!(inode_state_read_unstable(ifile) & I_NEW)) goto out; =20 err =3D nilfs_mdt_init(ifile, NILFS_MDT_GFP, diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 87ddde159f0c..6a6de2ee5d65 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -365,7 +365,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_= t mode) =20 failed_after_creation: clear_nlink(inode); - if (inode->i_state & I_NEW) + if (inode_state_read_unstable(inode) & I_NEW) unlock_new_inode(inode); iput(inode); /* * raw_inode will be deleted through @@ -562,7 +562,7 @@ struct inode *nilfs_iget(struct super_block *sb, struct= nilfs_root *root, if (unlikely(!inode)) return ERR_PTR(-ENOMEM); =20 - if (!(inode->i_state & I_NEW)) { + if (!(inode_state_read_unstable(inode) & I_NEW)) { if (!inode->i_nlink) { iput(inode); return ERR_PTR(-ESTALE); @@ -591,7 +591,7 @@ struct inode *nilfs_iget_for_gc(struct super_block *sb,= unsigned long ino, inode =3D iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args); if (unlikely(!inode)) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 err =3D nilfs_init_gcinode(inode); @@ -631,7 +631,7 @@ int nilfs_attach_btree_node_cache(struct inode *inode) nilfs_iget_set, &args); if (unlikely(!btnc_inode)) return -ENOMEM; - if (btnc_inode->i_state & I_NEW) { + if (inode_state_read_unstable(btnc_inode) & I_NEW) { nilfs_init_btnc_inode(btnc_inode); unlock_new_inode(btnc_inode); } @@ -686,7 +686,7 @@ struct inode *nilfs_iget_for_shadow(struct inode *inode) nilfs_iget_set, &args); if (unlikely(!s_inode)) return ERR_PTR(-ENOMEM); - if (!(s_inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(s_inode) & I_NEW)) return inode; =20 NILFS_I(s_inode)->i_flags =3D 0; diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c index 330f269abedf..7fe97dec31e9 100644 --- a/fs/nilfs2/sufile.c +++ b/fs/nilfs2/sufile.c @@ -1226,7 +1226,7 @@ int nilfs_sufile_read(struct super_block *sb, size_t = susize, sufile =3D nilfs_iget_locked(sb, NULL, NILFS_SUFILE_INO); if (unlikely(!sufile)) return -ENOMEM; - if (!(sufile->i_state & I_NEW)) + if (!(inode_state_read_unstable(sufile) & I_NEW)) goto out; =20 err =3D nilfs_mdt_init(sufile, NILFS_MDT_GFP, sizeof(*sui)); diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 37cbbee7fa58..a611e841c8fd 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -536,7 +536,7 @@ struct inode *ntfs_iget5(struct super_block *sb, const = struct MFT_REF *ref, return ERR_PTR(-ENOMEM); =20 /* If this is a freshly allocated inode, need to read it now. */ - if (inode->i_state & I_NEW) + if (inode_state_read_unstable(inode) & I_NEW) inode =3D ntfs_read_mft(inode, name, ref); else if (ref->seq !=3D ntfs_i(inode)->mi.mrec->seq) { /* diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 92a6149da9c1..82d414eef927 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -2487,7 +2487,7 @@ int ocfs2_inode_lock_full_nested(struct inode *inode, * which hasn't been populated yet, so clear the refresh flag * and let the caller handle it. */ - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { status =3D 0; if (lockres) ocfs2_complete_lock_res_refresh(lockres, 0); diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 14bf440ea4df..3ec269998bf2 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -152,8 +152,8 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 b= lkno, unsigned flags, mlog_errno(PTR_ERR(inode)); goto bail; } - trace_ocfs2_iget5_locked(inode->i_state); - if (inode->i_state & I_NEW) { + trace_ocfs2_iget5_locked(inode_state_read_unstable(inode)); + if (inode_state_read_unstable(inode) & I_NEW) { rc =3D ocfs2_read_locked_inode(inode, &args); unlock_new_inode(inode); } @@ -1307,12 +1307,12 @@ int ocfs2_drop_inode(struct inode *inode) inode->i_nlink, oi->ip_flags); =20 assert_spin_locked(&inode->i_lock); - inode->i_state |=3D I_WILL_FREE; + inode_state_add(inode, I_WILL_FREE); spin_unlock(&inode->i_lock); write_inode_now(inode, 1); spin_lock(&inode->i_lock); - WARN_ON(inode->i_state & I_NEW); - inode->i_state &=3D ~I_WILL_FREE; + WARN_ON(inode_state_read(inode) & I_NEW); + inode_state_del(inode, I_WILL_FREE); =20 return 1; } diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c index 135c49c5d848..798bb88bfa76 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c @@ -212,7 +212,7 @@ struct inode *omfs_iget(struct super_block *sb, ino_t i= no) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 bh =3D omfs_bread(inode->i_sb, ino); diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c index 26ecda0e4d19..9429bcba455e 100644 --- a/fs/openpromfs/inode.c +++ b/fs/openpromfs/inode.c @@ -236,7 +236,7 @@ static struct dentry *openpromfs_lookup(struct inode *d= ir, struct dentry *dentry mutex_unlock(&op_mutex); if (IS_ERR(inode)) return ERR_CAST(inode); - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { simple_inode_init_ts(inode); ent_oi =3D OP_I(inode); ent_oi->type =3D ent_type; diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index a01400cd41fd..3bf31fb0224b 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -1041,7 +1041,7 @@ struct inode *orangefs_iget(struct super_block *sb, if (!inode) return ERR_PTR(-ENOMEM); =20 - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 error =3D orangefs_inode_getattr(inode, ORANGEFS_GETATTR_NEW); diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c index 0fdceb00ca07..9ab1119ebd28 100644 --- a/fs/orangefs/orangefs-utils.c +++ b/fs/orangefs/orangefs-utils.c @@ -247,7 +247,7 @@ int orangefs_inode_getattr(struct inode *inode, int fla= gs) spin_lock(&inode->i_lock); /* Must have all the attributes in the mask and be within cache time. */ if ((!flags && time_before(jiffies, orangefs_inode->getattr_time)) || - orangefs_inode->attr_valid || inode->i_state & I_DIRTY_PAGES) { + orangefs_inode->attr_valid || inode_state_read(inode) & I_DIRTY_PAGES= ) { if (orangefs_inode->attr_valid) { spin_unlock(&inode->i_lock); write_inode_now(inode, 1); @@ -281,13 +281,13 @@ int orangefs_inode_getattr(struct inode *inode, int f= lags) spin_lock(&inode->i_lock); /* Must have all the attributes in the mask and be within cache time. */ if ((!flags && time_before(jiffies, orangefs_inode->getattr_time)) || - orangefs_inode->attr_valid || inode->i_state & I_DIRTY_PAGES) { + orangefs_inode->attr_valid || inode_state_read(inode) & I_DIRTY_PAGES= ) { if (orangefs_inode->attr_valid) { spin_unlock(&inode->i_lock); write_inode_now(inode, 1); goto again2; } - if (inode->i_state & I_DIRTY_PAGES) { + if (inode_state_read(inode) & I_DIRTY_PAGES) { ret =3D 0; goto out_unlock; } diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 70b8687dc45e..eb3419c25dfc 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -659,7 +659,7 @@ static int ovl_create_object(struct dentry *dentry, int= mode, dev_t rdev, goto out_drop_write; =20 spin_lock(&inode->i_lock); - inode->i_state |=3D I_CREATING; + inode_state_add(inode, I_CREATING); spin_unlock(&inode->i_lock); =20 inode_init_owner(&nop_mnt_idmap, inode, dentry->d_parent->d_inode, mode); diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index ecb9f2019395..3bc98184f632 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -1149,7 +1149,7 @@ struct inode *ovl_get_trap_inode(struct super_block *= sb, struct dentry *dir) if (!trap) return ERR_PTR(-ENOMEM); =20 - if (!(trap->i_state & I_NEW)) { + if (!(inode_state_read_unstable(trap) & I_NEW)) { /* Conflicting layer roots? */ iput(trap); return ERR_PTR(-ELOOP); @@ -1240,7 +1240,7 @@ struct inode *ovl_get_inode(struct super_block *sb, inode =3D ovl_iget5(sb, oip->newinode, key); if (!inode) goto out_err; - if (!(inode->i_state & I_NEW)) { + if (!(inode_state_read_unstable(inode) & I_NEW)) { /* * Verify that the underlying files stored in the inode * match those in the dentry. @@ -1299,7 +1299,7 @@ struct inode *ovl_get_inode(struct super_block *sb, if (upperdentry) ovl_check_protattr(inode, upperdentry); =20 - if (inode->i_state & I_NEW) + if (inode_state_read_unstable(inode) & I_NEW) unlock_new_inode(inode); out: return inode; diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index a33115e7384c..cfc7a7b00fba 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -1019,8 +1019,8 @@ bool ovl_inuse_trylock(struct dentry *dentry) bool locked =3D false; =20 spin_lock(&inode->i_lock); - if (!(inode->i_state & I_OVL_INUSE)) { - inode->i_state |=3D I_OVL_INUSE; + if (!(inode_state_read(inode) & I_OVL_INUSE)) { + inode_state_add(inode, I_OVL_INUSE); locked =3D true; } spin_unlock(&inode->i_lock); @@ -1034,8 +1034,8 @@ void ovl_inuse_unlock(struct dentry *dentry) struct inode *inode =3D d_inode(dentry); =20 spin_lock(&inode->i_lock); - WARN_ON(!(inode->i_state & I_OVL_INUSE)); - inode->i_state &=3D ~I_OVL_INUSE; + WARN_ON(!(inode_state_read(inode) & I_OVL_INUSE)); + inode_state_del(inode, I_OVL_INUSE); spin_unlock(&inode->i_lock); } } @@ -1046,7 +1046,7 @@ bool ovl_is_inuse(struct dentry *dentry) bool inuse; =20 spin_lock(&inode->i_lock); - inuse =3D (inode->i_state & I_OVL_INUSE); + inuse =3D (inode_state_read(inode) & I_OVL_INUSE); spin_unlock(&inode->i_lock); =20 return inuse; diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index e399e2dd3a12..8cc7a336bb44 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c @@ -290,7 +290,7 @@ struct inode *qnx4_iget(struct super_block *sb, unsigne= d long ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 qnx4_inode =3D qnx4_raw_inode(inode); diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c index 3310d1ad4d0e..96eb956a6ebc 100644 --- a/fs/qnx6/inode.c +++ b/fs/qnx6/inode.c @@ -521,7 +521,7 @@ struct inode *qnx6_iget(struct super_block *sb, unsigne= d ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 ei =3D QNX6_I(inode); diff --git a/fs/romfs/super.c b/fs/romfs/super.c index 0addcc849ff2..3e5d09d6e4d7 100644 --- a/fs/romfs/super.c +++ b/fs/romfs/super.c @@ -302,7 +302,7 @@ static struct inode *romfs_iget(struct super_block *sb,= unsigned long pos) if (!i) return ERR_PTR(-ENOMEM); =20 - if (!(i->i_state & I_NEW)) + if (!(inode_state_read_unstable(i) & I_NEW)) return i; =20 /* precalculate the data offset */ diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index 3bd85ab2deb1..11f77e2cd69a 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -444,7 +444,7 @@ cifs_evict_inode(struct inode *inode) { netfs_wait_for_outstanding_io(inode); truncate_inode_pages_final(&inode->i_data); - if (inode->i_state & I_PINNING_NETFS_WB) + if (inode_state_read_unstable(inode) & I_PINNING_NETFS_WB) cifs_fscache_unuse_inode_cookie(inode, true); cifs_fscache_release_inode_cookie(inode); clear_inode(inode); diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index 211d5b8b42f4..7803d1f23149 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -101,7 +101,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_= fattr *fattr) cifs_dbg(FYI, "%s: revalidating inode %llu\n", __func__, cifs_i->uniqueid); =20 - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { cifs_dbg(FYI, "%s: inode %llu is new\n", __func__, cifs_i->uniqueid); return; @@ -146,7 +146,7 @@ cifs_nlink_fattr_to_inode(struct inode *inode, struct c= ifs_fattr *fattr) */ if (fattr->cf_flags & CIFS_FATTR_UNKNOWN_NLINK) { /* only provide fake values on a new inode */ - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { if (fattr->cf_cifsattrs & ATTR_DIRECTORY) set_nlink(inode, 2); else @@ -167,12 +167,12 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_= fattr *fattr, struct cifsInodeInfo *cifs_i =3D CIFS_I(inode); struct cifs_sb_info *cifs_sb =3D CIFS_SB(inode->i_sb); =20 - if (!(inode->i_state & I_NEW) && + if (!(inode_state_read_unstable(inode) & I_NEW) && unlikely(inode_wrong_type(inode, fattr->cf_mode))) { CIFS_I(inode)->time =3D 0; /* force reval */ return -ESTALE; } - if (inode->i_state & I_NEW) + if (inode_state_read_unstable(inode) & I_NEW) CIFS_I(inode)->netfs.zero_point =3D fattr->cf_eof; =20 cifs_revalidate_cache(inode, fattr); @@ -194,7 +194,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fa= ttr *fattr, inode->i_gid =3D fattr->cf_gid; =20 /* if dynperm is set, don't clobber existing mode */ - if (inode->i_state & I_NEW || + if (inode_state_read_unstable(inode) & I_NEW || !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)) inode->i_mode =3D fattr->cf_mode; =20 @@ -236,7 +236,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fa= ttr *fattr, =20 if (fattr->cf_flags & CIFS_FATTR_JUNCTION) inode->i_flags |=3D S_AUTOMOUNT; - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { cifs_set_netfs_context(inode); cifs_set_ops(inode); } @@ -1638,7 +1638,7 @@ cifs_iget(struct super_block *sb, struct cifs_fattr *= fattr) cifs_fattr_to_inode(inode, fattr, false); if (sb->s_flags & SB_NOATIME) inode->i_flags |=3D S_NOATIME | S_NOCMTIME; - if (inode->i_state & I_NEW) { + if (inode_state_read_unstable(inode) & I_NEW) { inode->i_ino =3D hash; cifs_fscache_get_inode_cookie(inode); unlock_new_inode(inode); diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c index d5918eba27e3..408e3362fca4 100644 --- a/fs/squashfs/inode.c +++ b/fs/squashfs/inode.c @@ -82,7 +82,7 @@ struct inode *squashfs_iget(struct super_block *sb, long = long ino, =20 if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 err =3D squashfs_read_inode(inode, ino); diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index e75a6cec67be..e859646ecb70 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -1323,7 +1323,7 @@ int ubifs_fsync(struct file *file, loff_t start, loff= _t end, int datasync) inode_lock(inode); =20 /* Synchronize the inode unless this is a 'datasync()' call. */ - if (!datasync || (inode->i_state & I_DIRTY_DATASYNC)) { + if (!datasync || (inode_state_read_unstable(inode) & I_DIRTY_DATASYNC)) { err =3D inode->i_sb->s_op->write_inode(inode, NULL); if (err) goto out; diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index a0269ba96e3d..82019e0c8434 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -114,7 +114,7 @@ struct inode *ubifs_iget(struct super_block *sb, unsign= ed long inum) inode =3D iget_locked(sb, inum); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; ui =3D ubifs_inode(inode); =20 diff --git a/fs/udf/inode.c b/fs/udf/inode.c index f24aa98e6869..c7c90987ad88 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -1962,7 +1962,7 @@ struct inode *__udf_iget(struct super_block *sb, stru= ct kernel_lb_addr *ino, if (!inode) return ERR_PTR(-ENOMEM); =20 - if (!(inode->i_state & I_NEW)) { + if (!(inode_state_read_unstable(inode) & I_NEW)) { if (UDF_I(inode)->i_hidden !=3D hidden_inode) { iput(inode); return ERR_PTR(-EFSCORRUPTED); diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 8361c00e8fa6..1edd75c8e30d 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -655,7 +655,7 @@ struct inode *ufs_iget(struct super_block *sb, unsigned= long ino) inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 ufsi =3D UFS_I(inode); diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 2ef7742be7d3..e27cfbcfc5c9 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -1249,7 +1249,7 @@ xchk_irele( * hits do not clear DONTCACHE, so we must do it here. */ spin_lock(&VFS_I(ip)->i_lock); - VFS_I(ip)->i_state &=3D ~I_DONTCACHE; + inode_state_del(VFS_I(ip), I_DONTCACHE); spin_unlock(&VFS_I(ip)->i_lock); } =20 diff --git a/fs/xfs/scrub/inode_repair.c b/fs/xfs/scrub/inode_repair.c index a90a011c7e5f..86a671d518d4 100644 --- a/fs/xfs/scrub/inode_repair.c +++ b/fs/xfs/scrub/inode_repair.c @@ -1933,7 +1933,7 @@ xrep_inode_pptr( * Unlinked inodes that cannot be added to the directory tree will not * have a parent pointer. */ - if (inode->i_nlink =3D=3D 0 && !(inode->i_state & I_LINKABLE)) + if (inode->i_nlink =3D=3D 0 && !(inode_state_read_unstable(inode) & I_LIN= KABLE)) return 0; =20 /* Children of the superblock do not have parent pointers. */ diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c index 3b692c4acc1e..42907000d559 100644 --- a/fs/xfs/scrub/parent.c +++ b/fs/xfs/scrub/parent.c @@ -915,7 +915,7 @@ xchk_pptr_looks_zapped( * Temporary files that cannot be linked into the directory tree do not * have attr forks because they cannot ever have parents. */ - if (inode->i_nlink =3D=3D 0 && !(inode->i_state & I_LINKABLE)) + if (inode->i_nlink =3D=3D 0 && !(inode_state_read_unstable(inode) & I_LIN= KABLE)) return false; =20 /* diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 06ca11731e43..f798ac597c16 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -514,7 +514,7 @@ xfs_can_free_eofblocks( * Caller must either hold the exclusive io lock; or be inactivating * the inode, which guarantees there are no other users of the inode. */ - if (!(VFS_I(ip)->i_state & I_FREEING)) + if (!(inode_state_read_unstable(VFS_I(ip)) & I_FREEING)) xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); =20 /* prealloc/delalloc exists only on regular files */ diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index 7c541fb373d5..c765a28b4556 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c @@ -285,7 +285,7 @@ xfs_inode_mark_sick( * is not the case here. */ spin_lock(&VFS_I(ip)->i_lock); - VFS_I(ip)->i_state &=3D ~I_DONTCACHE; + inode_state_del(VFS_I(ip), I_DONTCACHE); spin_unlock(&VFS_I(ip)->i_lock); } =20 @@ -309,7 +309,7 @@ xfs_inode_mark_corrupt( * is not the case here. */ spin_lock(&VFS_I(ip)->i_lock); - VFS_I(ip)->i_state &=3D ~I_DONTCACHE; + inode_state_del(VFS_I(ip), I_DONTCACHE); spin_unlock(&VFS_I(ip)->i_lock); } =20 diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 4cf7abe50143..a3f57466f6c4 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -334,7 +334,7 @@ xfs_reinit_inode( dev_t dev =3D inode->i_rdev; kuid_t uid =3D inode->i_uid; kgid_t gid =3D inode->i_gid; - unsigned long state =3D inode->i_state; + unsigned long state =3D inode_state_read_unstable(inode); =20 error =3D inode_init_always(mp->m_super, inode); =20 @@ -345,7 +345,7 @@ xfs_reinit_inode( inode->i_rdev =3D dev; inode->i_uid =3D uid; inode->i_gid =3D gid; - inode->i_state =3D state; + inode_state_set_unchecked(inode, state); mapping_set_folio_min_order(inode->i_mapping, M_IGEO(mp)->min_folio_order); return error; @@ -411,7 +411,7 @@ xfs_iget_recycle( ip->i_flags |=3D XFS_INEW; xfs_perag_clear_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG); - inode->i_state =3D I_NEW; + inode_state_set_unchecked(inode, I_NEW); spin_unlock(&ip->i_flags_lock); spin_unlock(&pag->pag_ici_lock); =20 diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index df8eab11dc48..f019e9dfdf08 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1569,7 +1569,7 @@ xfs_iunlink_reload_next( next_ip->i_prev_unlinked =3D prev_agino; trace_xfs_iunlink_reload_next(next_ip); rele: - ASSERT(!(VFS_I(next_ip)->i_state & I_DONTCACHE)); + ASSERT(!(inode_state_read_unstable(VFS_I(next_ip)) & I_DONTCACHE)); if (xfs_is_quotacheck_running(mp) && next_ip) xfs_iflags_set(next_ip, XFS_IQUOTAUNCHECKED); xfs_irele(next_ip); @@ -2093,7 +2093,7 @@ xfs_rename_alloc_whiteout( */ xfs_setup_iops(tmpfile); xfs_finish_inode_setup(tmpfile); - VFS_I(tmpfile)->i_state |=3D I_LINKABLE; + inode_state_add_unchecked(VFS_I(tmpfile), I_LINKABLE); =20 *wip =3D tmpfile; return 0; @@ -2319,7 +2319,7 @@ xfs_rename( * flag from the inode so it doesn't accidentally get misused in * future. */ - VFS_I(du_wip.ip)->i_state &=3D ~I_LINKABLE; + inode_state_del_unchecked(VFS_I(du_wip.ip), I_LINKABLE); } =20 out_commit: diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 829675700fcd..4ae67c0a6f14 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -113,9 +113,9 @@ xfs_inode_item_precommit( * to log the timestamps, or will clear already cleared fields in the * worst case. */ - if (inode->i_state & I_DIRTY_TIME) { + if (inode_state_read_unstable(inode) & I_DIRTY_TIME) { spin_lock(&inode->i_lock); - inode->i_state &=3D ~I_DIRTY_TIME; + inode_state_del(inode, I_DIRTY_TIME); spin_unlock(&inode->i_lock); } =20 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 149b5460fbfd..6963c1d34e3f 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1419,7 +1419,7 @@ xfs_setup_inode( bool is_meta =3D xfs_is_internal_inode(ip); =20 inode->i_ino =3D ip->i_ino; - inode->i_state |=3D I_NEW; + inode_state_add_unchecked(inode, I_NEW); =20 inode_sb_list_add(inode); /* make the inode look hashed for the writeback code */ diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index 36cda724da89..d5278c36caa0 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -17,7 +17,7 @@ xfs_can_free_cowblocks(struct xfs_inode *ip) { struct inode *inode =3D VFS_I(ip); =20 - if ((inode->i_state & I_DIRTY_PAGES) || + if ((inode_state_read_unstable(inode) & I_DIRTY_PAGES) || mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) || mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK) || atomic_read(&inode->i_dio_count)) diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index 4dc7f967c861..4a293832e8ec 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -644,7 +644,7 @@ static struct inode *zonefs_get_file_inode(struct inode= *dir, inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) { + if (!(inode_state_read_unstable(inode) & I_NEW)) { WARN_ON_ONCE(inode->i_private !=3D z); return inode; } @@ -683,7 +683,7 @@ static struct inode *zonefs_get_zgroup_inode(struct sup= er_block *sb, inode =3D iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode_state_read_unstable(inode) & I_NEW)) return inode; =20 inode->i_ino =3D ino; --=20 2.43.0 From nobody Thu Oct 2 20:38:43 2025 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 26A0F2417C6; Thu, 11 Sep 2025 04:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757566581; cv=none; b=TWfYp4MBfutPmC99HsVFiQJLV+sMc3wvgZYgUKphG0QUuXJFbxFo3BJ5oc+2pE+kWsZUz6r+xiXzDBUX4m/6+y0/JYwkQ4E5loOgZAy+I3lUrgaUmDKY2Vq1uFAZQsbOOHcHY17qSwqydPARkh6/gsvOkxwM8YCRRQwQwDlRknU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757566581; c=relaxed/simple; bh=+OpnHav0x6JMfHFpFQpCzutgMoUi/ESeVF79sx8hjFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q7SybOL+jm++AZePX+H01ad7dAKAAHIE1Vd5vD8hSxiNp0gTP2d2bIVWYQxCNo+BP++E9B4dua/QEbZ0PFFOrqCLFimSOxwyA1CTADeZiqexRidbgPkpXGuHb1y6ii1MxqmgFy/ldiEZJda9GpcOpOCUiggHJPnFIqjXJz0xdu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KqkSoDUy; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KqkSoDUy" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3e751508f21so188227f8f.0; Wed, 10 Sep 2025 21:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757566579; x=1758171379; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5YLHicn9dTH5/070mxiYCI0YLNhb1ob9gFIcwBqIMYE=; b=KqkSoDUyP9bVyU/6Zzvq1vQ243yvpp7pRKKz+3WNnadi7XlWQcY4tDJJACow/IFEHZ zSEURQk3sUQLnn+O6Z8EE6gCnGDzJU312Wn85YlowPMJvigFGSVCZr0AZV/YNfiB51ZD KSeFZFTMdebJaYbvbRY+EijNWoB5TWYt57XqO+ZsxLX1qVg4Zefzxi7Bx7FwTV3sFogQ jFwWAcfYnlHEHkHL5vIa930De0ds4ByhBEzE5WUM3OvqosWxZ8lLd4/q7NwdKvAGlEIY 9Bz4gvnKX/lPMm3r9eGMiLrk9yYVKUv83zvuZ1t5RH2iRrmYgl0qpj/mx0DKaZd010/j i/TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757566579; x=1758171379; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5YLHicn9dTH5/070mxiYCI0YLNhb1ob9gFIcwBqIMYE=; b=agXIyWtcNighWHv7okyPiTfFhlyYXYhcquZqCdDye28XDnuQaH4lzoFehBLWJSV8zn zhwHJ9puEqcvSgaNuGH8cFBqRkpPfRf+K33IWL5Fs3Uk5Qgf7SlDHjVEPkn379ltelPi 3m9mnoCtBs5kAlQ8CTVtVZvnqP0AO9i8YrJ/eu0LRElkULJozaq8PIYKb8fqJd7x/w1J Uf5kQNSrWDgiLeo8eoVtJLlh1rPdbsUGF77sfMls3b9zrVaKZ6pBfqUlNSQXfy9Cpd6z IZWPEr1eN4G1JtQri7SGbBbu06pAwqDxUe8cxk967zfAaP7DN/T/dLLQF4wVCEIF7a+8 AMXQ== X-Forwarded-Encrypted: i=1; AJvYcCVi3C63hwQO6udS/D7927K6lD1BGkKNE5xmYGZ5iDJxdzNzp0Qkl1mi2fnOwc26ptYTROZ88T+6oDTG@vger.kernel.org, AJvYcCVigElzJKPS1En7S8jEtYuP7riA/u71ZA1xtWPyKEDLhYkj4oEd7L6j1MkklU32+tAcCHe+jpGpHwJOIcv9@vger.kernel.org, AJvYcCWkDl/uKRTYkInubxRzk/omCEBC2kbx8Zw0nAYmjdhvJzWIXlte1hrOzpVYcmWv9V5rhfUxwG576DQ70lxb5w==@vger.kernel.org, AJvYcCXEKwcIMvG7Q7s6lDqQMon7CkMQl3E6gwTKQm6Yt3oIdP7DbKRSzRe7bSj+/nzAwch7N69OnPcKIOVyLw==@vger.kernel.org, AJvYcCXfRTOGCw6iY3W6W3bVG2yTfZsCSWiuq0I79Ytmq4tKL54dYa/AELUULS+L2l8htZPx0A7nRenakPErTQ==@vger.kernel.org X-Gm-Message-State: AOJu0Yy5s5+lzN3jX/OnOuaVwmZkoqJPKXW9qserltdPwUKYEL3XYqyZ MxtRKTRG4u1Ac8gSckYChn91NwKLoMYLrIAXlX5aR+9OCoFdfYYHBYkR X-Gm-Gg: ASbGncvTVSPn5A4muvTPtU8UhmAIAExh77ArTQRifeKOnCtlWK8ql5BX4lN73kaAyVW 4J0mli4GQPUOWBKnF86ye70akwudCP5rFx4Qso8BgtIn1wnaVt28rN5p3B/aFY/8bN0v4UHDfBQ uImGhaFrPXjlWApxfUKLf39UP48aadAtQivuzPF01005BF8xOgZ/wRAzI3yjvgMZQeijx5zRX92 9cuGJggIGIwCL/ms3XLZdCVQAu/2ydqwQ7h2B4mQN7XA5jtR+HLTBhC+sOeyxxa2cmXRBf52S+g bweoolh+ZzRfKhhPH4DoJgwqLTW5JlyLHOKqpVwIVdcUBE6Oe22sJZ3kqpBRGvEDq5xIGQ41ovJ R4tsghfd4Eq8Zk+JHypwWRKhCJjws7gQOGBk0hXoa3PKyQ1tWSoEraqwWXu/PAw== X-Google-Smtp-Source: AGHT+IH43UmBU64jK+xL3m62yMA10v9nozy9RFWM7cuwJpC5B1nBbx9LsGq+u1ZXEjc4PtCQBy4Z3Q== X-Received: by 2002:a05:6000:178e:b0:3ce:a06e:f24e with SMTP id ffacd0b85a97d-3e64c87e0a1mr12521762f8f.52.1757566578594; Wed, 10 Sep 2025 21:56:18 -0700 (PDT) Received: from f.. (cst-prg-67-222.cust.vodafone.cz. [46.135.67.222]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607e9e6asm889419f8f.62.2025.09.10.21.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Sep 2025 21:56:17 -0700 (PDT) From: Mateusz Guzik To: brauner@kernel.org Cc: viro@zeniv.linux.org.uk, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, josef@toxicpanda.com, kernel-team@fb.com, amir73il@gmail.com, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, Mateusz Guzik Subject: [PATCH v3 4/4] type switch Date: Thu, 11 Sep 2025 06:55:57 +0200 Message-ID: <20250911045557.1552002-5-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911045557.1552002-1-mjguzik@gmail.com> References: <20250911045557.1552002-1-mjguzik@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" --- include/linux/fs.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index ed482e5d14a6..fd8e68352fbd 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -782,6 +782,10 @@ enum inode_state_flags_enum { #define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES) #define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME) =20 +struct inode_state_flags { + enum inode_state_flags_enum __state; +}; + /* * Keep mostly read-only and often accessed (especially for * the RCU path lookup and 'stat' data) fields at the beginning @@ -840,7 +844,7 @@ struct inode { #endif =20 /* Misc */ - enum inode_state_flags_enum i_state; + struct inode_state_flags i_state; /* 32-bit hole */ struct rw_semaphore i_rwsem; =20 @@ -908,44 +912,44 @@ struct inode { static inline enum inode_state_flags_enum inode_state_read(struct inode *i= node) { lockdep_assert_held(&inode->i_lock); - return inode->i_state; + return inode->i_state.__state; } =20 static inline enum inode_state_flags_enum inode_state_read_unstable(struct= inode *inode) { - return READ_ONCE(inode->i_state); + return READ_ONCE(inode->i_state.__state); } =20 static inline void inode_state_add(struct inode *inode, enum inode_state_flags_enum newflags) { lockdep_assert_held(&inode->i_lock); - WRITE_ONCE(inode->i_state, inode->i_state | newflags); + WRITE_ONCE(inode->i_state.__state, inode->i_state.__state | newflags); } =20 static inline void inode_state_add_unchecked(struct inode *inode, enum inode_state_flags_enum newflags) { - WRITE_ONCE(inode->i_state, inode->i_state | newflags); + WRITE_ONCE(inode->i_state.__state, inode->i_state.__state | newflags); } =20 static inline void inode_state_del(struct inode *inode, enum inode_state_flags_enum rmflags) { lockdep_assert_held(&inode->i_lock); - WRITE_ONCE(inode->i_state, inode->i_state & ~rmflags); + WRITE_ONCE(inode->i_state.__state, inode->i_state.__state & ~rmflags); } =20 static inline void inode_state_del_unchecked(struct inode *inode, enum inode_state_flags_enum rmflags) { - WRITE_ONCE(inode->i_state, inode->i_state & ~rmflags); + WRITE_ONCE(inode->i_state.__state, inode->i_state.__state & ~rmflags); } =20 static inline void inode_state_set_unchecked(struct inode *inode, enum inode_state_flags_enum newflags) { - WRITE_ONCE(inode->i_state, newflags); + WRITE_ONCE(inode->i_state.__state, newflags); } =20 static inline void inode_set_cached_link(struct inode *inode, char *link, = int linklen) --=20 2.43.0