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>
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
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),