From 12a695d5b2fea73ee5edb7a0a79d557c94cafa35 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 13 Sep 2018 13:41:09 -0400 Subject: [PATCH] LU-11193 llog: Do not write to read-only devices Check if device is read-only before trying to start a transaction on a devices. Lustre snapshots are generally read-only. When underlying device is read-only we check in the following places: * llog_destroy, llog_write - return EROFS * llog_open_create - on the create sized we return EROFS * llog_cancel_rec - we return 0 which means success where 1 means "success & log destroyed" Test-Parameters: trivial testlist=sanity-lsnapshot mdtcount=4 mdscount=2 ostfilesystemtype=zfs mdtfilesystemtype=zfs Signed-off-by: Nathaniel Clark Change-Id: Ia0083c57ceb589698b1422fec57e75aa6e68948a Reviewed-on: https://review.whamcloud.com/33157 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/obdclass/llog.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index dc33905..7f491ac 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -169,6 +169,9 @@ int llog_destroy(const struct lu_env *env, struct llog_handle *handle) dt = lu2dt_dev(handle->lgh_obj->do_lu.lo_dev); + if (unlikely(unlikely(dt->dd_rdonly))) + RETURN(-EROFS); + th = dt_trans_create(env, dt); if (IS_ERR(th)) RETURN(PTR_ERR(th)); @@ -221,6 +224,9 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, dt = lu2dt_dev(loghandle->lgh_obj->do_lu.lo_dev); + if (unlikely(unlikely(dt->dd_rdonly))) + RETURN(0); + th = dt_trans_create(env, dt); if (IS_ERR(th)) RETURN(PTR_ERR(th)); @@ -1117,6 +1123,9 @@ int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt, d = lu2dt_dev((*res)->lgh_obj->do_lu.lo_dev); + if (unlikely(unlikely(d->dd_rdonly))) + RETURN(-EROFS); + th = dt_trans_create(env, d); if (IS_ERR(th)) GOTO(out, rc = PTR_ERR(th)); @@ -1195,6 +1204,9 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, dt = lu2dt_dev(loghandle->lgh_obj->do_lu.lo_dev); + if (unlikely(unlikely(dt->dd_rdonly))) + RETURN(-EROFS); + th = dt_trans_create(env, dt); if (IS_ERR(th)) RETURN(PTR_ERR(th)); -- 1.8.3.1