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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'fscache-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs

Pull fscache cleanups from David Howells:

- fix checker complaint in afs

- two netfs cleanups:

- netfs_inode calling convention cleanup plus the requisite
documentation changes

- replace the ->cleanup op with a ->free_request op.

This is possible as the I/O request is now always available at
the cleanup point as the stuff to be cleaned up is no longer
passed into the API functions, but rather obtained by ->init_request.

* 'fscache-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
netfs: Rename the netfs_io_request cleanup op and give it an op pointer
netfs: Further cleanups after struct netfs_inode wrapper introduced
afs: Fix some checker issues

+60 -62
+17 -16
Documentation/filesystems/netfs_library.rst
··· 79 79 provided. Firstly, a function to perform basic initialisation on a context and 80 80 set the operations table pointer:: 81 81 82 - void netfs_inode_init(struct inode *inode, 82 + void netfs_inode_init(struct netfs_inode *ctx, 83 83 const struct netfs_request_ops *ops); 84 84 85 85 then a function to cast from the VFS inode structure to the netfs context:: ··· 89 89 and finally, a function to get the cache cookie pointer from the context 90 90 attached to an inode (or NULL if fscache is disabled):: 91 91 92 - struct fscache_cookie *netfs_i_cookie(struct inode *inode); 92 + struct fscache_cookie *netfs_i_cookie(struct netfs_inode *ctx); 93 93 94 94 95 95 Buffered Read Helpers ··· 136 136 137 137 void netfs_readahead(struct readahead_control *ractl); 138 138 int netfs_read_folio(struct file *file, 139 - struct folio *folio); 140 - int netfs_write_begin(struct file *file, 139 + struct folio *folio); 140 + int netfs_write_begin(struct netfs_inode *ctx, 141 + struct file *file, 141 142 struct address_space *mapping, 142 143 loff_t pos, 143 144 unsigned int len, ··· 158 157 through the suppplied table of operations. Waits will be performed as 159 158 necessary before returning for helpers that are meant to be synchronous. 160 159 161 - If an error occurs and netfs_priv is non-NULL, ops->cleanup() will be called to 162 - deal with it. If some parts of the request are in progress when an error 163 - occurs, the request will get partially completed if sufficient data is read. 160 + If an error occurs, the ->free_request() will be called to clean up the 161 + netfs_io_request struct allocated. If some parts of the request are in 162 + progress when an error occurs, the request will get partially completed if 163 + sufficient data is read. 164 164 165 165 Additionally, there is:: 166 166 ··· 209 207 * ``netfs_priv`` 210 208 211 209 The network filesystem's private data. The value for this can be passed in 212 - to the helper functions or set during the request. The ->cleanup() op will 213 - be called if this is non-NULL at the end. 210 + to the helper functions or set during the request. 214 211 215 212 * ``start`` 216 213 * ``len`` ··· 294 293 295 294 struct netfs_request_ops { 296 295 void (*init_request)(struct netfs_io_request *rreq, struct file *file); 296 + void (*free_request)(struct netfs_io_request *rreq); 297 297 int (*begin_cache_operation)(struct netfs_io_request *rreq); 298 298 void (*expand_readahead)(struct netfs_io_request *rreq); 299 299 bool (*clamp_length)(struct netfs_io_subrequest *subreq); ··· 303 301 int (*check_write_begin)(struct file *file, loff_t pos, unsigned len, 304 302 struct folio *folio, void **_fsdata); 305 303 void (*done)(struct netfs_io_request *rreq); 306 - void (*cleanup)(struct address_space *mapping, void *netfs_priv); 307 304 }; 308 305 309 306 The operations are as follows: ··· 310 309 * ``init_request()`` 311 310 312 311 [Optional] This is called to initialise the request structure. It is given 313 - the file for reference and can modify the ->netfs_priv value. 312 + the file for reference. 313 + 314 + * ``free_request()`` 315 + 316 + [Optional] This is called as the request is being deallocated so that the 317 + filesystem can clean up any state it has attached there. 314 318 315 319 * ``begin_cache_operation()`` 316 320 ··· 388 382 389 383 [Optional] This is called after the folios in the request have all been 390 384 unlocked (and marked uptodate if applicable). 391 - 392 - * ``cleanup`` 393 - 394 - [Optional] This is called as the request is being deallocated so that the 395 - filesystem can clean up ->netfs_priv. 396 385 397 386 398 387
+1 -1
fs/9p/v9fs.h
··· 124 124 static inline struct fscache_cookie *v9fs_inode_cookie(struct v9fs_inode *v9inode) 125 125 { 126 126 #ifdef CONFIG_9P_FSCACHE 127 - return netfs_i_cookie(&v9inode->netfs.inode); 127 + return netfs_i_cookie(&v9inode->netfs); 128 128 #else 129 129 return NULL; 130 130 #endif
+6 -7
fs/9p/vfs_addr.c
··· 66 66 } 67 67 68 68 /** 69 - * v9fs_req_cleanup - Cleanup request initialized by v9fs_init_request 70 - * @mapping: unused mapping of request to cleanup 71 - * @priv: private data to cleanup, a fid, guaranted non-null. 69 + * v9fs_free_request - Cleanup request initialized by v9fs_init_rreq 70 + * @rreq: The I/O request to clean up 72 71 */ 73 - static void v9fs_req_cleanup(struct address_space *mapping, void *priv) 72 + static void v9fs_free_request(struct netfs_io_request *rreq) 74 73 { 75 - struct p9_fid *fid = priv; 74 + struct p9_fid *fid = rreq->netfs_priv; 76 75 77 76 p9_client_clunk(fid); 78 77 } ··· 93 94 94 95 const struct netfs_request_ops v9fs_req_ops = { 95 96 .init_request = v9fs_init_request, 97 + .free_request = v9fs_free_request, 96 98 .begin_cache_operation = v9fs_begin_cache_operation, 97 99 .issue_read = v9fs_issue_read, 98 - .cleanup = v9fs_req_cleanup, 99 100 }; 100 101 101 102 /** ··· 273 274 * file. We need to do this before we get a lock on the page in case 274 275 * there's more than one writer competing for the same cache block. 275 276 */ 276 - retval = netfs_write_begin(filp, mapping, pos, len, &folio, fsdata); 277 + retval = netfs_write_begin(&v9inode->netfs, filp, mapping, pos, len, &folio, fsdata); 277 278 if (retval < 0) 278 279 return retval; 279 280
+2 -1
fs/9p/vfs_inode.c
··· 252 252 */ 253 253 static void v9fs_set_netfs_context(struct inode *inode) 254 254 { 255 - netfs_inode_init(inode, &v9fs_req_ops); 255 + struct v9fs_inode *v9inode = V9FS_I(inode); 256 + netfs_inode_init(&v9inode->netfs, &v9fs_req_ops); 256 257 } 257 258 258 259 int v9fs_init_inode(struct v9fs_session_info *v9ses,
+1 -1
fs/afs/dynroot.c
··· 76 76 /* there shouldn't be an existing inode */ 77 77 BUG_ON(!(inode->i_state & I_NEW)); 78 78 79 - netfs_inode_init(inode, NULL); 79 + netfs_inode_init(&vnode->netfs, NULL); 80 80 inode->i_size = 0; 81 81 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; 82 82 if (root) {
+3 -3
fs/afs/file.c
··· 382 382 return test_bit(AFS_VNODE_DELETED, &vnode->flags) ? -ESTALE : 0; 383 383 } 384 384 385 - static void afs_priv_cleanup(struct address_space *mapping, void *netfs_priv) 385 + static void afs_free_request(struct netfs_io_request *rreq) 386 386 { 387 - key_put(netfs_priv); 387 + key_put(rreq->netfs_priv); 388 388 } 389 389 390 390 const struct netfs_request_ops afs_req_ops = { 391 391 .init_request = afs_init_request, 392 + .free_request = afs_free_request, 392 393 .begin_cache_operation = afs_begin_cache_operation, 393 394 .check_write_begin = afs_check_write_begin, 394 395 .issue_read = afs_issue_read, 395 - .cleanup = afs_priv_cleanup, 396 396 }; 397 397 398 398 int afs_write_inode(struct inode *inode, struct writeback_control *wbc)
+1 -1
fs/afs/inode.c
··· 58 58 */ 59 59 static void afs_set_netfs_context(struct afs_vnode *vnode) 60 60 { 61 - netfs_inode_init(&vnode->netfs.inode, &afs_req_ops); 61 + netfs_inode_init(&vnode->netfs, &afs_req_ops); 62 62 } 63 63 64 64 /*
+1 -1
fs/afs/internal.h
··· 670 670 static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode) 671 671 { 672 672 #ifdef CONFIG_AFS_FSCACHE 673 - return netfs_i_cookie(&vnode->netfs.inode); 673 + return netfs_i_cookie(&vnode->netfs); 674 674 #else 675 675 return NULL; 676 676 #endif
+1 -2
fs/afs/volume.c
··· 9 9 #include <linux/slab.h> 10 10 #include "internal.h" 11 11 12 - unsigned __read_mostly afs_volume_gc_delay = 10; 13 - unsigned __read_mostly afs_volume_record_life = 60 * 60; 12 + static unsigned __read_mostly afs_volume_record_life = 60 * 60; 14 13 15 14 /* 16 15 * Insert a volume into a cell. If there's an existing volume record, that is
+1 -1
fs/afs/write.c
··· 60 60 * file. We need to do this before we get a lock on the page in case 61 61 * there's more than one writer competing for the same cache block. 62 62 */ 63 - ret = netfs_write_begin(file, mapping, pos, len, &folio, fsdata); 63 + ret = netfs_write_begin(&vnode->netfs, file, mapping, pos, len, &folio, fsdata); 64 64 if (ret < 0) 65 65 return ret; 66 66
+6 -6
fs/ceph/addr.c
··· 394 394 return 0; 395 395 } 396 396 397 - static void ceph_readahead_cleanup(struct address_space *mapping, void *priv) 397 + static void ceph_netfs_free_request(struct netfs_io_request *rreq) 398 398 { 399 - struct inode *inode = mapping->host; 400 - struct ceph_inode_info *ci = ceph_inode(inode); 401 - int got = (uintptr_t)priv; 399 + struct ceph_inode_info *ci = ceph_inode(rreq->inode); 400 + int got = (uintptr_t)rreq->netfs_priv; 402 401 403 402 if (got) 404 403 ceph_put_cap_refs(ci, got); ··· 405 406 406 407 const struct netfs_request_ops ceph_netfs_ops = { 407 408 .init_request = ceph_init_request, 409 + .free_request = ceph_netfs_free_request, 408 410 .begin_cache_operation = ceph_begin_cache_operation, 409 411 .issue_read = ceph_netfs_issue_read, 410 412 .expand_readahead = ceph_netfs_expand_readahead, 411 413 .clamp_length = ceph_netfs_clamp_length, 412 414 .check_write_begin = ceph_netfs_check_write_begin, 413 - .cleanup = ceph_readahead_cleanup, 414 415 }; 415 416 416 417 #ifdef CONFIG_CEPH_FSCACHE ··· 1321 1322 struct page **pagep, void **fsdata) 1322 1323 { 1323 1324 struct inode *inode = file_inode(file); 1325 + struct ceph_inode_info *ci = ceph_inode(inode); 1324 1326 struct folio *folio = NULL; 1325 1327 int r; 1326 1328 1327 - r = netfs_write_begin(file, inode->i_mapping, pos, len, &folio, NULL); 1329 + r = netfs_write_begin(&ci->netfs, file, inode->i_mapping, pos, len, &folio, NULL); 1328 1330 if (r == 0) 1329 1331 folio_wait_fscache(folio); 1330 1332 if (r < 0) {
+1 -1
fs/ceph/cache.h
··· 28 28 29 29 static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci) 30 30 { 31 - return netfs_i_cookie(&ci->netfs.inode); 31 + return netfs_i_cookie(&ci->netfs); 32 32 } 33 33 34 34 static inline void ceph_fscache_resize(struct inode *inode, loff_t to)
+1 -1
fs/ceph/inode.c
··· 460 460 dout("alloc_inode %p\n", &ci->netfs.inode); 461 461 462 462 /* Set parameters for the netfs library */ 463 - netfs_inode_init(&ci->netfs.inode, &ceph_netfs_ops); 463 + netfs_inode_init(&ci->netfs, &ceph_netfs_ops); 464 464 465 465 spin_lock_init(&ci->i_ceph_lock); 466 466
+1 -1
fs/cifs/fscache.h
··· 61 61 62 62 static inline struct fscache_cookie *cifs_inode_cookie(struct inode *inode) 63 63 { 64 - return netfs_i_cookie(inode); 64 + return netfs_i_cookie(&CIFS_I(inode)->netfs); 65 65 } 66 66 67 67 static inline void cifs_invalidate_cache(struct inode *inode, unsigned int flags)
+3 -2
fs/netfs/buffered_read.c
··· 297 297 298 298 /** 299 299 * netfs_write_begin - Helper to prepare for writing 300 + * @ctx: The netfs context 300 301 * @file: The file to read from 301 302 * @mapping: The mapping to read from 302 303 * @pos: File position at which the write will begin ··· 327 326 * 328 327 * This is usable whether or not caching is enabled. 329 328 */ 330 - int netfs_write_begin(struct file *file, struct address_space *mapping, 329 + int netfs_write_begin(struct netfs_inode *ctx, 330 + struct file *file, struct address_space *mapping, 331 331 loff_t pos, unsigned int len, struct folio **_folio, 332 332 void **_fsdata) 333 333 { 334 334 struct netfs_io_request *rreq; 335 - struct netfs_inode *ctx = netfs_inode(file_inode(file )); 336 335 struct folio *folio; 337 336 unsigned int fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE; 338 337 pgoff_t index = pos >> PAGE_SHIFT;
+3 -3
fs/netfs/objects.c
··· 75 75 struct netfs_io_request *rreq = 76 76 container_of(work, struct netfs_io_request, work); 77 77 78 - netfs_clear_subrequests(rreq, false); 79 - if (rreq->netfs_priv) 80 - rreq->netfs_ops->cleanup(rreq->mapping, rreq->netfs_priv); 81 78 trace_netfs_rreq(rreq, netfs_rreq_trace_free); 79 + netfs_clear_subrequests(rreq, false); 80 + if (rreq->netfs_ops->free_request) 81 + rreq->netfs_ops->free_request(rreq); 82 82 if (rreq->cache_resources.ops) 83 83 rreq->cache_resources.ops->end_operation(&rreq->cache_resources); 84 84 kfree(rreq);
+11 -14
include/linux/netfs.h
··· 206 206 */ 207 207 struct netfs_request_ops { 208 208 int (*init_request)(struct netfs_io_request *rreq, struct file *file); 209 + void (*free_request)(struct netfs_io_request *rreq); 209 210 int (*begin_cache_operation)(struct netfs_io_request *rreq); 211 + 210 212 void (*expand_readahead)(struct netfs_io_request *rreq); 211 213 bool (*clamp_length)(struct netfs_io_subrequest *subreq); 212 214 void (*issue_read)(struct netfs_io_subrequest *subreq); ··· 216 214 int (*check_write_begin)(struct file *file, loff_t pos, unsigned len, 217 215 struct folio *folio, void **_fsdata); 218 216 void (*done)(struct netfs_io_request *rreq); 219 - void (*cleanup)(struct address_space *mapping, void *netfs_priv); 220 217 }; 221 218 222 219 /* ··· 278 277 struct readahead_control; 279 278 extern void netfs_readahead(struct readahead_control *); 280 279 int netfs_read_folio(struct file *, struct folio *); 281 - extern int netfs_write_begin(struct file *, struct address_space *, 280 + extern int netfs_write_begin(struct netfs_inode *, 281 + struct file *, struct address_space *, 282 282 loff_t, unsigned int, struct folio **, 283 283 void **); 284 284 ··· 304 302 305 303 /** 306 304 * netfs_inode_init - Initialise a netfslib inode context 307 - * @inode: The inode with which the context is associated 305 + * @inode: The netfs inode to initialise 308 306 * @ops: The netfs's operations list 309 307 * 310 308 * Initialise the netfs library context struct. This is expected to follow on 311 309 * directly from the VFS inode struct. 312 310 */ 313 - static inline void netfs_inode_init(struct inode *inode, 311 + static inline void netfs_inode_init(struct netfs_inode *ctx, 314 312 const struct netfs_request_ops *ops) 315 313 { 316 - struct netfs_inode *ctx = netfs_inode(inode); 317 - 318 314 ctx->ops = ops; 319 - ctx->remote_i_size = i_size_read(inode); 315 + ctx->remote_i_size = i_size_read(&ctx->inode); 320 316 #if IS_ENABLED(CONFIG_FSCACHE) 321 317 ctx->cache = NULL; 322 318 #endif ··· 322 322 323 323 /** 324 324 * netfs_resize_file - Note that a file got resized 325 - * @inode: The inode being resized 325 + * @ctx: The netfs inode being resized 326 326 * @new_i_size: The new file size 327 327 * 328 328 * Inform the netfs lib that a file got resized so that it can adjust its state. 329 329 */ 330 - static inline void netfs_resize_file(struct inode *inode, loff_t new_i_size) 330 + static inline void netfs_resize_file(struct netfs_inode *ctx, loff_t new_i_size) 331 331 { 332 - struct netfs_inode *ctx = netfs_inode(inode); 333 - 334 332 ctx->remote_i_size = new_i_size; 335 333 } 336 334 337 335 /** 338 336 * netfs_i_cookie - Get the cache cookie from the inode 339 - * @inode: The inode to query 337 + * @ctx: The netfs inode to query 340 338 * 341 339 * Get the caching cookie (if enabled) from the network filesystem's inode. 342 340 */ 343 - static inline struct fscache_cookie *netfs_i_cookie(struct inode *inode) 341 + static inline struct fscache_cookie *netfs_i_cookie(struct netfs_inode *ctx) 344 342 { 345 343 #if IS_ENABLED(CONFIG_FSCACHE) 346 - struct netfs_inode *ctx = netfs_inode(inode); 347 344 return ctx->cache; 348 345 #else 349 346 return NULL;