Skip to content

Commit c3f5e69

Browse files
committed
Merge tag 'ceph-for-5.18-rc7' of https://github.com/ceph/ceph-client
Pull ceph fix from Ilya Dryomov: "Two fixes to properly maintain xattrs on async creates and thus preserve SELinux context on newly created files and to avoid improper usage of folio->private field which triggered BUG_ONs. Both marked for stable" * tag 'ceph-for-5.18-rc7' of https://github.com/ceph/ceph-client: ceph: check folio PG_private bit instead of folio->private ceph: fix setting of xattrs on async created inodes
2 parents 6dd5884 + 642d51f commit c3f5e69

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

fs/ceph/addr.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static bool ceph_dirty_folio(struct address_space *mapping, struct folio *folio)
8585
if (folio_test_dirty(folio)) {
8686
dout("%p dirty_folio %p idx %lu -- already dirty\n",
8787
mapping->host, folio, folio->index);
88-
BUG_ON(!folio_get_private(folio));
88+
VM_BUG_ON_FOLIO(!folio_test_private(folio), folio);
8989
return false;
9090
}
9191

@@ -122,7 +122,7 @@ static bool ceph_dirty_folio(struct address_space *mapping, struct folio *folio)
122122
* Reference snap context in folio->private. Also set
123123
* PagePrivate so that we get invalidate_folio callback.
124124
*/
125-
BUG_ON(folio_get_private(folio));
125+
VM_BUG_ON_FOLIO(folio_test_private(folio), folio);
126126
folio_attach_private(folio, snapc);
127127

128128
return ceph_fscache_dirty_folio(mapping, folio);
@@ -150,7 +150,7 @@ static void ceph_invalidate_folio(struct folio *folio, size_t offset,
150150
}
151151

152152
WARN_ON(!folio_test_locked(folio));
153-
if (folio_get_private(folio)) {
153+
if (folio_test_private(folio)) {
154154
dout("%p invalidate_folio idx %lu full dirty page\n",
155155
inode, folio->index);
156156

@@ -729,8 +729,11 @@ static void writepages_finish(struct ceph_osd_request *req)
729729

730730
/* clean all pages */
731731
for (i = 0; i < req->r_num_ops; i++) {
732-
if (req->r_ops[i].op != CEPH_OSD_OP_WRITE)
732+
if (req->r_ops[i].op != CEPH_OSD_OP_WRITE) {
733+
pr_warn("%s incorrect op %d req %p index %d tid %llu\n",
734+
__func__, req->r_ops[i].op, req, i, req->r_tid);
733735
break;
736+
}
734737

735738
osd_data = osd_req_op_extent_osd_data(req, i);
736739
BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);

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)