From: Fan Yong Date: Wed, 30 May 2012 12:27:48 +0000 (+0800) Subject: LU-957 scrub: Ancillary work for LFSCK/OI scrub X-Git-Tag: 2.2.55~34 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=960857b6b23d9e715cd9737db6e25229d523e2a8 LU-957 scrub: Ancillary work for LFSCK/OI scrub 1) New debug sub-system - 'D_LFSCK' For Lustre fsck/scrub running trace. 2) New MDT mount option - 'noscrub' To disable auto triggering OI scrub when MDT mounts up or by RPC which accesses inconsistent OI mapping entry. 3) Any object which will be used when Lustre server mounts should not be added into OI files to guarantee that the Lustre server can start up even though OI files corrupt. Signed-off-by: Fan Yong Change-Id: I8b1f1f1160db25ce05bd2d5688f9ff1507e3841b Reviewed-on: http://review.whamcloud.com/2897 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index 3167231..687755e 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -26,6 +26,8 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012 Whamcloud, Inc. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -149,6 +151,7 @@ struct ptldebug_header { #define D_CONSOLE 0x02000000 #define D_QUOTA 0x04000000 #define D_SEC 0x08000000 +#define D_LFSCK 0x10000000 /* For both OI scrub and LFSCK */ /* keep these in sync with lnet/{utils,libcfs}/debug.c */ #define D_HSM D_TRACE diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index 8d46a8b..262eb02 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -27,7 +27,7 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, Whamcloud, Inc. + * Copyright (c) 2011, 2012, Whamcloud, Inc. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -245,7 +245,9 @@ libcfs_debug_dbg2str(int debug) return "quota"; case D_SEC: return "sec"; - } + case D_LFSCK: + return "lfsck"; + } } int diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index a0b7526..5fcf6a3 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -214,6 +214,7 @@ struct lustre_mount_data { existing MGS services */ #define LMD_FLG_WRITECONF 0x0040 /* Rewrite config log */ #define LMD_FLG_NOIR 0x0080 /* NO imperative recovery */ +#define LMD_FLG_NOSCRUB 0x0100 /* Do not trigger scrub automatically */ #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT) @@ -476,6 +477,7 @@ struct lustre_sb_info { #define s2lsi_nocast(sb) ((sb)->s_fs_info) #define get_profile_name(sb) (s2lsi(sb)->lsi_lmd->lmd_profile) +#define get_mount_flags(sb) (s2lsi(sb)->lsi_lmd->lmd_flags) #endif /* __KERNEL__ */ diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 36106fe..b5f816f 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -986,6 +986,11 @@ struct ptlrpc_thread { struct lu_env *t_env; }; +static inline int thread_is_init(struct ptlrpc_thread *thread) +{ + return thread->t_flags == 0; +} + static inline int thread_is_stopped(struct ptlrpc_thread *thread) { return !!(thread->t_flags & SVC_STOPPED); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 6785e29..85f0e67 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -2198,6 +2198,9 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } else if (strncmp(s1, "nomgs", 5) == 0) { lmd->lmd_flags |= LMD_FLG_NOMGS; clear++; + } else if (strncmp(s1, "noscrub", 7) == 0) { + lmd->lmd_flags |= LMD_FLG_NOSCRUB; + clear++; } else if (strncmp(s1, "writeconf", 9) == 0) { lmd->lmd_flags |= LMD_FLG_WRITECONF; clear++; diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index 2099ea0..69bea5d 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -551,18 +551,17 @@ int osd_compat_spec_insert(struct osd_thread_info *info, } int osd_compat_spec_lookup(struct osd_thread_info *info, - struct osd_device *osd, const struct lu_fid *fid, - struct osd_inode_id *id) + struct osd_device *osd, const struct lu_fid *fid, + struct osd_inode_id *id) { - struct dentry *dentry; - char *name; - int rc = -ERESTART; - - ENTRY; + struct dentry *dentry; + char *name; + int rc = -ENOENT; + ENTRY; - name = oid2name(fid_oid(fid)); - if (name == NULL || strlen(name) == 0) - return -ERESTART; + name = oid2name(fid_oid(fid)); + if (name == NULL || strlen(name) == 0) + RETURN(-ENOENT); dentry = ll_lookup_one_len(name, osd_sb(osd)->s_root, strlen(name)); if (!IS_ERR(dentry)) { diff --git a/lustre/osd-ldiskfs/osd_oi.c b/lustre/osd-ldiskfs/osd_oi.c index 587a8dc..d5f7a31 100644 --- a/lustre/osd-ldiskfs/osd_oi.c +++ b/lustre/osd-ldiskfs/osd_oi.c @@ -453,11 +453,8 @@ int osd_oi_lookup(struct osd_thread_info *info, struct osd_device *osd, id->oii_ino = inode->i_ino; id->oii_gen = inode->i_generation; } else { - if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) { - rc = osd_compat_spec_lookup(info, osd, fid, id); - if (rc == 0 || rc != -ERESTART) - goto out; - } + if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) + return osd_compat_spec_lookup(info, osd, fid, id); fid_cpu_to_be(oi_fid, fid); key = (struct dt_key *)oi_fid; @@ -473,8 +470,6 @@ int osd_oi_lookup(struct osd_thread_info *info, struct osd_device *osd, rc = -ENOENT; } } - -out: return rc; } @@ -525,22 +520,22 @@ static int osd_oi_iam_insert(struct osd_thread_info *oti, struct osd_oi *oi, } int osd_oi_insert(struct osd_thread_info *info, struct osd_device *osd, - const struct lu_fid *fid, const struct osd_inode_id *id0, - struct thandle *th, int ignore_quota) + const struct lu_fid *fid, const struct osd_inode_id *id0, + struct thandle *th, int ignore_quota) { - struct lu_fid *oi_fid = &info->oti_fid; - struct osd_inode_id *id; - const struct dt_key *key; + struct lu_fid *oi_fid = &info->oti_fid; + struct osd_inode_id *id; + const struct dt_key *key; - if (fid_is_igif(fid)) - return 0; + if (fid_is_igif(fid) || unlikely(fid_seq(fid) == FID_SEQ_DOT_LUSTRE)) + return 0; - if (fid_is_idif(fid) || fid_seq(fid) == FID_SEQ_LLOG) - return osd_compat_objid_insert(info, osd, fid, id0, th); + if (fid_is_idif(fid) || fid_seq(fid) == FID_SEQ_LLOG) + return osd_compat_objid_insert(info, osd, fid, id0, th); - /* notice we don't return immediately, but continue to get into OI */ - if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) - osd_compat_spec_insert(info, osd, fid, id0, th); + /* Server mount should not depends on OI files */ + if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) + return osd_compat_spec_insert(info, osd, fid, id0, th); fid_cpu_to_be(oi_fid, fid); key = (struct dt_key *)oi_fid; @@ -586,9 +581,6 @@ int osd_oi_delete(struct osd_thread_info *info, struct lu_fid *oi_fid = &info->oti_fid; const struct dt_key *key; - if (!fid_is_norm(fid)) - return 0; - LASSERT(fid_seq(fid) != FID_SEQ_LOCAL_FILE); if (fid_is_idif(fid) || fid_seq(fid) == FID_SEQ_LLOG)