History

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

Linus Torvalds committed 4 years ago

Commit 045fb9c2 parents b098915 40a811017 files · +60 −62Browse files

Unified · Split

17 files
  1. Documentation/filesystems/netfs_library.rst +17 −16
  2. fs/9p/v9fs.h +1 −1
  3. fs/9p/vfs_addr.c +6 −7
  4. fs/9p/vfs_inode.c +2 −1
  5. fs/afs/dynroot.c +1 −1
  6. fs/afs/file.c +3 −3
  7. fs/afs/inode.c +1 −1
  8. fs/afs/internal.h +1 −1
  9. fs/afs/volume.c +1 −2
  10. fs/afs/write.c +1 −1
  11. fs/ceph/addr.c +6 −6
  12. fs/ceph/cache.h +1 −1
  13. fs/ceph/inode.c +1 −1
  14. fs/cifs/fscache.h +1 −1
  15. fs/netfs/buffered_read.c +3 −2
  16. fs/netfs/objects.c +3 −3
  17. include/linux/netfs.h +11 −14
Documentation/filesystems/netfs_library.rst+17−16
@@ -79,7 +79,7 @@ To help deal with the per-inode context, a number helper functions are · 78 unmodified lines
7979 provided. Firstly, a function to perform basic initialisation on a context and
8080 set the operations table pointer::
8181
82− void netfs_inode_init(struct inode *inode,
82+ void netfs_inode_init(struct netfs_inode *ctx,
8383 const struct netfs_request_ops *ops);
8484
8585 then a function to cast from the VFS inode structure to the netfs context::
@@ -89,7 +89,7 @@ then a function to cast from the VFS inode structure to the netfs context:: · 3 unmodified lines
8989 and finally, a function to get the cache cookie pointer from the context
9090 attached to an inode (or NULL if fscache is disabled)::
9191
92− struct fscache_cookie *netfs_i_cookie(struct inode *inode);
92+ struct fscache_cookie *netfs_i_cookie(struct netfs_inode *ctx);
9393
9494
9595 Buffered Read Helpers
@@ -136,8 +136,9 @@ Three read helpers are provided:: · 40 unmodified lines
136136
137137 void netfs_readahead(struct readahead_control *ractl);
138138 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,
141142 struct address_space *mapping,
142143 loff_t pos,
143144 unsigned int len,
@@ -157,9 +158,10 @@ The helpers manage the read request, calling back into the network filesystem · 13 unmodified lines
157158 through the suppplied table of operations. Waits will be performed as
158159 necessary before returning for helpers that are meant to be synchronous.
159160
160−If an error occurs and netfs_priv is non-NULL, ops->cleanup() will be called to
161−deal with it. If some parts of the request are in progress when an error
162−occurs, the request will get partially completed if sufficient data is read.
161+If an error occurs, the ->free_request() will be called to clean up the
162+netfs_io_request struct allocated. If some parts of the request are in
163+progress when an error occurs, the request will get partially completed if
164+sufficient data is read.
163165
164166 Additionally, there is::
165167
@@ -207,8 +209,7 @@ The above fields are the ones the netfs can use. They are: · 41 unmodified lines
207209 * ``netfs_priv``
208210
209211 The network filesystem's private data. The value for this can be passed in
210− to the helper functions or set during the request. The ->cleanup() op will
211− be called if this is non-NULL at the end.
212+ to the helper functions or set during the request.
212213
213214 * ``start``
214215 * ``len``
@@ -293,6 +294,7 @@ through which it can issue requests and negotiate:: · 78 unmodified lines
293294
294295 struct netfs_request_ops {
295296 void (*init_request)(struct netfs_io_request *rreq, struct file *file);
297+ void (*free_request)(struct netfs_io_request *rreq);
296298 int (*begin_cache_operation)(struct netfs_io_request *rreq);
297299 void (*expand_readahead)(struct netfs_io_request *rreq);
298300 bool (*clamp_length)(struct netfs_io_subrequest *subreq);
@@ -301,7 +303,6 @@ through which it can issue requests and negotiate:: · 2 unmodified lines
301303 int (*check_write_begin)(struct file *file, loff_t pos, unsigned len,
302304 struct folio *folio, void **_fsdata);
303305 void (*done)(struct netfs_io_request *rreq);
304− void (*cleanup)(struct address_space *mapping, void *netfs_priv);
305306 };
306307
307308 The operations are as follows:
@@ -309,7 +310,12 @@ The operations are as follows: · 1 unmodified line
309310 * ``init_request()``
310311
311312 [Optional] This is called to initialise the request structure. It is given
312− the file for reference and can modify the ->netfs_priv value.
313+ the file for reference.
314+
315+ * ``free_request()``
316+
317+ [Optional] This is called as the request is being deallocated so that the
318+ filesystem can clean up any state it has attached there.
313319
314320 * ``begin_cache_operation()``
315321
@@ -383,11 +389,6 @@ The operations are as follows: · 67 unmodified lines
383389 [Optional] This is called after the folios in the request have all been
384390 unlocked (and marked uptodate if applicable).
385391
386− * ``cleanup``
387−
388− [Optional] This is called as the request is being deallocated so that the
389− filesystem can clean up ->netfs_priv.
390−
391392
392393
393394 Read Helper Procedure
fs/9p/v9fs.h+1−1
@@ -124,7 +124,7 @@ static inline struct v9fs_inode *V9FS_I(const struct inode *inode) · 123 unmodified lines
124124 static inline struct fscache_cookie *v9fs_inode_cookie(struct v9fs_inode *v9inode)
125125 {
126126 #ifdef CONFIG_9P_FSCACHE
127− return netfs_i_cookie(&v9inode->netfs.inode);
127+ return netfs_i_cookie(&v9inode->netfs);
128128 #else
129129 return NULL;
130130 #endif
fs/9p/vfs_addr.c+6−7
@@ -66,13 +66,12 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file) · 65 unmodified lines
6666 }
6767
6868 /**
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
7271 */
73−static void v9fs_req_cleanup(struct address_space *mapping, void *priv)
72+static void v9fs_free_request(struct netfs_io_request *rreq)
7473 {
75− struct p9_fid *fid = priv;
74+ struct p9_fid *fid = rreq->netfs_priv;
7675
7776 p9_client_clunk(fid);
7877 }
@@ -94,9 +93,9 @@ static int v9fs_begin_cache_operation(struct netfs_io_request *rreq) · 15 unmodified lines
9493
9594 const struct netfs_request_ops v9fs_req_ops = {
9695 .init_request = v9fs_init_request,
96+ .free_request = v9fs_free_request,
9797 .begin_cache_operation = v9fs_begin_cache_operation,
9898 .issue_read = v9fs_issue_read,
99− .cleanup = v9fs_req_cleanup,
10099 };
101100
102101 /**
@@ -274,7 +273,7 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping, · 171 unmodified lines
274273 * file. We need to do this before we get a lock on the page in case
275274 * there's more than one writer competing for the same cache block.
276275 */
277− retval = netfs_write_begin(filp, mapping, pos, len, &folio, fsdata);
276+ retval = netfs_write_begin(&v9inode->netfs, filp, mapping, pos, len, &folio, fsdata);
278277 if (retval < 0)
279278 return retval;
280279
fs/9p/vfs_inode.c+2−1
@@ -252,7 +252,8 @@ void v9fs_free_inode(struct inode *inode) · 251 unmodified lines
252252 */
253253 static void v9fs_set_netfs_context(struct inode *inode)
254254 {
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);
256257 }
257258
258259 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) · 75 unmodified lines
7676 /* there shouldn't be an existing inode */
7777 BUG_ON(!(inode->i_state & I_NEW));
7878
79− netfs_inode_init(inode, NULL);
79+ netfs_inode_init(&vnode->netfs, NULL);
8080 inode->i_size = 0;
8181 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
8282 if (root) {
fs/afs/file.c+3−3
@@ -382,17 +382,17 @@ static int afs_check_write_begin(struct file *file, loff_t pos, unsigned len, · 381 unmodified lines
382382 return test_bit(AFS_VNODE_DELETED, &vnode->flags) ? -ESTALE : 0;
383383 }
384384
385−static void afs_priv_cleanup(struct address_space *mapping, void *netfs_priv)
385+static void afs_free_request(struct netfs_io_request *rreq)
386386 {
387− key_put(netfs_priv);
387+ key_put(rreq->netfs_priv);
388388 }
389389
390390 const struct netfs_request_ops afs_req_ops = {
391391 .init_request = afs_init_request,
392+ .free_request = afs_free_request,
392393 .begin_cache_operation = afs_begin_cache_operation,
393394 .check_write_begin = afs_check_write_begin,
394395 .issue_read = afs_issue_read,
395− .cleanup = afs_priv_cleanup,
396396 };
397397
398398 int afs_write_inode(struct inode *inode, struct writeback_control *wbc)
fs/afs/inode.c+1−1
@@ -58,7 +58,7 @@ static noinline void dump_vnode(struct afs_vnode *vnode, struct afs_vnode *paren · 57 unmodified lines
5858 */
5959 static void afs_set_netfs_context(struct afs_vnode *vnode)
6060 {
61− netfs_inode_init(&vnode->netfs.inode, &afs_req_ops);
61+ netfs_inode_init(&vnode->netfs, &afs_req_ops);
6262 }
6363
6464 /*
fs/afs/internal.h+1−1
@@ -670,7 +670,7 @@ struct afs_vnode { · 669 unmodified lines
670670 static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode)
671671 {
672672 #ifdef CONFIG_AFS_FSCACHE
673− return netfs_i_cookie(&vnode->netfs.inode);
673+ return netfs_i_cookie(&vnode->netfs);
674674 #else
675675 return NULL;
676676 #endif
fs/afs/volume.c+1−2
@@ -9,8 +9,7 @@ · 8 unmodified lines
99 #include <linux/slab.h>
1010 #include "internal.h"
1111
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;
1413
1514 /*
1615 * Insert a volume into a cell. If there's an existing volume record, that is
fs/afs/write.c+1−1
@@ -60,7 +60,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping, · 59 unmodified lines
6060 * file. We need to do this before we get a lock on the page in case
6161 * there's more than one writer competing for the same cache block.
6262 */
63− ret = netfs_write_begin(file, mapping, pos, len, &folio, fsdata);
63+ ret = netfs_write_begin(&vnode->netfs, file, mapping, pos, len, &folio, fsdata);
6464 if (ret < 0)
6565 return ret;
6666
fs/ceph/addr.c+6−6
@@ -394,11 +394,10 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file) · 393 unmodified lines
394394 return 0;
395395 }
396396
397−static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
397+static void ceph_netfs_free_request(struct netfs_io_request *rreq)
398398 {
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;
402401
403402 if (got)
404403 ceph_put_cap_refs(ci, got);
@@ -406,12 +405,12 @@ static void ceph_readahead_cleanup(struct address_space *mapping, void *priv) · 1 unmodified line
406405
407406 const struct netfs_request_ops ceph_netfs_ops = {
408407 .init_request = ceph_init_request,
408+ .free_request = ceph_netfs_free_request,
409409 .begin_cache_operation = ceph_begin_cache_operation,
410410 .issue_read = ceph_netfs_issue_read,
411411 .expand_readahead = ceph_netfs_expand_readahead,
412412 .clamp_length = ceph_netfs_clamp_length,
413413 .check_write_begin = ceph_netfs_check_write_begin,
414− .cleanup = ceph_readahead_cleanup,
415414 };
416415
417416 #ifdef CONFIG_CEPH_FSCACHE
@@ -1322,10 +1321,11 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping, · 904 unmodified lines
13221321 struct page **pagep, void **fsdata)
13231322 {
13241323 struct inode *inode = file_inode(file);
1324+ struct ceph_inode_info *ci = ceph_inode(inode);
13251325 struct folio *folio = NULL;
13261326 int r;
13271327
1328− r = netfs_write_begin(file, inode->i_mapping, pos, len, &folio, NULL);
1328+ r = netfs_write_begin(&ci->netfs, file, inode->i_mapping, pos, len, &folio, NULL);
13291329 if (r == 0)
13301330 folio_wait_fscache(folio);
13311331 if (r < 0) {
fs/ceph/cache.h+1−1
@@ -28,7 +28,7 @@ void ceph_fscache_invalidate(struct inode *inode, bool dio_write); · 27 unmodified lines
2828
2929 static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci)
3030 {
31− return netfs_i_cookie(&ci->netfs.inode);
31+ return netfs_i_cookie(&ci->netfs);
3232 }
3333
3434 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) · 459 unmodified lines
460460 dout("alloc_inode %p\n", &ci->netfs.inode);
461461
462462 /* 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);
464464
465465 spin_lock_init(&ci->i_ceph_lock);
466466
fs/cifs/fscache.h+1−1
@@ -61,7 +61,7 @@ void cifs_fscache_fill_coherency(struct inode *inode, · 60 unmodified lines
6161
6262 static inline struct fscache_cookie *cifs_inode_cookie(struct inode *inode)
6363 {
64− return netfs_i_cookie(inode);
64+ return netfs_i_cookie(&CIFS_I(inode)->netfs);
6565 }
6666
6767 static inline void cifs_invalidate_cache(struct inode *inode, unsigned int flags)
fs/netfs/buffered_read.c+3−2
@@ -297,6 +297,7 @@ zero_out: · 296 unmodified lines
297297
298298 /**
299299 * netfs_write_begin - Helper to prepare for writing
300+ * @ctx: The netfs context
300301 * @file: The file to read from
301302 * @mapping: The mapping to read from
302303 * @pos: File position at which the write will begin
@@ -326,12 +327,12 @@ zero_out: · 23 unmodified lines
326327 *
327328 * This is usable whether or not caching is enabled.
328329 */
329−int netfs_write_begin(struct file *file, struct address_space *mapping,
330+int netfs_write_begin(struct netfs_inode *ctx,
331+ struct file *file, struct address_space *mapping,
330332 loff_t pos, unsigned int len, struct folio **_folio,
331333 void **_fsdata)
332334 {
333335 struct netfs_io_request *rreq;
334− struct netfs_inode *ctx = netfs_inode(file_inode(file ));
335336 struct folio *folio;
336337 unsigned int fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE;
337338 pgoff_t index = pos >> PAGE_SHIFT;
fs/netfs/objects.c+3−3
@@ -75,10 +75,10 @@ static void netfs_free_request(struct work_struct *work) · 74 unmodified lines
7575 struct netfs_io_request *rreq =
7676 container_of(work, struct netfs_io_request, work);
7777
78− netfs_clear_subrequests(rreq, false);
79− if (rreq->netfs_priv)
80− rreq->netfs_ops->cleanup(rreq->mapping, rreq->netfs_priv);
8178 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);
8282 if (rreq->cache_resources.ops)
8383 rreq->cache_resources.ops->end_operation(&rreq->cache_resources);
8484 kfree(rreq);
include/linux/netfs.h+11−14
@@ -206,7 +206,9 @@ struct netfs_io_request { · 205 unmodified lines
206206 */
207207 struct netfs_request_ops {
208208 int (*init_request)(struct netfs_io_request *rreq, struct file *file);
209+ void (*free_request)(struct netfs_io_request *rreq);
209210 int (*begin_cache_operation)(struct netfs_io_request *rreq);
211+
210212 void (*expand_readahead)(struct netfs_io_request *rreq);
211213 bool (*clamp_length)(struct netfs_io_subrequest *subreq);
212214 void (*issue_read)(struct netfs_io_subrequest *subreq);
@@ -214,7 +216,6 @@ struct netfs_request_ops { · 1 unmodified line
214216 int (*check_write_begin)(struct file *file, loff_t pos, unsigned len,
215217 struct folio *folio, void **_fsdata);
216218 void (*done)(struct netfs_io_request *rreq);
217− void (*cleanup)(struct address_space *mapping, void *netfs_priv);
218219 };
219220
220221 /*
@@ -277,7 +278,8 @@ struct netfs_cache_ops { · 56 unmodified lines
277278 struct readahead_control;
278279 extern void netfs_readahead(struct readahead_control *);
279280 int netfs_read_folio(struct file *, struct folio *);
280−extern int netfs_write_begin(struct file *, struct address_space *,
281+extern int netfs_write_begin(struct netfs_inode *,
282+ struct file *, struct address_space *,
281283 loff_t, unsigned int, struct folio **,
282284 void **);
283285
@@ -302,19 +304,17 @@ static inline struct netfs_inode *netfs_inode(struct inode *inode) · 18 unmodified lines
302304
303305 /**
304306 * netfs_inode_init - Initialise a netfslib inode context
305− * @inode: The inode with which the context is associated
307+ * @inode: The netfs inode to initialise
306308 * @ops: The netfs's operations list
307309 *
308310 * Initialise the netfs library context struct. This is expected to follow on
309311 * directly from the VFS inode struct.
310312 */
311−static inline void netfs_inode_init(struct inode *inode,
313+static inline void netfs_inode_init(struct netfs_inode *ctx,
312314 const struct netfs_request_ops *ops)
313315 {
314− struct netfs_inode *ctx = netfs_inode(inode);
315−
316316 ctx->ops = ops;
317− ctx->remote_i_size = i_size_read(inode);
317+ ctx->remote_i_size = i_size_read(&ctx->inode);
318318 #if IS_ENABLED(CONFIG_FSCACHE)
319319 ctx->cache = NULL;
320320 #endif
@@ -322,28 +322,25 @@ static inline void netfs_inode_init(struct inode *inode, · 1 unmodified line
322322
323323 /**
324324 * netfs_resize_file - Note that a file got resized
325− * @inode: The inode being resized
325+ * @ctx: The netfs inode being resized
326326 * @new_i_size: The new file size
327327 *
328328 * Inform the netfs lib that a file got resized so that it can adjust its state.
329329 */
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)
331331 {
332− struct netfs_inode *ctx = netfs_inode(inode);
333−
334332 ctx->remote_i_size = new_i_size;
335333 }
336334
337335 /**
338336 * netfs_i_cookie - Get the cache cookie from the inode
339− * @inode: The inode to query
337+ * @ctx: The netfs inode to query
340338 *
341339 * Get the caching cookie (if enabled) from the network filesystem's inode.
342340 */
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)
344342 {
345343 #if IS_ENABLED(CONFIG_FSCACHE)
346− struct netfs_inode *ctx = netfs_inode(inode);
347344 return ctx->cache;
348345 #else
349346 return NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t