]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-fuse: reserve stag number 1 for snapdirs
authorXiubo Li <xiubli@redhat.com>
Wed, 23 Mar 2022 06:30:07 +0000 (14:30 +0800)
committerXiubo Li <xiubli@redhat.com>
Wed, 15 Jun 2022 02:29:38 +0000 (10:29 +0800)
There have two stags will be reserved, 0 for CEPH_NOSNAP and 1 for
CPEH_SNAPDIR.

This will always make sure that for the nonsnap and snapdir inode
numbers to be consistent for all the ceph-fuse mounts.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/client/fuse_ll.cc

index ee81752721c6bbffddcd6a9469827cb39a929239..587a40c39fd10d57946343461ec61175ef13c791 100644 (file)
@@ -1267,8 +1267,14 @@ CephFuse::Handle::Handle(Client *c, int fd) :
 #endif
   last_stag(0)
 {
+  /*
+   * stag 0 and 1 are always reserved for the
+   * inodes of CEPH_NOSNAP and CEPH_SNAPDIR
+   */
   snap_stag_map[CEPH_NOSNAP] = 0;
+  snap_stag_map[CEPH_SNAPDIR] = 1;
   stag_snap_map[0] = CEPH_NOSNAP;
+  stag_snap_map[1] = CEPH_SNAPDIR;
   memset(&args, 0, sizeof(args));
 #if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
   memset(&opts, 0, sizeof(opts));
@@ -1573,7 +1579,8 @@ uint64_t CephFuse::Handle::make_fake_ino(inodeno_t ino, snapid_t snapid)
     int first = last_stag & STAG_MASK;
     int stag =  (++last_stag) & STAG_MASK;
     for (; stag != first; stag = (++last_stag) & STAG_MASK) {
-      if (stag == 0)
+      // two reserved stags: 0 for CEPH_NOSNAP and 1 for CEPH_SNAPDIR
+      if (stag == 0 || stag == 1)
        continue;
 
       auto p = stag_snap_map.find(stag);