Skip to contentSkip to conversation

mds: handle xattrs on inode creation

DISCUSSION Sage Weil 2 participants 3 messages Oct 21, 2011 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Sage Weil

author
#1 lore raw

[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_mode entry of the new inode. However, since i_mode is 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_fmode field of ceph_mds_request seems to be informing the MDS of modes, but at least for ceph_mkdir, doesn't appear to be used at all. Should the r_fmode be 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_pages and r_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 creation

Branch: refs/heads/wip-create-xattr
Home: https://github.com/NewDreamNetwork/ceph

Commit: d2d2149d364ee5b5fe078a964e2c1089c2153cd1

      https://github.com/NewDreamNetwork/ceph/commit/d2d2149d364ee5b5fe078a964e2c1089c2153cd1

Author: Sage Weil <[email protected]>
Date: 2011-10-18 (Tue, 18 Oct 2011)

Changed paths:
M src/mds/Server.cc

Log Message:
-----------
mds: handle xattrs on inode creation

Allow 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.

_______________________________________________
Ceph-commit mailing list
[email protected]
http://lists.ceph.newdream.net/listinfo.cgi/ceph-commit-ceph.newdream.net

#2 lore raw

----- 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() in dir.c.

Thanks, this is the part I originally was wondering about. Twas right under my nose.

-Noah

author
#3 lore raw
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