]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ceph: fix version check on racing inode updates
authorSage Weil <sage@newdream.net>
Mon, 8 Nov 2010 17:23:12 +0000 (09:23 -0800)
committerSage Weil <sage@newdream.net>
Mon, 8 Nov 2010 17:23:12 +0000 (09:23 -0800)
We may get updates on the same inode from multiple MDSs; generally we only
pay attention if the update is newer than what we already have.  The
exception is when an MDS sense unstable information, in which case we
always update.

The old > check got this wrong when our version was odd (e.g. 3) and the
reply version was even (e.g. 2): the older stale (v2) info would be
applied.  Fixed and clarified the comment.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/inode.c

index 5a9f907b805e26ea6e2c8037bcfa884028a5294c..425c5b1f944e4c5db563270340a8a495c46f2513 100644 (file)
@@ -567,12 +567,17 @@ static int fill_inode(struct inode *inode,
 
        /*
         * provided version will be odd if inode value is projected,
-        * even if stable.  skip the update if we have a newer info
-        * (e.g., due to inode info racing form multiple MDSs), or if
-        * we are getting projected (unstable) inode info.
+        * even if stable.  skip the update if we have newer stable
+        * info (ours>=theirs, e.g. due to racing mds replies), unless
+        * we are getting projected (unstable) info (in which case the
+        * version is odd, and we want ours>theirs).
+        *   us   them
+        *   2    2     skip
+        *   3    2     skip
+        *   3    3     update
         */
        if (le64_to_cpu(info->version) > 0 &&
-           (ci->i_version & ~1) > le64_to_cpu(info->version))
+           (ci->i_version & ~1) >= le64_to_cpu(info->version))
                goto no_change;
 
        issued = __ceph_caps_issued(ci, &implemented);