// states and such.
// C = cache reads, R = read, W = write, A = append, B = buffer writes, L = lazyio
+//
+// lower-case on a transition state means a 'trailing' rdlock or wrlock..
+// the old locks still there (from the prior state), but new locks aren't
+// allowed.
// -----auth-------- ---replica-------
#define LOCK_SYNC_ 1 // AR R . / C R . . . L R . / C R . . . L stat()
#define LOCK_LONER_SYNC -12 // A . . / C r . . . L * loner -> sync
#define LOCK_MIXED_SYNC -13 // A . . / . R . . . L
+#define LOCK_LOCK_SYNC -14 // A R w / C . . . b L
#define LOCK_LOCK_ 2 // AR R W / C . . . B . . . / C . . . . . truncate()
#define LOCK_SYNC_LOCK_ -3 // AR R . / C . . . . . . . / C . . . . .
#define LOCK_MIXED_LOCK -5 // A . . / . . . . . .
#define LOCK_MIXED 6 // AR . . / . R W A . L . . / . R . . . L
-#define LOCK_SYNC_MIXED -7 // AR R . / . R . . . L . . / . R . . . L
+#define LOCK_SYNC_MIXED -7 // AR r . / . R . . . L . . / . R . . . L
#define LOCK_LONER_MIXED -8 // A . . / . r w a . L * loner -> mixed
#define LOCK_LONER 9 // A . . / c r w a b L * (lock)
-#define LOCK_SYNC_LONER -10 // A . . / . R . . . L
+#define LOCK_SYNC_LONER -10 // A r . / . R . . . L
#define LOCK_MIXED_LONER -11 // A . . / . R W A . L
#define LOCK_LOCK_LONER -15 // A . . / c . . . b . *
case LOCK_SYNC: return "sync";
case LOCK_LONER_SYNC: return "loner->sync";
case LOCK_MIXED_SYNC: return "mixed->sync";
+ case LOCK_LOCK_SYNC: return "lock->sync";
case LOCK_LOCK: return "lock";
case LOCK_SYNC_LOCK: return "sync->lock";
case LOCK_LONER_LOCK: return "loner->lock";
// to sync
case LOCK_LONER_SYNC:
case LOCK_MIXED_SYNC:
+ case LOCK_LOCK_SYNC:
lock->set_state(LOCK_SYNC);
in->loner_cap = -1;
assert(in->is_auth());
assert(lock->is_stable());
- if (lock->get_state() != LOCK_LOCK) {
- // gather?
- switch (lock->get_state()) {
- case LOCK_MIXED: lock->set_state(LOCK_MIXED_SYNC); break;
- case LOCK_LONER: lock->set_state(LOCK_LONER_SYNC); break;
- default: assert(0);
- }
-
- int gather = 0;
- int loner_issued, other_issued;
- in->get_caps_issued(&loner_issued, &other_issued);
- if ((loner_issued & ~lock->caps_allowed(true)) ||
- (other_issued & ~lock->caps_allowed(false))) {
- issue_caps(in);
- gather++;
- }
- if (lock->is_wrlocked())
- gather++;
- if (in->state_test(CInode::STATE_NEEDSRECOVER)) {
- mds->mdcache->queue_file_recover(in);
- mds->mdcache->do_file_recover();
- gather++;
- }
-
- if (gather) {
- lock->get_parent()->auth_pin(lock);
- return false;
- }
+ // gather?
+ switch (lock->get_state()) {
+ case LOCK_MIXED: lock->set_state(LOCK_MIXED_SYNC); break;
+ case LOCK_LONER: lock->set_state(LOCK_LONER_SYNC); break;
+ case LOCK_LOCK: lock->set_state(LOCK_LOCK_SYNC); break;
+ default: assert(0);
}
- assert(!lock->is_wrlocked()); // FIXME if we hit this we need a new gsynck state or somethin'
+ int gather = 0;
+ int loner_issued, other_issued;
+ in->get_caps_issued(&loner_issued, &other_issued);
+ if ((loner_issued & ~lock->caps_allowed(true)) ||
+ (other_issued & ~lock->caps_allowed(false))) {
+ issue_caps(in);
+ gather++;
+ }
+ if (lock->is_wrlocked())
+ gather++;
+ if (in->state_test(CInode::STATE_NEEDSRECOVER)) {
+ mds->mdcache->queue_file_recover(in);
+ mds->mdcache->do_file_recover();
+ gather++;
+ }
+
+ if (gather) {
+ lock->get_parent()->auth_pin(lock);
+ return false;
+ }
// ok
if (in->is_replicated()) {