Whamcloud - gitweb
LU-14677 llite: move env contexts to ll_inode_info level 98/44198/1
authorSebastien Buisson <sbuisson@ddn.com>
Fri, 9 Jul 2021 13:41:34 +0000 (15:41 +0200)
committerSebastien Buisson <sbuisson@ddn.com>
Fri, 9 Jul 2021 15:14:44 +0000 (17:14 +0200)
Contrary to file, inode is always available, so move the list of
env contexts from the file data to the ll_inode_info level.
This is needed because we will have to handle env properties in
ll_get_context() and ll_xattr_list()/ll_listxattr().

Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I478d2a8eabfcb09074ba52601f05840d047a6da2

lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/llite_mmap.c
lustre/llite/rw.c
lustre/llite/rw26.c

index ebab2b8..abeac81 100644 (file)
@@ -740,10 +740,6 @@ static int ll_local_open(struct file *file, struct lookup_intent *it,
        /* turn off the kernel's read-ahead */
        file->f_ra.ra_pages = 0;
 
-       /* ll_cl_context initialize */
-       rwlock_init(&fd->fd_lock);
-       INIT_LIST_HEAD(&fd->fd_lccs);
-
        RETURN(0);
 }
 
@@ -1700,9 +1696,9 @@ restart:
                        range_locked = true;
                }
 
-               ll_cl_add(file, env, io, LCC_RW);
+               ll_cl_add(inode, env, io, LCC_RW);
                rc = cl_io_loop(env, io);
-               ll_cl_remove(file, env);
+               ll_cl_remove(inode, env);
 
                if (range_locked && !is_parallel_dio) {
                        CDEBUG(D_VFSTRACE, "Range unlock "RL_FMT"\n",
index d9529bd..0224f34 100644 (file)
@@ -267,6 +267,7 @@ struct ll_inode_info {
        struct rw_semaphore             lli_xattrs_list_rwsem;
        struct mutex                    lli_xattrs_enq_lock;
        struct list_head                lli_xattrs; /* ll_xattr_entry->xe_list */
+       struct list_head                lli_lccs; /* list of ll_cl_context */
 };
 
 static inline void ll_trunc_sem_init(struct ll_trunc_sem *sem)
@@ -927,8 +928,6 @@ struct ll_file_data {
         * false: unknown failure, should report. */
        bool fd_write_failed;
        bool ll_lock_no_expand;
-       rwlock_t fd_lock; /* protect lcc list */
-       struct list_head fd_lccs; /* list of ll_cl_context */
        /* Used by mirrored file to lead IOs to a specific mirror, usually
         * for mirror resync. 0 means default. */
        __u32 fd_designated_mirror;
@@ -1093,10 +1092,10 @@ void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
 int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io);
 
 enum lcc_type;
-void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io,
+void ll_cl_add(struct inode *inode, const struct lu_env *env, struct cl_io *io,
               enum lcc_type type);
-void ll_cl_remove(struct file *file, const struct lu_env *env);
-struct ll_cl_context *ll_cl_find(struct file *file);
+void ll_cl_remove(struct inode *inode, const struct lu_env *env);
+struct ll_cl_context *ll_cl_find(struct inode *inode);
 
 extern const struct address_space_operations ll_aops;
 
index 8c73f4f..8fa88c9 100644 (file)
@@ -1162,6 +1162,8 @@ void ll_lli_init(struct ll_inode_info *lli)
        }
        mutex_init(&lli->lli_layout_mutex);
        memset(lli->lli_jobid, 0, sizeof(lli->lli_jobid));
+       /* ll_cl_context initialize */
+       INIT_LIST_HEAD(&lli->lli_lccs);
 }
 
 #define MAX_STRING_SIZE 128
index 8873f70..379cfec 100644 (file)
@@ -261,6 +261,7 @@ static inline int to_fault_error(int result)
  */
 static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
+       struct inode *inode = file_inode(vma->vm_file);
        struct lu_env           *env;
        struct cl_io            *io;
        struct vvp_io           *vio = NULL;
@@ -274,15 +275,15 @@ static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
        if (IS_ERR(env))
                RETURN(PTR_ERR(env));
 
