netfs: Fix gcc-12 warning by embedding vfs inode in netfs_i_context
Subsystems (8)
David Howells
maintainerPATCH 1/1 netfs: Fix gcc-12 warning by embedding vfs inode in netfs_i_context
Hi Linus,
Can you apply this please? It fixes the gcc-12 warnings in netfslib.
David
---
netfs: Fix gcc-12 warning by embedding vfs inode in netfs_i_context
While randstruct was satisfied with using an open-coded "void *" offset cast for the netfs_i_context <-> inode casting, __builtin_object_size() as used by FORTIFY_SOURCE was not as easily fooled. This was causing the following complaint[1] from gcc v12:
In file included from ./include/linux/string.h:253,
from ./include/linux/ceph/ceph_debug.h:7,
from fs/ceph/inode.c:2:In function 'fortify_memset_chk',
inlined from 'netfs_i_context_init' at ./include/linux/netfs.h:326:2,
inlined from 'ceph_alloc_inode' at fs/ceph/inode.c:463:2:./include/linux/fortify-string.h:242:25: warning: call to '__write_overflow_field' declared with attribute warning:
detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
242 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fix this by embedding a struct inode into struct netfs_i_context (which should perhaps be renamed to struct netfs_inode). The struct inode vfs_inode fields are then removed from the 9p, afs, ceph and cifs inode structs and vfs_inode is then simply changed to "netfs.inode" in those filesystems.
Further, rename netfs_i_context to netfs_inode, get rid of the netfs_inode() function that converted a netfs_i_context pointer to an inode pointer (that can now be done with &ctx->inode) and rename the netfs_i_context() function to netfs_inode() (which is now a wrapper around container_of()).
Most of the changes were done with:
perl -p -i -e 's/vfs_inode/netfs.inode/'g \
`git grep -l 'vfs_inode' -- fs/{9p,afs,ceph,cifs}/*.[ch]`Kees suggested doing it with a pair structure[2] and a special declarator to insert that into the network filesystem's inode wrapper[3], but I think it's cleaner to embed it - and then it doesn't matter if struct randomisation reorders things.
Dave Chinner suggested using a filesystem-specific VFS_I() function in each filesystem to convert that filesystem's own inode wrapper struct into the VFS inode struct[4].
Changes
=======
ver #2)
- Fix a couple of missed name changes due to a disabled cifs option.
- Rename nfs_i_context to nfs_inode
- Use "netfs" instead of "nic" as the member name in per-fs inode wrapper structs.
--- Documentation/filesystems/netfs_library.rst | 37 ++++----- fs/9p/cache.c | 4 - fs/9p/v9fs.c | 2 fs/9p/v9fs.h | 10 -- fs/9p/vfs_addr.c | 2 fs/9p/vfs_inode.c | 4 - fs/afs/callback.c | 2 fs/afs/dir.c | 32 ++++---- fs/afs/dir_edit.c | 10 +- fs/afs/dir_silly.c | 4 - fs/afs/dynroot.c | 2 fs/afs/file.c | 4 - fs/afs/fs_operation.c | 6 - fs/afs/inode.c | 38 +++++----- fs/afs/internal.h | 23 ++---- fs/afs/super.c | 6 - fs/afs/write.c | 21 ++--- fs/ceph/addr.c | 4 - fs/ceph/cache.c | 4 - fs/ceph/cache.h | 2 fs/ceph/caps.c | 104 ++++++++++++++-------------- fs/ceph/file.c | 2 fs/ceph/inode.c | 10 +- fs/ceph/mds_client.c | 4 - fs/ceph/snap.c | 8 +- fs/ceph/super.c | 2 fs/ceph/super.h | 10 -- fs/ceph/xattr.c | 14 +-- fs/cifs/cifsfs.c | 8 +- fs/cifs/cifsglob.h | 12 +-- fs/cifs/file.c | 8 +- fs/cifs/fscache.c | 8 +- fs/cifs/fscache.h | 8 +- fs/cifs/inode.c | 4 - fs/cifs/misc.c | 4 - fs/cifs/smb2ops.c | 8 +- fs/netfs/buffered_read.c | 6 - fs/netfs/internal.h | 2 fs/netfs/objects.c | 2 include/linux/netfs.h | 41 ++++------- 40 files changed, 227 insertions(+), 255 deletions(-)
Documentation/filesystems/netfs_library.rst +18 -19
@@ -37,30 +37,31 @@ The network filesystem helper library needs a place to store a bit of state for its use on each netfs inode it is helping to manage. To this end, a context structure is defined:: - struct netfs_i_context { + struct netfs_inode { + struct inode inode; const struct netfs_request_ops *ops; - struct fscache_cookie *cache; + struct fscache_cookie *cache; }; -A network filesystem that wants to use netfs lib must place one of these -directly after the VFS ``struct inode`` it allocates, usually as part of its -own struct. This can be done in a way similar to the following:: +A network filesystem that wants to use netfs lib must place one of these in its +inode wrapper struct instead of the VFS ``struct inode``. This can be done in +a way similar to the following:: struct my_inode { - struct { - /* These must be contiguous */ - struct inode vfs_inode; - struct netfs_i_context netfs_ctx; - }; + struct netfs_inode netfs; /* Netfslib context and vfs inode */ ... }; -This allows netfslib to find its state by simple offset from the inode pointer, -thereby allowing the netfslib helper functions to be pointed to directly by the -VFS/VM operation tables. +This allows netfslib to find its state by using ``container_of()`` from the +inode pointer, thereby allowing the netfslib helper functions to be pointed to +directly by the VFS/VM operation tables. The structure contains the following fields: + * ``inode`` + + The VFS inode structure. + * ``ops`` The set of operations provided by the network filesystem to netfslib.
@@ -78,14 +79,12 @@ To help deal with the per-inode context, a number helper functions are provided. Firstly, a function to perform basic initialisation on a context and set the operations table pointer:: - void netfs_i_context_init(struct inode *inode, - const struct netfs_request_ops *ops); + void netfs_inode_init(struct inode *inode, + const struct netfs_request_ops *ops); -then two functions to cast between the VFS inode structure and the netfs -context:: +then a function to cast from the VFS inode structure to the netfs context:: - struct netfs_i_context *netfs_i_context(struct inode *inode); - struct inode *netfs_inode(struct netfs_i_context *ctx); + struct netfs_inode *netfs_node(struct inode *inode); and finally, a function to get the cache cookie pointer from the context attached to an inode (or NULL if fscache is disabled)::
fs/9p/cache.c +2 -2
@@ -62,12 +62,12 @@ void v9fs_cache_inode_get_cookie(struct inode *inode) version =cpu_to_le32 (v9inode->qid.version); path =cpu_to_le64 (v9inode->qid.path); v9ses =v9fs_inode2v9ses (inode); - v9inode->netfs_ctx.cache = + v9inode->netfs.cache =fscache_acquire_cookie (v9fs_session_cache (v9ses),0 , &path,sizeof (path), &version,sizeof (version), -i_size_read (&v9inode->vfs_inode)); +i_size_read (&v9inode->netfs.inode));p9_debug (P9_DEBUG_FSC ,"inode %p get cookie %p\n" , inode,v9fs_inode_cookie (v9inode));
fs/9p/v9fs.c +1 -1
@@ -625,7 +625,7 @@ static void v9fs_inode_init_once(void *foo)struct v9fs_inode *v9inode = (struct v9fs_inode *)foo;memset (&v9inode->qid,0 ,sizeof (v9inode->qid)); -inode_init_once (&v9inode->vfs_inode); +inode_init_once (&v9inode->netfs.inode); }/**
fs/9p/v9fs.h +3 -7
@@ -109,11 +109,7 @@ struct v9fs_session_info {#define V9FS_INO_INVALID_ATTR 0x01struct v9fs_inode { -struct { -/* These must be contiguous */ -struct inode vfs_inode;/* the VFS's inode record */ -struct netfs_i_context netfs_ctx;/* Netfslib context */ - }; +struct netfs_inode netfs;/* Netfslib context and vfs inode */ struct p9_qid qid;unsigned int cache_validity;struct p9_fid *writeback_fid;
@@ -122,13 +118,13 @@ struct v9fs_inode {static inline struct v9fs_inode *V9FS_I (const struct inode *inode) { - return container_of(inode, struct v9fs_inode, vfs_inode); + return container_of(inode, struct v9fs_inode, netfs.inode); }static inline struct fscache_cookie *v9fs_inode_cookie (struct v9fs_inode *v9inode) {#ifdef CONFIG_9P_FSCACHE -return netfs_i_cookie (&v9inode->vfs_inode); +return netfs_i_cookie (&v9inode->netfs.inode);#else return NULL ;#endif
fs/9p/vfs_addr.c +1 -1
@@ -140,7 +140,7 @@ static void v9fs_write_to_cache_done(void *priv, ssize_t transferred_or_error, transferred_or_error != -ENOBUFS) { version =cpu_to_le32 (v9inode->qid.version);fscache_invalidate (v9fs_inode_cookie (v9inode), &version, -i_size_read (&v9inode->vfs_inode),0 ); +i_size_read (&v9inode->netfs.inode),0 ); } }
fs/9p/vfs_inode.c +2 -2
@@ -234,7 +234,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb) v9inode->writeback_fid =NULL ; v9inode->cache_validity =0 ;mutex_init (&v9inode->v_mutex); -return &v9inode->vfs_inode; +return &v9inode->netfs.inode; }/**
@@ -252,7 +252,7 @@ void v9fs_free_inode(struct inode *inode)*/ static void v9fs_set_netfs_context (struct inode *inode) { -netfs_i_context_init (inode, &v9fs_req_ops); +netfs_inode_init (inode, &v9fs_req_ops); } int v9fs_init_inode(struct v9fs_session_info *v9ses,
fs/afs/callback.c +1 -1
@@ -30,7 +30,7 @@ void afs_invalidate_mmap_work(struct work_struct *work) { struct afs_vnode *vnode = container_of(work, struct afs_vnode, cb_work); -unmap_mapping_pages (vnode->vfs_inode.i_mapping,0 ,0 , false); +unmap_mapping_pages (vnode->netfs.inode.i_mapping,0 ,0 , false); }void afs_server_init_callback_work (struct work_struct *work)
fs/afs/dir.c +16 -16
@@ -109,7 +109,7 @@ struct afs_lookup_cookie {*/ static void afs_dir_read_cleanup (struct afs_read *req) { -struct address_space *mapping = req->vnode->vfs_inode.i_mapping; +struct address_space *mapping = req->vnode->netfs.inode.i_mapping;struct folio *folio;pgoff_t last = req->nr_pages -1 ;
@@ -153,7 +153,7 @@ static bool afs_dir_check_folio(struct afs_vnode *dvnode, struct folio *folio, block =kmap_local_folio (folio, offset);if (block->hdr.magic !=AFS_DIR_MAGIC ) {printk ("kAFS: %s(%lx): [%llx] bad magic %zx/%zx is %04hx\n" , - __func__, dvnode->vfs_inode.i_ino, + __func__, dvnode->netfs.inode.i_ino, pos, offset, size,ntohs (block->hdr.magic));trace_afs_dir_check_failed (dvnode, pos + offset, i_size);kunmap_local (block);
@@ -183,7 +183,7 @@ static bool afs_dir_check_folio(struct afs_vnode *dvnode, struct folio *folio,static void afs_dir_dump (struct afs_vnode *dvnode,struct afs_read *req) {union afs_xdr_dir_block *block; -struct address_space *mapping = dvnode->vfs_inode.i_mapping; +struct address_space *mapping = dvnode->netfs.inode.i_mapping;struct folio *folio;pgoff_t last = req->nr_pages -1 ;size_t offset, size;
@@ -217,7 +217,7 @@ static void afs_dir_dump(struct afs_vnode *dvnode, struct afs_read *req)*/ static int afs_dir_check (struct afs_vnode *dvnode,struct afs_read *req) { -struct address_space *mapping = dvnode->vfs_inode.i_mapping; +struct address_space *mapping = dvnode->netfs.inode.i_mapping;struct folio *folio;pgoff_t last = req->nr_pages -1 ;int ret =0 ;
@@ -269,7 +269,7 @@ static int afs_dir_open(struct inode *inode, struct file *file)static struct afs_read *afs_read_dir (struct afs_vnode *dvnode,struct key *key) __acquires(&dvnode->validate_lock) { -struct address_space *mapping = dvnode->vfs_inode.i_mapping; +struct address_space *mapping = dvnode->netfs.inode.i_mapping;struct afs_read *req;loff_t i_size;int nr_pages, i;
@@ -287,7 +287,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key) req->cleanup = afs_dir_read_cleanup; expand: - i_size =i_size_read (&dvnode->vfs_inode); + i_size =i_size_read (&dvnode->netfs.inode);if (i_size <2048 ) { ret =afs_bad (dvnode, afs_file_error_dir_small); goto error;
@@ -305,7 +305,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key) req->actual_len = i_size;/* May change */ req->len = nr_pages *PAGE_SIZE ;/* We can ask for more than there is */ req->data_version = dvnode->status.data_version;/* May change */ -iov_iter_xarray (&req->def_iter,READ , &dvnode->vfs_inode.i_mapping->i_pages, +iov_iter_xarray (&req->def_iter,READ , &dvnode->netfs.inode.i_mapping->i_pages,0 , i_size); req->iter = &req->def_iter;
@@ -897,7 +897,7 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry, out_op:if (op->error ==0 ) { - inode = &op->file[1 ].vnode->vfs_inode; + inode = &op->file[1 ].vnode->netfs.inode; op->file[1 ].vnode =NULL ; }
@@ -1139,7 +1139,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)afs_stat_v (dir, n_reval);/* search the directory for this vnode */ - ret =afs_do_lookup_one (&dir->vfs_inode, dentry, &fid, key, &dir_version); + ret =afs_do_lookup_one (&dir->netfs.inode, dentry, &fid, key, &dir_version);switch (ret) {case 0 :/* the filename maps to something */
@@ -1170,7 +1170,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)_debug ("%pd: file deleted (uq %u -> %u I:%u)" , dentry, fid.unique, vnode->fid.unique, - vnode->vfs_inode.i_generation); + vnode->netfs.inode.i_generation); goto not_found; } goto out_valid;
@@ -1368,7 +1368,7 @@ static void afs_dir_remove_subdir(struct dentry *dentry)if (d_really_is_positive (dentry)) {struct afs_vnode *vnode =AFS_FS_I (d_inode (dentry)); -clear_nlink (&vnode->vfs_inode); +clear_nlink (&vnode->netfs.inode);set_bit (AFS_VNODE_DELETED , &vnode->flags);clear_bit (AFS_VNODE_CB_PROMISED , &vnode->flags);clear_bit (AFS_VNODE_DIR_VALID , &vnode->flags);
@@ -1487,8 +1487,8 @@ static void afs_dir_remove_link(struct afs_operation *op)/* Already done */ }else if (test_bit (AFS_VNODE_DIR_VALID , &dvnode->flags)) {write_seqlock (&vnode->cb_lock); -drop_nlink (&vnode->vfs_inode); -if (vnode->vfs_inode.i_nlink ==0 ) { +drop_nlink (&vnode->netfs.inode); +if (vnode->netfs.inode.i_nlink ==0 ) {set_bit (AFS_VNODE_DELETED , &vnode->flags);__afs_break_callback (vnode, afs_cb_break_for_unlink); }
@@ -1504,7 +1504,7 @@ static void afs_dir_remove_link(struct afs_operation *op) op->error = ret; } -_debug ("nlink %d [val %d]" , vnode->vfs_inode.i_nlink, op->error); +_debug ("nlink %d [val %d]" , vnode->netfs.inode.i_nlink, op->error); }static void afs_unlink_success (struct afs_operation *op)
@@ -1680,8 +1680,8 @@ static void afs_link_success(struct afs_operation *op)afs_update_dentry_version (op, dvp, op->dentry);if (op->dentry_2->d_parent == op->dentry->d_parent)afs_update_dentry_version (op, dvp, op->dentry_2); -ihold (&vp->vnode->vfs_inode); -d_instantiate (op->dentry, &vp->vnode->vfs_inode); +ihold (&vp->vnode->netfs.inode); +d_instantiate (op->dentry, &vp->vnode->netfs.inode); }static void afs_link_put (struct afs_operation *op)
fs/afs/dir_edit.c +5 -5
@@ -109,7 +109,7 @@ static void afs_clear_contig_bits(union afs_xdr_dir_block *block,*/ static struct folio *afs_dir_get_folio (struct afs_vnode *vnode,pgoff_t index) { -struct address_space *mapping = vnode->vfs_inode.i_mapping; +struct address_space *mapping = vnode->netfs.inode.i_mapping;struct folio *folio; folio = __filemap_get_folio(mapping, index,
@@ -216,7 +216,7 @@ void afs_edit_dir_add(struct afs_vnode *vnode,_enter (",,{%d,%s}," , name->len, name->name); - i_size =i_size_read (&vnode->vfs_inode); + i_size =i_size_read (&vnode->netfs.inode);if (i_size >AFS_DIR_BLOCK_SIZE *AFS_DIR_MAX_BLOCKS || (i_size & (AFS_DIR_BLOCK_SIZE -1 ))) {clear_bit (AFS_VNODE_DIR_VALID , &vnode->flags);
@@ -336,7 +336,7 @@ void afs_edit_dir_add(struct afs_vnode *vnode,if (b <AFS_DIR_BLOCKS_WITH_CTR ) meta->meta.alloc_ctrs[b] -= need_slots; -inode_inc_iversion_raw (&vnode->vfs_inode); +inode_inc_iversion_raw (&vnode->netfs.inode);afs_stat_v (vnode, n_dir_cr);_debug ("Insert %s in %u[%u]" , name->name, b, slot);
@@ -383,7 +383,7 @@ void afs_edit_dir_remove(struct afs_vnode *vnode,_enter (",,{%d,%s}," , name->len, name->name); - i_size =i_size_read (&vnode->vfs_inode); + i_size =i_size_read (&vnode->netfs.inode);if (i_size <AFS_DIR_BLOCK_SIZE || i_size >AFS_DIR_BLOCK_SIZE *AFS_DIR_MAX_BLOCKS || (i_size & (AFS_DIR_BLOCK_SIZE -1 ))) {
@@ -463,7 +463,7 @@ void afs_edit_dir_remove(struct afs_vnode *vnode,if (b <AFS_DIR_BLOCKS_WITH_CTR ) meta->meta.alloc_ctrs[b] += need_slots; -inode_set_iversion_raw (&vnode->vfs_inode, vnode->status.data_version); +inode_set_iversion_raw (&vnode->netfs.inode, vnode->status.data_version);afs_stat_v (vnode, n_dir_rm);_debug ("Remove %s from %u[%u]" , name->name, b, slot);
fs/afs/dir_silly.c +2 -2
@@ -131,7 +131,7 @@ int afs_sillyrename(struct afs_vnode *dvnode, struct afs_vnode *vnode, goto out; }while (!d_is_negative (sdentry)); -ihold (&vnode->vfs_inode); +ihold (&vnode->netfs.inode); ret =afs_do_silly_rename (dvnode, vnode, dentry, sdentry, key);switch (ret) {
@@ -148,7 +148,7 @@ int afs_sillyrename(struct afs_vnode *dvnode, struct afs_vnode *vnode,d_drop (sdentry); } -iput (&vnode->vfs_inode); +iput (&vnode->netfs.inode);dput (sdentry); out:_leave (" = %d" , ret);
fs/afs/dynroot.c +1 -1
@@ -76,7 +76,7 @@ struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)/* there shouldn't be an existing inode */ BUG_ON (!(inode->i_state &I_NEW )); -netfs_i_context_init (inode,NULL ); +netfs_inode_init (inode,NULL ); inode->i_size =0 ; inode->i_mode =S_IFDIR |S_IRUGO |S_IXUGO ;if (root) {
fs/afs/file.c +2 -2
@@ -194,7 +194,7 @@ int afs_release(struct inode *inode, struct file *file)afs_put_wb_key (af->wb);if ((file->f_mode &FMODE_WRITE )) { - i_size =i_size_read (&vnode->vfs_inode); + i_size =i_size_read (&vnode->netfs.inode);afs_set_cache_aux (vnode, &aux);fscache_unuse_cookie (afs_vnode_cache (vnode), &aux, &i_size); }else {
@@ -325,7 +325,7 @@ static void afs_issue_read(struct netfs_io_subrequest *subreq) fsreq->iter = &fsreq->def_iter;iov_iter_xarray (&fsreq->def_iter,READ , - &fsreq->vnode->vfs_inode.i_mapping->i_pages, + &fsreq->vnode->netfs.inode.i_mapping->i_pages, fsreq->pos, fsreq->len);afs_fetch_data (fsreq->vnode, fsreq);
fs/afs/fs_operation.c +3 -3
@@ -232,14 +232,14 @@ int afs_put_operation(struct afs_operation *op)if (op->file[1 ].modification && op->file[1 ].vnode != op->file[0 ].vnode)clear_bit (AFS_VNODE_MODIFYING , &op->file[1 ].vnode->flags);if (op->file[0 ].put_vnode) -iput (&op->file[0 ].vnode->vfs_inode); +iput (&op->file[0 ].vnode->netfs.inode);if (op->file[1 ].put_vnode) -iput (&op->file[1 ].vnode->vfs_inode); +iput (&op->file[1 ].vnode->netfs.inode);if (op->more_files) {for (i =0 ; i < op->nr_files -2 ; i++)if (op->more_files[i].put_vnode) -iput (&op->more_files[i].vnode->vfs_inode); +iput (&op->more_files[i].vnode->netfs.inode);kfree (op->more_files); }
fs/afs/inode.c +19 -19
@@ -58,7 +58,7 @@ static noinline void dump_vnode(struct afs_vnode *vnode, struct afs_vnode *paren*/ static void afs_set_netfs_context (struct afs_vnode *vnode) { -netfs_i_context_init (&vnode->vfs_inode, &afs_req_ops); +netfs_inode_init (&vnode->netfs.inode, &afs_req_ops); }/*
@@ -96,7 +96,7 @@ static int afs_inode_init_from_status(struct afs_operation *op, inode->i_flags |=S_NOATIME ; inode->i_uid =make_kuid (&init_user_ns, status->owner); inode->i_gid =make_kgid (&init_user_ns, status->group); -set_nlink (&vnode->vfs_inode, status->nlink); +set_nlink (&vnode->netfs.inode, status->nlink);switch (status->type) {case AFS_FTYPE_FILE :
@@ -139,7 +139,7 @@ static int afs_inode_init_from_status(struct afs_operation *op,afs_set_netfs_context (vnode); vnode->invalid_before = status->data_version; -inode_set_iversion_raw (&vnode->vfs_inode, status->data_version); +inode_set_iversion_raw (&vnode->netfs.inode, status->data_version);if (!vp->scb.have_cb) {/* it's a symlink we just created (the fileserver
@@ -163,7 +163,7 @@ static void afs_apply_status(struct afs_operation *op, {struct afs_file_status *status = &vp->scb.status;struct afs_vnode *vnode = vp->vnode; -struct inode *inode = &vnode->vfs_inode; +struct inode *inode = &vnode->netfs.inode;struct timespec64 t;umode_t mode;bool data_changed = false;
@@ -246,7 +246,7 @@ static void afs_apply_status(struct afs_operation *op,* idea of what the size should be that's not the same as * what's on the server. */ - vnode->netfs_ctx.remote_i_size = status->size; + vnode->netfs.remote_i_size = status->size;if (change_size) {afs_set_i_size (vnode, status->size); inode->i_ctime = t;
@@ -289,7 +289,7 @@ void afs_vnode_commit_status(struct afs_operation *op, struct afs_vnode_param *v*/ if (vp->scb.status.abort_code ==VNOVNODE ) {set_bit (AFS_VNODE_DELETED , &vnode->flags); -clear_nlink (&vnode->vfs_inode); +clear_nlink (&vnode->netfs.inode);__afs_break_callback (vnode, afs_cb_break_for_deleted); op->flags &= ~AFS_OPERATION_DIR_CONFLICT ; }
@@ -306,8 +306,8 @@ void afs_vnode_commit_status(struct afs_operation *op, struct afs_vnode_param *vif (vp->scb.have_cb)afs_apply_callback (op, vp); }else if (vp->op_unlinked && !(op->flags &AFS_OPERATION_DIR_CONFLICT )) { -drop_nlink (&vnode->vfs_inode); -if (vnode->vfs_inode.i_nlink ==0 ) { +drop_nlink (&vnode->netfs.inode); +if (vnode->netfs.inode.i_nlink ==0 ) {set_bit (AFS_VNODE_DELETED , &vnode->flags);__afs_break_callback (vnode, afs_cb_break_for_deleted); }
@@ -326,7 +326,7 @@ static void afs_fetch_status_success(struct afs_operation *op)struct afs_vnode *vnode = vp->vnode;int ret; -if (vnode->vfs_inode.i_state &I_NEW ) { +if (vnode->netfs.inode.i_state &I_NEW ) { ret =afs_inode_init_from_status (op, vp, vnode); op->error = ret;if (ret ==0 )
@@ -430,7 +430,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode)struct afs_vnode_cache_aux aux;if (vnode->status.type !=AFS_FTYPE_FILE ) { - vnode->netfs_ctx.cache =NULL ; + vnode->netfs.cache =NULL ;return ; }
@@ -457,7 +457,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode)struct inode *afs_iget (struct afs_operation *op,struct afs_vnode_param *vp) {struct afs_vnode_param *dvp = &op->file[0 ]; -struct super_block *sb = dvp->vnode->vfs_inode.i_sb; +struct super_block *sb = dvp->vnode->netfs.inode.i_sb;struct afs_vnode *vnode;struct inode *inode;int ret;
@@ -582,10 +582,10 @@ static void afs_zap_data(struct afs_vnode *vnode)/* nuke all the non-dirty pages that aren't locked, mapped or being * written back in a regular file and completely discard the pages in a * directory or symlink */ -if (S_ISREG (vnode->vfs_inode.i_mode)) -invalidate_remote_inode (&vnode->vfs_inode); +if (S_ISREG (vnode->netfs.inode.i_mode)) +invalidate_remote_inode (&vnode->netfs.inode);else -invalidate_inode_pages2 (vnode->vfs_inode.i_mapping); +invalidate_inode_pages2 (vnode->netfs.inode.i_mapping); }/*
@@ -683,8 +683,8 @@ int afs_validate(struct afs_vnode *vnode, struct key *key) key_serial(key));if (unlikely (test_bit (AFS_VNODE_DELETED , &vnode->flags))) { -if (vnode->vfs_inode.i_nlink) -clear_nlink (&vnode->vfs_inode); +if (vnode->netfs.inode.i_nlink) +clear_nlink (&vnode->netfs.inode); goto valid; }
@@ -826,7 +826,7 @@ void afs_evict_inode(struct inode *inode)static void afs_setattr_success (struct afs_operation *op) {struct afs_vnode_param *vp = &op->file[0 ]; -struct inode *inode = &vp->vnode->vfs_inode; +struct inode *inode = &vp->vnode->netfs.inode;loff_t old_i_size =i_size_read (inode); op->setattr.old_i_size = old_i_size;
@@ -843,7 +843,7 @@ static void afs_setattr_success(struct afs_operation *op)static void afs_setattr_edit_file (struct afs_operation *op) {struct afs_vnode_param *vp = &op->file[0 ]; -struct inode *inode = &vp->vnode->vfs_inode; +struct inode *inode = &vp->vnode->netfs.inode;if (op->setattr.attr->ia_valid &ATTR_SIZE ) {loff_t size = op->setattr.attr->ia_size;
@@ -875,7 +875,7 @@ int afs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,ATTR_MTIME |ATTR_MTIME_SET |ATTR_TIMES_SET |ATTR_TOUCH ;struct afs_operation *op;struct afs_vnode *vnode =AFS_FS_I (d_inode (dentry)); -struct inode *inode = &vnode->vfs_inode; +struct inode *inode = &vnode->netfs.inode;loff_t i_size;int ret;
fs/afs/internal.h +9 -14
@@ -619,12 +619,7 @@ enum afs_lock_state {* leak from one inode to another. */ struct afs_vnode { -struct { -/* These must be contiguous */ -struct inode vfs_inode;/* the VFS's inode record */ -struct netfs_i_context netfs_ctx;/* Netfslib context */ - }; - +struct netfs_inode netfs;/* Netfslib context and vfs inode */ struct afs_volume *volume;/* volume on which vnode resides */ struct afs_fid fid;/* the file identifier for this inode */ struct afs_file_status status;/* AFS status info for this file */
@@ -675,7 +670,7 @@ struct afs_vnode {static inline struct fscache_cookie *afs_vnode_cache (struct afs_vnode *vnode) {#ifdef CONFIG_AFS_FSCACHE -return netfs_i_cookie (&vnode->vfs_inode); +return netfs_i_cookie (&vnode->netfs.inode);#else return NULL ;#endif
@@ -685,7 +680,7 @@ static inline void afs_vnode_set_cache(struct afs_vnode *vnode, struct fscache_cookie *cookie) {#ifdef CONFIG_AFS_FSCACHE - vnode->netfs_ctx.cache = cookie; + vnode->netfs.cache = cookie;#endif }
@@ -892,7 +887,7 @@ static inline void afs_invalidate_cache(struct afs_vnode *vnode, unsigned int flafs_set_cache_aux (vnode, &aux);fscache_invalidate (afs_vnode_cache (vnode), &aux, -i_size_read (&vnode->vfs_inode), flags); +i_size_read (&vnode->netfs.inode), flags); }/*
@@ -1217,7 +1212,7 @@ static inline struct afs_net *afs_i2net(struct inode *inode)static inline struct afs_net *afs_v2net (struct afs_vnode *vnode) { -return afs_i2net (&vnode->vfs_inode); +return afs_i2net (&vnode->netfs.inode); }static inline struct afs_net *afs_sock2net (struct sock *sk)
@@ -1593,12 +1588,12 @@ extern void yfs_fs_store_opaque_acl2(struct afs_operation *);*/ static inline struct afs_vnode *AFS_FS_I (struct inode *inode) { - return container_of(inode, struct afs_vnode, vfs_inode); + return container_of(inode, struct afs_vnode, netfs.inode); }static inline struct inode *AFS_VNODE_TO_I (struct afs_vnode *vnode) { -return &vnode->vfs_inode; +return &vnode->netfs.inode; }/*
@@ -1621,8 +1616,8 @@ static inline void afs_update_dentry_version(struct afs_operation *op,*/ static inline void afs_set_i_size (struct afs_vnode *vnode,u64 size) { -i_size_write (&vnode->vfs_inode, size); - vnode->vfs_inode.i_blocks = ((size +1023 ) >>10 ) <<1 ; +i_size_write (&vnode->netfs.inode, size); + vnode->netfs.inode.i_blocks = ((size +1023 ) >>10 ) <<1 ; }/*
fs/afs/super.c +3 -3
@@ -659,7 +659,7 @@ static void afs_i_init_once(void *_vnode)struct afs_vnode *vnode = _vnode;memset (vnode,0 ,sizeof (*vnode)); -inode_init_once (&vnode->vfs_inode); +inode_init_once (&vnode->netfs.inode);mutex_init (&vnode->io_lock);init_rwsem (&vnode->validate_lock);spin_lock_init (&vnode->wb_lock);
@@ -700,8 +700,8 @@ static struct inode *afs_alloc_inode(struct super_block *sb)init_rwsem (&vnode->rmdir_lock);INIT_WORK (&vnode->cb_work, afs_invalidate_mmap_work); -_leave (" = %p" , &vnode->vfs_inode); -return &vnode->vfs_inode; +_leave (" = %p" , &vnode->netfs.inode); +return &vnode->netfs.inode; }static void afs_free_inode (struct inode *inode)
fs/afs/write.c +10 -11
@@ -146,10 +146,10 @@ int afs_write_end(struct file *file, struct address_space *mapping, write_end_pos = pos + copied; - i_size =i_size_read (&vnode->vfs_inode); + i_size =i_size_read (&vnode->netfs.inode);if (write_end_pos > i_size) {write_seqlock (&vnode->cb_lock); - i_size =i_size_read (&vnode->vfs_inode); + i_size =i_size_read (&vnode->netfs.inode);if (write_end_pos > i_size)afs_set_i_size (vnode, write_end_pos);write_sequnlock (&vnode->cb_lock);
@@ -257,7 +257,7 @@ static void afs_redirty_pages(struct writeback_control *wbc,*/ static void afs_pages_written_back (struct afs_vnode *vnode,loff_t start,unsigned int len) { -struct address_space *mapping = vnode->vfs_inode.i_mapping; +struct address_space *mapping = vnode->netfs.inode.i_mapping;struct folio *folio;pgoff_t end;
@@ -354,7 +354,6 @@ static const struct afs_operation_ops afs_store_data_operation = {static int afs_store_data (struct afs_vnode *vnode,struct iov_iter *iter,loff_t pos,bool laundering) { -struct netfs_i_context *ictx = &vnode->netfs_ctx;struct afs_operation *op;struct afs_wb_key *wbk =NULL ;loff_t size =iov_iter_count (iter);
@@ -385,9 +384,9 @@ static int afs_store_data(struct afs_vnode *vnode, struct iov_iter *iter, loff_t op->store.write_iter = iter; op->store.pos = pos; op->store.size = size; - op->store.i_size =max (pos + size, ictx->remote_i_size); + op->store.i_size =max (pos + size, vnode->netfs.remote_i_size); op->store.laundering = laundering; - op->mtime = vnode->vfs_inode.i_mtime; + op->mtime = vnode->netfs.inode.i_mtime; op->flags |=AFS_OPERATION_UNINTR ; op->ops = &afs_store_data_operation;
@@ -554,7 +553,7 @@ static ssize_t afs_write_back_from_locked_folio(struct address_space *mapping,struct iov_iter iter;unsigned long priv;unsigned int offset, to, len, max_len; -loff_t i_size =i_size_read (&vnode->vfs_inode); +loff_t i_size =i_size_read (&vnode->netfs.inode);bool new_content =test_bit (AFS_VNODE_NEW_CONTENT , &vnode->flags);bool caching =fscache_cookie_enabled (afs_vnode_cache (vnode));long count = wbc->nr_to_write;
@@ -845,7 +844,7 @@ ssize_t afs_file_write(struct kiocb *iocb, struct iov_iter *from)_enter ("{%llx:%llu},{%zu}," , vnode->fid.vid, vnode->fid.vnode, count); -if (IS_SWAPFILE (&vnode->vfs_inode)) { +if (IS_SWAPFILE (&vnode->netfs.inode)) {printk (KERN_INFO "AFS: Attempt to write to active swap file!\n" );return -EBUSY ;
@@ -958,8 +957,8 @@ void afs_prune_wb_keys(struct afs_vnode *vnode)/* Discard unused keys */ spin_lock (&vnode->wb_lock); -if (!mapping_tagged (&vnode->vfs_inode.i_data,PAGECACHE_TAG_WRITEBACK ) && - !mapping_tagged (&vnode->vfs_inode.i_data,PAGECACHE_TAG_DIRTY )) { +if (!mapping_tagged (&vnode->netfs.inode.i_data,PAGECACHE_TAG_WRITEBACK ) && + !mapping_tagged (&vnode->netfs.inode.i_data,PAGECACHE_TAG_DIRTY )) {list_for_each_entry_safe (wbk, tmp, &vnode->wb_keys, vnode_link) {if (refcount_read (&wbk->usage) ==1 )list_move (&wbk->vnode_link, &graveyard);
@@ -1034,6 +1033,6 @@ static void afs_write_to_cache(struct afs_vnode *vnode, bool caching) {fscache_write_to_cache (afs_vnode_cache (vnode), - vnode->vfs_inode.i_mapping, start, len, i_size, + vnode->netfs.inode.i_mapping, start, len, i_size, afs_write_to_cache_done, vnode, caching); }
fs/ceph/addr.c +2 -2
@@ -1798,7 +1798,7 @@ enum {static int __ceph_pool_perm_get (struct ceph_inode_info *ci,s64 pool,struct ceph_string *pool_ns) { -struct ceph_fs_client *fsc =ceph_inode_to_client (&ci->vfs_inode); +struct ceph_fs_client *fsc =ceph_inode_to_client (&ci->netfs.inode);struct ceph_mds_client *mdsc = fsc->mdsc;struct ceph_osd_request *rd_req =NULL , *wr_req =NULL ;struct rb_node **p, *parent;
@@ -1913,7 +1913,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, 0, false, true); err =ceph_osdc_start_request (&fsc->client->osdc, rd_req, false); - wr_req->r_mtime = ci->vfs_inode.i_mtime; + wr_req->r_mtime = ci->netfs.inode.i_mtime; err2 =ceph_osdc_start_request (&fsc->client->osdc, wr_req, false);if (!err)
fs/ceph/cache.c +2 -2
@@ -29,9 +29,9 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)if (!(inode->i_state &I_NEW ))return ; -WARN_ON_ONCE (ci->netfs_ctx.cache); +WARN_ON_ONCE (ci->netfs.cache); - ci->netfs_ctx.cache = + ci->netfs.cache = fscache_acquire_cookie(fsc->fscache, 0, &ci->i_vino, sizeof(ci->i_vino), &ci->i_version, sizeof(ci->i_version),
fs/ceph/cache.h +1 -1
@@ -28,7 +28,7 @@ void ceph_fscache_invalidate(struct inode *inode, bool dio_write);static inline struct fscache_cookie *ceph_fscache_cookie (struct ceph_inode_info *ci) { -return netfs_i_cookie (&ci->vfs_inode); +return netfs_i_cookie (&ci->netfs.inode); }static inline void ceph_fscache_resize (struct inode *inode,loff_t to)
fs/ceph/caps.c +52 -52
380 lines not on this page · raw message
fs/ceph/file.c +1 -1
@@ -205,7 +205,7 @@ static int ceph_init_file_info(struct inode *inode, struct file *file, {struct ceph_inode_info *ci =ceph_inode (inode);struct ceph_mount_options *opt = -ceph_inode_to_client (&ci->vfs_inode)->mount_options; +ceph_inode_to_client (&ci->netfs.inode)->mount_options;struct ceph_file_info *fi;int ret;
fs/ceph/inode.c +5 -5
@@ -176,7 +176,7 @@ static struct ceph_inode_frag *__get_or_create_frag(struct ceph_inode_info *ci,rb_insert_color (&frag->node, &ci->i_fragtree);dout ("get_or_create_frag added %llx.%llx frag %x\n" , -ceph_vinop (&ci->vfs_inode), f); +ceph_vinop (&ci->netfs.inode), f);return frag; }
@@ -457,10 +457,10 @@ struct inode *ceph_alloc_inode(struct super_block *sb)if (!ci)return NULL ; -dout ("alloc_inode %p\n" , &ci->vfs_inode); +dout ("alloc_inode %p\n" , &ci->netfs.inode);/* Set parameters for the netfs library */ -netfs_i_context_init (&ci->vfs_inode, &ceph_netfs_ops); +netfs_inode_init (&ci->netfs.inode, &ceph_netfs_ops);spin_lock_init (&ci->i_ceph_lock);
@@ -547,7 +547,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)INIT_WORK (&ci->i_work, ceph_inode_work); ci->i_work_mask =0 ;memset (&ci->i_btime,'\0' ,sizeof (ci->i_btime)); -return &ci->vfs_inode; +return &ci->netfs.inode; }void ceph_free_inode (struct inode *inode)
@@ -1978,7 +1978,7 @@ static void ceph_inode_work(struct work_struct *work) { struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, i_work); -struct inode *inode = &ci->vfs_inode; +struct inode *inode = &ci->netfs.inode;if (test_and_clear_bit (CEPH_I_WORK_WRITEBACK , &ci->i_work_mask)) {dout ("writeback %p\n" , inode);
fs/ceph/mds_client.c +2 -2
@@ -1564,7 +1564,7 @@ int ceph_iterate_session_caps(struct ceph_mds_session *session, p = session->s_caps.next;while (p != &session->s_caps) { cap = list_entry(p, struct ceph_cap, session_caps); - inode =igrab (&cap->ci->vfs_inode); + inode =igrab (&cap->ci->netfs.inode);if (!inode) { p = p->next;continue ;
@@ -1622,7 +1622,7 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,int iputs;dout ("removing cap %p, ci is %p, inode is %p\n" , - cap, ci, &ci->vfs_inode); + cap, ci, &ci->netfs.inode);spin_lock (&ci->i_ceph_lock); iputs =ceph_purge_inode_cap (inode, cap, &invalidate);spin_unlock (&ci->i_ceph_lock);
fs/ceph/snap.c +4 -4
@@ -521,7 +521,7 @@ static bool has_new_snaps(struct ceph_snap_context *o,static void ceph_queue_cap_snap (struct ceph_inode_info *ci,struct ceph_cap_snap **pcapsnap) { -struct inode *inode = &ci->vfs_inode; +struct inode *inode = &ci->netfs.inode;struct ceph_snap_context *old_snapc, *new_snapc;struct ceph_cap_snap *capsnap = *pcapsnap;struct ceph_buffer *old_blob =NULL ;
@@ -652,7 +652,7 @@ static void ceph_queue_cap_snap(struct ceph_inode_info *ci,int __ceph_finish_cap_snap (struct ceph_inode_info *ci,struct ceph_cap_snap *capsnap) { -struct inode *inode = &ci->vfs_inode; +struct inode *inode = &ci->netfs.inode;struct ceph_mds_client *mdsc =ceph_sb_to_mdsc (inode->i_sb);BUG_ON (capsnap->writing);
@@ -712,7 +712,7 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm *realm)spin_lock (&realm->inodes_with_caps_lock);list_for_each_entry (ci, &realm->inodes_with_caps, i_snap_realm_item) { -struct inode *inode =igrab (&ci->vfs_inode); +struct inode *inode =igrab (&ci->netfs.inode);if (!inode)continue ;spin_unlock (&realm->inodes_with_caps_lock);
@@ -904,7 +904,7 @@ static void flush_snaps(struct ceph_mds_client *mdsc)while (!list_empty (&mdsc->snap_flush_list)) { ci =list_first_entry (&mdsc->snap_flush_list, struct ceph_inode_info, i_snap_flush_item); - inode = &ci->vfs_inode; + inode = &ci->netfs.inode;ihold (inode);spin_unlock (&mdsc->snap_flush_lock);ceph_flush_snaps (ci, &session);
fs/ceph/super.c +1 -1
@@ -876,7 +876,7 @@ mempool_t *ceph_wb_pagevec_pool;static void ceph_inode_init_once (void *foo) {struct ceph_inode_info *ci = foo; -inode_init_once (&ci->vfs_inode); +inode_init_once (&ci->netfs.inode); }static int __init init_caches (void )
fs/ceph/super.h +3 -7
@@ -316,11 +316,7 @@ struct ceph_inode_xattrs_info {* Ceph inode. */ struct ceph_inode_info { -struct { -/* These must be contiguous */ -struct inode vfs_inode; -struct netfs_i_context netfs_ctx;/* Netfslib context */ - }; +struct netfs_inode netfs;/* Netfslib context and vfs inode */ struct ceph_vino i_vino;/* ceph ino + snap */ spinlock_t i_ceph_lock;
@@ -436,7 +432,7 @@ struct ceph_inode_info {static inline struct ceph_inode_info *ceph_inode (const struct inode *inode) { - return container_of(inode, struct ceph_inode_info, vfs_inode); + return container_of(inode, struct ceph_inode_info, netfs.inode); } static inline struct ceph_fs_client *
@@ -1316,7 +1312,7 @@ static inline void __ceph_update_quota(struct ceph_inode_info *ci, has_quota =__ceph_has_quota (ci,QUOTA_GET_ANY );if (had_quota != has_quota) -ceph_adjust_quota_realms_count (&ci->vfs_inode, has_quota); +ceph_adjust_quota_realms_count (&ci->netfs.inode, has_quota); } extern void ceph_handle_quota(struct ceph_mds_client *mdsc,
fs/ceph/xattr.c +7 -7
@@ -57,7 +57,7 @@ static bool ceph_vxattrcb_layout_exists(struct ceph_inode_info *ci)static ssize_t ceph_vxattrcb_layout (struct ceph_inode_info *ci,char *val,size_t size) { -struct ceph_fs_client *fsc =ceph_sb_to_client (ci->vfs_inode.i_sb); +struct ceph_fs_client *fsc =ceph_sb_to_client (ci->netfs.inode.i_sb);struct ceph_osd_client *osdc = &fsc->client->osdc;struct ceph_string *pool_ns;s64 pool = ci->i_layout.pool_id;
@@ -69,7 +69,7 @@ static ssize_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val, pool_ns =ceph_try_get_string (ci->i_layout.pool_ns); -dout ("ceph_vxattrcb_layout %p\n" , &ci->vfs_inode); +dout ("ceph_vxattrcb_layout %p\n" , &ci->netfs.inode);down_read (&osdc->lock); pool_name =ceph_pg_pool_name_by_id (osdc->osdmap, pool);if (pool_name) {
@@ -161,7 +161,7 @@ static ssize_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci, char *val, size_t size) { ssize_t ret; -struct ceph_fs_client *fsc =ceph_sb_to_client (ci->vfs_inode.i_sb); +struct ceph_fs_client *fsc =ceph_sb_to_client (ci->netfs.inode.i_sb);struct ceph_osd_client *osdc = &fsc->client->osdc;s64 pool = ci->i_layout.pool_id;const char *pool_name;
@@ -313,7 +313,7 @@ static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val,static ssize_t ceph_vxattrcb_cluster_fsid (struct ceph_inode_info *ci,char *val,size_t size) { -struct ceph_fs_client *fsc =ceph_sb_to_client (ci->vfs_inode.i_sb); +struct ceph_fs_client *fsc =ceph_sb_to_client (ci->netfs.inode.i_sb);return ceph_fmt_xattr (val, size,"%pU" , &fsc->client->fsid); }
@@ -321,7 +321,7 @@ static ssize_t ceph_vxattrcb_cluster_fsid(struct ceph_inode_info *ci,static ssize_t ceph_vxattrcb_client_id (struct ceph_inode_info *ci,char *val,size_t size) { -struct ceph_fs_client *fsc =ceph_sb_to_client (ci->vfs_inode.i_sb); +struct ceph_fs_client *fsc =ceph_sb_to_client (ci->netfs.inode.i_sb);return ceph_fmt_xattr (val, size,"client%lld" ,ceph_client_gid (fsc->client));
@@ -629,7 +629,7 @@ static int __set_xattr(struct ceph_inode_info *ci, }dout ("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s\n" , -ceph_vinop (&ci->vfs_inode), xattr, name_len, name, val_len, val); +ceph_vinop (&ci->netfs.inode), xattr, name_len, name, val_len, val);return 0 ; }
@@ -871,7 +871,7 @@ struct ceph_buffer *__ceph_build_xattrs_blob(struct ceph_inode_info *ci)struct ceph_buffer *old_blob =NULL ;void *dest; -dout ("__build_xattrs_blob %p\n" , &ci->vfs_inode); +dout ("__build_xattrs_blob %p\n" , &ci->netfs.inode);if (ci->i_xattrs.dirty) {int need =__get_required_blob_size (ci,0 ,0 );
fs/cifs/cifsfs.c +4 -4
@@ -377,7 +377,7 @@ cifs_alloc_inode(struct super_block *sb) cifs_inode->flags =0 ;spin_lock_init (&cifs_inode->writers_lock); cifs_inode->writers =0 ; - cifs_inode->vfs_inode.i_blkbits =14 ;/* 2**14 = CIFS_MAX_MSGSIZE */ + cifs_inode->netfs.inode.i_blkbits =14 ;/* 2**14 = CIFS_MAX_MSGSIZE */ cifs_inode->server_eof =0 ; cifs_inode->uniqueid =0 ; cifs_inode->createtime =0 ;
@@ -389,12 +389,12 @@ cifs_alloc_inode(struct super_block *sb)* Can not set i_flags here - they get immediately overwritten to zero * by the VFS. */ -/* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME; */ +/* cifs_inode->netfs.inode.i_flags = S_NOATIME | S_NOCMTIME; */ INIT_LIST_HEAD (&cifs_inode->openFileList);INIT_LIST_HEAD (&cifs_inode->llist);INIT_LIST_HEAD (&cifs_inode->deferred_closes);spin_lock_init (&cifs_inode->deferred_lock); -return &cifs_inode->vfs_inode; +return &cifs_inode->netfs.inode; } static void
@@ -1418,7 +1418,7 @@ cifs_init_once(void *inode) {struct cifsInodeInfo *cifsi = inode; -inode_init_once (&cifsi->vfs_inode); +inode_init_once (&cifsi->netfs.inode);init_rwsem (&cifsi->lock_sem); }
fs/cifs/cifsglob.h +4 -8
@@ -1479,20 +1479,16 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file);#define CIFS_CACHE_RW_FLG (CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG)#define CIFS_CACHE_RHW_FLG (CIFS_CACHE_RW_FLG | CIFS_CACHE_HANDLE_FLG) -#define CIFS_CACHE_READ (cinode) ((cinode->oplock & CIFS_CACHE_READ_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE)) +#define CIFS_CACHE_READ (cinode) ((cinode->oplock & CIFS_CACHE_READ_FLG) || (CIFS_SB(cinode->netfs.inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE))#define CIFS_CACHE_HANDLE (cinode) (cinode->oplock & CIFS_CACHE_HANDLE_FLG) -#define CIFS_CACHE_WRITE (cinode) ((cinode->oplock & CIFS_CACHE_WRITE_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE)) +#define CIFS_CACHE_WRITE (cinode) ((cinode->oplock & CIFS_CACHE_WRITE_FLG) || (CIFS_SB(cinode->netfs.inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE))/* * One of these for each file inode */ struct cifsInodeInfo { -struct { -/* These must be contiguous */ -struct inode vfs_inode;/* the VFS's inode record */ -struct netfs_i_context netfs_ctx;/* Netfslib context */ - }; +struct netfs_inode netfs;/* Netfslib context and vfs inode */ bool can_cache_brlcks;struct list_head llist;/* locks helb by this inode */ /*
@@ -1531,7 +1527,7 @@ struct cifsInodeInfo {static inline struct cifsInodeInfo *CIFS_I (struct inode *inode) { - return container_of(inode, struct cifsInodeInfo, vfs_inode); + return container_of(inode, struct cifsInodeInfo, netfs.inode); } static inline struct cifs_sb_info *
fs/cifs/file.c +4 -4
@@ -2004,7 +2004,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, bool fsuid_only) {struct cifsFileInfo *open_file =NULL ; -struct cifs_sb_info *cifs_sb =CIFS_SB (cifs_inode->vfs_inode.i_sb); +struct cifs_sb_info *cifs_sb =CIFS_SB (cifs_inode->netfs.inode.i_sb);/* only filter by fsuid on multiuser mounts */ if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER ))
@@ -2060,7 +2060,7 @@ cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags,return rc; } - cifs_sb =CIFS_SB (cifs_inode->vfs_inode.i_sb); + cifs_sb =CIFS_SB (cifs_inode->netfs.inode.i_sb);/* only filter by fsuid on multiuser mounts */ if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER ))
@@ -4669,14 +4669,14 @@ bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)/* This inode is open for write at least once */ struct cifs_sb_info *cifs_sb; - cifs_sb =CIFS_SB (cifsInode->vfs_inode.i_sb); + cifs_sb =CIFS_SB (cifsInode->netfs.inode.i_sb);if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_DIRECT_IO ) {/* since no page cache to corrupt on directio we can change size safely */ return true; } -if (i_size_read (&cifsInode->vfs_inode) < end_of_file) +if (i_size_read (&cifsInode->netfs.inode) < end_of_file)return true;return false;
fs/cifs/fscache.c +4 -4
@@ -101,13 +101,13 @@ void cifs_fscache_get_inode_cookie(struct inode *inode)struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);struct cifs_tcon *tcon =cifs_sb_master_tcon (cifs_sb); -cifs_fscache_fill_coherency (&cifsi->vfs_inode, &cd); +cifs_fscache_fill_coherency (&cifsi->netfs.inode, &cd); - cifsi->netfs_ctx.cache = + cifsi->netfs.cache =fscache_acquire_cookie (tcon->fscache,0 , &cifsi->uniqueid,sizeof (cifsi->uniqueid), &cd,sizeof (cd), -i_size_read (&cifsi->vfs_inode)); +i_size_read (&cifsi->netfs.inode)); }void cifs_fscache_unuse_inode_cookie (struct inode *inode,bool update)
@@ -131,7 +131,7 @@ void cifs_fscache_release_inode_cookie(struct inode *inode)if (cookie) {cifs_dbg (FYI ,"%s: (0x%p)\n" , __func__, cookie);fscache_relinquish_cookie (cookie, false); - cifsi->netfs_ctx.cache =NULL ; + cifsi->netfs.cache =NULL ; } }
fs/cifs/fscache.h +4 -4
@@ -52,10 +52,10 @@ void cifs_fscache_fill_coherency(struct inode *inode,struct cifsInodeInfo *cifsi =CIFS_I (inode);memset (cd,0 ,sizeof (*cd)); - cd->last_write_time_sec =cpu_to_le64 (cifsi->vfs_inode.i_mtime.tv_sec); - cd->last_write_time_nsec =cpu_to_le32 (cifsi->vfs_inode.i_mtime.tv_nsec); - cd->last_change_time_sec =cpu_to_le64 (cifsi->vfs_inode.i_ctime.tv_sec); - cd->last_change_time_nsec =cpu_to_le32 (cifsi->vfs_inode.i_ctime.tv_nsec); + cd->last_write_time_sec =cpu_to_le64 (cifsi->netfs.inode.i_mtime.tv_sec); + cd->last_write_time_nsec =cpu_to_le32 (cifsi->netfs.inode.i_mtime.tv_nsec); + cd->last_change_time_sec =cpu_to_le64 (cifsi->netfs.inode.i_ctime.tv_sec); + cd->last_change_time_nsec =cpu_to_le32 (cifsi->netfs.inode.i_ctime.tv_nsec); }
fs/cifs/inode.c +2 -2
@@ -115,7 +115,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr) __func__, cifs_i->uniqueid);set_bit (CIFS_INO_INVALID_MAPPING , &cifs_i->flags);/* Invalidate fscache cookie */ -cifs_fscache_fill_coherency (&cifs_i->vfs_inode, &cd); +cifs_fscache_fill_coherency (&cifs_i->netfs.inode, &cd);fscache_invalidate (cifs_inode_cookie (inode), &cd,i_size_read (inode),0 ); }
@@ -2499,7 +2499,7 @@ int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start, u64 len) {struct cifsInodeInfo *cifs_i =CIFS_I (inode); -struct cifs_sb_info *cifs_sb =CIFS_SB (cifs_i->vfs_inode.i_sb); +struct cifs_sb_info *cifs_sb =CIFS_SB (cifs_i->netfs.inode.i_sb);struct cifs_tcon *tcon =cifs_sb_master_tcon (cifs_sb);struct TCP_Server_Info *server = tcon->ses->server;struct cifsFileInfo *cfile;
fs/cifs/misc.c +2 -2
@@ -537,11 +537,11 @@ void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)if (oplock ==OPLOCK_EXCLUSIVE ) { cinode->oplock =CIFS_CACHE_WRITE_FLG |CIFS_CACHE_READ_FLG ;cifs_dbg (FYI ,"Exclusive Oplock granted on inode %p\n" , - &cinode->vfs_inode); + &cinode->netfs.inode); }else if (oplock ==OPLOCK_READ ) { cinode->oplock =CIFS_CACHE_READ_FLG ;cifs_dbg (FYI ,"Level II Oplock granted on inode %p\n" , - &cinode->vfs_inode); + &cinode->netfs.inode); }else cinode->oplock =0 ; }
fs/cifs/smb2ops.c +4 -4
@@ -4260,15 +4260,15 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,if (oplock ==SMB2_OPLOCK_LEVEL_BATCH ) { cinode->oplock =CIFS_CACHE_RHW_FLG ;cifs_dbg (FYI ,"Batch Oplock granted on inode %p\n" , - &cinode->vfs_inode); + &cinode->netfs.inode); }else if (oplock ==SMB2_OPLOCK_LEVEL_EXCLUSIVE ) { cinode->oplock =CIFS_CACHE_RW_FLG ;cifs_dbg (FYI ,"Exclusive Oplock granted on inode %p\n" , - &cinode->vfs_inode); + &cinode->netfs.inode); }else if (oplock ==SMB2_OPLOCK_LEVEL_II ) { cinode->oplock =CIFS_CACHE_READ_FLG ;cifs_dbg (FYI ,"Level II Oplock granted on inode %p\n" , - &cinode->vfs_inode); + &cinode->netfs.inode); }else cinode->oplock =0 ; }
@@ -4307,7 +4307,7 @@ smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock, cinode->oplock = new_oplock;cifs_dbg (FYI ,"%s Lease granted on inode %p\n" , message, - &cinode->vfs_inode); + &cinode->netfs.inode); } static void
fs/netfs/buffered_read.c +3 -3
@@ -155,7 +155,7 @@ static void netfs_rreq_expand(struct netfs_io_request *rreq,void netfs_readahead (struct readahead_control *ractl) {struct netfs_io_request *rreq; -struct netfs_i_context *ctx =netfs_i_context (ractl->mapping->host); +struct netfs_inode *ctx =netfs_inode (ractl->mapping->host);int ret;_enter ("%lx,%x" ,readahead_index (ractl),readahead_count (ractl));
@@ -215,7 +215,7 @@ int netfs_read_folio(struct file *file, struct folio *folio) {struct address_space *mapping =folio_file_mapping (folio);struct netfs_io_request *rreq; -struct netfs_i_context *ctx =netfs_i_context (mapping->host); +struct netfs_inode *ctx =netfs_inode (mapping->host);int ret;_enter ("%lx" ,folio_index (folio));
@@ -331,7 +331,7 @@ int netfs_write_begin(struct file *file, struct address_space *mapping, void **_fsdata) {struct netfs_io_request *rreq; -struct netfs_i_context *ctx =netfs_i_context (file_inode (file )); +struct netfs_inode *ctx =netfs_inode (file_inode (file ));struct folio *folio;unsigned int fgp_flags =FGP_LOCK |FGP_WRITE |FGP_CREAT |FGP_STABLE ;pgoff_t index = pos >>PAGE_SHIFT ;
fs/netfs/internal.h +1 -1
@@ -91,7 +91,7 @@ static inline void netfs_stat_d(atomic_t *stat)/* * Miscellaneous functions. */ -static inline bool netfs_is_cache_enabled (struct netfs_i_context *ctx) +static inline bool netfs_is_cache_enabled (struct netfs_inode *ctx) {#if IS_ENABLED (CONFIG_FSCACHE )struct fscache_cookie *cookie = ctx->cache;
fs/netfs/objects.c +1 -1
@@ -18,7 +18,7 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, {static atomic_t debug_ids;struct inode *inode = file ?file_inode (file) : mapping->host; -struct netfs_i_context *ctx =netfs_i_context (inode); +struct netfs_inode *ctx =netfs_inode (inode);struct netfs_io_request *rreq;int ret;
include/linux/netfs.h +16 -25
91 lines not on this page · raw message
Review
Quoted 9 lines · David Howells
struct my_inode {(quoted diff) +1
-5- struct { - /* These must be contiguous */ - struct inode vfs_inode; - struct netfs_i_context netfs_ctx; - }; + struct netfs_inode netfs; /* Netfslib context and vfs inode */
Side note: I think this could have been done with an unnamed union as
struct my_inode {
union {
struct inode vfs_inode;
struct netfs_inode netfs_inode;
};
[...]instead, with the rule that 'netfs_inode' always starts with a 'struct inode'.
The advantage would have been that the old 'vfs_inode' syntax would have continued to work, and much less of the ugliness.
So a fair amount of the noise in this patch could have been avoided.
That said, I think the end result is fine (and maybe less complicated than using that union trick), so that's not the big deal.
But what I actually *really* detest in this patch is that
struct netfs_inode *ctx = netfs_inode(file_inode(file));
pattern.
In several cases that's just a different syntax for almost the same problem that gcc-12 already complained about.
And yes, in some cases you do need it - particularly in the "mapping->host" situation, you really have lost sight of the fact that you really have a "struct netfs_inode *", and all you have is the "struct inode *".
But in a lot of cases you really could do so much better: you *have* a "struct netfs_inode" to begin with, but you converted it to just "struct inode *", and now you're converting it back.
Look at that AFS code, for example, where we have afs_vnode_cache() doing
return netfs_i_cookie(&vnode->netfs.inode);
and look how it *had* a netfs structure, and it was passing it to a netfs function, but it explicitly passed the WRONG TYPE, so now we've lost the type information and it is using that cast to fake it all back.
So I think the 'netfs' functions should take a 'struct netfs_inode *ctx' as their argument.
Because the callers know what kind of inode they have, and they can - and should - then pass the proper netfs context down.
IOW, I think you really should do something like the attached on top of this all.
Only *very* lightly build-tested, but let me quote part of the diff to explain:
-static inline struct fscache_cookie *netfs_i_cookie(struct inode *inode)
+static inline struct fscache_cookie *netfs_i_cookie(struct netfs_inode *ctx)
{
#if IS_ENABLED(CONFIG_FSCACHE)
- struct netfs_inode *ctx = netfs_inode(inode);
return ctx->cache;
#elselook, this part is obvious. If you are doing a "netfs_i_cookie()" call, you had *better* know that you actually have a netfs_inode, not some random "inode".
And most of the users already knew exactly that, so other paths of the patch actually get cleaner too:
- return netfs_i_cookie(&v9inode->netfs.inode);
+ return netfs_i_cookie(&v9inode->netfs);
but even when that wasn't the case, as in netfs_inode_init() use, we have:
static void v9fs_set_netfs_context(struct inode *inode) {
- netfs_inode_init(inode, &v9fs_req_ops); + struct v9fs_inode *v9inode = V9FS_I(inode); + netfs_inode_init(&v9inode->netfs, &v9fs_req_ops);
}
and now we're basically doing that same "taek inode pointer, convert it to someting else" that I'm complaining about wrt the netfs code, but notice how we are now doing it within the context of the 9p filesystem.
So now we're converting not a 'random inode pointer that could come from many different filesystems', but an *actual* well-defined 'this is a 9p inode, so doing that V9FS_I(inode) conversion is normal' kind of situation.
And at that point, we now have that 'struct netfs_inode' directly, and don't need to play any other games.
Yes, a few 'netfs_inode()' users still remain. I don't love them either, but they tend to be places where we really did get just the raw inode pointer from the VFS layer (eg netfs_readahead is just used directly as the ".readahead" function for filesystems).
Hmm?
Linus
fs/9p/v9fs.h | 2 +- fs/9p/vfs_addr.c | 2 +- fs/9p/vfs_inode.c | 3 ++- fs/afs/dynroot.c | 2 +- fs/afs/inode.c | 2 +- fs/afs/internal.h | 2 +- fs/afs/write.c | 2 +- fs/ceph/addr.c | 3 ++- fs/ceph/cache.h | 2 +- fs/ceph/inode.c | 2 +- fs/cifs/fscache.h | 2 +- fs/netfs/buffered_read.c | 4 ++-- include/linux/netfs.h | 16 ++++++---------- 13 files changed, 21 insertions(+), 23 deletions(-)
fs/9p/v9fs.h +1 -1
@@ -124,7 +124,7 @@ static inline struct v9fs_inode *V9FS_I(const struct inode *inode)static inline struct fscache_cookie *v9fs_inode_cookie (struct v9fs_inode *v9inode) {#ifdef CONFIG_9P_FSCACHE -return netfs_i_cookie (&v9inode->netfs.inode); +return netfs_i_cookie (&v9inode->netfs);#else return NULL ;#endif
fs/9p/vfs_addr.c +1 -1
@@ -274,7 +274,7 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,* file. We need to do this before we get a lock on the page in case * there's more than one writer competing for the same cache block. */ - retval =netfs_write_begin (filp, mapping, pos, len, &folio, fsdata); + retval =netfs_write_begin (&v9inode->netfs, filp, mapping, pos, len, &folio, fsdata);if (retval <0 )return retval;
fs/9p/vfs_inode.c +2 -1
@@ -252,7 +252,8 @@ void v9fs_free_inode(struct inode *inode)*/ static void v9fs_set_netfs_context (struct inode *inode) { -netfs_inode_init (inode, &v9fs_req_ops); +struct v9fs_inode *v9inode =V9FS_I (inode); +netfs_inode_init (&v9inode->netfs, &v9fs_req_ops); } int v9fs_init_inode(struct v9fs_session_info *v9ses,
fs/afs/dynroot.c +1 -1
@@ -76,7 +76,7 @@ struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)/* there shouldn't be an existing inode */ BUG_ON (!(inode->i_state &I_NEW )); -netfs_inode_init (inode,NULL ); +netfs_inode_init (&vnode->netfs,NULL ); inode->i_size =0 ; inode->i_mode =S_IFDIR |S_IRUGO |S_IXUGO ;if (root) {
fs/afs/inode.c +1 -1
@@ -58,7 +58,7 @@ static noinline void dump_vnode(struct afs_vnode *vnode, struct afs_vnode *paren*/ static void afs_set_netfs_context (struct afs_vnode *vnode) { -netfs_inode_init (&vnode->netfs.inode, &afs_req_ops); +netfs_inode_init (&vnode->netfs, &afs_req_ops); }/*
fs/afs/internal.h +1 -1
@@ -670,7 +670,7 @@ struct afs_vnode {static inline struct fscache_cookie *afs_vnode_cache (struct afs_vnode *vnode) {#ifdef CONFIG_AFS_FSCACHE -return netfs_i_cookie (&vnode->netfs.inode); +return netfs_i_cookie (&vnode->netfs);#else return NULL ;#endif
fs/afs/write.c +1 -1
@@ -60,7 +60,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,* file. We need to do this before we get a lock on the page in case * there's more than one writer competing for the same cache block. */ - ret =netfs_write_begin (file, mapping, pos, len, &folio, fsdata); + ret =netfs_write_begin (&vnode->netfs, file, mapping, pos, len, &folio, fsdata);if (ret <0 )return ret;
fs/ceph/addr.c +2 -1
@@ -1322,10 +1322,11 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping, struct page **pagep, void **fsdata) { struct inode *inode = file_inode(file); +struct ceph_inode_info *ci =ceph_inode (inode);struct folio *folio =NULL ;int r; - r =netfs_write_begin (file, inode->i_mapping, pos, len, &folio,NULL ); + r =netfs_write_begin (&ci->netfs, file, inode->i_mapping, pos, len, &folio,NULL );if (r ==0 )folio_wait_fscache (folio);if (r <0 ) {
fs/ceph/cache.h +1 -1
@@ -28,7 +28,7 @@ void ceph_fscache_invalidate(struct inode *inode, bool dio_write);static inline struct fscache_cookie *ceph_fscache_cookie (struct ceph_inode_info *ci) { -return netfs_i_cookie (&ci->netfs.inode); +return netfs_i_cookie (&ci->netfs); }static inline void ceph_fscache_resize (struct inode *inode,loff_t to)
fs/ceph/inode.c +1 -1
@@ -460,7 +460,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)dout ("alloc_inode %p\n" , &ci->netfs.inode);/* Set parameters for the netfs library */ -netfs_inode_init (&ci->netfs.inode, &ceph_netfs_ops); +netfs_inode_init (&ci->netfs, &ceph_netfs_ops);spin_lock_init (&ci->i_ceph_lock);
fs/cifs/fscache.h +1 -1
@@ -61,7 +61,7 @@ void cifs_fscache_fill_coherency(struct inode *inode,static inline struct fscache_cookie *cifs_inode_cookie (struct inode *inode) { -return netfs_i_cookie (inode); +return netfs_i_cookie (&CIFS_I (inode)->netfs); }static inline void cifs_invalidate_cache (struct inode *inode,unsigned int flags)
fs/netfs/buffered_read.c +2 -2
@@ -326,12 +326,12 @@ static bool netfs_skip_folio_read(struct folio *folio, loff_t pos, size_t len,* * This is usable whether or not caching is enabled. */ -int netfs_write_begin (struct file *file,struct address_space *mapping, +int netfs_write_begin (struct netfs_inode *ctx, +struct file *file,struct address_space *mapping,loff_t pos,unsigned int len,struct folio **_folio,void **_fsdata) {struct netfs_io_request *rreq; -struct netfs_inode *ctx =netfs_inode (file_inode (file ));struct folio *folio;unsigned int fgp_flags =FGP_LOCK |FGP_WRITE |FGP_CREAT |FGP_STABLE ;pgoff_t index = pos >>PAGE_SHIFT ;
include/linux/netfs.h +6 -10
@@ -277,7 +277,8 @@ struct netfs_cache_ops {struct readahead_control ;extern void netfs_readahead (struct readahead_control *);int netfs_read_folio (struct file *,struct folio *); -extern int netfs_write_begin (struct file *,struct address_space *, +extern int netfs_write_begin (struct netfs_inode *, +struct file *,struct address_space *,loff_t ,unsigned int ,struct folio **,void **);
@@ -308,13 +309,11 @@ static inline struct netfs_inode *netfs_inode(struct inode *inode)* Initialise the netfs library context struct. This is expected to follow on * directly from the VFS inode struct. */ -static inline void netfs_inode_init (struct inode *inode, +static inline void netfs_inode_init (struct netfs_inode *ctx,const struct netfs_request_ops *ops) { -struct netfs_inode *ctx =netfs_inode (inode); - ctx->ops = ops; - ctx->remote_i_size =i_size_read (inode); + ctx->remote_i_size =i_size_read (&ctx->inode);#if IS_ENABLED (CONFIG_FSCACHE ) ctx->cache =NULL ;#endif
@@ -327,10 +326,8 @@ static inline void netfs_inode_init(struct inode *inode,* * Inform the netfs lib that a file got resized so that it can adjust its state. */ -static inline void netfs_resize_file (struct inode *inode,loff_t new_i_size) +static inline void netfs_resize_file (struct netfs_inode *ctx,loff_t new_i_size) { -struct netfs_inode *ctx =netfs_inode (inode); - ctx->remote_i_size = new_i_size; }
@@ -340,10 +337,9 @@ static inline void netfs_resize_file(struct inode *inode, loff_t new_i_size)* * Get the caching cookie (if enabled) from the network filesystem's inode. */ -static inline struct fscache_cookie *netfs_i_cookie (struct inode *inode) +static inline struct fscache_cookie *netfs_i_cookie (struct netfs_inode *ctx) {#if IS_ENABLED (CONFIG_FSCACHE ) -struct netfs_inode *ctx =netfs_inode (inode);return ctx->cache;#else return NULL ;
Quoted 3 lines · Linus Torvalds
IOW, I think you really should do something like the attached on top of this all.
Just to clarify: I did apply your patch. It's an improvement on what used to go on.
I just think it wasn't as much of an improvement that it should have been, and that largely untested patch I attached is I think another step in a better direction.
Linus
David Howells
maintainerQuoted 10 lines · Linus Torvalds
Side note: I think this could have been done with an unnamed union as
struct my_inode { union { struct inode vfs_inode; struct netfs_inode netfs_inode; }; [...]instead, with the rule that '
netfs_inode' always starts with a 'struct inode'.
I'm slightly wary of that, lest struct netfs_inode gets randomised. I'm not sure how likely that would be without netfs_inode getting explicitly marked.
Quoted 4 lines
But in a lot of cases you really could do so much better: you *have* a "struct
netfs_inode" to begin with, but you converted it to just "struct inode *", and now you're converting it back.
Quoted 8 lines
Look at that AFS code, for example, where we have
afs_vnode_cache()doingreturn netfs_i_cookie(&vnode->netfs.inode);and look how it *had* a netfs structure, and it was passing it to a netfs function, but it explicitly passed the WRONG TYPE, so now we've lost the type information and it is using that cast to fake it all back.
Yeah, I didn't look at those as they didn't cause warnings, but you're right - those should take struct netfs_inode pointers in some cases, rather than struct inode.
Note that some functions, such as netfs_readpage() and netfs_readpages() do need to take struct inode pointers as I'm trying to get the VFS ops to jump into netfslib and get all the VM interface stuff out of the network filesystems - the idea being that the network filesystem will provide netfslib primarily with two functions: do a read op and do a write op.
I'll have a look at your patch in a bit.
Thanks,
David