Whamcloud - gitweb
LU-6142 llite: use %pd to report dentry names. 42/38442/3
authorMr NeilBrown <neilb@suse.de>
Fri, 1 May 2020 05:46:33 +0000 (15:46 +1000)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 May 2020 05:04:05 +0000 (05:04 +0000)
Since Linux 3.12, it has been possible use the "%pd" format specifier
to print a dentry name, so use that instead of "%.*s" and having
to pass both the length and the name.

Redhat's 3.10 kernels also have this functionality backported.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I70303a2c375d54825e89a0ba6703914528c54c05
Reviewed-on: https://review.whamcloud.com/38442
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/dcache.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/namei.c
lustre/llite/pcc.c
lustre/llite/statahead.c

index d33e680..b60f5d7 100644 (file)
@@ -127,9 +127,9 @@ static int ll_ddelete(const struct dentry *de)
        ENTRY;
        LASSERT(de);
 
-       CDEBUG(D_DENTRY, "%s dentry %.*s (%p, parent %p, inode %p) %s%s\n",
+       CDEBUG(D_DENTRY, "%s dentry %pd (%p, parent %p, inode %p) %s%s\n",
               d_lustre_invalid((struct dentry *)de) ? "deleting" : "keeping",
-              de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
+              de, de, de->d_parent, de->d_inode,
               d_unhashed((struct dentry *)de) ? "" : "hashed,",
               list_empty(&de->d_subdirs) ? "" : "subdirs");
 
@@ -146,9 +146,9 @@ int ll_d_init(struct dentry *de)
        ENTRY;
        LASSERT(de != NULL);
 
-       CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n",
-               de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
-               ll_d_count(de));
+       CDEBUG(D_DENTRY, "ldd on dentry %pd (%p) parent %p inode %p refc %d\n",
+              de, de, de->d_parent, de->d_inode,
+              ll_d_count(de));
 
        if (de->d_fsdata == NULL) {
                struct ll_dentry_data *lld;
@@ -229,9 +229,9 @@ void ll_invalidate_aliases(struct inode *inode)
 
        spin_lock(&inode->i_lock);
        hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
-               CDEBUG(D_DENTRY, "dentry in drop %.*s (%p) parent %p "
-                      "inode %p flags %d\n", dentry->d_name.len,
-                      dentry->d_name.name, dentry, dentry->d_parent,
+               CDEBUG(D_DENTRY,
+                      "dentry in drop %pd (%p) parent %p inode %p flags %d\n",
+                      dentry, dentry, dentry->d_parent,
                       dentry->d_inode, dentry->d_flags);
 
                d_lustre_invalidate(dentry, 0);
index 23aa55b..46377df 100644 (file)
@@ -2960,9 +2960,9 @@ int ll_file_lock_ahead(struct file *file, struct llapi_lu_ladvise *ladvise)
 
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "Lock request: file=%.*s, inode=%p, mode=%s "
-              "start=%llu, end=%llu\n", dentry->d_name.len,
-              dentry->d_name.name, dentry->d_inode,
+       CDEBUG(D_VFSTRACE,
+              "Lock request: file=%pd, inode=%p, mode=%s start=%llu, end=%llu\n",
+              dentry, dentry->d_inode,
               user_lockname[ladvise->lla_lockahead_mode], (__u64) start,
               (__u64) end);
 
index b6b0908..43a46eb 100644 (file)
@@ -1553,8 +1553,8 @@ static inline void __d_lustre_invalidate(struct dentry *dentry)
  */
 static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
 {
-       CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p "
-              "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry,
+       CDEBUG(D_DENTRY, "invalidate dentry %pd (%p) parent %p inode %p refc %d\n",
+              dentry, dentry,
               dentry->d_parent, dentry->d_inode, ll_d_count(dentry));
 
        spin_lock_nested(&dentry->d_lock,
index 92a99c4..47fb612 100644 (file)
@@ -749,15 +749,14 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
 
        ENTRY;
 
-        if (dentry->d_name.len > ll_i2sbi(parent)->ll_namelen)
-                RETURN(ERR_PTR(-ENAMETOOLONG));
+       if (dentry->d_name.len > ll_i2sbi(parent)->ll_namelen)
+               RETURN(ERR_PTR(-ENAMETOOLONG));
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p), intent=%s\n",
-              dentry->d_name.len, dentry->d_name.name,
-              PFID(ll_inode2fid(parent)), parent, LL_IT2STR(it));
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p), intent=%s\n",
+              dentry, PFID(ll_inode2fid(parent)), parent, LL_IT2STR(it));
 
