Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 188722
b: refs/heads/master
c: 5ecad6f
h: refs/heads/master
v: v3
  • Loading branch information
Sage Weil committed Feb 19, 2010
1 parent 135fd15 commit 524b8ee
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 33 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: 2c27c9a57c93a0757b9b4b0e7dc1abeaf1db1ce2
refs/heads/master: 5ecad6fd7bfd30b3eaea51345f546b81de7a6473
82 changes: 50 additions & 32 deletions trunk/fs/ceph/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,41 @@ static int __mark_caps_flushing(struct inode *inode,
return flushing;
}

/*
* try to invalidate mapping pages without blocking.
*/
static int mapping_is_empty(struct address_space *mapping)
{
struct page *page = find_get_page(mapping, 0);

if (!page)
return 1;

put_page(page);
return 0;
}

static int try_nonblocking_invalidate(struct inode *inode)
{
struct ceph_inode_info *ci = ceph_inode(inode);
u32 invalidating_gen = ci->i_rdcache_gen;

spin_unlock(&inode->i_lock);
invalidate_mapping_pages(&inode->i_data, 0, -1);
spin_lock(&inode->i_lock);

if (mapping_is_empty(&inode->i_data) &&
invalidating_gen == ci->i_rdcache_gen) {
/* success. */
dout("try_nonblocking_invalidate %p success\n", inode);
ci->i_rdcache_gen = 0;
ci->i_rdcache_revoking = 0;
return 0;
}
dout("try_nonblocking_invalidate %p failed\n", inode);
return -1;
}

/*
* Swiss army knife function to examine currently used and wanted
* versus held caps. Release, flush, ack revoked caps to mds as
Expand Down Expand Up @@ -1451,27 +1486,19 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
(file_wanted == 0 || /* no open files */
(revoking & CEPH_CAP_FILE_CACHE)) && /* or revoking cache */
!tried_invalidate) {
u32 invalidating_gen = ci->i_rdcache_gen;
int ret;

dout("check_caps trying to invalidate on %p\n", inode);
spin_unlock(&inode->i_lock);
ret = invalidate_mapping_pages(&inode->i_data, 0, -1);
spin_lock(&inode->i_lock);
if (ret == 0 && invalidating_gen == ci->i_rdcache_gen) {
/* success. */
ci->i_rdcache_gen = 0;
ci->i_rdcache_revoking = 0;
} else if (revoking & CEPH_CAP_FILE_CACHE) {
dout("check_caps queuing invalidate\n");
queue_invalidate = 1;
ci->i_rdcache_revoking = ci->i_rdcache_gen;
} else {
dout("check_caps failed to invalidate pages\n");
/* we failed to invalidate pages. check these
caps again later. */
force_requeue = 1;
__cap_set_timeouts(mdsc, ci);
if (try_nonblocking_invalidate(inode) < 0) {
if (revoking & CEPH_CAP_FILE_CACHE) {
dout("check_caps queuing invalidate\n");
queue_invalidate = 1;
ci->i_rdcache_revoking = ci->i_rdcache_gen;
} else {
dout("check_caps failed to invalidate pages\n");
/* we failed to invalidate pages. check these
caps again later. */
force_requeue = 1;
__cap_set_timeouts(mdsc, ci);
}
}
tried_invalidate = 1;
goto retry_locked;
Expand Down Expand Up @@ -2184,7 +2211,6 @@ static int handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
int revoked_rdcache = 0;
int queue_invalidate = 0;
int tried_invalidate = 0;
int ret;

dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n",
inode, cap, mds, seq, ceph_cap_string(newcaps));
Expand All @@ -2199,24 +2225,16 @@ static int handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
restart:
if (((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) &&
!ci->i_wrbuffer_ref && !tried_invalidate) {
dout("CACHE invalidation\n");
spin_unlock(&inode->i_lock);
tried_invalidate = 1;

ret = invalidate_mapping_pages(&inode->i_data, 0, -1);
spin_lock(&inode->i_lock);
if (ret < 0) {
if (try_nonblocking_invalidate(inode) == 0) {
revoked_rdcache = 1;
} else {
/* there were locked pages.. invalidate later
in a separate thread. */
if (ci->i_rdcache_revoking != ci->i_rdcache_gen) {
queue_invalidate = 1;
ci->i_rdcache_revoking = ci->i_rdcache_gen;
}
} else {
/* we successfully invalidated those pages */
revoked_rdcache = 1;
ci->i_rdcache_gen = 0;
ci->i_rdcache_revoking = 0;
}
goto restart;
}
Expand Down

0 comments on commit 524b8ee

Please sign in to comment.