Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347823
b: refs/heads/master
c: 9dc8d9b
h: refs/heads/master
i:
  347821: 062035b
  347819: 43948b5
  347815: 0bfcf03
  347807: d0fe0ec
v: v3
  • Loading branch information
David Howells committed Dec 20, 2012
1 parent 475e1d2 commit 5c60ad8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a02de9608595c8ef649ef03ae735b0b45e3d4396
refs/heads/master: 9dc8d9bfe4415efb61a5e9390706b8a3bffef329
49 changes: 49 additions & 0 deletions trunk/fs/cachefiles/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,54 @@ static int cachefiles_attr_changed(struct fscache_object *_object)
return ret;
}

/*
* Invalidate an object
*/
static void cachefiles_invalidate_object(struct fscache_operation *op)
{
struct cachefiles_object *object;
struct cachefiles_cache *cache;
const struct cred *saved_cred;
struct path path;
uint64_t ni_size;
int ret;

object = container_of(op->object, struct cachefiles_object, fscache);
cache = container_of(object->fscache.cache,
struct cachefiles_cache, cache);

op->object->cookie->def->get_attr(op->object->cookie->netfs_data,
&ni_size);

_enter("{OBJ%x},[%llu]",
op->object->debug_id, (unsigned long long)ni_size);

if (object->backer) {
ASSERT(S_ISREG(object->backer->d_inode->i_mode));

fscache_set_store_limit(&object->fscache, ni_size);

path.dentry = object->backer;
path.mnt = cache->mnt;

cachefiles_begin_secure(cache, &saved_cred);
ret = vfs_truncate(&path, 0);
if (ret == 0)
ret = vfs_truncate(&path, ni_size);
cachefiles_end_secure(cache, saved_cred);

if (ret != 0) {
fscache_set_store_limit(&object->fscache, 0);
if (ret == -EIO)
cachefiles_io_error_obj(object,
"Invalidate failed");
}
}

fscache_op_complete(op);
_leave("");
}

/*
* dissociate a cache from all the pages it was backing
*/
Expand All @@ -455,6 +503,7 @@ const struct fscache_cache_ops cachefiles_cache_ops = {
.lookup_complete = cachefiles_lookup_complete,
.grab_object = cachefiles_grab_object,
.update_object = cachefiles_update_object,
.invalidate_object = cachefiles_invalidate_object,
.drop_object = cachefiles_drop_object,
.put_object = cachefiles_put_object,
.sync_cache = cachefiles_sync_cache,
Expand Down
5 changes: 4 additions & 1 deletion trunk/fs/cachefiles/rdwr.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ static void cachefiles_read_copier(struct fscache_operation *_op)
_debug("- copy {%lu}", monitor->back_page->index);

recheck:
if (PageUptodate(monitor->back_page)) {
if (test_bit(FSCACHE_COOKIE_INVALIDATING,
&object->fscache.cookie->flags)) {
error = -ESTALE;
} else if (PageUptodate(monitor->back_page)) {
copy_highpage(monitor->netfs_page, monitor->back_page);
fscache_mark_page_cached(monitor->op,
monitor->netfs_page);
Expand Down

0 comments on commit 5c60ad8

Please sign in to comment.