diff options
author | Sage Weil <sage@newdream.net> | 2010-11-04 14:05:05 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-11-08 10:29:05 -0500 |
commit | cd045cb42a266882ac24bc21a3a8d03683c72954 (patch) | |
tree | 2938560e8362804e829cc9feb23ef746d354140b /fs/ceph/inode.c | |
parent | feb4cc9bb433bf1491ac5ffbba133f3258dacf06 (diff) |
ceph: fix rdcache_gen usage and invalidate
We used to use rdcache_gen to indicate whether we "might" have cached
pages. Now we just look at the mapping to determine that. However, some
old behavior remains from that transition.
First, rdcache_gen == 0 no longer means we have no pages. That can happen
at any time (presumably when we carry FILE_CACHE). We should not reset it
to zero, and we should not check that it is zero.
That means that the only purpose for rdcache_revoking is to resolve races
between new issues of FILE_CACHE and an async invalidate. If they are
equal, we should invalidate. On success, we decrement rdcache_revoking,
so that it is no longer equal to rdcache_gen. Similarly, if we success
in doing a sync invalidate, set revoking = gen - 1. (This is a small
optimization to avoid doing unnecessary invalidate work and does not
affect correctness.)
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/inode.c')
-rw-r--r-- | fs/ceph/inode.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 0a49ffde5bcb..5a9f907b805e 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -1394,11 +1394,8 @@ static void ceph_invalidate_work(struct work_struct *work) | |||
1394 | spin_lock(&inode->i_lock); | 1394 | spin_lock(&inode->i_lock); |
1395 | dout("invalidate_pages %p gen %d revoking %d\n", inode, | 1395 | dout("invalidate_pages %p gen %d revoking %d\n", inode, |
1396 | ci->i_rdcache_gen, ci->i_rdcache_revoking); | 1396 | ci->i_rdcache_gen, ci->i_rdcache_revoking); |
1397 | if (ci->i_rdcache_gen == 0 || | 1397 | if (ci->i_rdcache_revoking != ci->i_rdcache_gen) { |
1398 | ci->i_rdcache_revoking != ci->i_rdcache_gen) { | ||
1399 | BUG_ON(ci->i_rdcache_revoking > ci->i_rdcache_gen); | ||
1400 | /* nevermind! */ | 1398 | /* nevermind! */ |
1401 | ci->i_rdcache_revoking = 0; | ||
1402 | spin_unlock(&inode->i_lock); | 1399 | spin_unlock(&inode->i_lock); |
1403 | goto out; | 1400 | goto out; |
1404 | } | 1401 | } |
@@ -1408,15 +1405,16 @@ static void ceph_invalidate_work(struct work_struct *work) | |||
1408 | ceph_invalidate_nondirty_pages(inode->i_mapping); | 1405 | ceph_invalidate_nondirty_pages(inode->i_mapping); |
1409 | 1406 | ||
1410 | spin_lock(&inode->i_lock); | 1407 | spin_lock(&inode->i_lock); |
1411 | if (orig_gen == ci->i_rdcache_gen) { | 1408 | if (orig_gen == ci->i_rdcache_gen && |
1409 | orig_gen == ci->i_rdcache_revoking) { | ||
1412 | dout("invalidate_pages %p gen %d successful\n", inode, | 1410 | dout("invalidate_pages %p gen %d successful\n", inode, |
1413 | ci->i_rdcache_gen); | 1411 | ci->i_rdcache_gen); |
1414 | ci->i_rdcache_gen = 0; | 1412 | ci->i_rdcache_revoking--; |
1415 | ci->i_rdcache_revoking = 0; | ||
1416 | check = 1; | 1413 | check = 1; |
1417 | } else { | 1414 | } else { |
1418 | dout("invalidate_pages %p gen %d raced, gen now %d\n", | 1415 | dout("invalidate_pages %p gen %d raced, now %d revoking %d\n", |
1419 | inode, orig_gen, ci->i_rdcache_gen); | 1416 | inode, orig_gen, ci->i_rdcache_gen, |
1417 | ci->i_rdcache_revoking); | ||
1420 | } | 1418 | } |
1421 | spin_unlock(&inode->i_lock); | 1419 | spin_unlock(&inode->i_lock); |
1422 | 1420 | ||