Whamcloud - gitweb
LU-17538 fid: do not use allocation set for ofd 91/54191/15
authorLi Dongyang <dongyangli@ddn.com>
Tue, 27 Feb 2024 04:05:35 +0000 (15:05 +1100)
committerOleg Drokin <green@whamcloud.com>
Thu, 2 Jan 2025 20:40:52 +0000 (20:40 +0000)
The sequence server on ofd is allocating new sequences
to osp, the lowater/hiwater allocation sets could
result in a gap of 2000 sequences after restaring the cluster.

Change-Id: I038a9b6add9977c58b58de3aa1f4d0926063bcb2
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54191
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sergey Cheremencev <scherementsev@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/fid/fid_handler.c
lustre/include/lustre_fid.h
lustre/mdt/mdt_handler.c
lustre/ofd/ofd_dev.c
lustre/tests/conf-sanity.sh

index 8007f25..ef66819 100644 (file)
@@ -283,7 +283,7 @@ int seq_server_check_and_alloc_super(const struct lu_env *env,
                }
        }
 
-       if (lu_seq_range_is_zero(&seq->lss_lowater_set))
+       if (lu_seq_range_is_zero(&seq->lss_lowater_set) && seq->lss_set_width)
                __seq_set_init(env, seq);
 
        RETURN(rc);
@@ -316,7 +316,13 @@ static int __seq_server_alloc_meta(struct lu_server_seq *seq,
                RETURN(rc);
        }
 
-       rc = range_alloc_set(env, out, seq);
+       if (seq->lss_set_width) {
+               rc = range_alloc_set(env, out, seq);
+       } else {
+               range_alloc(out, space, seq->lss_width);
+               rc = seq_store_update(env, seq, NULL, 1);
+       }
+
        if (rc != 0) {
                CERROR("%s: Allocated meta-sequence failed: rc = %d\n",
                       seq->lss_name, rc);
@@ -458,12 +464,10 @@ static void seq_server_debugfs_init(struct lu_server_seq *seq)
                                    seq, &seq_fld_debugfs_seq_fops);
 }
 
-int seq_server_init(const struct lu_env *env,
-                   struct lu_server_seq *seq,
-                   struct dt_device *dev,
-                   const char *prefix,
-                   enum lu_mgr_type type,
-                   struct seq_server_site *ss)
+int seq_server_init(const struct lu_env *env, struct lu_server_seq *seq,
+                   struct dt_device *dev, const char *prefix,
+                   enum lu_mgr_type type, struct seq_server_site *ss,
+                   bool set_batch_width)
 {
        int rc, is_srv = (type == LUSTRE_SEQ_SERVER);
        ENTRY;
@@ -491,7 +495,7 @@ int seq_server_init(const struct lu_env *env,
 
        lu_seq_range_init(&seq->lss_lowater_set);
        lu_seq_range_init(&seq->lss_hiwater_set);
-       seq->lss_set_width = LUSTRE_SEQ_BATCH_WIDTH;
+       seq->lss_set_width = set_batch_width ? LUSTRE_SEQ_BATCH_WIDTH : 0;
 
        mutex_init(&seq->lss_mutex);
 
index ae782ea..8a9b9db 100644 (file)
@@ -484,12 +484,10 @@ struct seq_server_site {
 
 /* Server methods */
 
-int seq_server_init(const struct lu_env *env,
-                   struct lu_server_seq *seq,
-                   struct dt_device *dev,
-                   const char *prefix,
-                   enum lu_mgr_type type,
-                   struct seq_server_site *ss);
+int seq_server_init(const struct lu_env *env, struct lu_server_seq *seq,
+                   struct dt_device *dev, const char *prefix,
+                   enum lu_mgr_type type, struct seq_server_site *ss,
+                   bool set_batch_width);
 
 void seq_server_fini(struct lu_server_seq *seq,
                     const struct lu_env *env);
index 2ef2755..6c53029 100644 (file)
@@ -5595,7 +5595,7 @@ static int mdt_seq_init(const struct lu_env *env, struct mdt_device *mdt)
 
                rc = seq_server_init(env, ss->ss_control_seq, mdt->mdt_bottom,
                                     mdt_obd_name(mdt), LUSTRE_SEQ_CONTROLLER,
-                                    ss);
+                                    ss, true);
                if (rc)
                        GOTO(out_seq_fini, rc);
        }
@@ -5606,7 +5606,7 @@ static int mdt_seq_init(const struct lu_env *env, struct mdt_device *mdt)
                GOTO(out_seq_fini, rc = -ENOMEM);
 
        rc = seq_server_init(env, ss->ss_server_seq, mdt->mdt_bottom,
-                            mdt_obd_name(mdt), LUSTRE_SEQ_SERVER, ss);
+                            mdt_obd_name(mdt), LUSTRE_SEQ_SERVER, ss, true);
        if (rc)
                GOTO(out_seq_fini, rc);
 
index 2cdbbba..85d6ae8 100644 (file)
@@ -779,7 +779,7 @@ int ofd_fid_init(const struct lu_env *env, struct ofd_device *ofd)
                GOTO(out_name, rc = -ENOMEM);
 
        rc = seq_server_init(env, ss->ss_server_seq, ofd->ofd_osd, obd_name,
-                            LUSTRE_SEQ_SERVER, ss);
+                            LUSTRE_SEQ_SERVER, ss, false);
        if (rc) {
                CERROR("%s: seq server init error: rc = %d\n", obd_name, rc);
                GOTO(out_server, rc);
index 50ec11a..f3289af 100755 (executable)
@@ -11958,6 +11958,34 @@ test_154() {
 }
 run_test 154 "expand .. on rename after MDT backup restore"
 
+test_155() {
+       (( OST1_VERSION >= $(version_code 2.16.50.134) )) ||
+               skip "Need OST version at least 2.16.50.134"
+
+       reformat_and_config
+       setupall
+
+       rm -rf $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
+       $LFS setstripe -c 1 -i 0 $DIR/$tdir
+
+       force_new_seq mds1
+       touch $DIR/$tdir/$tfile
+       local seq1=$($LFS getstripe --yaml $DIR/$tdir/$tfile |
+                    awk -F ':' '/l_fid:/ {print $2}' | tr -d [:blank:])
+
+       stopall
+       setupall
+
+       force_new_seq mds1
+       touch $DIR/$tdir/${tfile}2
+       local seq2=$($LFS getstripe --yaml $DIR/$tdir/${tfile}2 |
+                    awk -F ':' '/l_fid:/ {print $2}' | tr -d [:blank:])
+
+       (( seq2 == seq1 + 1 )) || error "gap in seq: old $seq1 new $seq2"
+}
+run_test 155 "gap in seq allocation from ofd after restarting"
+
 cleanup_200() {
        local modopts=$1
        stopall