[PATCH 01/60] staging: lustre: llite: Remove access of stripe in ll_setattr_raw

2017-01-28 Thread James Simmons
From: Jinshan Xiong 

In ll_setattr_raw(), it needs to know if a file is released
when the file is being truncated. It used to get this information
by accessing lov_stripe_md. This turns out not necessary. This
patch removes the access of lov_stripe_md and solves the problem
in lov_io_init_released().

Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5823
Reviewed-on: http://review.whamcloud.com/13514
Reviewed-by: James Simmons 
Reviewed-by: Henri Doreau 
Reviewed-by: John L. Hammond 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/cl_object.h  |   6 --
 drivers/staging/lustre/lustre/llite/file.c |   2 +-
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |   9 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |   1 +
 drivers/staging/lustre/lustre/llite/llite_lib.c| 109 ++---
 drivers/staging/lustre/lustre/llite/vvp_io.c   |  10 +-
 drivers/staging/lustre/lustre/lov/lov_io.c |   7 +-
 drivers/staging/lustre/lustre/lov/lov_object.c |   3 -
 8 files changed, 68 insertions(+), 79 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index dc68561..a1b8301 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -284,12 +284,6 @@ struct cl_layout {
size_t  cl_size;
/** Layout generation. */
u32 cl_layout_gen;
-   /**
-* True if this is a released file.
-* Temporarily added for released file truncate in ll_setattr_raw().
-* It will be removed later. -Jinshan
-*/
-   boolcl_is_released;
 };
 
 /**
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index a171188..0ee02f1 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -1821,7 +1821,7 @@ static int ll_swap_layouts(struct file *file1, struct 
file *file2,
return rc;
 }
 
-static int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss)
+int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss)
 {
struct md_op_data   *op_data;
int  rc;
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c 
b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
index dd1cfd8..f1036f4 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
@@ -94,6 +94,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr 
*attr,
 
io = vvp_env_thread_io(env);
io->ci_obj = obj;
+   io->ci_verify_layout = 1;
 
io->u.ci_setattr.sa_attr.lvb_atime = LTIME_S(attr->ia_atime);
io->u.ci_setattr.sa_attr.lvb_mtime = LTIME_S(attr->ia_mtime);
@@ -120,13 +121,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct 
iattr *attr,
cl_io_fini(env, io);
if (unlikely(io->ci_need_restart))
goto again;
-   /* HSM import case: file is released, cannot be restored
-* no need to fail except if restore registration failed
-* with -ENODATA
-*/
-   if (result == -ENODATA && io->ci_restore_needed &&
-   io->ci_result != -ENODATA)
-   result = 0;
+
cl_env_put(env, );
return result;
 }
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 065a9a7..2c72177 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -766,6 +766,7 @@ int ll_dir_getstripe(struct inode *inode, void **lmmp, int 
*lmm_size,
 int ll_fid2path(struct inode *inode, void __user *arg);
 int ll_data_version(struct inode *inode, __u64 *data_version, int flags);
 int ll_hsm_release(struct inode *inode);
+int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss);
 
 /* llite/dcache.c */
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 9cb4909..769b307 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1402,7 +1402,11 @@ static int ll_md_setattr(struct dentry *dentry, struct 
md_op_data *op_data)
 * cache is not cleared yet.
 */
op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE);
+   if (S_ISREG(inode->i_mode))
+   inode_lock(inode);
rc = simple_setattr(dentry, _data->op_attr);
+   if (S_ISREG(inode->i_mode))
+   inode_unlock(inode);
op_data->op_attr.ia_valid = ia_valid;
 
rc 

[PATCH 01/60] staging: lustre: llite: Remove access of stripe in ll_setattr_raw

2017-01-28 Thread James Simmons
From: Jinshan Xiong 

In ll_setattr_raw(), it needs to know if a file is released
when the file is being truncated. It used to get this information
by accessing lov_stripe_md. This turns out not necessary. This
patch removes the access of lov_stripe_md and solves the problem
in lov_io_init_released().

Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5823
Reviewed-on: http://review.whamcloud.com/13514
Reviewed-by: James Simmons 
Reviewed-by: Henri Doreau 
Reviewed-by: John L. Hammond 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/cl_object.h  |   6 --
 drivers/staging/lustre/lustre/llite/file.c |   2 +-
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |   9 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |   1 +
 drivers/staging/lustre/lustre/llite/llite_lib.c| 109 ++---
 drivers/staging/lustre/lustre/llite/vvp_io.c   |  10 +-
 drivers/staging/lustre/lustre/lov/lov_io.c |   7 +-
 drivers/staging/lustre/lustre/lov/lov_object.c |   3 -
 8 files changed, 68 insertions(+), 79 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index dc68561..a1b8301 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -284,12 +284,6 @@ struct cl_layout {
size_t  cl_size;
/** Layout generation. */
u32 cl_layout_gen;
-   /**
-* True if this is a released file.
-* Temporarily added for released file truncate in ll_setattr_raw().
-* It will be removed later. -Jinshan
-*/
-   boolcl_is_released;
 };
 
 /**
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index a171188..0ee02f1 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -1821,7 +1821,7 @@ static int ll_swap_layouts(struct file *file1, struct 
file *file2,
return rc;
 }
 
-static int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss)
+int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss)
 {
struct md_op_data   *op_data;
int  rc;
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c 
b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
index dd1cfd8..f1036f4 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
@@ -94,6 +94,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr 
*attr,
 
io = vvp_env_thread_io(env);
io->ci_obj = obj;
+   io->ci_verify_layout = 1;
 
io->u.ci_setattr.sa_attr.lvb_atime = LTIME_S(attr->ia_atime);
io->u.ci_setattr.sa_attr.lvb_mtime = LTIME_S(attr->ia_mtime);
@@ -120,13 +121,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct 
iattr *attr,
cl_io_fini(env, io);
if (unlikely(io->ci_need_restart))
goto again;
-   /* HSM import case: file is released, cannot be restored
-* no need to fail except if restore registration failed
-* with -ENODATA
-*/
-   if (result == -ENODATA && io->ci_restore_needed &&
-   io->ci_result != -ENODATA)
-   result = 0;
+
cl_env_put(env, );
return result;
 }
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 065a9a7..2c72177 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -766,6 +766,7 @@ int ll_dir_getstripe(struct inode *inode, void **lmmp, int 
*lmm_size,
 int ll_fid2path(struct inode *inode, void __user *arg);
 int ll_data_version(struct inode *inode, __u64 *data_version, int flags);
 int ll_hsm_release(struct inode *inode);
+int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss);
 
 /* llite/dcache.c */
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 9cb4909..769b307 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1402,7 +1402,11 @@ static int ll_md_setattr(struct dentry *dentry, struct 
md_op_data *op_data)
 * cache is not cleared yet.
 */
op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE);
+   if (S_ISREG(inode->i_mode))
+   inode_lock(inode);
rc = simple_setattr(dentry, _data->op_attr);
+   if (S_ISREG(inode->i_mode))
+   inode_unlock(inode);
op_data->op_attr.ia_valid = ia_valid;
 
rc = ll_update_inode(inode, );
@@ -1431,7 +1435,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr 
*attr, bool hsm_import)
struct inode *inode =