Lustre fixes and cleanups
cover Lustre fixes and cleanups
From: Oleg Drokin <[email protected]>
Here are a few more Lustre fixes and cleanups.
Jinshan Xiong (2):
staging/lustre/lov: calculate file offset correctly staging/lustre/llite: define per open file cache for ll_cl_context
Oleg Drokin (2):
staging/lustre/osc: Remove ops_temp from osc_page staging/lustre/osc: Get rid of osc_page_protected()
drivers/staging/lustre/lustre/llite/file.c | 7 + .../staging/lustre/lustre/llite/llite_internal.h | 11 +- drivers/staging/lustre/lustre/llite/llite_mmap.c | 5 + drivers/staging/lustre/lustre/llite/rw.c | 145 +++++++++------------ drivers/staging/lustre/lustre/llite/rw26.c | 17 +-- drivers/staging/lustre/lustre/lov/lov_offset.c | 2 +- .../staging/lustre/lustre/osc/osc_cl_internal.h | 5 - drivers/staging/lustre/lustre/osc/osc_page.c | 22 ---- 8 files changed, 89 insertions(+), 125 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/4 staging/lustre/lov: calculate file offset correctly
From: Jinshan Xiong <[email protected]>
In lov_stripe_pgoff(), it calls lov_stripe_size() to calculate the file size by ost_size, which will be wrong if the stripe_index happens to be stripe aligned.
Reviewed-on: http://review.whamcloud.com/14462
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6482
--- drivers/staging/lustre/lustre/lov/lov_offset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/lov/lov_offset.c +1 -1
@@ -74,7 +74,7 @@ pgoff_t lov_stripe_pgoff(struct lov_stripe_md *lsm, pgoff_t stripe_index, {loff_t offset; - offset =lov_stripe_size (lsm, stripe_index <<PAGE_SHIFT , stripe); + offset =lov_stripe_size (lsm, (stripe_index <<PAGE_SHIFT ) +1 , stripe);return offset >>PAGE_SHIFT ; }
Signature · 1 line
2.7.4
PATCH 2/4 staging/lustre/llite: define per open file cache for ll_cl_context
In reply to [email protected]From: Jinshan Xiong <[email protected]>
In ll_readpage and ll_write_begin, it needs to find out the cl_env and cl_io, a.k.a ll_cl_context, when the IO is initialized. It used to call cl_env_get() to figure it out but turned out to be contended if multiple threads are doing IO.
In this patch, a per open file ll_cl_context cache is created. When IO type of CIT_READ, CIT_WRITE and CIR_FAULT is initialized, it will add a ll_cl_context into the cache maintained in ll_file_data. In this case, the ll_cl_context can be found in ll_readpage and ll_write_begin later.
Reviewed-on: http://review.whamcloud.com/10503
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108
Reviewed-on: http://review.whamcloud.com/10955
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5260
--- drivers/staging/lustre/lustre/llite/file.c | 7 + .../staging/lustre/lustre/llite/llite_internal.h | 11 +- drivers/staging/lustre/lustre/llite/llite_mmap.c | 5 + drivers/staging/lustre/lustre/llite/rw.c | 145 +++++++++------------ drivers/staging/lustre/lustre/llite/rw26.c | 17 +-- 5 files changed, 88 insertions(+), 97 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +7 -0
@@ -519,6 +519,11 @@ static int ll_local_open(struct file *file, struct lookup_intent *it,LUSTRE_FPRIVATE (file) = fd;ll_readahead_init (inode, &fd->fd_ras); fd->fd_omode = it->it_flags & (FMODE_READ |FMODE_WRITE |FMODE_EXEC ); + +/* ll_cl_context initialize */ +rwlock_init (&fd->fd_lock); +INIT_LIST_HEAD (&fd->fd_lccs); +return 0 ; }
@@ -1178,7 +1183,9 @@ restart:CERROR ("Unknown IO type - %u\n" , vio->vui_io_subtype);LBUG (); } +ll_cl_add (file, env, io); result =cl_io_loop (env, io); +ll_cl_remove (file, env);if (args->via_io_subtype ==IO_NORMAL )up_read (&lli->lli_trunc_sem);if (write_mutex_locked)
drivers/staging/lustre/lustre/llite/llite_internal.h +7 -4
@@ -640,6 +640,8 @@ struct ll_file_data {* false: unknown failure, should report. */ bool fd_write_failed; +rwlock_t fd_lock;/* protect lcc list */ +struct list_head fd_lccs;/* list of ll_cl_context */ };struct lov_stripe_md ;
@@ -715,8 +717,9 @@ void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);int ll_readahead (const struct lu_env *env,struct cl_io *io,struct cl_page_list *queue,struct ll_readahead_state *ras,bool hit); -struct ll_cl_context *ll_cl_init (struct file *file,struct page *vmpage); -void ll_cl_fini (struct ll_cl_context *lcc); +struct ll_cl_context *ll_cl_find (struct file *file); +void ll_cl_add (struct file *file,const struct lu_env *env,struct cl_io *io); +void ll_cl_remove (struct file *file,const struct lu_env *env);extern const struct address_space_operations ll_aops;
@@ -858,11 +861,11 @@ struct vvp_io_args { };struct ll_cl_context { +struct list_head lcc_list;void *lcc_cookie; +const struct lu_env *lcc_env;struct cl_io *lcc_io;struct cl_page *lcc_page; -struct lu_env *lcc_env; -int lcc_refcheck; };struct ll_thread_info {
drivers/staging/lustre/lustre/llite/llite_mmap.c +5 -0
@@ -315,8 +315,13 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) vio->u.fault.ft_flags =0 ; vio->u.fault.ft_flags_valid = false; +/* May call ll_readpage() */ +ll_cl_add (vma->vm_file, env, io); + result =cl_io_loop (env, io); +ll_cl_remove (vma->vm_file, env); +/* ft_flags are only valid if we reached * the call to filemap_fault */
drivers/staging/lustre/lustre/llite/rw.c +60 -85
171 lines not on this page · raw message
drivers/staging/lustre/lustre/llite/rw26.c +9 -8
@@ -489,7 +489,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, struct page **pagep, void **fsdata) { struct ll_cl_context *lcc; -struct lu_env *env; +const struct lu_env *env;struct cl_io *io;struct cl_page *page;struct cl_object *clob =ll_i2info (mapping->host)->lli_clob;
@@ -501,9 +501,9 @@ 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_init (file,NULL ); -if (IS_ERR (lcc)) { - result =PTR_ERR (lcc); + lcc =ll_cl_find (file); +if (!lcc) { + result = -EIO ; goto out; }
@@ -579,8 +579,6 @@ out:unlock_page (vmpage);put_page (vmpage); } -if (!IS_ERR (lcc)) -ll_cl_fini (lcc); }else { *pagep = vmpage; *fsdata = lcc;
@@ -593,7 +591,7 @@ static int ll_write_end(struct file *file, struct address_space *mapping, struct page *vmpage, void *fsdata) { struct ll_cl_context *lcc = fsdata; -struct lu_env *env; +const struct lu_env *env;struct cl_io *io;struct vvp_io *vio;struct cl_page *page;
@@ -631,6 +629,10 @@ static int ll_write_end(struct file *file, struct address_space *mapping, }else {cl_page_disown (env, io, page); + lcc->lcc_page =NULL ; +lu_ref_del (&page->cp_reference,"cl_io" , io); +cl_page_put (env, page); +/* page list is not contiguous now, commit it now */ unplug = true; }
@@ -639,7 +641,6 @@ static int ll_write_end(struct file *file, struct address_space *mapping, file->f_flags & O_SYNC || IS_SYNC(file_inode(file))) result =vvp_io_write_commit (env, io); -ll_cl_fini (lcc);return result >=0 ? copied : result; }
Signature · 1 line
2.7.4
PATCH 3/4 staging/lustre/osc: Remove ops_temp from osc_page
In reply to [email protected]From: Oleg Drokin <[email protected]>
It's no longer used and never set anywhere.
--- drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 5 ----- drivers/staging/lustre/lustre/osc/osc_page.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/staging/lustre/lustre/osc/osc_cl_internal.h +0 -5
@@ -356,11 +356,6 @@ struct osc_page {*/ unsigned ops_transfer_pinned:1, /** -* True for a `temporary page' created by read-ahead code, probably -* outside of any DLM lock. -*/ - ops_temp:1, -/** * in LRU? */ ops_in_lru:1,
drivers/staging/lustre/lustre/osc/osc_page.c +1 -1
@@ -214,7 +214,7 @@ static void osc_page_delete(const struct lu_env *env,struct osc_object *obj =cl2osc (opg->ops_cl.cpl_obj);int rc; -LINVRNT (opg->ops_temp ||osc_page_protected (env, opg,CLM_READ ,1 )); +LINVRNT (osc_page_protected (env, opg,CLM_READ ,1 ));CDEBUG (D_TRACE ,"%p\n" , opg);osc_page_transfer_put (env, opg);
Signature · 1 line
2.7.4
PATCH 4/4 staging/lustre/osc: Get rid of osc_page_protected()
In reply to [email protected]From: Oleg Drokin <[email protected]>
There was a proper debugging function by that name that's long gone.
The currently remaining shadow that always returns true is not really useful so it could be dropped along with all the asserts it is part of.
--- drivers/staging/lustre/lustre/osc/osc_page.c | 22 ---------------------- 1 file changed, 22 deletions(-)
drivers/staging/lustre/lustre/osc/osc_page.c +0 -22
@@ -52,13 +52,6 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj,* @{ */ -static int osc_page_protected (const struct lu_env *env, -const struct osc_page *opg, -enum cl_lock_mode mode,int unref) -{ -return 1 ; -} -/***************************************************************************** * * Page operations.
@@ -110,8 +103,6 @@ int osc_page_cache_add(const struct lu_env *env,struct osc_page *opg =cl2osc_page (slice);int result; -LINVRNT (osc_page_protected (env, opg,CLM_WRITE ,0 )); -osc_page_transfer_get (opg,"transfer\0cache" ); result =osc_queue_async_io (env, io, opg);if (result !=0 )
@@ -214,8 +205,6 @@ static void osc_page_delete(const struct lu_env *env,struct osc_object *obj =cl2osc (opg->ops_cl.cpl_obj);int rc; -LINVRNT (osc_page_protected (env, opg,CLM_READ ,1 )); -CDEBUG (D_TRACE ,"%p\n" , opg);osc_page_transfer_put (env, opg); rc =osc_teardown_async_page (env, obj, opg);
@@ -254,8 +243,6 @@ static void osc_page_clip(const struct lu_env *env,struct osc_page *opg =cl2osc_page (slice);struct osc_async_page *oap = &opg->ops_oap; -LINVRNT (osc_page_protected (env, opg,CLM_READ ,0 )); - opg->ops_from = from; opg->ops_to = to;spin_lock (&oap->oap_lock);
@@ -269,8 +256,6 @@ static int osc_page_cancel(const struct lu_env *env,struct osc_page *opg =cl2osc_page (slice);int rc =0 ; -LINVRNT (osc_page_protected (env, opg,CLM_READ ,0 )); -/* Check if the transferring against this page * is completed, or not even queued. */
@@ -320,10 +305,6 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj,cl_page_slice_add (page, &opg->ops_cl, obj, index, &osc_page_ops); } -/* -* Cannot assert osc_page_protected() here as read-ahead -* creates temporary pages outside of a lock. -*/ /* ops_inflight and ops_lru are the same field, but it doesn't * hurt to initialize it twice :-) */
@@ -382,9 +363,6 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,struct osc_async_page *oap = &opg->ops_oap;struct osc_object *obj = oap->oap_obj; -LINVRNT (osc_page_protected (env, opg, - crt ==CRT_WRITE ?CLM_WRITE :CLM_READ ,1 )); -LASSERTF (oap->oap_magic ==OAP_MAGIC ,"Bad oap magic: oap %p, magic 0x%x\n" , oap, oap->oap_magic);LASSERT (oap->oap_async_flags &ASYNC_READY );
Signature · 1 line
2.7.4