Whamcloud - gitweb
LU-11193 llog: Do not write to read-only devices 57/33157/4
authorNathaniel Clark <nclark@whamcloud.com>
Thu, 13 Sep 2018 17:41:09 +0000 (13:41 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 23 Oct 2018 05:16:01 +0000 (05:16 +0000)
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 <nclark@whamcloud.com>
Change-Id: Ia0083c57ceb589698b1422fec57e75aa6e68948a
Reviewed-on: https://review.whamcloud.com/33157
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/llog.c

index dc33905..7f491ac 100644 (file)
@@ -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));