Whamcloud - gitweb
LU-7727 mdt: fail FMODE_WRITE open if the client is read only 42/18242/2
authorLi Dongyang <dongyang.li@anu.edu.au>
Mon, 1 Feb 2016 04:31:03 +0000 (15:31 +1100)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 14 Mar 2016 02:41:41 +0000 (02:41 +0000)
O_WRONLY/O_RDWR open on a file will get EROFS on a read only client,
but the rpc gets sent to the mdt anyway.
mdt will increase the mot_write_count of the mdt object, blocking
subsequent FMODE_EXEC open to the same file.

This patch makes sure we fail the FMODE_WRITE open with EROFS on mdt
if the open request is from a read only client.
We also do a similar check on the client so we can fail with EROFS
straight away without sending the rpc to mdt.

Signed-off-by: Li Dongyang <dongyang.li@anu.edu.au>
Change-Id: I8b08e9d100a1ab8edf2fa47d4e2ebc5170f36df5
Reviewed-on: http://review.whamcloud.com/18242
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Ian Costello <icostello@ddn.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/namei.c
lustre/mdt/mdt_open.c

index 1359d25..021fc0f 100644 (file)
@@ -578,6 +578,10 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
                        RETURN(dentry == save ? NULL : dentry);
        }
 
+       if (it->it_op & IT_OPEN && it->it_flags & FMODE_WRITE &&
+           dentry->d_sb->s_flags & MS_RDONLY)
+               RETURN(ERR_PTR(-EROFS));
+
        if (it->it_op & IT_CREAT)
                opc = LUSTRE_OPC_CREATE;
        else
index ce9be37..f716949 100644 (file)
@@ -1219,6 +1219,10 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
             info->mti_spec.u.sp_ea.eadata == NULL)
                 GOTO(out, result = err_serious(-EINVAL));
 
+       if (create_flags & FMODE_WRITE &&
+           exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY)
+               GOTO(out, result = -EROFS);
+
        CDEBUG(D_INODE, "I am going to open "DFID"/("DNAME"->"DFID") "
               "cr_flag="LPO64" mode=0%06o msg_flag=0x%x\n",
               PFID(rr->rr_fid1), PNAME(&rr->rr_name),