Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Notable upstream pull request merges:
 #15517 2a27fd4 ZIL: Assert record sizes in different places
 #15557 b94ce4e module/icp/asm-arm/sha2: fix compiling on armv5/6
 #15557 4340f69 module/icp/asm-arm/sha2: auto detect __ARM_ARCH
 #15603 a03ebd9 ZIL: Call brt_pending_add() replaying TX_CLONE_RANGE
 #15606 1c38cdf zdb: fix printf() length for uint64_t devid

Obtained from:	OpenZFS
OpenZFS commit:	a03ebd9
  • Loading branch information
mmatuska committed Nov 29, 2023
2 parents b70e57b + a03ebd9 commit 525fe93
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 65 deletions.
2 changes: 1 addition & 1 deletion sys/contrib/openzfs/config/kernel-inode-times.m4
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
#include <linux/fs.h>
],[
struct inode ip;
struct timespec64 ts;
struct timespec64 ts = {0};
memset(&ip, 0, sizeof(ip));
inode_set_ctime_to_ts(&ip, ts);
Expand Down
3 changes: 1 addition & 2 deletions sys/contrib/openzfs/include/sys/dmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,7 @@ int dmu_offset_next(objset_t *os, uint64_t object, boolean_t hole,
int dmu_read_l0_bps(objset_t *os, uint64_t object, uint64_t offset,
uint64_t length, struct blkptr *bps, size_t *nbpsp);
int dmu_brt_clone(objset_t *os, uint64_t object, uint64_t offset,
uint64_t length, dmu_tx_t *tx, const struct blkptr *bps, size_t nbps,
boolean_t replay);
uint64_t length, dmu_tx_t *tx, const struct blkptr *bps, size_t nbps);

/*
* Initial setup and final teardown.
Expand Down
8 changes: 4 additions & 4 deletions sys/contrib/openzfs/lib/libspl/os/linux/zone.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ getzoneid(void)
int c = snprintf(path, sizeof (path), "/proc/self/ns/user");
/* This API doesn't have any error checking... */
if (c < 0 || c >= sizeof (path))
return (0);
return (GLOBAL_ZONEID);

ssize_t r = readlink(path, buf, sizeof (buf) - 1);
if (r < 0)
return (0);
return (GLOBAL_ZONEID);

cp = strchr(buf, '[');
if (cp == NULL)
return (0);
return (GLOBAL_ZONEID);
cp++;

unsigned long n = strtoul(cp, NULL, 10);
if (n == ULONG_MAX && errno == ERANGE)
return (0);
return (GLOBAL_ZONEID);
zoneid_t z = (zoneid_t)n;

return (z);
Expand Down
11 changes: 9 additions & 2 deletions sys/contrib/openzfs/module/icp/asm-arm/sha2/sha256-armv7.S
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

#if defined(__arm__)

#define __ARM_ARCH__ 7
#define __ARM_MAX_ARCH__ 7
#ifndef __ARM_ARCH
# define __ARM_ARCH__ 7
#else
# define __ARM_ARCH__ __ARM_ARCH
#endif

#if defined(__thumb2__)
.syntax unified
Expand Down Expand Up @@ -1846,7 +1849,11 @@ zfs_sha256_block_neon:
stmdb sp!,{r4-r12,lr}

sub r11,sp,#16*4+16
#if __ARM_ARCH__ >=7
adr r14,K256
#else
ldr r14,=K256
#endif
bic r11,r11,#15 @ align for 128-bit stores
mov r12,sp
mov sp,r11 @ alloca
Expand Down
7 changes: 5 additions & 2 deletions sys/contrib/openzfs/module/icp/asm-arm/sha2/sha512-armv7.S
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

#if defined(__arm__)

#define __ARM_ARCH__ 7
#define __ARM_MAX_ARCH__ 7
#ifndef __ARM_ARCH
# define __ARM_ARCH__ 7
#else
# define __ARM_ARCH__ __ARM_ARCH
#endif

#ifndef __KERNEL__
# define VFP_ABI_PUSH vstmdb sp!,{d8-d15}
Expand Down
9 changes: 7 additions & 2 deletions sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
iovec_t *dst_iovecs;
zil_chain_t *zilc;
lr_t *lr;
uint64_t txtype, lr_len;
uint64_t txtype, lr_len, nused;
uint_t crypt_len, nr_iovecs, vec;
uint_t aad_len = 0, total_len = 0;

Expand All @@ -1268,7 +1268,10 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
zilc = (zil_chain_t *)src;
slrp = src + sizeof (zil_chain_t);
aadp = aadbuf;
blkend = src + ((byteswap) ? BSWAP_64(zilc->zc_nused) : zilc->zc_nused);
nused = ((byteswap) ? BSWAP_64(zilc->zc_nused) : zilc->zc_nused);
ASSERT3U(nused, >=, sizeof (zil_chain_t));
ASSERT3U(nused, <=, datalen);
blkend = src + nused;

/*
* Calculate the number of encrypted iovecs we will need.
Expand All @@ -1287,6 +1290,8 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
txtype = lr->lrc_txtype;
lr_len = lr->lrc_reclen;
}
ASSERT3U(lr_len, >=, sizeof (lr_t));
ASSERT3U(lr_len, <=, blkend - slrp);

nr_iovecs++;
if (txtype == TX_WRITE && lr_len != sizeof (lr_write_t))
Expand Down
9 changes: 7 additions & 2 deletions sys/contrib/openzfs/module/os/linux/zfs/zio_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
boolean_t *no_crypt)
{
int ret;
uint64_t txtype, lr_len;
uint64_t txtype, lr_len, nused;
uint_t nr_src, nr_dst, crypt_len;
uint_t aad_len = 0, nr_iovecs = 0, total_len = 0;
iovec_t *src_iovecs = NULL, *dst_iovecs = NULL;
Expand All @@ -1432,7 +1432,10 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
zilc = (zil_chain_t *)src;
slrp = src + sizeof (zil_chain_t);
aadp = aadbuf;
blkend = src + ((byteswap) ? BSWAP_64(zilc->zc_nused) : zilc->zc_nused);
nused = ((byteswap) ? BSWAP_64(zilc->zc_nused) : zilc->zc_nused);
ASSERT3U(nused, >=, sizeof (zil_chain_t));
ASSERT3U(nused, <=, datalen);
blkend = src + nused;

/* calculate the number of encrypted iovecs we will need */
for (; slrp < blkend; slrp += lr_len) {
Expand All @@ -1445,6 +1448,8 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
txtype = BSWAP_64(lr->lrc_txtype);
lr_len = BSWAP_64(lr->lrc_reclen);
}
ASSERT3U(lr_len, >=, sizeof (lr_t));
ASSERT3U(lr_len, <=, blkend - slrp);

nr_iovecs++;
if (txtype == TX_WRITE && lr_len != sizeof (lr_write_t))
Expand Down
14 changes: 7 additions & 7 deletions sys/contrib/openzfs/module/zfs/brt.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@
* destination dataset is mounted and its ZIL replayed.
* To address this situation we leverage zil_claim() mechanism where ZFS will
* parse all the ZILs on pool import. When we come across TX_CLONE_RANGE
* entries, we will bump reference counters for their BPs in the BRT and then
* on mount and ZIL replay we will just attach BPs to the file without
* bumping reference counters.
* Note it is still possible that after zil_claim() we never mount the
* destination, so we never replay its ZIL and we destroy it. This way we would
* end up with leaked references in BRT. We address that too as ZFS gives us
* a chance to clean this up on dataset destroy (see zil_free_clone_range()).
* entries, we will bump reference counters for their BPs in the BRT. Then
* on mount and ZIL replay we bump the reference counters once more, while the
* first references are dropped during ZIL destroy by zil_free_clone_range().
* It is possible that after zil_claim() we never mount the destination, so
* we never replay its ZIL and just destroy it. In this case the only taken
* references will be dropped by zil_free_clone_range(), since the cloning is
* not going to ever take place.
*/

static kmem_cache_t *brt_entry_cache;
Expand Down
6 changes: 2 additions & 4 deletions sys/contrib/openzfs/module/zfs/dmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ dmu_read_l0_bps(objset_t *os, uint64_t object, uint64_t offset, uint64_t length,

int
dmu_brt_clone(objset_t *os, uint64_t object, uint64_t offset, uint64_t length,
dmu_tx_t *tx, const blkptr_t *bps, size_t nbps, boolean_t replay)
dmu_tx_t *tx, const blkptr_t *bps, size_t nbps)
{
spa_t *spa;
dmu_buf_t **dbp, *dbuf;
Expand Down Expand Up @@ -2360,10 +2360,8 @@ dmu_brt_clone(objset_t *os, uint64_t object, uint64_t offset, uint64_t length,
* When data in embedded into BP there is no need to create
* BRT entry as there is no data block. Just copy the BP as
* it contains the data.
* Also, when replaying ZIL we don't want to bump references
* in the BRT as it was already done during ZIL claim.
*/
if (!replay && !BP_IS_HOLE(bp) && !BP_IS_EMBEDDED(bp)) {
if (!BP_IS_HOLE(bp) && !BP_IS_EMBEDDED(bp)) {
brt_pending_add(spa, bp, tx);
}
}
Expand Down
50 changes: 43 additions & 7 deletions sys/contrib/openzfs/module/zfs/zfs_replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap)
uint64_t dnodesize;
int error;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lracl));