-        if (d_mountpoint(dentry))
-                CERROR("Tell Peter, lookup on mtpt, it %s\n", LL_IT2STR(it));
+       if (d_mountpoint(dentry))
+               CERROR("Tell Peter, lookup on mtpt, it %s\n", LL_IT2STR(it));
 
        if (it == NULL || it->it_op == IT_GETXATTR)
                it = &lookup_it;
@@ -924,9 +923,8 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
        struct lookup_intent *itp, it = { .it_op = IT_GETATTR };
        struct dentry *de;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p), flags=%u\n",
-              dentry->d_name.len, dentry->d_name.name,
-              PFID(ll_inode2fid(parent)), parent, flags);
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p), flags=%u\n",
+              dentry, PFID(ll_inode2fid(parent)), parent, flags);
 
        /*
         * Optimize away (CREATE && !OPEN). Let .create handle the race.
@@ -988,9 +986,8 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
        ENTRY;
 
        CDEBUG(D_VFSTRACE,
-              "VFS Op:name=%.*s, dir="DFID"(%p), file %p, open_flags %x, mode %x opened %d\n",
-              dentry->d_name.len, dentry->d_name.name,
-              PFID(ll_inode2fid(dir)), dir, file, open_flags, mode,
+              "VFS Op:name=%pd, dir="DFID"(%p), file %p, open_flags %x, mode %x opened %d\n",
+              dentry, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode,
               ll_is_opened(opened, file));
 
        /* Only negative dentries enter here */
@@ -1171,9 +1168,8 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry,
        int rc = 0;
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p), intent=%s\n",
-              dentry->d_name.len, dentry->d_name.name,
-              PFID(ll_inode2fid(dir)), dir, LL_IT2STR(it));
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p), intent=%s\n",
+              dentry, PFID(ll_inode2fid(dir)), dir, LL_IT2STR(it));
 
        rc = it_open_error(DISP_OPEN_CREATE, it);
        if (rc)
@@ -1372,14 +1368,12 @@ err_exit:
 static int ll_mknod(struct inode *dir, struct dentry *dchild, umode_t mode,
                    dev_t rdev)
 {
-       struct qstr *name = &dchild->d_name;
        ktime_t kstart = ktime_get();
        int err;
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p) mode %o dev %x\n",
-              name->len, name->name, PFID(ll_inode2fid(dir)), dir,
-              mode, rdev);
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p) mode %o dev %x\n",
+              dchild, PFID(ll_inode2fid(dir)), dir, mode, rdev);
 
        if (!IS_POSIXACL(dir) || !exp_connect_umask(ll_i2mdexp(dir)))
                mode &= ~current_umask();
@@ -1421,17 +1415,16 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry,
 
        CFS_FAIL_TIMEOUT(OBD_FAIL_LLITE_CREATE_FILE_PAUSE, cfs_fail_val);
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p), "
-                          "flags=%u, excl=%d\n", dentry->d_name.len,
-              dentry->d_name.name, PFID(ll_inode2fid(dir)),
-              dir, mode, want_excl);
+       CDEBUG(D_VFSTRACE,
+              "VFS Op:name=%pd, dir="DFID"(%p), flags=%u, excl=%d\n",
+              dentry, PFID(ll_inode2fid(dir)), dir, mode, want_excl);
 
        /* Using mknod(2) to create a regular file is designed to not recognize
         * volatile file name, so we use ll_mknod() here. */
        rc = ll_mknod(dir, dentry, mode, 0);
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, unhashed %d\n",
-              dentry->d_name.len, dentry->d_name.name, d_unhashed(dentry));
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, unhashed %d\n",
+              dentry, d_unhashed(dentry));
 
        if (!rc)
                ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_CREATE,
