Skip to content

Commit 87a367f

Browse files
committed
Merge tag 'ceph-for-7.0-rc1' of https://github.com/ceph/ceph-client
Pull ceph updates from Ilya Dryomov: "This adds support for the upcoming aes256k key type in CephX that is based on Kerberos 5 and brings a bunch of assorted CephFS fixes from Ethan and Sam. One of Sam's patches in particular undoes a change in the fscrypt area that had an inadvertent side effect of making CephFS behave as if mounted with wsize=4096 and leading to the corresponding degradation in performance, especially for sequential writes" * tag 'ceph-for-7.0-rc1' of https://github.com/ceph/ceph-client: ceph: assert loop invariants in ceph_writepages_start() ceph: remove error return from ceph_process_folio_batch() ceph: fix write storm on fscrypted files ceph: do not propagate page array emplacement errors as batch errors ceph: supply snapshot context in ceph_uninline_data() ceph: supply snapshot context in ceph_zero_partial_object() libceph: adapt ceph_x_challenge_blob hashing and msgr1 message signing libceph: add support for CEPH_CRYPTO_AES256KRB5 libceph: introduce ceph_crypto_key_prepare() libceph: generalize ceph_x_encrypt_offset() and ceph_x_encrypt_buflen() libceph: define and enforce CEPH_MAX_KEY_LEN
2 parents 0ba83f0 + cfdde14 commit 87a367f

9 files changed

Lines changed: 481 additions & 134 deletions

File tree

