Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kernfs: introduce kernfs_node_id

inode number and generation can identify a kernfs node. We are going to
export the identification by exportfs operations, so put ino and
generation into a separate structure. It's convenient when later patches
use the identification.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Shaohua Li and committed by
Jens Axboe
c53cd490 319ba91d

+21 -13
+5 -5
fs/kernfs/dir.c
··· 539 539 } 540 540 kfree(kn->iattr); 541 541 spin_lock(&kernfs_idr_lock); 542 - idr_remove(&root->ino_idr, kn->ino); 542 + idr_remove(&root->ino_idr, kn->id.ino); 543 543 spin_unlock(&kernfs_idr_lock); 544 544 kmem_cache_free(kernfs_node_cache, kn); 545 545 ··· 645 645 idr_preload_end(); 646 646 if (ret < 0) 647 647 goto err_out2; 648 - kn->ino = ret; 649 - kn->generation = gen; 648 + kn->id.ino = ret; 649 + kn->id.generation = gen; 650 650 651 651 /* 652 652 * set ino first. This barrier is paired with atomic_inc_not_zero in ··· 721 721 * before 'count'. So if 'count' is uptodate, 'ino' should be uptodate, 722 722 * hence we can use 'ino' to filter stale node. 723 723 */ 724 - if (kn->ino != ino) 724 + if (kn->id.ino != ino) 725 725 goto out; 726 726 rcu_read_unlock(); 727 727 ··· 1654 1654 const char *name = pos->name; 1655 1655 unsigned int type = dt_type(pos); 1656 1656 int len = strlen(name); 1657 - ino_t ino = pos->ino; 1657 + ino_t ino = pos->id.ino; 1658 1658 1659 1659 ctx->pos = pos->hash; 1660 1660 file->private_data = pos;
+2 -2
fs/kernfs/file.c
··· 895 895 * have the matching @file available. Look up the inodes 896 896 * and generate the events manually. 897 897 */ 898 - inode = ilookup(info->sb, kn->ino); 898 + inode = ilookup(info->sb, kn->id.ino); 899 899 if (!inode) 900 900 continue; 901 901 ··· 903 903 if (parent) { 904 904 struct inode *p_inode; 905 905 906 - p_inode = ilookup(info->sb, parent->ino); 906 + p_inode = ilookup(info->sb, parent->id.ino); 907 907 if (p_inode) { 908 908 fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD, 909 909 inode, FSNOTIFY_EVENT_INODE, kn->name, 0);
+2 -2
fs/kernfs/inode.c
··· 220 220 inode->i_private = kn; 221 221 inode->i_mapping->a_ops = &kernfs_aops; 222 222 inode->i_op = &kernfs_iops; 223 - inode->i_generation = kn->generation; 223 + inode->i_generation = kn->id.generation; 224 224 225 225 set_default_inode_attr(inode, kn->mode); 226 226 kernfs_refresh_inode(kn, inode); ··· 266 266 { 267 267 struct inode *inode; 268 268 269 - inode = iget_locked(sb, kn->ino); 269 + inode = iget_locked(sb, kn->id.ino); 270 270 if (inode && (inode->i_state & I_NEW)) 271 271 kernfs_init_inode(kn, inode); 272 272
+1 -1
include/linux/cgroup.h
··· 543 543 /* returns ino associated with a cgroup */ 544 544 static inline ino_t cgroup_ino(struct cgroup *cgrp) 545 545 { 546 - return cgrp->kn->ino; 546 + return cgrp->kn->id.ino; 547 547 } 548 548 549 549 /* cft/css accessors for cftype->write() operation */
+10 -2
include/linux/kernfs.h
··· 95 95 struct kernfs_node *notify_next; /* for kernfs_notify() */ 96 96 }; 97 97 98 + /* represent a kernfs node */ 99 + union kernfs_node_id { 100 + struct { 101 + u32 ino; 102 + u32 generation; 103 + }; 104 + u64 id; 105 + }; 106 + 98 107 /* 99 108 * kernfs_node - the building block of kernfs hierarchy. Each and every 100 109 * kernfs node is represented by single kernfs_node. Most fields are ··· 140 131 141 132 void *priv; 142 133 134 + union kernfs_node_id id; 143 135 unsigned short flags; 144 136 umode_t mode; 145 - unsigned int ino; 146 137 struct kernfs_iattrs *iattr; 147 - u32 generation; 148 138 }; 149 139 150 140 /*
+1 -1
include/trace/events/writeback.h
··· 136 136 137 137 static inline unsigned int __trace_wb_assign_cgroup(struct bdi_writeback *wb) 138 138 { 139 - return wb->memcg_css->cgroup->kn->ino; 139 + return wb->memcg_css->cgroup->kn->id.ino; 140 140 } 141 141 142 142 static inline unsigned int __trace_wbc_assign_cgroup(struct writeback_control *wbc)