Skip to content

Commit a3fb8a6

Browse files
committed
Merge tag 'ceph-for-6.16-rc1' of https://github.com/ceph/ceph-client
Pull ceph updates from Ilya Dryomov: - a one-liner that leads to a startling (but also very much rational) performance improvement in cases where an IMA policy with rules that are based on fsmagic matching is enforced - an encryption-related fixup that addresses generic/397 and other fstest failures - a couple of cleanups in CephFS * tag 'ceph-for-6.16-rc1' of https://github.com/ceph/ceph-client: ceph: fix variable dereferenced before check in ceph_umount_begin() ceph: set superblock s_magic for IMA fsmagic matching ceph: cleanup hardcoded constants of file handle size ceph: fix possible integer overflow in ceph_zero_objects() ceph: avoid kernel BUG for encrypted inode with unaligned file size
2 parents 28fb80f + b828b4b commit a3fb8a6

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

fs/ceph/addr.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,15 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq)
409409
struct page **pages;
410410
size_t page_off;
411411

412+
/*
413+
* FIXME: io_iter.count needs to be corrected to aligned
414+
* length. Otherwise, iov_iter_get_pages_alloc2() operates
415+
* with the initial unaligned length value. As a result,
416+
* ceph_msg_data_cursor_init() triggers BUG_ON() in the case
417+
* if msg->sparse_read_total > msg->data_length.
418+
*/
419+
subreq->io_iter.count = len;
420+
412421
err = iov_iter_get_pages_alloc2(&subreq->io_iter, &pages, len, &page_off);
413422
if (err < 0) {
414423
doutc(cl, "%llx.%llx failed to allocate pages, %d\n",

fs/ceph/export.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@ struct ceph_nfs_snapfh {
3333
u32 hash;
3434
} __attribute__ ((packed));
3535

36+
#define BYTES_PER_U32 (sizeof(u32))
37+
#define CEPH_FH_BASIC_SIZE \
38+
(sizeof(struct ceph_nfs_fh) / BYTES_PER_U32)
39+
#define CEPH_FH_WITH_PARENT_SIZE \
40+
(sizeof(struct ceph_nfs_confh) / BYTES_PER_U32)
41+
#define CEPH_FH_SNAPPED_INODE_SIZE \
42+
(sizeof(struct ceph_nfs_snapfh) / BYTES_PER_U32)
43+
3644
static int ceph_encode_snapfh(struct inode *inode, u32 *rawfh, int *max_len,
3745
struct inode *parent_inode)
3846
{
3947
struct ceph_client *cl = ceph_inode_to_client(inode);
40-
static const int snap_handle_length =
41-
sizeof(struct ceph_nfs_snapfh) >> 2;
48+
static const int snap_handle_length = CEPH_FH_SNAPPED_INODE_SIZE;
4249
struct ceph_nfs_snapfh *sfh = (void *)rawfh;
4350
u64 snapid = ceph_snap(inode);
4451
int ret;
@@ -88,10 +95,8 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len,
8895
struct inode *parent_inode)
8996
{
9097
struct ceph_client *cl = ceph_inode_to_client(inode);
91-
static const int handle_length =
92-
sizeof(struct ceph_nfs_fh) >> 2;
93-
static const int connected_handle_length =
94-
sizeof(struct ceph_nfs_confh) >> 2;
98+
static const int handle_length = CEPH_FH_BASIC_SIZE;
99+
static const int connected_handle_length = CEPH_FH_WITH_PARENT_SIZE;
95100
int type;
96101

97102
if (ceph_snap(inode) != CEPH_NOSNAP)
@@ -308,7 +313,7 @@ static struct dentry *ceph_fh_to_dentry(struct super_block *sb,
308313
if (fh_type != FILEID_INO32_GEN &&
309314
fh_type != FILEID_INO32_GEN_PARENT)
310315
return NULL;
311-
if (fh_len < sizeof(*fh) / 4)
316+
if (fh_len < sizeof(*fh) / BYTES_PER_U32)
312317
return NULL;
313318

314319
doutc(fsc->client, "%llx\n", fh->ino);
@@ -427,7 +432,7 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb,
427432

428433
if (fh_type != FILEID_INO32_GEN_PARENT)
429434
return NULL;
430-
if (fh_len < sizeof(*cfh) / 4)
435+
if (fh_len < sizeof(*cfh) / BYTES_PER_U32)
431436
return NULL;
432437

433438
doutc(fsc->client, "%llx\n", cfh->parent_ino);

fs/ceph/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@ static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length)
26162616
s32 stripe_unit = ci->i_layout.stripe_unit;
26172617
s32 stripe_count = ci->i_layout.stripe_count;
26182618
s32 object_size = ci->i_layout.object_size;
2619-
u64 object_set_size = object_size * stripe_count;
2619+
u64 object_set_size = (u64) object_size * stripe_count;
26202620
u64 nearly, t;
26212621

26222622
/* round offset up to next period boundary */

fs/ceph/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,7 @@ void ceph_umount_begin(struct super_block *sb)
10331033
struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);
10341034

10351035
doutc(fsc->client, "starting forced umount\n");
1036-
if (!fsc)
1037-
return;
1036+
10381037
fsc->mount_state = CEPH_MOUNT_SHUTDOWN;
10391038
__ceph_umount_begin(fsc);
10401039
}
@@ -1227,6 +1226,7 @@ static int ceph_set_super(struct super_block *s, struct fs_context *fc)
12271226
s->s_time_min = 0;
12281227
s->s_time_max = U32_MAX;
12291228
s->s_flags |= SB_NODIRATIME | SB_NOATIME;
1229+
s->s_magic = CEPH_SUPER_MAGIC;
12301230

12311231
ceph_fscrypt_set_ops(s);
12321232

0 commit comments

Comments
 (0)