X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fllite%2Fllite_lib.c;h=08936e2f539a7554b14820838992e4f158ebea15;hp=9769ec318334f1b7d534af064c4bcdab5fceceb7;hb=8f34119e3dc448f75605bf4968ef5540789426ec;hpb=9d3ff0a1562f8283572c5e0d9c20df2f07aa93a1 diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 9769ec3..08936e2 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2157,12 +2157,9 @@ int ll_prep_inode(struct inode **inode, ibits = MDS_INODELOCK_LAYOUT; if (S_ISREG(md.body->mode) && sbi->ll_flags & LL_SBI_LAYOUT_LOCK && md.lsm != NULL && !ll_have_md_lock(*inode, &ibits, LCK_MINMODE)) { - char *fsname = ll_get_fsname(*inode); CERROR("%s: inode "DFID" (%p) layout lock not granted.\n", - fsname, PFID(ll_inode2fid(*inode)), - *inode); - if (fsname) - OBD_FREE(fsname, MGS_PARAM_MAXLEN); + ll_get_fsname(sb, NULL, 0), + PFID(ll_inode2fid(*inode)), *inode); } out: @@ -2363,3 +2360,36 @@ int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg) RETURN(0); } + +/** + * Get lustre file system name by \a sbi. If \a buf is provided(non-NULL), the + * fsname will be returned in this buffer; otherwise, a static buffer will be + * used to store the fsname and returned to caller. + */ +char *ll_get_fsname(struct super_block *sb, char *buf, int buflen) +{ + static char fsname_static[MTI_NAME_MAXLEN]; + struct lustre_sb_info *lsi = s2lsi(sb); + char *ptr; + int len; + + if (buf == NULL) { + /* this means the caller wants to use static buffer + * and it doesn't care about race. Usually this is + * in error reporting path */ + buf = fsname_static; + buflen = sizeof(fsname_static); + } + + len = strlen(lsi->lsi_lmd->lmd_profile); + ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-'); + if (ptr && (strcmp(ptr, "-client") == 0)) + len -= 7; + + if (unlikely(len >= buflen)) + len = buflen - 1; + strncpy(buf, lsi->lsi_lmd->lmd_profile, len); + buf[len] = '\0'; + + return buf; +}