summaryrefslogtreecommitdiffstats
path: root/fs/afs/internal.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2020-10-26 13:22:47 +0000
committerDavid Howells <dhowells@redhat.com>2020-10-29 13:53:04 +0000
commit185f0c7073bd5c78f86265f703f5daf1306ab5a7 (patch)
tree01355ebab583d813e1a38823473626d0eb9aa046 /fs/afs/internal.h
parentf792e3ac82fe2c6c863e93187eb7ddfccab68fa7 (diff)
downloadlinux-185f0c7073bd5c78f86265f703f5daf1306ab5a7.tar.gz
linux-185f0c7073bd5c78f86265f703f5daf1306ab5a7.tar.bz2
linux-185f0c7073bd5c78f86265f703f5daf1306ab5a7.zip
afs: Wrap page->private manipulations in inline functions
The afs filesystem uses page->private to store the dirty range within a page such that in the event of a conflicting 3rd-party write to the server, we write back just the bits that got changed locally. However, there are a couple of problems with this: (1) I need a bit to note if the page might be mapped so that partial invalidation doesn't shrink the range. (2) There aren't necessarily sufficient bits to store the entire range of data altered (say it's a 32-bit system with 64KiB pages or transparent huge pages are in use). So wrap the accesses in inline functions so that future commits can change how this works. Also move them out of the tracing header into the in-directory header. There's not really any need for them to be in the tracing header. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/internal.h')
-rw-r--r--fs/afs/internal.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 289f5dffa46f..edaccd07e18e 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -858,6 +858,34 @@ struct afs_vnode_cache_aux {
u64 data_version;
} __packed;
+/*
+ * We use page->private to hold the amount of the page that we've written to,
+ * splitting the field into two parts. However, we need to represent a range
+ * 0...PAGE_SIZE inclusive, so we can't support 64K pages on a 32-bit system.
+ */
+#if PAGE_SIZE > 32768
+#define __AFS_PAGE_PRIV_MASK 0xffffffffUL
+#define __AFS_PAGE_PRIV_SHIFT 32
+#else
+#define __AFS_PAGE_PRIV_MASK 0xffffUL
+#define __AFS_PAGE_PRIV_SHIFT 16
+#endif
+
+static inline size_t afs_page_dirty_from(unsigned long priv)
+{
+ return priv & __AFS_PAGE_PRIV_MASK;
+}
+
+static inline size_t afs_page_dirty_to(unsigned long priv)
+{
+ return (priv >> __AFS_PAGE_PRIV_SHIFT) & __AFS_PAGE_PRIV_MASK;
+}
+
+static inline unsigned long afs_page_dirty(size_t from, size_t to)
+{
+ return ((unsigned long)to << __AFS_PAGE_PRIV_SHIFT) | from;
+}
+
#include <trace/events/afs.h>
/*****************************************************************************/