@@ -1443,14 +1436,12 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry,
 static int ll_symlink(struct inode *dir, struct dentry *dchild,
                      const char *oldpath)
 {
-       struct qstr *name = &dchild->d_name;
        ktime_t kstart = ktime_get();
        int err;
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p), target=%.*s\n",
-              name->len, name->name, PFID(ll_inode2fid(dir)),
-              dir, 3000, oldpath);
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p), target=%.*s\n",
+              dchild, PFID(ll_inode2fid(dir)), dir, 3000, oldpath);
 
        err = ll_new_node(dir, dchild, oldpath, S_IFLNK | S_IRWXUGO, 0,
                          LUSTRE_OPC_SYMLINK);
@@ -1474,9 +1465,10 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir,
        int err;
 
        ENTRY;
-       CDEBUG(D_VFSTRACE, "VFS Op: inode="DFID"(%p), dir="DFID"(%p), "
-              "target=%.*s\n", PFID(ll_inode2fid(src)), src,
-              PFID(ll_inode2fid(dir)), dir, name->len, name->name);
+       CDEBUG(D_VFSTRACE,
+              "VFS Op: inode="DFID"(%p), dir="DFID"(%p), target=%pd\n",
+              PFID(ll_inode2fid(src)), src,
+              PFID(ll_inode2fid(dir)), dir, new_dentry);
 
        op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len,
                                     0, LUSTRE_OPC_ANY, NULL);
@@ -1499,13 +1491,12 @@ out:
 
 static int ll_mkdir(struct inode *dir, struct dentry *dchild, umode_t mode)
 {
-       struct qstr *name = &dchild->d_name;
        ktime_t kstart = ktime_get();
        int err;
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p)\n",
-              name->len, name->name, PFID(ll_inode2fid(dir)), dir);
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p)\n",
+              dchild, PFID(ll_inode2fid(dir)), dir);
 
        if (!IS_POSIXACL(dir) || !exp_connect_umask(ll_i2mdexp(dir)))
                mode &= ~current_umask();
@@ -1530,16 +1521,16 @@ static int ll_rmdir(struct inode *dir, struct dentry *dchild)
 
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p)\n",
-              name->len, name->name, PFID(ll_inode2fid(dir)), dir);
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p)\n",
+              dchild, PFID(ll_inode2fid(dir)), dir);
 
        if (unlikely(d_mountpoint(dchild)))
                 RETURN(-EBUSY);
 
-        op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len,
-                                     S_IFDIR, LUSTRE_OPC_ANY, NULL);
-        if (IS_ERR(op_data))
-                RETURN(PTR_ERR(op_data));
+       op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len,
+                                    S_IFDIR, LUSTRE_OPC_ANY, NULL);
+       if (IS_ERR(op_data))
+               RETURN(PTR_ERR(op_data));
 
        if (dchild->d_inode != NULL)
                op_data->op_fid3 = *ll_inode2fid(dchild->d_inode);
