/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * linux/mds/mds_xattr.c
- * Lustre Metadata Server (mds) extended attributes handling
+ * GPL HEADER START
*
- * Copyright (C) 2004-2005 Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * This file is part of the Lustre file system, http://www.lustre.org
- * Lustre is a trademark of Cluster File Systems, Inc.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
*
- * You may have signed or agreed to another license before downloading
- * this software. If so, you are bound by the terms and conditions
- * of that agreement, and the following does not apply to you. See the
- * LICENSE file included with this distribution for more information.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * If you did not agree to a different license, then this copy of Lustre
- * is open source software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
- * In either case, Lustre is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * license text for more details.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/mds/mds_xattr.c
+ *
+ * Lustre Metadata Server (mds) extended attributes handling
*/
#ifndef EXPORT_SYMTAB
} else if (reqbody->valid & OBD_MD_FLXATTRLS) {
DEBUG_REQ(D_INODE, req, "listxattr");
- if (inode->i_op && inode->i_op->listxattr) {
+ if (inode->i_op && inode->i_op->listxattr)
rc = inode->i_op->listxattr(dentry, buf, buflen);
- }
if (rc < 0)
CDEBUG(D_OTHER, "listxattr failed: %d\n", rc);
} else
struct lvfs_run_ctxt saved;
struct dentry *de;
struct mds_body *body;
- struct lvfs_ucred uc = {0,};
+ struct lvfs_ucred uc = { NULL, };
int rc = 0;
ENTRY;
struct obd_device *obd = req->rq_export->exp_obd;
struct dentry *de;
struct inode *inode = NULL;
+ struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
struct lustre_handle lockh;
void *handle = NULL;
char *xattr_name;
char *xattr = NULL;
int xattrlen;
- int rc = -EOPNOTSUPP, err = 0;
+ int rc = -EOPNOTSUPP, err = 0, sync = 0;
__u64 lockpart;
ENTRY;
if (strncmp(xattr_name, "trusted.", 8) == 0) {
if (strcmp(xattr_name + 8, XATTR_LUSTRE_MDS_LOV_EA) == 0)
GOTO(out, rc = -EACCES);
+ if (strcmp(xattr_name + 8, "lma") == 0 &&
+ !OBD_FAIL_CHECK(OBD_FAIL_MDS_ALLOW_COMMON_EA_SETTING))
+ GOTO(out, rc = 0);
}
if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_XATTR) &&
GOTO(out, rc = -EOPNOTSUPP);
}
+ /* currently lustre limit xattr size */
+ if (body->valid & OBD_MD_FLXATTR && !strcmp(xattr_name, XATTR_NAME_ACL_ACCESS)) {
+ xattrlen = lustre_msg_buflen(req->rq_reqmsg,
+ REQ_REC_OFF + 2);
+
+ if (xattrlen > LUSTRE_POSIX_ACL_MAX_SIZE)
+ GOTO(out, -ERANGE);
+ }
+
+
if (!strcmp(xattr_name, XATTR_NAME_ACL_ACCESS))
lockpart |= MDS_INODELOCK_LOOKUP;
de = mds_fid2locked_dentry(obd, &body->fid1, NULL, LCK_EX,
- &lockh, lockpart);
+ &lockh, NULL, 0, lockpart);
if (IS_ERR(de))
GOTO(out, rc = PTR_ERR(de));
inode = de->d_inode;
LASSERT(inode);
- OBD_FAIL_WRITE(OBD_FAIL_MDS_SETXATTR_WRITE, inode->i_sb);
+ OBD_FAIL_WRITE(obd, OBD_FAIL_MDS_SETXATTR_WRITE, inode->i_sb);
+
+ /* version recovery check */
+ rc = mds_version_get_check(req, inode, 0);
+ if (rc)
+ GOTO(out_dput, rc);
/* filter_op simply use setattr one */
handle = fsfilt_start(obd, inode, FSFILT_OP_SETATTR, NULL);
xattrlen = lustre_msg_buflen(req->rq_reqmsg,
REQ_REC_OFF + 2);
- if (xattrlen)
- xattr = lustre_msg_buf(req->rq_reqmsg,
- REQ_REC_OFF+2, xattrlen);
+
+ xattr = lustre_msg_buf(req->rq_reqmsg,
+ REQ_REC_OFF+2, xattrlen);
LOCK_INODE_MUTEX(inode);
rc = inode->i_op->setxattr(de, xattr_name, xattr,
LASSERT(rc <= 0);
out_trans:
- err = mds_finish_transno(mds, inode, handle, req, rc, 0, 0);
-
+ /* security-replated changes may require sync */
+ if (!strcmp(xattr_name, XATTR_NAME_ACL_ACCESS))
+ sync = mds->mds_sync_permission;
+ inodes[0] = inode;
+ err = mds_finish_transno(mds, inodes, handle, req, rc, 0, sync);
out_dput:
l_dput(de);
if (rc)
struct obd_device *obd = req->rq_export->exp_obd;
struct lvfs_run_ctxt saved;
struct mds_body *body;
- struct lvfs_ucred uc = {0,};
+ struct lvfs_ucred uc = { NULL, };
int rc;
ENTRY;