fs/ceph/addr.c

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,8 @@ unsigned int ceph_define_write_size(struct address_space *mapping)
10001000
{
10011001
struct inode *inode = mapping->host;
10021002
struct ceph_fs_client *fsc = ceph_inode_to_fs_client(inode);
1003-
unsigned int wsize = i_blocksize(inode);
1003+
struct ceph_inode_info *ci = ceph_inode(inode);
1004+
unsigned int wsize = ci->i_layout.stripe_unit;
10041005

10051006
if (fsc->mount_options->wsize < wsize)
10061007
wsize = fsc->mount_options->wsize;
@@ -1283,16 +1284,16 @@ static inline int move_dirty_folio_in_page_array(struct address_space *mapping,
12831284
}
12841285

12851286
static
1286-
int ceph_process_folio_batch(struct address_space *mapping,
1287-
struct writeback_control *wbc,
1288-
struct ceph_writeback_ctl *ceph_wbc)
1287+
void ceph_process_folio_batch(struct address_space *mapping,
1288+
struct writeback_control *wbc,
1289+
struct ceph_writeback_ctl *ceph_wbc)
12891290
{
12901291
struct inode *inode = mapping->host;
12911292
struct ceph_fs_client *fsc = ceph_inode_to_fs_client(inode);
12921293
struct ceph_client *cl = fsc->client;
12931294
struct folio *folio = NULL;
12941295
unsigned i;
1295-
int rc = 0;
1296+
int rc;
12961297

12971298
for (i = 0; can_next_page_be_processed(ceph_wbc, i); i++) {
12981299
folio = ceph_wbc->fbatch.folios[i];
@@ -1322,12 +1323,10 @@ int ceph_process_folio_batch(struct address_space *mapping,
13221323
rc = ceph_check_page_before_write(mapping, wbc,
13231324
ceph_wbc, folio);
13241325
if (rc == -ENODATA) {
1325-
rc = 0;
13261326
folio_unlock(folio);
13271327
ceph_wbc->fbatch.folios[i] = NULL;
13281328
continue;
13291329
} else if (rc == -E2BIG) {
1330-
rc = 0;
13311330
folio_unlock(folio);
13321331
ceph_wbc->fbatch.folios[i] = NULL;
13331332
break;
@@ -1379,8 +1378,6 @@ int ceph_process_folio_batch(struct address_space *mapping,
13791378
}
13801379

13811380
ceph_wbc->processed_in_fbatch = i;
1382-
1383-
return rc;
13841381
}
13851382

13861383
static inline
@@ -1666,7 +1663,9 @@ static int ceph_writepages_start(struct address_space *mapping,
16661663
tag_pages_for_writeback(mapping, ceph_wbc.index, ceph_wbc.end);
16671664

16681665
while (!has_writeback_done(&ceph_wbc)) {
1669-
ceph_wbc.locked_pages = 0;
1666+
BUG_ON(ceph_wbc.locked_pages);
1667+
BUG_ON(ceph_wbc.pages);
1668+
16701669
ceph_wbc.max_pages = ceph_wbc.wsize >> PAGE_SHIFT;
16711670

16721671
get_more_pages:
@@ -1684,10 +1683,8 @@ static int ceph_writepages_start(struct address_space *mapping,
16841683
break;
16851684

16861685
process_folio_batch:
1687-
rc = ceph_process_folio_batch(mapping, wbc, &ceph_wbc);
1686+
ceph_process_folio_batch(mapping, wbc, &ceph_wbc);
16881687
ceph_shift_unused_folios_left(&ceph_wbc.fbatch);
1689-
if (rc)
1690-
goto release_folios;
16911688

16921689
/* did we get anything? */
16931690
if (!ceph_wbc.locked_pages)
@@ -2199,6 +2196,7 @@ int ceph_uninline_data(struct file *file)
21992196
struct ceph_osd_request *req = NULL;
22002197
struct ceph_cap_flush *prealloc_cf = NULL;
22012198
struct folio *folio = NULL;
2199+
struct ceph_snap_context *snapc = NULL;
22022200
u64 inline_version = CEPH_INLINE_NONE;
22032201
struct page *pages[1];
22042202
int err = 0;
@@ -2226,6 +2224,24 @@ int ceph_uninline_data(struct file *file)
22262224
if (inline_version == 1) /* initial version, no data */
22272225
goto out_uninline;
22282226

2227+
down_read(&fsc->mdsc->snap_rwsem);
2228+
spin_lock(&ci->i_ceph_lock);
2229+
if (__ceph_have_pending_cap_snap(ci)) {
2230+
struct ceph_cap_snap *capsnap =
2231+
list_last_entry(&ci->i_cap_snaps,
2232+
struct ceph_cap_snap,
2233+
ci_item);
2234+
snapc = ceph_get_snap_context(capsnap->context);
2235+
} else {
2236+
if (!ci->i_head_snapc) {
2237+
ci->i_head_snapc = ceph_get_snap_context(
2238+
ci->i_snap_realm->cached_context);
2239+
}
2240+
snapc = ceph_get_snap_context(ci->i_head_snapc);
2241+
}
2242+
spin_unlock(&ci->i_ceph_lock);
2243+
up_read(&fsc->mdsc->snap_rwsem);
2244+
22292245
folio = read_mapping_folio(inode->i_mapping, 0, file);
22302246
if (IS_ERR(folio)) {
22312247
err = PTR_ERR(folio);
@@ -2241,7 +2257,7 @@ int ceph_uninline_data(struct file *file)
22412257
req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
22422258
ceph_vino(inode), 0, &len, 0, 1,
22432259
CEPH_OSD_OP_CREATE, CEPH_OSD_FLAG_WRITE,
2244-
NULL, 0, 0, false);
2260+
snapc, 0, 0, false);
22452261
if (IS_ERR(req)) {
22462262
err = PTR_ERR(req);
22472263
goto out_unlock;
@@ -2257,7 +2273,7 @@ int ceph_uninline_data(struct file *file)
22572273
req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
22582274
ceph_vino(inode), 0, &len, 1, 3,
22592275
CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_WRITE,
2260-
NULL, ci->i_truncate_seq,
2276+
snapc, ci->i_truncate_seq,
22612277
ci->i_truncate_size, false);
22622278
if (IS_ERR(req)) {
22632279
err = PTR_ERR(req);
@@ -2320,6 +2336,7 @@ int ceph_uninline_data(struct file *file)
23202336
folio_put(folio);
23212337
}
23222338
out:
2339+
ceph_put_snap_context(snapc);
23232340
ceph_free_cap_flush(prealloc_cf);
23242341
doutc(cl, "%llx.%llx inline_version %llu = %d\n",
23252342
ceph_vinop(inode), inline_version, err);

fs/ceph/file.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2568,6 +2568,7 @@ static int ceph_zero_partial_object(struct inode *inode,
25682568
struct ceph_inode_info *ci = ceph_inode(inode);
25692569
struct ceph_fs_client *fsc = ceph_inode_to_fs_client(inode);
25702570
struct ceph_osd_request *req;
2571+
struct ceph_snap_context *snapc;
25712572
int ret = 0;
25722573
loff_t zero = 0;
25732574
int op;
@@ -2582,12 +2583,25 @@ static int ceph_zero_partial_object(struct inode *inode,
25822583
op = CEPH_OSD_OP_ZERO;
25832584
}
25842585

2586+
spin_lock(&ci->i_ceph_lock);
2587+
if (__ceph_have_pending_cap_snap(ci)) {
2588+
struct ceph_cap_snap *capsnap =
2589+
list_last_entry(&ci->i_cap_snaps,
2590+
struct ceph_cap_snap,
2591+
ci_item);
2592+
snapc = ceph_get_snap_context(capsnap->context);
2593+
} else {
2594+
BUG_ON(!ci->i_head_snapc);
2595+
snapc = ceph_get_snap_context(ci->i_head_snapc);
2596+
}
2597+
spin_unlock(&ci->i_ceph_lock);
2598+
25852599
req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
25862600
ceph_vino(inode),
25872601
offset, length,
25882602
0, 1, op,
25892603
CEPH_OSD_FLAG_WRITE,
2590-
NULL, 0, 0, false);
2604+
snapc, 0, 0, false);
25912605
if (IS_ERR(req)) {
25922606
ret = PTR_ERR(req);
25932607
goto out;
@@ -2601,6 +2615,7 @@ static int ceph_zero_partial_object(struct inode *inode,
26012615
ceph_osdc_put_request(req);
26022616

26032617
out:
2618+
ceph_put_snap_context(snapc);
26042619
return ret;
26052620
}
26062621

include/linux/ceph/ceph_fs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ struct ceph_dir_layout {
8989
} __attribute__ ((packed));
9090

9191
/* crypto algorithms */
92-
#define CEPH_CRYPTO_NONE 0x0
93-
#define CEPH_CRYPTO_AES 0x1
92+
#define CEPH_CRYPTO_NONE 0x0
93+
#define CEPH_CRYPTO_AES 0x1
94+
#define CEPH_CRYPTO_AES256KRB5 0x2 /* AES256-CTS-HMAC384-192 */
9495

9596
#define CEPH_AES_IV "cephsageyudagreg"
9697

net/ceph/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ config CEPH_LIB
66
select CRYPTO_AES
77
select CRYPTO_CBC
88
select CRYPTO_GCM
9+
select CRYPTO_KRB5
910
select CRYPTO_LIB_SHA256
1011
select CRYPTO
1112
select KEYS

0 commit comments

Comments
 (0)