@@ -1599,8 +1590,8 @@ static int ll_unlink(struct inode *dir, struct dentry *dchild)
 
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p)\n",
-              name->len, name->name, PFID(ll_inode2fid(dir)), dir);
+       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p)\n",
+              dchild, PFID(ll_inode2fid(dir)), dir);
 
        /*
         * XXX: unlink bind mountpoint maybe call to here,
@@ -1665,11 +1656,10 @@ static int ll_rename(struct inode *src, struct dentry *src_dchild,
                return -EINVAL;
 #endif
 
-       CDEBUG(D_VFSTRACE, "VFS Op:oldname=%.*s, src_dir="DFID
-              "(%p), newname=%.*s, tgt_dir="DFID"(%p)\n",
-              src_name->len, src_name->name,
-              PFID(ll_inode2fid(src)), src, tgt_name->len,
-              tgt_name->name, PFID(ll_inode2fid(tgt)), tgt);
+       CDEBUG(D_VFSTRACE,
+              "VFS Op:oldname=%pd, src_dir="DFID"(%p), newname=%pd, tgt_dir="DFID"(%p)\n",
+              src_dchild, PFID(ll_inode2fid(src)), src,
+              tgt_dchild, PFID(ll_inode2fid(tgt)), tgt);
 
        if (unlikely(d_mountpoint(src_dchild) || d_mountpoint(tgt_dchild)))
                RETURN(-EBUSY);
index 9b00644..70e6bfc 100644 (file)
@@ -1443,7 +1443,6 @@ int pcc_file_open(struct inode *inode, struct file *file)
        struct pcc_file *pccf = &fd->fd_pcc_file;
        struct file *pcc_file;
        struct path *path;
-       struct qstr *dname;
        bool cached = false;
        int rc = 0;
 
@@ -1473,9 +1472,7 @@ int pcc_file_open(struct inode *inode, struct file *file)
        WARN_ON(pccf->pccf_file);
 
        path = &pcci->pcci_path;
-       dname = &path->dentry->d_name;
-       CDEBUG(D_CACHE, "opening pcc file '%.*s'\n", dname->len,
-              dname->name);
+       CDEBUG(D_CACHE, "opening pcc file '%pd'\n", path->dentry);
 
        pcc_file = dentry_open(path, file->f_flags,
                               pcc_super_cred(inode->i_sb));
@@ -1498,7 +1495,6 @@ void pcc_file_release(struct inode *inode, struct file *file)
        struct ll_file_data *fd = file->private_data;
        struct pcc_file *pccf;
        struct path *path;
-       struct qstr *dname;
 
        ENTRY;
 
@@ -1513,9 +1509,7 @@ void pcc_file_release(struct inode *inode, struct file *file)
        pcci = ll_i2pcci(inode);
        LASSERT(pcci);
        path = &pcci->pcci_path;
-       dname = &path->dentry->d_name;
-       CDEBUG(D_CACHE, "releasing pcc file \"%.*s\"\n", dname->len,
-              dname->name);
+       CDEBUG(D_CACHE, "releasing pcc file \"%pd\"\n", path->dentry);
        pcc_inode_put(pcci);
        fput(pccf->pccf_file);
        pccf->pccf_file = NULL;
@@ -2091,9 +2085,8 @@ static int pcc_inode_remove(struct inode *inode, struct dentry *pcc_dentry)
 
        rc = ll_vfs_unlink(pcc_dentry->d_parent->d_inode, pcc_dentry);
        if (rc)
-               CWARN("%s: failed to unlink PCC file %.*s, rc = %d\n",
-                     ll_i2sbi(inode)->ll_fsname, pcc_dentry->d_name.len,
-                     pcc_dentry->d_name.name, rc);
+               CWARN("%s: failed to unlink PCC file %pd, rc = %d\n",
+                     ll_i2sbi(inode)->ll_fsname, pcc_dentry, rc);
 
        return rc;
 }
@@ -2327,9 +2320,8 @@ void pcc_create_attach_cleanup(struct super_block *sb,
                rc = ll_vfs_unlink(pca->pca_dentry->d_parent->d_inode,
                                   pca->pca_dentry);
                if (rc)
-                       CWARN("failed to unlink PCC file %.*s, rc = %d\n",
-                             pca->pca_dentry->d_name.len,
-                             pca->pca_dentry->d_name.name, rc);
+                       CWARN("%s: failed to unlink PCC file %pd: rc = %d\n",
+                             ll_s2sbi(sb)->ll_fsname, pca->pca_dentry, rc);
                /* ignore the unlink failure */
                revert_creds(old_cred);
                dput(pca->pca_dentry);