txtype = (lr->lr_common.lrc_txtype & ~TX_CI);
if (byteswap) {
byteswap_uint64_array(lracl, sizeof (*lracl));
Expand Down Expand Up @@ -470,6 +472,8 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap)
uint64_t dnodesize;
int error;

ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr));

txtype = (lr->lr_common.lrc_txtype & ~TX_CI);
if (byteswap) {
byteswap_uint64_array(lr, sizeof (*lr));
Expand Down Expand Up @@ -613,6 +617,8 @@ zfs_replay_remove(void *arg1, void *arg2, boolean_t byteswap)
int error;
int vflg = 0;

ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

Expand Down Expand Up @@ -648,6 +654,8 @@ zfs_replay_link(void *arg1, void *arg2, boolean_t byteswap)
int error;
int vflg = 0;

ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

Expand Down Expand Up @@ -715,12 +723,14 @@ zfs_replay_rename(void *arg1, void *arg2, boolean_t byteswap)
{
zfsvfs_t *zfsvfs = arg1;
lr_rename_t *lr = arg2;
char *sname = (char *)(lr + 1); /* sname and tname follow lr_rename_t */
char *tname = sname + strlen(sname) + 1;

ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

char *sname = (char *)(lr + 1); /* sname and tname follow lr_rename_t */
char *tname = sname + strlen(sname) + 1;
return (do_zfs_replay_rename(zfsvfs, lr, sname, tname, 0, NULL));
}

Expand All @@ -730,12 +740,14 @@ zfs_replay_rename_exchange(void *arg1, void *arg2, boolean_t byteswap)
#ifdef __linux__
zfsvfs_t *zfsvfs = arg1;
lr_rename_t *lr = arg2;
char *sname = (char *)(lr + 1); /* sname and tname follow lr_rename_t */
char *tname = sname + strlen(sname) + 1;

ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

char *sname = (char *)(lr + 1); /* sname and tname follow lr_rename_t */
char *tname = sname + strlen(sname) + 1;
return (do_zfs_replay_rename(zfsvfs, lr, sname, tname, RENAME_EXCHANGE,
NULL));
#else
Expand All @@ -750,14 +762,13 @@ zfs_replay_rename_whiteout(void *arg1, void *arg2, boolean_t byteswap)
zfsvfs_t *zfsvfs = arg1;
lr_rename_whiteout_t *lr = arg2;
int error;
/* sname and tname follow lr_rename_whiteout_t */
char *sname = (char *)(lr + 1);
char *tname = sname + strlen(sname) + 1;
/* For the whiteout file. */
xvattr_t xva;
uint64_t objid;
uint64_t dnodesize;

ASSERT3U(lr->lr_rename.lr_common.lrc_reclen, >, sizeof (*lr));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

Expand All @@ -783,6 +794,9 @@ zfs_replay_rename_whiteout(void *arg1, void *arg2, boolean_t byteswap)
if (error)
return (error);

/* sname and tname follow lr_rename_whiteout_t */
char *sname = (char *)(lr + 1);
char *tname = sname + strlen(sname) + 1;
return (do_zfs_replay_rename(zfsvfs, &lr->lr_rename, sname, tname,
RENAME_WHITEOUT, &xva.xva_vattr));
#else
Expand All @@ -800,6 +814,8 @@ zfs_replay_write(void *arg1, void *arg2, boolean_t byteswap)
int error;
uint64_t eod, offset, length;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

Expand Down Expand Up @@ -863,6 +879,8 @@ zfs_replay_write2(void *arg1, void *arg2, boolean_t byteswap)
int error;
uint64_t end;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

Expand Down Expand Up @@ -910,6 +928,8 @@ zfs_replay_truncate(void *arg1, void *arg2, boolean_t byteswap)
flock64_t fl = {0};
int error;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

Expand Down Expand Up @@ -940,6 +960,8 @@ zfs_replay_setattr(void *arg1, void *arg2, boolean_t byteswap)
int error;
void *start;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr));

