diff options
author | Jinshan Xiong <jinshan.xiong@intel.com> | 2015-02-01 21:52:13 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-02-07 04:32:33 -0500 |
commit | 4c309612ddb9107c3fdbd5233198d59708114bc4 (patch) | |
tree | f192b5630ac257ac549d13635ca98e10c19e25fa | |
parent | d27f9b077e113b0fa46e466465233a5e51085228 (diff) |
staging/lustre/llite: Solve a race to access lli_has_smd in read case
In vvp_io_read_lock(), it used to decide if to add read lock by
checking lli_has_smd. Accessing lli_has_smd is racy when an empty
file is turned into raid0, therefore, it may result in read requests
are issued without corresponding lock.
Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-on: http://review.whamcloud.com/12139
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5062
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/lustre/lustre/include/lclient.h | 1 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/lclient/lcommon_cl.c | 6 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/vvp_io.c | 15 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/vvp_lock.c | 1 |
4 files changed, 13 insertions, 10 deletions
diff --git a/drivers/staging/lustre/lustre/include/lclient.h b/drivers/staging/lustre/lustre/include/lclient.h index 316500cdff75..c5c3a8d9eaa4 100644 --- a/drivers/staging/lustre/lustre/include/lclient.h +++ b/drivers/staging/lustre/lustre/include/lclient.h | |||
@@ -325,6 +325,7 @@ void ccc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice); | |||
325 | int ccc_lock_enqueue(const struct lu_env *env, | 325 | int ccc_lock_enqueue(const struct lu_env *env, |
326 | const struct cl_lock_slice *slice, | 326 | const struct cl_lock_slice *slice, |
327 | struct cl_io *io, __u32 enqflags); | 327 | struct cl_io *io, __u32 enqflags); |
328 | int ccc_lock_use(const struct lu_env *env, const struct cl_lock_slice *slice); | ||
328 | int ccc_lock_unuse(const struct lu_env *env, const struct cl_lock_slice *slice); | 329 | int ccc_lock_unuse(const struct lu_env *env, const struct cl_lock_slice *slice); |
329 | int ccc_lock_wait(const struct lu_env *env, const struct cl_lock_slice *slice); | 330 | int ccc_lock_wait(const struct lu_env *env, const struct cl_lock_slice *slice); |
330 | int ccc_lock_fits_into(const struct lu_env *env, | 331 | int ccc_lock_fits_into(const struct lu_env *env, |
diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 24d26ab35346..23095bb75226 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c | |||
@@ -586,6 +586,12 @@ int ccc_lock_enqueue(const struct lu_env *env, | |||
586 | return 0; | 586 | return 0; |
587 | } | 587 | } |
588 | 588 | ||
589 | int ccc_lock_use(const struct lu_env *env, const struct cl_lock_slice *slice) | ||
590 | { | ||
591 | CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj)); | ||
592 | return 0; | ||
593 | } | ||
594 | |||
589 | int ccc_lock_unuse(const struct lu_env *env, const struct cl_lock_slice *slice) | 595 | int ccc_lock_unuse(const struct lu_env *env, const struct cl_lock_slice *slice) |
590 | { | 596 | { |
591 | CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj)); | 597 | CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj)); |
diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 65d610abe06e..91bba79678cf 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c | |||
@@ -307,18 +307,13 @@ static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, | |||
307 | static int vvp_io_read_lock(const struct lu_env *env, | 307 | static int vvp_io_read_lock(const struct lu_env *env, |
308 | const struct cl_io_slice *ios) | 308 | const struct cl_io_slice *ios) |
309 | { | 309 | { |
310 | struct cl_io *io = ios->cis_io; | 310 | struct cl_io *io = ios->cis_io; |
311 | struct ll_inode_info *lli = ll_i2info(ccc_object_inode(io->ci_obj)); | 311 | struct cl_io_rw_common *rd = &io->u.ci_rd.rd; |
312 | int result; | 312 | int result; |
313 | 313 | ||
314 | /* XXX: Layer violation, we shouldn't see lsm at llite level. */ | 314 | result = vvp_io_rw_lock(env, io, CLM_READ, rd->crw_pos, |
315 | if (lli->lli_has_smd) /* lsm-less file doesn't need to lock */ | 315 | rd->crw_pos + rd->crw_count - 1); |
316 | result = vvp_io_rw_lock(env, io, CLM_READ, | 316 | |
317 | io->u.ci_rd.rd.crw_pos, | ||
318 | io->u.ci_rd.rd.crw_pos + | ||
319 | io->u.ci_rd.rd.crw_count - 1); | ||
320 | else | ||
321 | result = 0; | ||
322 | return result; | 317 | return result; |
323 | } | 318 | } |
324 | 319 | ||
diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index 372633e164b9..f354e82d4ae7 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c | |||
@@ -71,6 +71,7 @@ static const struct cl_lock_operations vvp_lock_ops = { | |||
71 | .clo_fini = ccc_lock_fini, | 71 | .clo_fini = ccc_lock_fini, |
72 | .clo_enqueue = ccc_lock_enqueue, | 72 | .clo_enqueue = ccc_lock_enqueue, |
73 | .clo_wait = ccc_lock_wait, | 73 | .clo_wait = ccc_lock_wait, |
74 | .clo_use = ccc_lock_use, | ||
74 | .clo_unuse = ccc_lock_unuse, | 75 | .clo_unuse = ccc_lock_unuse, |
75 | .clo_fits_into = ccc_lock_fits_into, | 76 | .clo_fits_into = ccc_lock_fits_into, |
76 | .clo_state = ccc_lock_state, | 77 | .clo_state = ccc_lock_state, |