Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux-2.6-microblaze.git] / fs / afs / file.c
index 10c6eaa..db035ae 100644 (file)
@@ -333,6 +333,13 @@ static void afs_init_rreq(struct netfs_read_request *rreq, struct file *file)
        rreq->netfs_priv = key_get(afs_file_key(file));
 }
 
+static bool afs_is_cache_enabled(struct inode *inode)
+{
+       struct fscache_cookie *cookie = afs_vnode_cache(AFS_FS_I(inode));
+
+       return fscache_cookie_enabled(cookie) && !hlist_empty(&cookie->backing_objects);
+}
+
 static int afs_begin_cache_operation(struct netfs_read_request *rreq)
 {
        struct afs_vnode *vnode = AFS_FS_I(rreq->inode);
@@ -340,14 +347,24 @@ static int afs_begin_cache_operation(struct netfs_read_request *rreq)
        return fscache_begin_read_operation(rreq, afs_vnode_cache(vnode));
 }
 
+static int afs_check_write_begin(struct file *file, loff_t pos, unsigned len,
+                                struct page *page, void **_fsdata)
+{
+       struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
+
+       return test_bit(AFS_VNODE_DELETED, &vnode->flags) ? -ESTALE : 0;
+}
+
 static void afs_priv_cleanup(struct address_space *mapping, void *netfs_priv)
 {
        key_put(netfs_priv);
 }
 
-static const struct netfs_read_request_ops afs_req_ops = {
+const struct netfs_read_request_ops afs_req_ops = {
        .init_rreq              = afs_init_rreq,
+       .is_cache_enabled       = afs_is_cache_enabled,
        .begin_cache_operation  = afs_begin_cache_operation,
+       .check_write_begin      = afs_check_write_begin,
        .issue_op               = afs_req_issue_op,
        .cleanup                = afs_priv_cleanup,
 };