mds: handle xattrs on inode creation
[adding ceph-devel CC]
Quoted 11 lines · Noah Watkins
Hi Sage,
This commit works fine, but I stumbled upon an additional complication when building up the rest of the ACL code.
The ACL initialization semantics can alter the
i_modeentry of the new inode. However, sincei_modeis filled in from the MDS request reply it seems as though there is a potential conflict in semantics between what the MDS computes, and what the ACL code may want to compute (I suppose strict POSIX).
Quoted 3 lines
The
r_fmodefield ofceph_mds_requestseems to be informing the MDS of modes, but at least forceph_mkdir, doesn't appear to be used at all. Should ther_fmodebe fully computed by the clients?
The r_fmode is actually a client-side thing use for initializing the struct file. (It's also not a unix permissions mode, but from the CEPH_FILE_MODE_* namespace.)
The mode for the newly created object is being passed to the mds for each request as part of the args struct/union. And it looks like it's being used on the MDS for everything except symlink (which always gets 0777 + the type bits). For example, for mkdir, it's
unsigned mode = req->head.args.mkdir.mode; mode &= ~S_IFMT; mode |= S_IFDIR;
and on the client there is
req->r_args.mkdir.mode = cpu_to_le32(mode);
in ceph_mkdir() in dir.c.
sage
Quoted 57 lines
-Noah
----- Original Message -----
From: "Sage Weil" <[email protected]>
To: [email protected]
Sent: Tuesday, October 18, 2011 1:50:08 PM
Subject: [ceph-commit] [NewDreamNetwork/ceph] d2d214: mds: handle xattrs on inode creation (fwd)Just need to attach the new xattr(s) in the msg payload. This will be similar to what setxattr does with
r_pagesandr_num_pages, except the page content will be<u32> number of xattrs
(
<u32> xattr name length
xattr name
<u32> xattr value length
xattr value
) * N---------- Forwarded message ----------
Date: Tue, 18 Oct 2011 13:39:13 -0700
From: [email protected]
To: [email protected]
Subject: [ceph-commit] [NewDreamNetwork/ceph] d2d214: mds: handle xattrs on
inode creationBranch: refs/heads/wip-create-xattr
Home: https://github.com/NewDreamNetwork/cephCommit:
d2d2149d364ee5b5fe078a964e2c1089c2153cd1https://github.com/NewDreamNetwork/ceph/commit/d2d2149d364ee5b5fe078a964e2c1089c2153cd1Author: Sage Weil <[email protected]>
Date: 2011-10-18 (Tue, 18 Oct 2011)Changed paths:
M src/mds/Server.ccLog Message:
-----------
mds: handle xattrs on inode creationAllow mknod, mkdir, symlink, create to provide xattrs for the new inode. This will be used by the kclient to set ACLs on new inodes based on the parent directory.
Signed-off-by Sage Weil <[email protected]>_______________________________________________
Ceph-commit mailing list
[email protected]
http://lists.ceph.newdream.net/listinfo.cgi/ceph-commit-ceph.newdream.net
----- Original Message -----
Quoted 9 lines
From: "Sage Weil" <[email protected]>
The mode for the newly created object is being passed to the mds for each
request as part of the args struct/union. And it looks like it's being used on the MDS for everything except symlink (which always gets 0777 +
the type bits). For example, for mkdir, it's
Quoted 3 lines
unsigned mode =
req->head.args.mkdir.mode;
mode &= ~S_IFMT;
mode |=S_IFDIR;
Since S_IFDIR (for example) is added by the MDS and the ACL is computed before the initial MDS request is made (and the final mode is available), the ACL code ends up looking like:
if (req->op == CEPH_MDS_OP_MKDIR) { ...
rather than
if (S_ISDIR(mode)) { ...
which, I suppose isn't a big deal. Should we go with the this, or is there a potential to fully compute the mode arguments on the client to allow reuse of the nice S_ISDIR (etc...) macros?
Quoted 5 lines
and on the client there is
req->r_args.mkdir.mode=cpu_to_le32(mode);in
ceph_mkdir()indir.c.
Thanks, this is the part I originally was wondering about. Twas right under my nose.
-Noah
Quoted 10 lines · Noah Watkins
----- Original Message -----
Quoted 9 lines
From: "Sage Weil" <[email protected]>
The mode for the newly created object is being passed to the mds for each
request as part of the args struct/union. And it looks like it's being used on the MDS for everything except symlink (which always gets 0777 +
the type bits). For example, for mkdir, it's
Quoted 7 lines
Quoted 3 lines
unsigned mode =
req->head.args.mkdir.mode;
mode &= ~S_IFMT;
mode |=S_IFDIR;Since
S_IFDIR(for example) is added by the MDS and the ACL is computed before the initial MDS request is made (and the final mode is available), the ACL code ends up looking like:
I would characterize it as "the MDS ensures the file type bits of the mode are correct."
Quoted 9 lines
if (
req->op==CEPH_MDS_OP_MKDIR) { ...rather than
if (
S_ISDIR(mode)) { ...which, I suppose isn't a big deal. Should we go with the this, or is there a potential to fully compute the mode arguments on the client to allow reuse of the nice
S_ISDIR(etc...) macros?
Yeah, just compute the whole thing on the client.
The MDS does fundamentally different things for different op types, and sometimes creation is implicit etc., so don't worry about that part. :) In the end, they all funnel into prepare_new_inode() with a correct mode, so that's where the "magic" of setting those initial xattrs happens.
sage