[PATCH 1/1] Debug crash in cachefiles_prepare_write with NFS netfs conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 fs/cachefiles/io.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c
index 000a28f46e59..1618849dd49b 100644
--- a/fs/cachefiles/io.c
+++ b/fs/cachefiles/io.c
@@ -583,11 +583,37 @@ static int cachefiles_prepare_write(struct netfs_cache_resources *cres,
 				    loff_t *_start, size_t *_len, loff_t i_size,
 				    bool no_space_allocated_yet)
 {
-	struct cachefiles_object *object = cachefiles_cres_object(cres);
-	struct cachefiles_cache *cache = object->volume->cache;
+	struct cachefiles_object *object;
+	struct cachefiles_cache *cache;
 	const struct cred *saved_cred;
 	int ret;
-
+	struct fscache_cookie *cookie;
+	struct fscache_volume *volume;
+
+	if (!cres)
+		BUG();
+	if (!fscache_cres_cookie(cres)) {
+		printk("cookie == NULL: cres = %p\n", cres);
+		BUG();
+	}
+	object = cachefiles_cres_object(cres);
+	if (!object) {
+		cookie = fscache_cres_cookie(cres);
+		trace_printk("object == NULL: c=%08x\n", cookie->debug_id);
+		BUG();
+	}
+	if (!object->volume) {
+		cookie = fscache_cres_cookie(cres);
+		trace_printk("volume == NULL: c=%08x\n", cookie->debug_id);
+		BUG();
+	}
+	if (!object->volume->cache) {
+		cookie = fscache_cres_cookie(cres);
+		volume = object->volume->vcookie;
+		trace_printk("cache == NULL: c=%08x V=%08x\n", cookie->debug_id, volume->debug_id);
+		BUG();
+	}
+	cache = object->volume->cache;
 	if (!cachefiles_cres_file(cres)) {
 		if (!fscache_wait_for_operation(cres, FSCACHE_WANT_WRITE))
 			return -ENOBUFS;
-- 
2.31.1

--
Linux-cachefs mailing list
Linux-cachefs@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/linux-cachefs




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]
  Powered by Linux