X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmds%2Fmds_reint.c;h=54601248efbbc4a71856a33af84f54be221f870c;hb=30964bcc157e3ad76714b7e55491112c3ae8ebad;hp=cd49c3c0cae0a7c83cf05fe2c9a1736fd57a60e9;hpb=69426b8d6812bb72ddc7290bd054233f175e27f3;p=fs%2Flustre-release.git diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index cd49c3c..5460124 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include "mds_internal.h" @@ -638,6 +639,39 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset, EXIT; } +static int mds_get_default_acl(struct inode *dir, void **pacl) +{ + struct dentry de = { .d_inode = dir }; + int size, size2; + + LASSERT(S_ISDIR(dir->i_mode)); + + if (!dir->i_op->getxattr) + return 0; + + size = dir->i_op->getxattr(&de, XATTR_NAME_ACL_DEFAULT, NULL, 0); + if (size == 0 || size == -ENODATA || size == -EOPNOTSUPP) + return 0; + else if (size < 0) + return size; + + OBD_ALLOC(*pacl, size); + if (!*pacl) + return -ENOMEM; + + size2 = dir->i_op->getxattr(&de, XATTR_NAME_ACL_DEFAULT, *pacl, size); + if (size2 != size) { + /* since we already locked the dir, it should not change + * between the 2 getxattr calls + */ + CERROR("2'nd getxattr got %d, expect %d\n", size2, size); + OBD_FREE(*pacl, size); + return -EIO; + } + + return size; +} + static int mds_reint_create(struct mds_update_record *rec, int offset, struct ptlrpc_request *req, struct lustre_handle *lh) @@ -832,7 +866,9 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, /* inode will be created on another MDS */ struct obdo *oa = NULL; struct mds_body *body; - + void *acl = NULL; + int acl_size; + /* first, create that inode */ oa = obdo_alloc(); if (!oa) @@ -877,11 +913,23 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, LASSERT(oa->o_fid != 0); } + /* obtain default ACL */ + acl_size = mds_get_default_acl(dir, &acl); + if (acl_size < 0) { + obdo_free(oa); + GOTO(cleanup, rc = -ENOMEM); + } + /* * before obd_create() is called, o_fid is not known if * this is not recovery of cause. */ - rc = obd_create(mds->mds_md_exp, oa, NULL, NULL); + rc = obd_create(mds->mds_md_exp, oa, acl, acl_size, + NULL, NULL); + + if (acl) + OBD_FREE(acl, acl_size); + if (rc) { CERROR("can't create remote inode: %d\n", rc); DEBUG_REQ(D_ERROR, req, "parent "LPU64"/%u name %s mode %o",