From: Fan Yong Date: Thu, 25 May 2017 19:35:20 +0000 (+0800) Subject: LU-9440 osd-ldiskfs: efficient way to get ldiskfs backend name X-Git-Tag: 2.9.59~10 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=2272a301f5e365c0ca02b5c939934c1051d910d3;hp=0e90e02ceddd60f24fac9709f3ab9e9421c80315;p=fs%2Flustre-release.git LU-9440 osd-ldiskfs: efficient way to get ldiskfs backend name In the OSD debug message, we originally used the code similar as "LDISKFS_SB(osd_sb(osd))>s_es>s_volume_name" to get the ldiskfs backend name information. That is inefficient, it can be replaced by the "osd_sb(osd)->s_id" or "inode->i_sb->s_id". Signed-off-by: Fan Yong Change-Id: I077452796065cc924e9ca3b9cfaec4b1a2a4bebe Reviewed-on: https://review.whamcloud.com/27177 Reviewed-by: Bob Glossman Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo --- diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index c950c21..b49f9b1 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -364,9 +364,9 @@ int osd_get_lma(struct osd_thread_info *info, struct inode *inode, lustre_loa_swab(loa, true); /* Check LMA compatibility */ if (lma->lma_incompat & ~LMA_INCOMPAT_SUPP) { - CWARN("%.16s: unsupported incompat LMA feature(s) %#x " + CWARN("%s: unsupported incompat LMA feature(s) %#x " "for fid = "DFID", ino = %lu\n", - LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, + osd_ino2name(inode), lma->lma_incompat & ~LMA_INCOMPAT_SUPP, PFID(&lma->lma_self_fid), inode->i_ino); rc = -EOPNOTSUPP; @@ -410,8 +410,8 @@ struct inode *osd_iget(struct osd_thread_info *info, struct osd_device *dev, iput(inode); inode = ERR_PTR(-ESTALE); } else if (is_bad_inode(inode)) { - CWARN("%.16s: bad inode: ino = %u\n", - LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name, id->oii_ino); + CWARN("%s: bad inode: ino = %u\n", + osd_dev2name(dev), id->oii_ino); iput(inode); inode = ERR_PTR(-ENOENT); } else if ((rc = osd_attach_jinode(inode))) { @@ -957,9 +957,8 @@ again: out: if (rc < 0) - CDEBUG(D_LFSCK, "%.16s: fail to check LMV EA, inode = %lu/%u," - DFID": rc = %d\n", - LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, + CDEBUG(D_LFSCK, "%s: fail to check LMV EA, inode = %lu/%u," + DFID": rc = %d\n", osd_ino2name(inode), inode->i_ino, inode->i_generation, PFID(&oic->oic_fid), rc); else @@ -1103,7 +1102,7 @@ trigger: join: rc1 = osd_scrub_start(dev, flags); - LCONSOLE_WARN("%.16s: trigger OI scrub by RPC " + LCONSOLE_WARN("%s: trigger OI scrub by RPC " "for the "DFID" with flags 0x%x," " rc = %d\n", osd_name(dev), PFID(fid), flags, rc1); @@ -5047,10 +5046,9 @@ trigger: rc = osd_scrub_start(dev, SS_AUTO_PARTIAL | SS_CLEAR_DRYRUN | SS_CLEAR_FAILOUT); CDEBUG(D_LFSCK | D_CONSOLE | D_WARNING, - "%.16s: trigger partial OI scrub for RPC inconsistency " + "%s: trigger partial OI scrub for RPC inconsistency " "checking FID "DFID": rc = %d\n", - LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name, - PFID(fid), rc); + osd_dev2name(dev), PFID(fid), rc); if (rc == 0 || rc == -EALREADY) goto again; } @@ -6143,9 +6141,9 @@ osd_dirent_reinsert(const struct lu_env *env, struct osd_device *dev, /* It is too bad, we cannot reinsert the name entry back. * That means we lose it! */ if (rc != 0) - CDEBUG(D_LFSCK, "%.16s: fail to reinsert the dirent, " + CDEBUG(D_LFSCK, "%s: fail to reinsert the dirent, " "dir = %lu/%u, name = %.*s, "DFID": rc = %d\n", - LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, + osd_ino2name(inode), dir->i_ino, dir->i_generation, namelen, dentry->d_name.name, PFID(fid), rc); diff --git a/lustre/osd-ldiskfs/osd_iam.c b/lustre/osd-ldiskfs/osd_iam.c index bf217eb..dd671d1 100644 --- a/lustre/osd-ldiskfs/osd_iam.c +++ b/lustre/osd-ldiskfs/osd_iam.c @@ -178,9 +178,8 @@ iam_load_idle_blocks(struct iam_container *c, iam_ptr_t blk) bh = __ldiskfs_bread(NULL, inode, blk, 0); if (IS_ERR_OR_NULL(bh)) { - CERROR("%.16s: cannot load idle blocks, blk = %u, err = %ld\n", - LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk, - bh ? PTR_ERR(bh) : -EIO); + CERROR("%s: cannot load idle blocks, blk = %u, err = %ld\n", + osd_ino2name(inode), blk, bh ? PTR_ERR(bh) : -EIO); c->ic_idle_failed = 1; if (bh == NULL) bh = ERR_PTR(-EIO); @@ -189,9 +188,8 @@ iam_load_idle_blocks(struct iam_container *c, iam_ptr_t blk) head = (struct iam_idle_head *)(bh->b_data); if (le16_to_cpu(head->iih_magic) != IAM_IDLE_HEADER_MAGIC) { - CERROR("%.16s: invalid idle block head, blk = %u, magic = %d\n", - LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk, - le16_to_cpu(head->iih_magic)); + CERROR("%s: invalid idle block head, blk = %u, magic = %d\n", + osd_ino2name(inode), blk, le16_to_cpu(head->iih_magic)); brelse(bh); c->ic_idle_failed = 1; return ERR_PTR(-EBADF); @@ -2219,8 +2217,8 @@ static iam_ptr_t iam_index_shrink(handle_t *h, struct iam_path *p, lh = iam_lock_htree(c, frame->curidx, DLT_WRITE); if (lh == NULL) { - CWARN("%.16s: No memory to recycle idle blocks\n", - LDISKFS_SB(inode->i_sb)->s_es->s_volume_name); + CWARN("%s: No memory to recycle idle blocks\n", + osd_ino2name(inode)); return 0; } @@ -2361,8 +2359,8 @@ static void iam_recycle_leaf(handle_t *h, struct iam_path *p, unlock: mutex_unlock(&c->ic_idle_mutex); if (rc != 0) - CWARN("%.16s: idle blocks failed, will lose the blk %u\n", - LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk); + CWARN("%s: idle blocks failed, will lose the blk %u\n", + osd_ino2name(inode), blk); } /* diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index 8166023..a7f10aa 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -935,6 +935,16 @@ static inline struct super_block *osd_sb(const struct osd_device *dev) return dev->od_mnt->mnt_sb; } +static inline const char *osd_dev2name(const struct osd_device *dev) +{ + return osd_sb(dev)->s_id; +} + +static inline const char *osd_ino2name(const struct inode *inode) +{ + return inode->i_sb->s_id; +} + /** * Put the osd object once done with it. * diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index c5c70e6..13b40c6 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1454,8 +1454,8 @@ int osd_ldiskfs_read(struct inode *inode, void *buf, int size, loff_t *offs) csize = min(blocksize - boffs, size); bh = __ldiskfs_bread(NULL, inode, block, 0); if (IS_ERR(bh)) { - CERROR("%s: can't read %u@%llu on ino %lu: rc = %ld\n", - LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, + CERROR("%s: can't read %u@%llu on ino %lu: " + "rc = %ld\n", osd_ino2name(inode), csize, *offs, inode->i_ino, PTR_ERR(bh)); return PTR_ERR(bh); diff --git a/lustre/osd-ldiskfs/osd_oi.c b/lustre/osd-ldiskfs/osd_oi.c index 3700879..cd1db06 100644 --- a/lustre/osd-ldiskfs/osd_oi.c +++ b/lustre/osd-ldiskfs/osd_oi.c @@ -316,12 +316,11 @@ osd_oi_table_open(struct osd_thread_info *info, struct osd_device *osd, continue; } - CERROR("%.16s: can't open %s: rc = %d\n", - LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name, name, rc); + CERROR("%s: can't open %s: rc = %d\n", + osd_dev2name(osd), name, rc); if (oi_count > 0) - CERROR("%.16s: expect to open total %d OI files.\n", - LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name, - oi_count); + CERROR("%s: expect to open total %d OI files.\n", + osd_dev2name(osd), oi_count); break; } @@ -362,10 +361,8 @@ static int osd_remove_ois(struct osd_thread_info *info, struct osd_device *osd) OSD_OI_NAME_BASE, i); rc = osd_remove_oi_one(osd_sb(osd)->s_root, name, namelen); if (rc != 0) { - CERROR("%.16s: fail to remove the stale OI file %s: " - "rc = %d\n", - LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name, - name, rc); + CERROR("%s: fail to remove the stale OI file %s: " + "rc = %d\n", osd_dev2name(osd), name, rc); return rc; } } @@ -373,8 +370,8 @@ static int osd_remove_ois(struct osd_thread_info *info, struct osd_device *osd) namelen = snprintf(name, sizeof(name), "%s", OSD_OI_NAME_BASE); rc = osd_remove_oi_one(osd_sb(osd)->s_root, name, namelen); if (rc != 0) - CERROR("%.16s: fail to remove the stale OI file %s: rc = %d\n", - LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name, name, rc); + CERROR("%s: fail to remove the stale OI file %s: rc = %d\n", + osd_dev2name(osd), name, rc); return rc; } @@ -435,9 +432,8 @@ int osd_oi_init(struct osd_thread_info *info, struct osd_device *osd, SF_UPGRADE); GOTO(out, rc = 1); } else if (rc != -ENOENT) { - CERROR("%.16s: can't open %s: rc = %d\n", - LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name, - OSD_OI_NAME_BASE, rc); + CERROR("%s: can't open %s: rc = %d\n", + osd_dev2name(osd), OSD_OI_NAME_BASE, rc); GOTO(out, rc); } @@ -732,9 +728,8 @@ int osd_oi_insert(struct osd_thread_info *info, struct osd_device *osd, if (!(lma->lma_compat & LMAC_NOT_IN_OI) && lu_fid_eq(fid, &lma->lma_self_fid)) { - CERROR("%.16s: the FID "DFID" is used by two objects: " - "%u/%u %u/%u\n", - LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name, + CERROR("%s: the FID "DFID" is used by two objects: " + "%u/%u %u/%u\n", osd_dev2name(osd), PFID(fid), oi_id->oii_ino, oi_id->oii_gen, id->oii_ino, id->oii_gen); return -EEXIST; diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 2f98d22..97b29b9 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -83,7 +83,7 @@ static inline int osd_scrub_has_window(struct osd_scrub *scrub, static inline const char *osd_scrub2name(struct osd_scrub *scrub) { - return LDISKFS_SB(osd_scrub2sb(scrub))->s_es->s_volume_name; + return osd_dev2name(osd_scrub2dev(scrub)); } /** @@ -274,7 +274,7 @@ void osd_scrub_file_reset(struct osd_scrub *scrub, __u8 *uuid, __u64 flags) { struct scrub_file *sf = &scrub->os_file; - CDEBUG(D_LFSCK, "%.16s: reset OI scrub file, old flags = " + CDEBUG(D_LFSCK, "%s: reset OI scrub file, old flags = " "%#llx, add flags = %#llx\n", osd_scrub2name(scrub), sf->sf_flags, flags); @@ -310,7 +310,7 @@ static int osd_scrub_file_load(struct osd_scrub *scrub) osd_scrub_file_to_cpu(sf, &scrub->os_file_disk); if (sf->sf_magic != SCRUB_MAGIC_V1) { - CDEBUG(D_LFSCK, "%.16s: invalid scrub magic " + CDEBUG(D_LFSCK, "%s: invalid scrub magic " "0x%x != 0x%x\n", osd_scrub2name(scrub), sf->sf_magic, SCRUB_MAGIC_V1); /* Process it as new scrub file. */ @@ -319,7 +319,7 @@ static int osd_scrub_file_load(struct osd_scrub *scrub) rc = 0; } } else if (rc != 0) { - CDEBUG(D_LFSCK, "%.16s: fail to load scrub file, " + CDEBUG(D_LFSCK, "%s: fail to load scrub file, " "expected = %d: rc = %d\n", osd_scrub2name(scrub), len, rc); if (rc > 0) @@ -347,7 +347,7 @@ int osd_scrub_file_store(struct osd_scrub *scrub) jh = osd_journal_start_sb(osd_sb(dev), LDISKFS_HT_MISC, credits); if (IS_ERR(jh)) { rc = PTR_ERR(jh); - CDEBUG(D_LFSCK, "%.16s: fail to start trans for scrub store: " + CDEBUG(D_LFSCK, "%s: fail to start trans for scrub store: " "rc = %d\n", osd_scrub2name(scrub), rc); return rc; } @@ -357,7 +357,7 @@ int osd_scrub_file_store(struct osd_scrub *scrub) len, 0, &pos, jh); ldiskfs_journal_stop(jh); if (rc != 0) - CDEBUG(D_LFSCK, "%.16s: fail to store scrub file, " + CDEBUG(D_LFSCK, "%s: fail to store scrub file, " "expected = %d: rc = %d\n", osd_scrub2name(scrub), len, rc); @@ -665,7 +665,7 @@ static int osd_scrub_prep(struct osd_device *dev) bool drop_dryrun = false; ENTRY; - CDEBUG(D_LFSCK, "%.16s: OI scrub prep, flags = 0x%x\n", + CDEBUG(D_LFSCK, "%s: OI scrub prep, flags = 0x%x\n", osd_scrub2name(scrub), flags); down_write(&scrub->os_rwsem); @@ -763,7 +763,7 @@ static int osd_scrub_post(struct osd_scrub *scrub, int result) int rc; ENTRY; - CDEBUG(D_LFSCK, "%.16s: OI scrub post, result = %d\n", + CDEBUG(D_LFSCK, "%s: OI scrub post, result = %d\n", osd_scrub2name(scrub), result); down_write(&scrub->os_rwsem); @@ -984,9 +984,8 @@ static int osd_iit_iget(struct osd_thread_info *info, struct osd_device *dev, if (rc == -ENOENT || rc == -ESTALE) RETURN(SCRUB_NEXT_CONTINUE); - CDEBUG(D_LFSCK, "%.16s: fail to read inode, ino# = %u: " - "rc = %d\n", LDISKFS_SB(sb)->s_es->s_volume_name, - pos, rc); + CDEBUG(D_LFSCK, "%s: fail to read inode, ino# = %u: " + "rc = %d\n", osd_dev2name(dev), pos, rc); RETURN(rc); } @@ -1147,7 +1146,7 @@ static int osd_scrub_exec(struct osd_thread_info *info, struct osd_device *dev, rc = osd_scrub_checkpoint(scrub); if (rc != 0) { - CDEBUG(D_LFSCK, "%.16s: fail to checkpoint, pos = %u: " + CDEBUG(D_LFSCK, "%s: fail to checkpoint, pos = %u: " "rc = %d\n", osd_scrub2name(scrub), scrub->os_pos_current, rc); /* Continue, as long as the scrub itself can go ahead. */ @@ -1255,7 +1254,7 @@ static void osd_scrub_join(struct osd_device *dev, __u32 flags, sf->sf_pos_last_checkpoint = sf->sf_pos_latest_start - 1; rc = osd_scrub_file_store(scrub); if (rc != 0) - CDEBUG(D_LFSCK, "%.16s: fail to store scrub file when join " + CDEBUG(D_LFSCK, "%s: fail to store scrub file when join " "the OI scrub: rc = %d\n", osd_scrub2name(scrub), rc); spin_lock(&scrub->os_lock); @@ -1414,7 +1413,7 @@ full: param.bitmap = ldiskfs_read_inode_bitmap(param.sb, param.bg); if (!param.bitmap) { - CERROR("%.16s: fail to read bitmap for %u, " + CERROR("%s: fail to read bitmap for %u, " "scrub will stop, urgent mode\n", osd_scrub2name(scrub), (__u32)param.bg); RETURN(-EIO); @@ -1515,14 +1514,14 @@ static int osd_scrub_main(void *args) rc = lu_env_init(&env, LCT_LOCAL); if (rc != 0) { - CDEBUG(D_LFSCK, "%.16s: OI scrub fail to init env: rc = %d\n", + CDEBUG(D_LFSCK, "%s: OI scrub fail to init env: rc = %d\n", osd_scrub2name(scrub), rc); GOTO(noenv, rc); } rc = osd_scrub_prep(dev); if (rc != 0) { - CDEBUG(D_LFSCK, "%.16s: OI scrub fail to scrub prep: rc = %d\n", + CDEBUG(D_LFSCK, "%s: OI scrub fail to scrub prep: rc = %d\n", osd_scrub2name(scrub), rc); GOTO(out, rc); } @@ -1541,7 +1540,7 @@ static int osd_scrub_main(void *args) scrub->os_pos_current = ooc->ooc_pos_preload; } - CDEBUG(D_LFSCK, "%.16s: OI scrub start, flags = 0x%x, pos = %u\n", + CDEBUG(D_LFSCK, "%s: OI scrub start, flags = 0x%x, pos = %u\n", osd_scrub2name(scrub), scrub->os_start_flags, scrub->os_pos_current); @@ -1552,7 +1551,7 @@ static int osd_scrub_main(void *args) post: rc = osd_scrub_post(scrub, rc); - CDEBUG(D_LFSCK, "%.16s: OI scrub: stop, pos = %u: rc = %d\n", + CDEBUG(D_LFSCK, "%s: OI scrub: stop, pos = %u: rc = %d\n", osd_scrub2name(scrub), scrub->os_pos_current, rc); out: @@ -2633,7 +2632,7 @@ again: task = kthread_run(osd_scrub_main, dev, "OI_scrub"); if (IS_ERR(task)) { rc = PTR_ERR(task); - CERROR("%.16s: cannot start iteration thread: rc = %d\n", + CERROR("%s: cannot start iteration thread: rc = %d\n", osd_scrub2name(scrub), rc); RETURN(rc); } @@ -2770,15 +2769,14 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev) OBD_ALLOC_PTR(old_uuid); OBD_ALLOC_PTR(new_uuid); if (old_uuid == NULL || new_uuid == NULL) { - CERROR("%.16s: UUID has been changed, but" + CERROR("%s: UUID has been changed, but" "failed to allocate RAM for report\n", - LDISKFS_SB(sb)->s_es->s_volume_name); + osd_dev2name(dev)); } else { class_uuid_unparse(sf->sf_uuid, old_uuid); class_uuid_unparse(es->s_uuid, new_uuid); - CERROR("%.16s: UUID has been changed from " - "%s to %s\n", - LDISKFS_SB(sb)->s_es->s_volume_name, + CERROR("%s: UUID has been changed from " + "%s to %s\n", osd_dev2name(dev), old_uuid->uuid, new_uuid->uuid); } osd_scrub_file_reset(scrub, es->s_uuid,SF_INCONSISTENT);