Whamcloud - gitweb
EX-5014 pcc: Readability cleanups
authorPatrick Farrell <pfarrell@whamcloud.com>
Mon, 25 Apr 2022 16:50:33 +0000 (12:50 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 9 Sep 2022 01:28:08 +0000 (01:28 +0000)
It's really hard to remember what 'inode' and 'file' mean
when there's more than one in a function, so I've redone
some of the names here.

Test-parameters: trivial

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ia00d0bda216a26f285f0fda8bc8edd3c51d66ce4
Reviewed-on: https://review.whamcloud.com/47157
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/llite/pcc.c
lustre/llite/pcc.h

index 6ed118b..0ffadba 100644 (file)
@@ -3742,11 +3742,12 @@ static int pcc_filp_write(struct file *filp, const void *buf, ssize_t count,
 
 static ssize_t pcc_copy_data(struct file *src, struct file *dst)
 {
+       size_t buf_len = PCC_COPY_BUFFER_BYTES;
+       struct inode *inode = file_inode(src);
+       loff_t offset = 0;
        ssize_t rc = 0;
        ssize_t rc2;
-       loff_t pos, offset = 0;
-       size_t buf_len = 1048576;
-       struct inode *inode = file_inode(src);
+       loff_t pos;
        void *buf;
 
        ENTRY;
@@ -3795,12 +3796,13 @@ out_free:
        RETURN(rc);
 }
 
-static int pcc_attach_data_archive(struct file *file, struct inode *inode,
+static int pcc_attach_data_archive(struct file *lu_file,
+                                  struct inode *lu_inode,
                                   struct pcc_dataset *dataset,
-                                  struct dentry **dentry)
+                                  struct dentry **pcc_dentry)
 {
        const struct cred *old_cred;
-       struct file *pcc_filp;
+       struct file *pcc_file;
        bool direct = false;
        struct path path;
        ktime_t kstart = ktime_get();
@@ -3810,33 +3812,34 @@ static int pcc_attach_data_archive(struct file *file, struct inode *inode,
 
        ENTRY;
 
-       old_cred = override_creds(pcc_super_cred(inode->i_sb));
-       rc = __pcc_inode_create(dataset, &ll_i2info(inode)->lli_fid, dentry);
+       old_cred = override_creds(pcc_super_cred(lu_inode->i_sb));
+       rc = __pcc_inode_create(dataset, &ll_i2info(lu_inode)->lli_fid,
+                               pcc_dentry);
        if (rc)
                GOTO(out_cred, rc);
 
        path.mnt = dataset->pccd_path.mnt;
-       path.dentry = *dentry;
+       path.dentry = *pcc_dentry;
        /* If the inode is encrypted, we want the PCC file to be synced to the
         * storage. This is necessary as we are going to decrypt the page cache
         * pages of the PCC inode later in pcc_file_read_iter(), but still we
         * need to keep the ciphertext version on disk.
         */
-       if (IS_ENCRYPTED(inode))
+       if (IS_ENCRYPTED(lu_inode))
                flags |= O_SYNC;
-       pcc_filp = dentry_open(&path, flags, current_cred());
-       if (IS_ERR_OR_NULL(pcc_filp)) {
-               rc = pcc_filp == NULL ? -EINVAL : PTR_ERR(pcc_filp);
+       pcc_file = dentry_open(&path, flags, current_cred());
+       if (IS_ERR_OR_NULL(pcc_file)) {
+               rc = pcc_file == NULL ? -EINVAL : PTR_ERR(pcc_file);
                GOTO(out_dentry, rc);
        }
 
-       rc = pcc_inode_reset_iattr(inode, *dentry, ATTR_UID | ATTR_GID,
+       rc = pcc_inode_reset_iattr(lu_inode, *pcc_dentry, ATTR_UID | ATTR_GID,
                                   old_cred->uid, old_cred->gid, 0);
        if (rc)
                GOTO(out_fput, rc);
 
-       rc = pcc_file_reset_projid(dataset, pcc_filp,
-                                   ll_i2info(inode)->lli_projid);
+       rc = pcc_file_reset_projid(dataset, pcc_file,
+                                   ll_i2info(lu_inode)->lli_projid);
        if (rc)
                GOTO(out_fput, rc);
 
@@ -3849,37 +3852,38 @@ static int pcc_attach_data_archive(struct file *file, struct inode *inode,
         * data copy. After finished data copying, restore the flag in the
         * file handle.
         */
-       if (file->f_flags & O_DIRECT) {
-               file->f_flags &= ~O_DIRECT;
+       if (lu_file->f_flags & O_DIRECT) {
+               lu_file->f_flags &= ~O_DIRECT;
                direct = true;
        }
 
-       ret = pcc_copy_data(file, pcc_filp);
+       ret = pcc_copy_data(lu_file, pcc_file);
        if (direct)
-               file->f_flags |= O_DIRECT;
+               lu_file->f_flags |= O_DIRECT;
        if (ret < 0)
                GOTO(out_fput, rc = ret);
 
-       CDEBUG(D_CACHE, "Copy data from OSTs to PCC for %pd\n", *dentry);
+       CDEBUG(D_CACHE, "Copy data from OSTs to PCC for %pd\n", *pcc_dentry);
        /*
         * It must to truncate the PCC copy to the same size of the Lustre
         * copy after copy data. Otherwise, it may get wrong file size after
         * re-attach a file. See LU-13023 for details.
         */
-       rc = pcc_inode_reset_iattr(inode, *dentry,
+       rc = pcc_inode_reset_iattr(lu_inode, *pcc_dentry,
                                   ATTR_SIZE | ATTR_MTIME | ATTR_MTIME_SET,
                                   KUIDT_INIT(0), KGIDT_INIT(0), ret);
 out_fput:
-       fput(pcc_filp);
+       fput(pcc_file);
 out_dentry:
        if (rc) {
-               pcc_inode_remove(inode, *dentry);
-               dput(*dentry);
+               pcc_inode_remove(lu_inode, *pcc_dentry);
+               dput(*pcc_dentry);
        } else {
-               ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_PCC_ATTACH,
+               ll_stats_ops_tally(ll_i2sbi(lu_inode), LPROC_LL_PCC_ATTACH,
                                   ktime_us_delta(ktime_get(), kstart));
-               ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_PCC_ATTACH_BYTES,
-                                  inode->i_size);
+               ll_stats_ops_tally(ll_i2sbi(lu_inode),
+                                  LPROC_LL_PCC_ATTACH_BYTES,
+                                  lu_inode->i_size);
        }
 out_cred:
        revert_creds(old_cred);
index 062abd0..208c490 100644 (file)
@@ -154,6 +154,12 @@ struct pcc_dataset {
 };
 
 #define PCC_DEFAULT_ASYNC_THRESHOLD    (256 << 20)
+/* buffer size for kernel buffered I/O for pcc attach
+ *
+ * performance barely varies for buffered I/O once size is more than a few
+ * hundred KiB, so just leave this at 1 MiB
+ */
+#define PCC_COPY_BUFFER_BYTES  (1 << 20) /* 1 MiB */
 
 /* after this many attaches are queued up, fall back to sync attach.  each
  * attach creates a kthread, so we don't allow too many at once, but sync