index 2adb72d..e20dd4d 100644 (file)
@@ -920,8 +920,8 @@ static int ll_agl_thread(void *arg)
 
        ENTRY;
 
-       CDEBUG(D_READA, "agl thread started: sai %p, parent %.*s\n",
-              sai, parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "agl thread started: sai %p, parent %pd\n",
+              sai, parent);
 
        while (({set_current_state(TASK_IDLE);
                 !kthread_should_stop(); })) {
@@ -971,8 +971,8 @@ static void ll_stop_agl(struct ll_statahead_info *sai)
                spin_lock(&plli->lli_agl_lock);
        }
        spin_unlock(&plli->lli_agl_lock);
-       CDEBUG(D_READA, "agl thread stopped: sai %p, parent %.*s\n",
-              sai, parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "agl thread stopped: sai %p, parent %pd\n",
+              sai, parent);
        ll_sai_put(sai);
 }
 
@@ -984,8 +984,8 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
 
        ENTRY;
 
-       CDEBUG(D_READA, "start agl thread: sai %p, parent %.*s\n",
-              sai, parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "start agl thread: sai %p, parent %pd\n",
+              sai, parent);
 
        plli = ll_i2info(parent->d_inode);
        task = kthread_create(ll_agl_thread, parent,
@@ -1022,8 +1022,8 @@ static int ll_statahead_thread(void *arg)
 
        ENTRY;
 
-       CDEBUG(D_READA, "statahead thread starting: sai %p, parent %.*s\n",
-              sai, parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "statahead thread starting: sai %p, parent %pd\n",
+              sai, parent);
 
        OBD_ALLOC_PTR(op_data);
        if (!op_data)
@@ -1195,8 +1195,8 @@ out:
        /* release resources held by statahead RPCs */
        sa_handle_callback(sai);
 
-       CDEBUG(D_READA, "statahead thread stopped: sai %p, parent %.*s\n",
-              sai, parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "%s: statahead thread stopped: sai %p, parent %pd\n",
+              sbi->ll_fsname, sai, parent);
 
        spin_lock(&lli->lli_sa_lock);
        sai->sai_task = NULL;
@@ -1510,10 +1510,8 @@ static int revalidate_statahead_dentry(struct inode *dir,
                        } else if ((*dentryp)->d_inode != inode) {
                                /* revalidate, but inode is recreated */
                                CDEBUG(D_READA,
-                                      "%s: stale dentry %.*s inode " DFID", statahead inode "DFID "\n",
-                                      ll_i2sbi(inode)->ll_fsname,
-                                      (*dentryp)->d_name.len,
-                                      (*dentryp)->d_name.name,
+                                      "%s: stale dentry %pd inode " DFID", statahead inode "DFID "\n",
+                                      ll_i2sbi(inode)->ll_fsname, *dentryp,
                                       PFID(ll_inode2fid((*dentryp)->d_inode)),
                                       PFID(ll_inode2fid(inode)));
                                ll_intent_release(&it);
@@ -1604,8 +1602,8 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
        lli->lli_sai = sai;
        spin_unlock(&lli->lli_sa_lock);
 
-       CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %.*s]\n",
-              current->pid, parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %pd]\n",
+              current->pid, parent);
 
        task = kthread_create(ll_statahead_thread, parent, "ll_sa_%u",
                              lli->lli_opendir_pid);
@@ -1673,8 +1671,8 @@ int ll_statahead(struct inode *dir, struct dentry **dentryp, bool unplug)
                int rc;
 
                rc = revalidate_statahead_dentry(dir, sai, dentryp, unplug);
-               CDEBUG(D_READA, "revalidate statahead %.*s: %d.\n",
-                      (*dentryp)->d_name.len, (*dentryp)->d_name.name, rc);
+               CDEBUG(D_READA, "revalidate statahead %pd: rc = %d.\n",
+                      *dentryp, rc);
                ll_sai_put(sai);
                return rc;
        }