Whamcloud - gitweb
LU-9679 llite: Discard LUSTRE_FPRIVATE()
[fs/lustre-release.git] / lustre / llite / pcc.c
index 57585e0..8ab41b4 100644 (file)
@@ -214,13 +214,13 @@ pcc_fname_list_add(struct cfs_lstr *id, struct list_head *fname_list)
 {
        struct pcc_match_fname *fname;
 
-       OBD_ALLOC(fname, sizeof(struct pcc_match_fname));
+       OBD_ALLOC_PTR(fname);
        if (fname == NULL)
                return -ENOMEM;
 
        OBD_ALLOC(fname->pmf_name, id->ls_len + 1);
        if (fname->pmf_name == NULL) {
-               OBD_FREE(fname, sizeof(struct pcc_match_fname));
+               OBD_FREE_PTR(fname);
                return -ENOMEM;
        }
 
@@ -313,7 +313,7 @@ pcc_expression_parse(struct cfs_lstr *src, struct list_head *cond_list)
        struct cfs_lstr field;
        int rc = 0;
 
-       OBD_ALLOC(expr, sizeof(struct pcc_expression));
+       OBD_ALLOC_PTR(expr);
        if (expr == NULL)
                return -ENOMEM;
 
@@ -371,7 +371,7 @@ pcc_conjunction_parse(struct cfs_lstr *src, struct list_head *cond_list)
        struct cfs_lstr expr;
        int rc = 0;
 
-       OBD_ALLOC(conjunction, sizeof(struct pcc_conjunction));
+       OBD_ALLOC_PTR(conjunction);
        if (conjunction == NULL)
                return -ENOMEM;
 
@@ -1338,21 +1338,18 @@ static int pcc_try_datasets_attach(struct inode *inode, enum pcc_io_type iot,
                 * from icache later.
                 * Set the saved dataset flags with PCC_DATASET_NONE. Then this
                 * file will skip from the candidates to try auto attach until
-                * the file is attached ninto PCC again.
+                * the file is attached into PCC again.
                 *
                 * If the file was never attached into PCC, or once attached but
                 * its inode was evicted from icache (lli_pcc_generation == 0),
+                * or the corresponding dataset was removed from the client,
                 * set the saved dataset flags with PCC_DATASET_NONE.
                 *
-                * If the file was once attached into PCC but the corresponding
-                * dataset was removed from the client, set the saved dataset
-                * flags with PCC_DATASET_NONE.
-                *
                 * TODO: If the file was once attached into PCC but not try to
                 * auto attach due to the change of the configuration parameters
                 * for this dataset (i.e. change from auto attach enabled to
                 * auto attach disabled for this dataset), update the saved
-                * dataset flags witha the found one.
+                * dataset flags with the found one.
                 */
                lli->lli_pcc_dsflags = PCC_DATASET_NONE;
        }
@@ -1431,7 +1428,7 @@ static inline bool pcc_may_auto_attach(struct inode *inode,
                return false;
 
        /*
-        * lli_pcc_generation = 0 means that the file was never attached into
+        * lli_pcc_generation == 0 means that the file was never attached into
         * PCC, or may be once attached into PCC but detached as the inode is
         * evicted from icache (i.e. "echo 3 > /proc/sys/vm/drop_caches" or
         * icache shrinking due to the memory pressure), which will cause the
@@ -1440,7 +1437,7 @@ static inline bool pcc_may_auto_attach(struct inode *inode,
         */
        /* lli_pcc_generation == 0, or the PCC setting was changed,
         * or there is no PCC setup on the client and the try will return
-        * immediately in pcc_try_auto_attch().
+        * immediately in pcc_try_auto_attach().
         */
        if (super->pccs_generation != lli->lli_pcc_generation)
                return true;
@@ -1459,7 +1456,7 @@ int pcc_file_open(struct inode *inode, struct file *file)
 {
        struct pcc_inode *pcci;
        struct ll_inode_info *lli = ll_i2info(inode);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct pcc_file *pccf = &fd->fd_pcc_file;
        struct file *pcc_file;
        struct path *path;
@@ -1520,7 +1517,7 @@ out_unlock:
 void pcc_file_release(struct inode *inode, struct file *file)
 {
        struct pcc_inode *pcci;
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct pcc_file *pccf;
        struct path *path;
        struct qstr *dname;
@@ -1622,7 +1619,7 @@ ssize_t pcc_file_read_iter(struct kiocb *iocb,
                           struct iov_iter *iter, bool *cached)
 {
        struct file *file = iocb->ki_filp;
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct pcc_file *pccf = &fd->fd_pcc_file;
        struct inode *inode = file_inode(file);
        ssize_t result;
@@ -1689,7 +1686,7 @@ ssize_t pcc_file_write_iter(struct kiocb *iocb,
                            struct iov_iter *iter, bool *cached)
 {
        struct file *file = iocb->ki_filp;
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct pcc_file *pccf = &fd->fd_pcc_file;
        struct inode *inode = file_inode(file);
        ssize_t result;
@@ -1789,11 +1786,10 @@ int pcc_inode_getattr(struct inode *inode, bool *cached)
                GOTO(out, rc);
 
        ll_inode_size_lock(inode);
-       if (inode->i_atime.tv_sec < lli->lli_atime ||
-           lli->lli_update_atime) {
+       if (ll_file_test_and_clear_flag(lli, LLIF_UPDATE_ATIME) ||
+           inode->i_atime.tv_sec < lli->lli_atime)
                inode->i_atime.tv_sec = lli->lli_atime;
-               lli->lli_update_atime = 0;
-       }
+
        inode->i_mtime.tv_sec = lli->lli_mtime;
        inode->i_ctime.tv_sec = lli->lli_ctime;
 
@@ -1829,7 +1825,7 @@ ssize_t pcc_file_splice_read(struct file *in_file, loff_t *ppos,
                             bool *cached)
 {
        struct inode *inode = file_inode(in_file);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(in_file);
+       struct ll_file_data *fd = in_file->private_data;
        struct file *pcc_file = fd->fd_pcc_file.pccf_file;
        ssize_t result;
 
@@ -1858,7 +1854,7 @@ int pcc_fsync(struct file *file, loff_t start, loff_t end,
              int datasync, bool *cached)
 {
        struct inode *inode = file_inode(file);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct file *pcc_file = fd->fd_pcc_file.pccf_file;
        int rc;
 
@@ -1884,7 +1880,7 @@ int pcc_file_mmap(struct file *file, struct vm_area_struct *vma,
                  bool *cached)
 {
        struct inode *inode = file_inode(file);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct file *pcc_file = fd->fd_pcc_file.pccf_file;
        struct pcc_inode *pcci;
        int rc = 0;
@@ -1919,7 +1915,7 @@ void pcc_vm_open(struct vm_area_struct *vma)
        struct pcc_inode *pcci;
        struct file *file = vma->vm_file;
        struct inode *inode = file_inode(file);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct file *pcc_file = fd->fd_pcc_file.pccf_file;
        struct vm_operations_struct *pcc_vm_ops = vma->vm_private_data;
 
@@ -1943,7 +1939,7 @@ void pcc_vm_close(struct vm_area_struct *vma)
 {
        struct file *file = vma->vm_file;
        struct inode *inode = file_inode(file);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct file *pcc_file = fd->fd_pcc_file.pccf_file;
        struct vm_operations_struct *pcc_vm_ops = vma->vm_private_data;
 
@@ -1968,7 +1964,7 @@ int pcc_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
        struct mm_struct *mm = vma->vm_mm;
        struct file *file = vma->vm_file;
        struct inode *inode = file_inode(file);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct file *pcc_file = fd->fd_pcc_file.pccf_file;
        struct vm_operations_struct *pcc_vm_ops = vma->vm_private_data;
        int rc;
@@ -2048,7 +2044,7 @@ int pcc_fault(struct vm_area_struct *vma, struct vm_fault *vmf,
 {
        struct file *file = vma->vm_file;
        struct inode *inode = file_inode(file);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct file *pcc_file = fd->fd_pcc_file.pccf_file;
        struct vm_operations_struct *pcc_vm_ops = vma->vm_private_data;
        int rc;
@@ -2078,13 +2074,12 @@ int pcc_fault(struct vm_area_struct *vma, struct vm_fault *vmf,
 
 static void pcc_layout_wait(struct pcc_inode *pcci)
 {
-       struct l_wait_info lwi = { 0 };
 
        while (atomic_read(&pcci->pcci_active_ios) > 0) {
                CDEBUG(D_CACHE, "Waiting for IO completion: %d\n",
                       atomic_read(&pcci->pcci_active_ios));
-               l_wait_event(pcci->pcci_waitq,
-                            atomic_read(&pcci->pcci_active_ios) == 0, &lwi);
+               wait_event_idle(pcci->pcci_waitq,
+                               atomic_read(&pcci->pcci_active_ios) == 0);
        }
 }
 
@@ -2685,7 +2680,7 @@ int pcc_ioctl_state(struct file *file, struct inode *inode,
        char *buf;
        char *path;
        int buf_len = sizeof(state->pccs_path);
-       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       struct ll_file_data *fd = file->private_data;
        struct pcc_file *pccf = &fd->fd_pcc_file;
        struct pcc_inode *pcci;