History

fscache: Provide a function to resize a cookie

Provide a function to change the size of the storage attached to a cookie, to match the size of the file being cached when it's changed by truncate or fallocate: void fscache_resize_cookie(struct fscache_cookie *cookie, loff_t new_size); This acts synchronously and is expected to run under the inode lock of the caller.

David Howells committed 5 years ago

Commit 16a96bd1 parent 1f67e6d6 files · +82 −2Browse files

Showing the changes to include (3 of 6 files). Show all

Unified · Split

3 files
  1. include/linux/fscache-cache.h +4 −0
  2. include/linux/fscache.h +18 −0
  3. include/trace/events/fscache.h +25 −0
include/linux/fscache-cache.h+4−0
@@ -64,6 +64,10 @@ struct fscache_cache_ops { · 63 unmodified lines
6464 /* Withdraw an object without any cookie access counts held */
6565 void (*withdraw_cookie)(struct fscache_cookie *cookie);
6666
67+ /* Change the size of a data object */
68+ void (*resize_cookie)(struct netfs_cache_resources *cres,
69+ loff_t new_size);
70+
6771 /* Invalidate an object */
6872 bool (*invalidate_cookie)(struct fscache_cookie *cookie);
6973
include/linux/fscache.h+18−0
@@ -163,6 +163,7 @@ extern struct fscache_cookie *__fscache_acquire_cookie( · 162 unmodified lines
163163 extern void __fscache_use_cookie(struct fscache_cookie *, bool);
164164 extern void __fscache_unuse_cookie(struct fscache_cookie *, const void *, const loff_t *);
165165 extern void __fscache_relinquish_cookie(struct fscache_cookie *, bool);
166+extern void __fscache_resize_cookie(struct fscache_cookie *, loff_t);
166167 extern void __fscache_invalidate(struct fscache_cookie *, const void *, loff_t, unsigned int);
167168 extern int __fscache_begin_read_operation(struct netfs_cache_resources *, struct fscache_cookie *);
168169
@@ -366,6 +367,23 @@ void fscache_update_cookie(struct fscache_cookie *cookie, const void *aux_data, · 197 unmodified lines
366367 __fscache_update_cookie(cookie, aux_data, object_size);
367368 }
368369
370+/**
371+ * fscache_resize_cookie - Request that a cache object be resized
372+ * @cookie: The cookie representing the cache object
373+ * @new_size: The new size of the object (may be NULL)
374+ *
375+ * Request that the size of an object be changed.
376+ *
377+ * See Documentation/filesystems/caching/netfs-api.txt for a complete
378+ * description.
379+ */
380+static inline
381+void fscache_resize_cookie(struct fscache_cookie *cookie, loff_t new_size)
382+{
383+ if (fscache_cookie_enabled(cookie))
384+ __fscache_resize_cookie(cookie, new_size);
385+}
386+
369387 /**
370388 * fscache_invalidate - Notify cache that an object needs invalidation
371389 * @cookie: The cookie representing the cache object
include/trace/events/fscache.h+25−0
@@ -78,6 +78,7 @@ enum fscache_access_trace { · 77 unmodified lines
7878 fscache_access_invalidate_cookie_end,
7979 fscache_access_io_not_live,
8080 fscache_access_io_read,
81+ fscache_access_io_resize,
8182 fscache_access_io_wait,
8283 fscache_access_io_write,
8384 fscache_access_lookup_cookie,
@@ -149,6 +150,7 @@ enum fscache_access_trace { · 65 unmodified lines
149150 EM(fscache_access_invalidate_cookie_end,"END inval ") \
150151 EM(fscache_access_io_not_live, "END io_notl") \
151152 EM(fscache_access_io_read, "BEGIN io_read") \
153+ EM(fscache_access_io_resize, "BEGIN io_resz") \
152154 EM(fscache_access_io_wait, "WAIT io ") \
153155 EM(fscache_access_io_write, "BEGIN io_writ") \
154156 EM(fscache_access_lookup_cookie, "BEGIN lookup ") \
@@ -418,6 +420,29 @@ TRACE_EVENT(fscache_invalidate, · 263 unmodified lines
418420 __entry->cookie, __entry->new_size)
419421 );
420422
423+TRACE_EVENT(fscache_resize,
424+ TP_PROTO(struct fscache_cookie *cookie, loff_t new_size),
425+
426+ TP_ARGS(cookie, new_size),
427+
428+ TP_STRUCT__entry(
429+ __field(unsigned int, cookie )
430+ __field(loff_t, old_size )
431+ __field(loff_t, new_size )
432+ ),
433+
434+ TP_fast_assign(
435+ __entry->cookie = cookie->debug_id;
436+ __entry->old_size = cookie->object_size;
437+ __entry->new_size = new_size;
438+ ),
439+
440+ TP_printk("c=%08x os=%08llx sz=%08llx",
441+ __entry->cookie,
442+ __entry->old_size,
443+ __entry->new_size)
444+ );
445+
421446 #endif /* _TRACE_FSCACHE_H */
422447
423448 /* This part must be outside protection */

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