Skip to content

Commit 620239d

Browse files
jtlaytonidryomov
authored andcommitted
ceph: fix setting of xattrs on async created inodes
Currently when we create a file, we spin up an xattr buffer to send along with the create request. If we end up doing an async create however, then we currently pass down a zero-length xattr buffer. Fix the code to send down the xattr buffer in req->r_pagelist. If the xattrs span more than a page, however give up and don't try to do an async create. Cc: [email protected] URL: https://bugzilla.redhat.com/show_bug.cgi?id=2063929 Fixes: 9a8d03c ("ceph: attempt to do async create when possible") Reported-by: John Fortin <[email protected]> Reported-by: Sri Ramanujam <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Reviewed-by: Xiubo Li <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent c5eb0a6 commit 620239d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

fs/ceph/file.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,15 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
629629
iinfo.change_attr = 1;
630630
ceph_encode_timespec64(&iinfo.btime, &now);
631631

632-
iinfo.xattr_len = ARRAY_SIZE(xattr_buf);
633-
iinfo.xattr_data = xattr_buf;
634-
memset(iinfo.xattr_data, 0, iinfo.xattr_len);
632+
if (req->r_pagelist) {
633+
iinfo.xattr_len = req->r_pagelist->length;
634+
iinfo.xattr_data = req->r_pagelist->mapped_tail;
635+
} else {
636+
/* fake it */
637+
iinfo.xattr_len = ARRAY_SIZE(xattr_buf);
638+
iinfo.xattr_data = xattr_buf;
639+
memset(iinfo.xattr_data, 0, iinfo.xattr_len);
640+
}
635641

636642
in.ino = cpu_to_le64(vino.ino);
637643
in.snapid = cpu_to_le64(CEPH_NOSNAP);
@@ -743,6 +749,10 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
743749
err = ceph_security_init_secctx(dentry, mode, &as_ctx);
744750
if (err < 0)
745751
goto out_ctx;
752+
/* Async create can't handle more than a page of xattrs */
753+
if (as_ctx.pagelist &&
754+
!list_is_singular(&as_ctx.pagelist->head))
755+
try_async = false;
746756
} else if (!d_in_lookup(dentry)) {
747757
/* If it's not being looked up, it's negative */
748758
return -ENOENT;

0 commit comments

Comments
 (0)