From 64d3eb81862edd649d6ead30c6e470534c208a0c Mon Sep 17 00:00:00 2001 From: pschwan Date: Thu, 10 Oct 2002 16:47:36 +0000 Subject: [PATCH] b=602707 b=620007 Fixes the ignored directory permissions bug, which was a direct cause of the "la -la" bug. - {push,pop}_ctxt now un-sets and re-sets CAP_DAC_OVERRIDE - ll_lookup2 needs to be much more careful about which errors lead to a negative dentry; I think I've gotten creations and unlinks right, but we _so_ need a regression test that attempts a slew of error-causing operations and verifies that we get the correct errors back. - fix yet another ptlrpc_request-related crasher in mds/handler.c - error during mds_reint_create is now par for the course; remove LBUG --- lustre/include/linux/obd.h | 3 ++- lustre/ldlm/ldlm_request.c | 2 +- lustre/lib/simple.c | 6 ++++++ lustre/llite/namei.c | 11 +++++++---- lustre/mds/handler.c | 3 +-- lustre/mds/mds_reint.c | 10 ++++------ 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 260035e..549a54d 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -59,7 +59,7 @@ struct ext2_obd { struct vfsmount *e2_vfsmnt; }; -struct obd_ucred { +struct obd_ucred { __u32 ouc_fsuid; __u32 ouc_fsgid; }; @@ -72,6 +72,7 @@ struct obd_run_ctxt { mm_segment_t fs; __u32 fsuid; __u32 fsgid; + __u32 override; #ifdef OBD_CTXT_DEBUG __u32 magic; #endif diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 87a9563..fc1415c 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -76,7 +76,7 @@ int ldlm_completion_ast(struct ldlm_lock *lock, int flags) ENTRY; if (flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED | - LDLM_FL_BLOCK_CONV)) { + LDLM_FL_BLOCK_CONV)) { /* Go to sleep until the lock is granted. */ /* FIXME: or cancelled. */ LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock," diff --git a/lustre/lib/simple.c b/lustre/lib/simple.c index 56c819b..98e2b46 100644 --- a/lustre/lib/simple.c +++ b/lustre/lib/simple.c @@ -50,6 +50,7 @@ void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new, save->fs = get_fs(); save->pwd = dget(current->fs->pwd); save->pwdmnt = mntget(current->fs->pwdmnt); + save->override = cap_raised(current->cap_effective, CAP_DAC_OVERRIDE); LASSERT(save->pwd); LASSERT(save->pwdmnt); @@ -64,6 +65,8 @@ void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new, } set_fs(new->fs); set_fs_pwd(current->fs, new->pwdmnt, new->pwd); + if (save->override) + cap_lower(current->cap_effective, CAP_DAC_OVERRIDE); } void pop_ctxt(struct obd_run_ctxt *saved) @@ -84,6 +87,9 @@ void pop_ctxt(struct obd_run_ctxt *saved) //printk("pc6\n"); current->fsuid = saved->fsuid; current->fsgid = saved->fsgid; + + if (saved->override) + cap_raise(current->cap_effective, CAP_DAC_OVERRIDE); } /* utility to make a file */ diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index a8b28a4..98797e8 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -185,8 +185,10 @@ static struct dentry *ll_lookup2(struct inode *dir, struct dentry *dentry, ino = lic.lic_body->fid1.id; mode = lic.lic_body->mode; if (it->it_op & (IT_CREAT | IT_MKDIR | IT_SYMLINK | IT_MKNOD)) { - /* For create ops, we want the lookup to be negative */ - if (!it->it_status) + /* For create ops, we want the lookup to be negative, + * unless the create failed in a way that indicates + * that the file is already there */ + if (it->it_status != -EEXIST) GOTO(negative, NULL); } else if (it->it_op & (IT_GETATTR | IT_SETATTR | IT_LOOKUP)) { /* For check ops, we want the lookup to succeed */ @@ -201,9 +203,10 @@ static struct dentry *ll_lookup2(struct inode *dir, struct dentry *dentry, } it->it_data = dentry; } else if (it->it_op & (IT_UNLINK | IT_RMDIR)) { - /* For remove ops, we want the lookup to succeed */ + /* For remove ops, we want the lookup to succeed unless + * the file truly doesn't exist */ it->it_data = NULL; - if (it->it_status) + if (it->it_status == -ENOENT) GOTO(neg_req, NULL); goto iget; } else if (it->it_op == IT_OPEN) { diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 3d209df..0f4f30b 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -609,8 +609,7 @@ static int mds_getattr(int offset, struct ptlrpc_request *req) push_ctxt(&saved, &mds->mds_ctxt, &uc); de = mds_fid2dentry(mds, &body->fid1, NULL); if (IS_ERR(de)) { - req->rq_status = -ENOENT; - rc = 0; + rc = req->rq_status = -ENOENT; GOTO(out_pop, PTR_ERR(de)); } diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 9c510c1..18ba01c 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -61,8 +61,8 @@ int mds_update_last_rcvd(struct mds_obd *mds, void *handle, mds_fs_set_last_rcvd(mds, handle); rc = lustre_fwrite(mds->mds_rcvd_filp, (char *)mcd, sizeof(*mcd), &off); - CDEBUG(D_INODE, "wrote trans #"LPD64" for client '%s' at #%d: rc = %d\n", - last_rcvd, mcd->mcd_uuid, med->med_off, rc); + CDEBUG(D_INODE, "wrote trans #"LPD64" for client '%s' at #%d: rc = " + "%d\n", last_rcvd, mcd->mcd_uuid, med->med_off, rc); if (rc == sizeof(*mcd)) rc = 0; @@ -152,7 +152,7 @@ out_setattr_de: l_dput(de); out_setattr: req->rq_status = rc; - return (0); + return 0; } static int mds_reint_recreate(struct mds_update_record *rec, int offset, @@ -327,9 +327,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, } if (rc) { - CERROR("error during create: %d\n", rc); - if (rc != -ENOSPC) - LBUG(); + CDEBUG(D_INODE, "error during create: %d\n", rc); GOTO(out_create_commit, rc); } else { struct iattr iattr; -- 1.8.3.1