summaryrefslogtreecommitdiffstats
path: root/include/trace/events/afs.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2017-11-02 15:27:52 +0000
committerDavid Howells <dhowells@redhat.com>2017-11-13 15:38:20 +0000
commitdab17c1add5c51b68027a9a3861af3a99cb5485a (patch)
tree17d9d716ff0903555bd1d4451974df3088625e33 /include/trace/events/afs.h
parent2c099014a0a456012c1778e80adce839bf956b77 (diff)
afs: Fix directory read/modify race
Because parsing of the directory wasn't being done under any sort of lock, the pages holding the directory content can get invalidated whilst the parsing is ongoing. Further, the directory page check function gets called outside of the page lock, so if the page gets cleared or updated, this may return reports of bad magic numbers in the directory page. Also, the directory may change size whilst checking and parsing are ongoing, so more care needs to be taken here. Fix this by: (1) Perform the page check from the page filling function before we set PageUptodate and drop the page lock. (2) Check for the file having shrunk and the page having been abandoned before checking the page contents. (3) Lock the page whilst parsing it for the directory iterator. Whilst we're at it, add a tracepoint to report check failure. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/trace/events/afs.h')
-rw-r--r--include/trace/events/afs.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h
index c780f4c39a53..9cfb7657b72c 100644
--- a/include/trace/events/afs.h
+++ b/include/trace/events/afs.h
@@ -381,6 +381,27 @@ TRACE_EVENT(afs_sent_pages,
__entry->cursor, __entry->ret)
);
+TRACE_EVENT(afs_dir_check_failed,
+ TP_PROTO(struct afs_vnode *vnode, loff_t off, loff_t i_size),
+
+ TP_ARGS(vnode, off, i_size),
+
+ TP_STRUCT__entry(
+ __field(struct afs_vnode *, vnode )
+ __field(loff_t, off )
+ __field(loff_t, i_size )
+ ),
+
+ TP_fast_assign(
+ __entry->vnode = vnode;
+ __entry->off = off;
+ __entry->i_size = i_size;
+ ),
+
+ TP_printk("vn=%p %llx/%llx",
+ __entry->vnode, __entry->off, __entry->i_size)
+ );
+
#endif /* _TRACE_AFS_H */
/* This part must be outside protection */