[PATCH v3 12/12] fs/ceph: remove redundant inode number from ceph_inode_info
Max Kellermann <[email protected]>
| Newsgroups | org.kernel.vger.ceph-devel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 64 bit systems, ceph_vino_to_ino_t() is a no-op, and inode.i_ino is the same as ceph_vino.ino. This reduces the size of `struct ceph_inode_info` by 8 bytes. Signed-off-by: Max Kellermann <[email protected]> --- fs/ceph/cache.c | 4 +++- fs/ceph/inode.c | 7 +++++++ fs/ceph/super.h | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/fs/ceph/cache.c b/fs/ceph/cache.c index f678bab189d8..289615e58196 100644 --- a/fs/ceph/cache.c +++ b/fs/ceph/cache.c @@ -16,6 +16,7 @@ void ceph_fscache_register_inode_cookie(struct inode *inode) { struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_fs_client *fsc = ceph_inode_to_fs_client(inode); + struct ceph_vino vino; /* No caching for filesystem? */ if (!fsc->fscache) @@ -31,9 +32,10 @@ void ceph_fscache_register_inode_cookie(struct inode *inode) WARN_ON_ONCE(ci->netfs.cache); + vino = ceph_vino(inode); ci->netfs.cache = fscache_acquire_cookie(fsc->fscache, 0, - &ci->i_vino, sizeof(ci->i_vino), + &vino, sizeof(vino), &ci->i_version, sizeof(ci->i_version), i_size_read(inode)); if (ci->netfs.cache) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index aba98975a8a3..e82877782601 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -44,11 +44,18 @@ static void ceph_inode_work(struct work_struct *work); */ static int ceph_set_ino_cb(struct inode *inode, void *data) { + const struct ceph_vino *vino = data; struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb); +#if BITS_PER_LONG >= 64 + inode->i_ino = vino->ino; + ci->i_snap = vino->snap; +#else ci->i_vino = *(struct ceph_vino *)data; inode->i_ino = ceph_vino_to_ino_t(ci->i_vino); +#endif + inode_set_iversion_raw(inode, 0); percpu_counter_inc(&mdsc->metric.total_inodes); diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 660125d94f8e..e5ab1b83a84d 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -378,7 +378,15 @@ struct ceph_inode_xattrs_info { */ struct ceph_inode_info { struct netfs_inode netfs; /* Netfslib context and vfs inode */ + +#if BITS_PER_LONG >= 64 + /* on 64 bit systems, the full Ceph inode number is stored in + * netfs.inode.i_ino + */ + u64 i_snap; +#else struct ceph_vino i_vino; /* ceph ino + snap */ +#endif spinlock_t i_ceph_lock; @@ -570,7 +578,14 @@ ceph_inode_to_client(const struct inode *inode) static inline struct ceph_vino ceph_vino(const struct inode *inode) { +#if BITS_PER_LONG >= 64 + return (struct ceph_vino){ + .ino = inode->i_ino, + .snap = ceph_inode(inode)->i_snap, + }; +#else return ceph_inode(inode)->i_vino; +#endif } static inline u32 ceph_ino_to_ino32(u64 vino) @@ -600,12 +615,20 @@ static inline ino_t ceph_vino_to_ino_t(const struct ceph_vino vino) static inline u64 ceph_ino(const struct inode *inode) { +#if BITS_PER_LONG >= 64 + return inode->i_ino; +#else return ceph_inode(inode)->i_vino.ino; +#endif } static inline u64 ceph_snap(const struct inode *inode) { +#if BITS_PER_LONG >= 64 + return ceph_inode(inode)->i_snap; +#else return ceph_inode(inode)->i_vino.snap; +#endif } /** -- 2.47.3