xva_init(&xva);
if (byteswap) {
byteswap_uint64_array(lr, sizeof (*lr));
Expand Down Expand Up @@ -1002,6 +1024,9 @@ zfs_replay_setsaxattr(void *arg1, void *arg2, boolean_t byteswap)
size_t size;
int error = 0;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr));
ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr) + lr->lr_size);

ASSERT(spa_feature_is_active(zfsvfs->z_os->os_spa,
SPA_FEATURE_ZILSAXATTR));
if (byteswap)
Expand Down Expand Up @@ -1079,6 +1104,10 @@ zfs_replay_acl_v0(void *arg1, void *arg2, boolean_t byteswap)
znode_t *zp;
int error;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr));
ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr) +
sizeof (ace_t) * lr->lr_aclcnt);

if (byteswap) {
byteswap_uint64_array(lr, sizeof (*lr));
zfs_oldace_byteswap(ace, lr->lr_aclcnt);
Expand Down Expand Up @@ -1124,6 +1153,9 @@ zfs_replay_acl(void *arg1, void *arg2, boolean_t byteswap)
znode_t *zp;
int error;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr));
ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr) + lr->lr_acl_bytes);

if (byteswap) {
byteswap_uint64_array(lr, sizeof (*lr));
zfs_ace_byteswap(ace, lr->lr_acl_bytes, B_FALSE);
Expand Down Expand Up @@ -1171,6 +1203,10 @@ zfs_replay_clone_range(void *arg1, void *arg2, boolean_t byteswap)
znode_t *zp;
int error;

ASSERT3U(lr->lr_common.lrc_reclen, >=, sizeof (*lr));
ASSERT3U(lr->lr_common.lrc_reclen, >=, offsetof(lr_clone_range_t,
lr_bps[lr->lr_nbps]));

if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));

Expand Down
4 changes: 2 additions & 2 deletions sys/contrib/openzfs/module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
}

error = dmu_brt_clone(outos, outzp->z_id, outoff, size, tx,
bps, nbps, B_FALSE);
bps, nbps);
if (error != 0) {
dmu_tx_commit(tx);
break;
Expand Down Expand Up @@ -1461,7 +1461,7 @@ zfs_clone_range_replay(znode_t *zp, uint64_t off, uint64_t len, uint64_t blksz,
if (zp->z_blksz < blksz)
zfs_grow_blocksize(zp, blksz, tx);

dmu_brt_clone(zfsvfs->z_os, zp->z_id, off, len, tx, bps, nbps, B_TRUE);
dmu_brt_clone(zfsvfs->z_os, zp->z_id, off, len, tx, bps, nbps);

zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime);

Expand Down
Loading

0 comments on commit 525fe93

Please sign in to comment.