-       if (ll_sbi_has_fast_read(ll_i2sbi(file_inode(vma->vm_file)))) {
+       if (ll_sbi_has_fast_read(ll_i2sbi(inode))) {
                /* do fast fault */
                bool has_retry = vmf->flags & FAULT_FLAG_RETRY_NOWAIT;
 
                /* To avoid loops, instruct downstream to not drop mmap_sem */
                vmf->flags |= FAULT_FLAG_RETRY_NOWAIT;
-               ll_cl_add(vma->vm_file, env, NULL, LCC_MMAP);
+               ll_cl_add(inode, env, NULL, LCC_MMAP);
                fault_ret = ll_filemap_fault(vma, vmf);
-               ll_cl_remove(vma->vm_file, env);
+               ll_cl_remove(inode, env);
                if (!has_retry)
                        vmf->flags &= ~FAULT_FLAG_RETRY_NOWAIT;
 
@@ -312,11 +313,11 @@ static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
                vio->u.fault.ft_flags_valid = 0;
 
                /* May call ll_readpage() */
-               ll_cl_add(vma->vm_file, env, io, LCC_MMAP);
+               ll_cl_add(inode, env, io, LCC_MMAP);
 
                result = cl_io_loop(env, io);
 
-               ll_cl_remove(vma->vm_file, env);
+               ll_cl_remove(inode, env);
 
                /* ft_flags are only valid if we reached
                 * the call to filemap_fault */
index 3f16b3e..a4565fc 100644 (file)
@@ -1564,28 +1564,28 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc)
        RETURN(result);
 }
 
-struct ll_cl_context *ll_cl_find(struct file *file)
+struct ll_cl_context *ll_cl_find(struct inode *inode)
 {
-       struct ll_file_data *fd = file->private_data;
+       struct ll_inode_info *lli = ll_i2info(inode);
        struct ll_cl_context *lcc;
        struct ll_cl_context *found = NULL;
 
-       read_lock(&fd->fd_lock);
-       list_for_each_entry(lcc, &fd->fd_lccs, lcc_list) {
+       spin_lock(&lli->lli_lock);
+       list_for_each_entry(lcc, &lli->lli_lccs, lcc_list) {
                if (lcc->lcc_cookie == current) {
                        found = lcc;
                        break;
                }
        }
-       read_unlock(&fd->fd_lock);
+       spin_unlock(&lli->lli_lock);
 
        return found;
 }
 
-void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io,
+void ll_cl_add(struct inode *inode, const struct lu_env *env, struct cl_io *io,
               enum lcc_type type)
 {
-       struct ll_file_data *fd = file->private_data;
+       struct ll_inode_info *lli = ll_i2info(inode);
        struct ll_cl_context *lcc = &ll_env_info(env)->lti_io_ctx;
 
        memset(lcc, 0, sizeof(*lcc));
@@ -1595,19 +1595,19 @@ void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io,
        lcc->lcc_io = io;
        lcc->lcc_type = type;
 
-       write_lock(&fd->fd_lock);
-       list_add(&lcc->lcc_list, &fd->fd_lccs);
-       write_unlock(&fd->fd_lock);
+       spin_lock(&lli->lli_lock);
+       list_add(&lcc->lcc_list, &lli->lli_lccs);
+       spin_unlock(&lli->lli_lock);
 }
 
-void ll_cl_remove(struct file *file, const struct lu_env *env)
+void ll_cl_remove(struct inode *inode, const struct lu_env *env)
 {
-       struct ll_file_data *fd = file->private_data;
+       struct ll_inode_info *lli = ll_i2info(inode);
        struct ll_cl_context *lcc = &ll_env_info(env)->lti_io_ctx;
 
-       write_lock(&fd->fd_lock);
+       spin_lock(&lli->lli_lock);
        list_del_init(&lcc->lcc_list);
-       write_unlock(&fd->fd_lock);
+       spin_unlock(&lli->lli_lock);
 }
 
 int ll_io_read_page(const struct lu_env *env, struct cl_io *io,
@@ -1822,7 +1822,7 @@ int ll_readpage(struct file *file, struct page *vmpage)
        int result;
        ENTRY;
 
-       lcc = ll_cl_find(file);
+       lcc = ll_cl_find(inode);
        if (lcc != NULL) {
                env = lcc->lcc_env;
                io  = lcc->lcc_io;
index 36d9c56..54fb0ae 100644 (file)
@@ -462,7 +462,7 @@ ll_direct_IO_impl(struct kiocb *iocb, struct iov_iter *iter, int rw)
        if (ll_iov_iter_alignment(iter) & ~PAGE_MASK)
                RETURN(-EINVAL);
 
-       lcc = ll_cl_find(file);
+       lcc = ll_cl_find(inode);
        if (lcc == NULL)
                RETURN(-EIO);
 
@@ -651,7 +651,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
        const struct lu_env  *env = NULL;
        struct cl_io   *io = NULL;
        struct cl_page *page = NULL;
-
+       struct inode *inode = file_inode(file);
        struct cl_object *clob = ll_i2info(mapping->host)->lli_clob;
        pgoff_t index = pos >> PAGE_SHIFT;
        struct page *vmpage = NULL;
@@ -662,7 +662,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
 
        CDEBUG(D_VFSTRACE, "Writing %lu of %d to %d bytes\n", index, from, len);
 
-       lcc = ll_cl_find(file);
+       lcc = ll_cl_find(inode);
        if (lcc == NULL) {
                vmpage = grab_cache_page_nowait(mapping, index);
                result = ll_tiny_write_begin(vmpage, mapping);