From 9a2bdd6ca1e441e3b019725c30dc460be0853216 Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Thu, 4 Jul 2013 14:13:49 +1000 Subject: [PATCH] LU-3557 mdt: fix open existing file with O_CREAT for ro mount We should only return -EROFS for read only mount if we really need to create the file in question. Defer the check to mdt_reint_open() instead of mdt_intent_opc(). Signed-off-by: Li Dongyang Change-Id: I68f34ef7abbae934cfc3564a67ff70e5ab8a12b1 Reviewed-on: http://review.whamcloud.com/6893 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Li Xi Reviewed-by: Emoly Liu Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 9 ++++++++- lustre/mdt/mdt_open.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 15f6c4b..0de83de 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -3537,7 +3537,14 @@ static struct mdt_it_flavor { }, [MDT_IT_OCREAT] = { .it_fmt = &RQF_LDLM_INTENT, - .it_flags = MUTABOR, + /* + * OCREAT is not a MUTABOR request as if the file + * already exists. + * We do the extra check of OBD_CONNECT_RDONLY in + * mdt_reint_open() when we really need to create + * the object. + */ + .it_flags = 0, .it_act = mdt_intent_reint, .it_reint = REINT_OPEN }, diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 28eb0ca..686a76f 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -1696,6 +1696,8 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) } if (!(create_flags & MDS_OPEN_CREAT)) GOTO(out_parent, result); + if (exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY) + GOTO(out_parent, result = -EROFS); *child_fid = *info->mti_rr.rr_fid2; LASSERTF(fid_is_sane(child_fid), "fid="DFID"\n", PFID(child_fid)); -- 1.8.3.1