From: David Howells Subject: [PATCH 06/13] FS-Cache: Check cookie is still correct in __fscache_read_or_alloc_pages() Date: Thu, 29 Sep 2011 15:46:48 +0100 Message-ID: <20110929144648.5812.87254.stgit@warthog.procyon.org.uk> References: <20110929144536.5812.84405.stgit@warthog.procyon.org.uk> Reply-To: Linux filesystem caching discussion list Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cachefs@redhat.com To: moseleymark@gmail.com, mark@pogo.org.uk, jlayton@redhat.com, steved@redhat.com Return-path: In-Reply-To: <20110929144536.5812.84405.stgit@warthog.procyon.org.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cachefs-bounces@redhat.com Errors-To: linux-cachefs-bounces@redhat.com List-Id: linux-fsdevel.vger.kernel.org Check the object's cookie pointer is still correct in __fscache_read_or_alloc_pages(). This may change as a result of the cookie being released by the netfs before we've finished reading from it. Signed-off-by: David Howells --- fs/fscache/page.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/fs/fscache/page.c b/fs/fscache/page.c index b8b62f4..aaed5cd 100644 --- a/fs/fscache/page.c +++ b/fs/fscache/page.c @@ -496,6 +496,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie, if (fscache_submit_op(object, &op->op) < 0) goto nobufs_unlock; spin_unlock(&cookie->lock); + ASSERTCMP(object->cookie, ==, cookie); fscache_stat(&fscache_n_retrieval_ops); @@ -513,6 +514,26 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie, goto error; /* ask the cache to honour the operation */ + if (!object->cookie) { + static const char prefix[] = "fs-"; + printk(KERN_ERR "%sobject: OBJ%x\n", + prefix, object->debug_id); + printk(KERN_ERR "%sobjstate=%s fl=%lx wbusy=%x ev=%lx[%lx]\n", + prefix, fscache_object_states[object->state], + object->flags, work_busy(&object->work), + object->events, + object->event_mask & FSCACHE_OBJECT_EVENTS_MASK); + printk(KERN_ERR "%sops=%u inp=%u exc=%u\n", + prefix, object->n_ops, object->n_in_progress, + object->n_exclusive); + printk(KERN_ERR "%sparent=%p\n", + prefix, object->parent); + printk(KERN_ERR "%scookie=%p [pr=%p nd=%p fl=%lx]\n", + prefix, object->cookie, + cookie->parent, cookie->netfs_data, cookie->flags); + } + ASSERTCMP(object->cookie, ==, cookie); + if (test_bit(FSCACHE_COOKIE_NO_DATA_YET, &object->cookie->flags)) { fscache_stat(&fscache_n_cop_allocate_pages); ret = object->cache->ops->allocate_pages(