mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
fs: add an icount_read helper
Instead of doing direct access to ->i_count, add a helper to handle this. This will make it easier to convert i_count to a refcount later. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Link: https://lore.kernel.org/9bc62a84c6b9d6337781203f60837bd98fbc4a96.1756222464.git.josef@toxicpanda.com Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
9e70e985bd
commit
37b27bd5d6
@ -1430,7 +1430,7 @@ static int spufs_mfc_open(struct inode *inode, struct file *file)
|
||||
if (ctx->owner != current->mm)
|
||||
return -EINVAL;
|
||||
|
||||
if (atomic_read(&inode->i_count) != 1)
|
||||
if (icount_read(inode) != 1)
|
||||
return -EBUSY;
|
||||
|
||||
mutex_lock(&ctx->mapping_lock);
|
||||
|
||||
@ -4538,7 +4538,7 @@ static void btrfs_prune_dentries(struct btrfs_root *root)
|
||||
|
||||
inode = btrfs_find_first_inode(root, min_ino);
|
||||
while (inode) {
|
||||
if (atomic_read(&inode->vfs_inode.i_count) > 1)
|
||||
if (icount_read(&inode->vfs_inode) > 1)
|
||||
d_prune_aliases(&inode->vfs_inode);
|
||||
|
||||
min_ino = btrfs_ino(inode) + 1;
|
||||
|
||||
@ -2221,7 +2221,7 @@ static int trim_caps_cb(struct inode *inode, int mds, void *arg)
|
||||
int count;
|
||||
dput(dentry);
|
||||
d_prune_aliases(inode);
|
||||
count = atomic_read(&inode->i_count);
|
||||
count = icount_read(inode);
|
||||
if (count == 1)
|
||||
(*remaining)--;
|
||||
doutc(cl, "%p %llx.%llx cap %p pruned, count now %d\n",
|
||||
|
||||
@ -252,10 +252,10 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
|
||||
"nonexistent device\n", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
if (atomic_read(&inode->i_count) > 1) {
|
||||
if (icount_read(inode) > 1) {
|
||||
ext4_msg(sb, KERN_ERR, "%s:%d: inode #%lu: count=%d",
|
||||
__func__, __LINE__, inode->i_ino,
|
||||
atomic_read(&inode->i_count));
|
||||
icount_read(inode));
|
||||
return;
|
||||
}
|
||||
if (inode->i_nlink) {
|
||||
|
||||
@ -1767,7 +1767,7 @@ static int writeback_single_inode(struct inode *inode,
|
||||
int ret = 0;
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
if (!atomic_read(&inode->i_count))
|
||||
if (!icount_read(inode))
|
||||
WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING)));
|
||||
else
|
||||
WARN_ON(inode->i_state & I_WILL_FREE);
|
||||
|
||||
@ -184,7 +184,7 @@ void hpfs_write_inode(struct inode *i)
|
||||
struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
|
||||
struct inode *parent;
|
||||
if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return;
|
||||
if (hpfs_inode->i_rddir_off && !atomic_read(&i->i_count)) {
|
||||
if (hpfs_inode->i_rddir_off && !icount_read(i)) {
|
||||
if (*hpfs_inode->i_rddir_off)
|
||||
pr_err("write_inode: some position still there\n");
|
||||
kfree(hpfs_inode->i_rddir_off);
|
||||
|
||||
@ -534,7 +534,7 @@ static void __inode_add_lru(struct inode *inode, bool rotate)
|
||||
{
|
||||
if (inode->i_state & (I_DIRTY_ALL | I_SYNC | I_FREEING | I_WILL_FREE))
|
||||
return;
|
||||
if (atomic_read(&inode->i_count))
|
||||
if (icount_read(inode))
|
||||
return;
|
||||
if (!(inode->i_sb->s_flags & SB_ACTIVE))
|
||||
return;
|
||||
@ -871,11 +871,11 @@ void evict_inodes(struct super_block *sb)
|
||||
again:
|
||||
spin_lock(&sb->s_inode_list_lock);
|
||||
list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
|
||||
if (atomic_read(&inode->i_count))
|
||||
if (icount_read(inode))
|
||||
continue;
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
if (atomic_read(&inode->i_count)) {
|
||||
if (icount_read(inode)) {
|
||||
spin_unlock(&inode->i_lock);
|
||||
continue;
|
||||
}
|
||||
@ -937,7 +937,7 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
|
||||
* unreclaimable for a while. Remove them lazily here; iput,
|
||||
* sync, or the last page cache deletion will requeue them.
|
||||
*/
|
||||
if (atomic_read(&inode->i_count) ||
|
||||
if (icount_read(inode) ||
|
||||
(inode->i_state & ~I_REFERENCED) ||
|
||||
!mapping_shrinkable(&inode->i_data)) {
|
||||
list_lru_isolate(lru, &inode->i_lru);
|
||||
|
||||
@ -608,7 +608,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
|
||||
inode->i_sb->s_id,
|
||||
(unsigned long long)NFS_FILEID(inode),
|
||||
nfs_display_fhandle_hash(fh),
|
||||
atomic_read(&inode->i_count));
|
||||
icount_read(inode));
|
||||
|
||||
out:
|
||||
return inode;
|
||||
@ -2229,7 +2229,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
|
||||
dfprintk(VFS, "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%llx)\n",
|
||||
__func__, inode->i_sb->s_id, inode->i_ino,
|
||||
nfs_display_fhandle_hash(NFS_FH(inode)),
|
||||
atomic_read(&inode->i_count), fattr->valid);
|
||||
icount_read(inode), fattr->valid);
|
||||
|
||||
if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) {
|
||||
/* Only a mounted-on-fileid? Just exit */
|
||||
|
||||
@ -66,7 +66,7 @@ static void fsnotify_unmount_inodes(struct super_block *sb)
|
||||
* removed all zero refcount inodes, in any case. Test to
|
||||
* be sure.
|
||||
*/
|
||||
if (!atomic_read(&inode->i_count)) {
|
||||
if (!icount_read(inode)) {
|
||||
spin_unlock(&inode->i_lock);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2749,7 +2749,7 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
|
||||
}
|
||||
|
||||
cifs_dbg(FYI, "Update attributes: %s inode 0x%p count %d dentry: 0x%p d_time %ld jiffies %ld\n",
|
||||
full_path, inode, inode->i_count.counter,
|
||||
full_path, inode, icount_read(inode),
|
||||
dentry, cifs_get_time(dentry), jiffies);
|
||||
|
||||
again:
|
||||
|
||||
@ -358,7 +358,7 @@ static void ubifs_evict_inode(struct inode *inode)
|
||||
goto out;
|
||||
|
||||
dbg_gen("inode %lu, mode %#x", inode->i_ino, (int)inode->i_mode);
|
||||
ubifs_assert(c, !atomic_read(&inode->i_count));
|
||||
ubifs_assert(c, !icount_read(inode));
|
||||
|
||||
truncate_inode_pages_final(&inode->i_data);
|
||||
|
||||
|
||||
@ -1035,7 +1035,7 @@ xfs_itruncate_extents_flags(
|
||||
int error = 0;
|
||||
|
||||
xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
|
||||
if (atomic_read(&VFS_I(ip)->i_count))
|
||||
if (icount_read(VFS_I(ip)))
|
||||
xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL);
|
||||
ASSERT(new_size <= XFS_ISIZE(ip));
|
||||
ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
|
||||
|
||||
@ -1151,7 +1151,7 @@ DECLARE_EVENT_CLASS(xfs_iref_class,
|
||||
TP_fast_assign(
|
||||
__entry->dev = VFS_I(ip)->i_sb->s_dev;
|
||||
__entry->ino = ip->i_ino;
|
||||
__entry->count = atomic_read(&VFS_I(ip)->i_count);
|
||||
__entry->count = icount_read(VFS_I(ip));
|
||||
__entry->pincount = atomic_read(&ip->i_pincount);
|
||||
__entry->iflags = ip->i_flags;
|
||||
__entry->caller_ip = caller_ip;
|
||||
|
||||
@ -2611,6 +2611,11 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
|
||||
__mark_inode_dirty(inode, I_DIRTY_SYNC);
|
||||
}
|
||||
|
||||
static inline int icount_read(const struct inode *inode)
|
||||
{
|
||||
return atomic_read(&inode->i_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the given inode itself only has dirty timestamps (its pages
|
||||
* may still be dirty) and isn't currently being allocated or freed.
|
||||
|
||||
@ -189,7 +189,7 @@ TRACE_EVENT(generic_add_lease,
|
||||
__entry->i_ino = inode->i_ino;
|
||||
__entry->wcount = atomic_read(&inode->i_writecount);
|
||||
__entry->rcount = atomic_read(&inode->i_readcount);
|
||||
__entry->icount = atomic_read(&inode->i_count);
|
||||
__entry->icount = icount_read(inode);
|
||||
__entry->owner = fl->c.flc_owner;
|
||||
__entry->flags = fl->c.flc_flags;
|
||||
__entry->type = fl->c.flc_type;
|
||||
|
||||
@ -1281,7 +1281,7 @@ static void hook_sb_delete(struct super_block *const sb)
|
||||
struct landlock_object *object;
|
||||
|
||||
/* Only handles referenced inodes. */
|
||||
if (!atomic_read(&inode->i_count))
|
||||
if (!icount_read(inode))
|
||||
continue;
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user