From 56608daa8de12e8131ecb7e8a4ac9e68a78ec144 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 21 Jul 2024 21:04:38 -0400 Subject: [PATCH 001/223] Cleanup DB_DNODE() macros usage - Use the macros in few places it was missed. - Reduce scope of DB_DNODE_ENTER/EXIT() and inline some DB_DNODE() uses to make it more obvious what exactly is protected there and make unprotected accesses by mistake more difficult. - Make use of zrl_owner(). Reviewed-by: Rob Wing Reviewed-by: Allan Jude Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16374 --- module/zfs/dbuf.c | 11 +++----- module/zfs/dmu.c | 61 +++++++++++++++++++------------------------- module/zfs/dmu_tx.c | 5 +--- module/zfs/dnode.c | 2 +- module/zfs/sa.c | 4 +-- module/zfs/zfs_log.c | 2 +- 6 files changed, 34 insertions(+), 51 deletions(-) diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index f81ae96f2e0b..35d0e59ee2cb 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -4332,7 +4332,7 @@ dbuf_lightweight_bp(dbuf_dirty_record_t *dr) dmu_buf_impl_t *parent_db = dr->dr_parent->dr_dbuf; int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; VERIFY3U(parent_db->db_level, ==, 1); - VERIFY3P(parent_db->db_dnode_handle->dnh_dnode, ==, dn); + VERIFY3P(DB_DNODE(parent_db), ==, dn); VERIFY3U(dr->dt.dll.dr_blkid >> epbs, ==, parent_db->db_blkid); blkptr_t *bp = parent_db->db.db_data; return (&bp[dr->dt.dll.dr_blkid & ((1 << epbs) - 1)]); @@ -4751,14 +4751,13 @@ dbuf_write_children_ready(zio_t *zio, arc_buf_t *buf, void *vdb) { (void) zio, (void) buf; dmu_buf_impl_t *db = vdb; - dnode_t *dn; blkptr_t *bp; unsigned int epbs, i; ASSERT3U(db->db_level, >, 0); DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT; + epbs = DB_DNODE(db)->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT; + DB_DNODE_EXIT(db); ASSERT3U(epbs, <, 31); /* Determine if all our children are holes */ @@ -4781,7 +4780,6 @@ dbuf_write_children_ready(zio_t *zio, arc_buf_t *buf, void *vdb) memset(db->db.db_data, 0, db->db.db_size); rw_exit(&db->db_rwlock); } - DB_DNODE_EXIT(db); } static void @@ -4999,8 +4997,7 @@ dbuf_remap(dnode_t *dn, dmu_buf_impl_t *db, dmu_tx_t *tx) } } else if (db->db.db_object == DMU_META_DNODE_OBJECT) { dnode_phys_t *dnp = db->db.db_data; - ASSERT3U(db->db_dnode_handle->dnh_dnode->dn_type, ==, - DMU_OT_DNODE); + ASSERT3U(dn->dn_type, ==, DMU_OT_DNODE); for (int i = 0; i < db->db.db_size >> DNODE_SHIFT; i += dnp[i].dn_extra_slots + 1) { for (int j = 0; j < dnp[i].dn_nblkptr; j++) { diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 24c5ab07df52..33f1cf948552 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -276,13 +276,14 @@ dmu_set_bonus(dmu_buf_t *db_fake, int newsize, dmu_tx_t *tx) dnode_t *dn; int error; + if (newsize < 0 || newsize > db_fake->db_size) + return (SET_ERROR(EINVAL)); + DB_DNODE_ENTER(db); dn = DB_DNODE(db); if (dn->dn_bonus != db) { error = SET_ERROR(EINVAL); - } else if (newsize < 0 || newsize > db_fake->db_size) { - error = SET_ERROR(EINVAL); } else { dnode_setbonuslen(dn, newsize, tx); error = 0; @@ -299,12 +300,13 @@ dmu_set_bonustype(dmu_buf_t *db_fake, dmu_object_type_t type, dmu_tx_t *tx) dnode_t *dn; int error; + if (!DMU_OT_IS_VALID(type)) + return (SET_ERROR(EINVAL)); + DB_DNODE_ENTER(db); dn = DB_DNODE(db); - if (!DMU_OT_IS_VALID(type)) { - error = SET_ERROR(EINVAL); - } else if (dn->dn_bonus != db) { + if (dn->dn_bonus != db) { error = SET_ERROR(EINVAL); } else { dnode_setbonus_type(dn, type, tx); @@ -319,12 +321,10 @@ dmu_object_type_t dmu_get_bonustype(dmu_buf_t *db_fake) { dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; - dnode_t *dn; dmu_object_type_t type; DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - type = dn->dn_bonustype; + type = DB_DNODE(db)->dn_bonustype; DB_DNODE_EXIT(db); return (type); @@ -486,7 +486,6 @@ dmu_spill_hold_by_bonus(dmu_buf_t *bonus, uint32_t flags, const void *tag, dmu_buf_t **dbp) { dmu_buf_impl_t *db = (dmu_buf_impl_t *)bonus; - dnode_t *dn; int err; uint32_t db_flags = DB_RF_CANFAIL; @@ -494,8 +493,7 @@ dmu_spill_hold_by_bonus(dmu_buf_t *bonus, uint32_t flags, const void *tag, db_flags |= DB_RF_NO_DECRYPT; DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - err = dmu_spill_hold_by_dnode(dn, db_flags, tag, dbp); + err = dmu_spill_hold_by_dnode(DB_DNODE(db), db_flags, tag, dbp); DB_DNODE_EXIT(db); return (err); @@ -668,13 +666,11 @@ dmu_buf_hold_array_by_bonus(dmu_buf_t *db_fake, uint64_t offset, dmu_buf_t ***dbpp) { dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; - dnode_t *dn; int err; DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag, - numbufsp, dbpp, DMU_READ_PREFETCH); + err = dmu_buf_hold_array_by_dnode(DB_DNODE(db), offset, length, read, + tag, numbufsp, dbpp, DMU_READ_PREFETCH); DB_DNODE_EXIT(db); return (err); @@ -1308,15 +1304,13 @@ int dmu_read_uio_dbuf(dmu_buf_t *zdb, zfs_uio_t *uio, uint64_t size) { dmu_buf_impl_t *db = (dmu_buf_impl_t *)zdb; - dnode_t *dn; int err; if (size == 0) return (0); DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - err = dmu_read_uio_dnode(dn, uio, size); + err = dmu_read_uio_dnode(DB_DNODE(db), uio, size); DB_DNODE_EXIT(db); return (err); @@ -1410,15 +1404,13 @@ dmu_write_uio_dbuf(dmu_buf_t *zdb, zfs_uio_t *uio, uint64_t size, dmu_tx_t *tx) { dmu_buf_impl_t *db = (dmu_buf_impl_t *)zdb; - dnode_t *dn; int err; if (size == 0) return (0); DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - err = dmu_write_uio_dnode(dn, uio, size, tx); + err = dmu_write_uio_dnode(DB_DNODE(db), uio, size, tx); DB_DNODE_EXIT(db); return (err); @@ -1546,11 +1538,11 @@ dmu_assign_arcbuf_by_dbuf(dmu_buf_t *handle, uint64_t offset, arc_buf_t *buf, dmu_tx_t *tx) { int err; - dmu_buf_impl_t *dbuf = (dmu_buf_impl_t *)handle; + dmu_buf_impl_t *db = (dmu_buf_impl_t *)handle; - DB_DNODE_ENTER(dbuf); - err = dmu_assign_arcbuf_by_dnode(DB_DNODE(dbuf), offset, buf, tx); - DB_DNODE_EXIT(dbuf); + DB_DNODE_ENTER(db); + err = dmu_assign_arcbuf_by_dnode(DB_DNODE(db), offset, buf, tx); + DB_DNODE_EXIT(db); return (err); } @@ -1789,7 +1781,6 @@ dmu_sync(zio_t *pio, uint64_t txg, dmu_sync_cb_t *done, zgd_t *zgd) dmu_sync_arg_t *dsa; zbookmark_phys_t zb; zio_prop_t zp; - dnode_t *dn; ASSERT(pio != NULL); ASSERT(txg != 0); @@ -1798,8 +1789,7 @@ dmu_sync(zio_t *pio, uint64_t txg, dmu_sync_cb_t *done, zgd_t *zgd) db->db.db_object, db->db_level, db->db_blkid); DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - dmu_write_policy(os, dn, db->db_level, WP_DMU_SYNC, &zp); + dmu_write_policy(os, DB_DNODE(db), db->db_level, WP_DMU_SYNC, &zp); DB_DNODE_EXIT(db); /* @@ -1884,11 +1874,14 @@ dmu_sync(zio_t *pio, uint64_t txg, dmu_sync_cb_t *done, zgd_t *zgd) * zio_done(), which VERIFYs that the override BP is identical * to the on-disk BP. */ - DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - if (dr_next != NULL || dnode_block_freed(dn, db->db_blkid)) + if (dr_next != NULL) { zp.zp_nopwrite = B_FALSE; - DB_DNODE_EXIT(db); + } else { + DB_DNODE_ENTER(db); + if (dnode_block_freed(DB_DNODE(db), db->db_blkid)) + zp.zp_nopwrite = B_FALSE; + DB_DNODE_EXIT(db); + } ASSERT(dr->dr_txg == txg); if (dr->dt.dl.dr_override_state == DR_IN_DMU_SYNC || @@ -2493,11 +2486,9 @@ void dmu_object_dnsize_from_db(dmu_buf_t *db_fake, int *dnsize) { dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; - dnode_t *dn; DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - *dnsize = dn->dn_num_slots << DNODE_SHIFT; + *dnsize = DB_DNODE(db)->dn_num_slots << DNODE_SHIFT; DB_DNODE_EXIT(db); } diff --git a/module/zfs/dmu_tx.c b/module/zfs/dmu_tx.c index 8451b5082e86..2c2a6c7642a5 100644 --- a/module/zfs/dmu_tx.c +++ b/module/zfs/dmu_tx.c @@ -1520,11 +1520,8 @@ dmu_tx_hold_sa(dmu_tx_t *tx, sa_handle_t *hdl, boolean_t may_grow) ASSERT(tx->tx_txg == 0); dmu_tx_hold_spill(tx, object); } else { - dnode_t *dn; - DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - if (dn->dn_have_spill) { + if (DB_DNODE(db)->dn_have_spill) { ASSERT(tx->tx_txg == 0); dmu_tx_hold_spill(tx, object); } diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c index ad9988366ada..efb94bbe23ba 100644 --- a/module/zfs/dnode.c +++ b/module/zfs/dnode.c @@ -1735,7 +1735,7 @@ dnode_rele_and_unlock(dnode_t *dn, const void *tag, boolean_t evicting) * handle. */ #ifdef ZFS_DEBUG - ASSERT(refs > 0 || dnh->dnh_zrlock.zr_owner != curthread); + ASSERT(refs > 0 || zrl_owner(&dnh->dnh_zrlock) != curthread); #endif /* NOTE: the DNODE_DNODE does not have a dn_dbuf */ diff --git a/module/zfs/sa.c b/module/zfs/sa.c index f9daaabbed3e..bb4cf246ea07 100644 --- a/module/zfs/sa.c +++ b/module/zfs/sa.c @@ -1851,7 +1851,6 @@ sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr, { sa_os_t *sa = hdl->sa_os->os_sa; dmu_buf_impl_t *db = (dmu_buf_impl_t *)hdl->sa_bonus; - dnode_t *dn; sa_bulk_attr_t *attr_desc; void *old_data[2]; int bonus_attr_count = 0; @@ -1871,8 +1870,7 @@ sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr, /* First make of copy of the old data */ DB_DNODE_ENTER(db); - dn = DB_DNODE(db); - if (dn->dn_bonuslen != 0) { + if (DB_DNODE(db)->dn_bonuslen != 0) { bonus_data_size = hdl->sa_bonus->db_size; old_data[0] = kmem_alloc(bonus_data_size, KM_SLEEP); memcpy(old_data[0], hdl->sa_bonus->db_data, diff --git a/module/zfs/zfs_log.c b/module/zfs/zfs_log.c index 006b91198160..6dc28499ad7e 100644 --- a/module/zfs/zfs_log.c +++ b/module/zfs/zfs_log.c @@ -670,13 +670,13 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype, DB_DNODE_ENTER(db); err = dmu_read_by_dnode(DB_DNODE(db), off, len, lr + 1, DMU_READ_NO_PREFETCH); + DB_DNODE_EXIT(db); if (err != 0) { zil_itx_destroy(itx); itx = zil_itx_create(txtype, sizeof (*lr)); lr = (lr_write_t *)&itx->itx_lr; wr_state = WR_NEED_COPY; } - DB_DNODE_EXIT(db); } itx->itx_wr_state = wr_state; From 30ea442961df9d8174ea15b9157b4ecac3472602 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 28 Sep 2024 02:18:11 +1000 Subject: [PATCH 002/223] zfs_log: add flex array fields to log record structs ZIL log record structs (lr_XX_t) are frequently allocated with extra space after the struct to carry variable-sized "payload" items. Linux 6.10+ compiled with CONFIG_FORTIFY_SOURCE has been doing runtime bounds checking on memcpy() calls. Because these types had no indicator that they might use more space than their simple definition, __fortify_memcpy_chk will frequently complain about overruns eg: memcpy: detected field-spanning write (size 7) of single field "lr + 1" at zfs_log.c:425 (size 0) memcpy: detected field-spanning write (size 9) of single field "(char *)(lr + 1)" at zfs_log.c:593 (size 0) memcpy: detected field-spanning write (size 4) of single field "(char *)(lr + 1) + snamesize" at zfs_log.c:594 (size 0) memcpy: detected field-spanning write (size 7) of single field "lr + 1" at zfs_log.c:425 (size 0) memcpy: detected field-spanning write (size 9) of single field "(char *)(lr + 1)" at zfs_log.c:593 (size 0) memcpy: detected field-spanning write (size 4) of single field "(char *)(lr + 1) + snamesize" at zfs_log.c:594 (size 0) memcpy: detected field-spanning write (size 7) of single field "lr + 1" at zfs_log.c:425 (size 0) memcpy: detected field-spanning write (size 9) of single field "(char *)(lr + 1)" at zfs_log.c:593 (size 0) memcpy: detected field-spanning write (size 4) of single field "(char *)(lr + 1) + snamesize" at zfs_log.c:594 (size 0) To fix this, this commit adds flex array fields to all lr_XX_t structs that require them, and then uses those fields to access that end-of-struct area rather than more complicated casts and pointer addition. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Alexander Motin Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16501 Closes #16539 --- cmd/zdb/zdb_il.c | 6 +- cmd/ztest.c | 24 +++---- include/sys/zil.h | 30 +++++++-- module/zfs/zfs_log.c | 90 ++++++++++++------------- module/zfs/zfs_replay.c | 143 +++++++++++++++++++++------------------- 5 files changed, 162 insertions(+), 131 deletions(-) diff --git a/cmd/zdb/zdb_il.c b/cmd/zdb/zdb_il.c index 63d95ddedc3b..88b85f989f60 100644 --- a/cmd/zdb/zdb_il.c +++ b/cmd/zdb/zdb_il.c @@ -64,7 +64,8 @@ static void zil_prt_rec_create(zilog_t *zilog, int txtype, const void *arg) { (void) zilog; - const lr_create_t *lr = arg; + const lr_create_t *lrc = arg; + const _lr_create_t *lr = &lrc->lr_create; time_t crtime = lr->lr_crtime[0]; char *name, *link; lr_attr_t *lrattr; @@ -121,7 +122,8 @@ static void zil_prt_rec_rename(zilog_t *zilog, int txtype, const void *arg) { (void) zilog, (void) txtype; - const lr_rename_t *lr = arg; + const lr_rename_t *lrr = arg; + const _lr_rename_t *lr = &lrr->lr_rename; char *snm = (char *)(lr + 1); char *tnm = snm + strlen(snm) + 1; diff --git a/cmd/ztest.c b/cmd/ztest.c index ca3105ffbbbe..66b9c06bd4f0 100644 --- a/cmd/ztest.c +++ b/cmd/ztest.c @@ -1861,7 +1861,7 @@ ztest_verify_unused_bonus(dmu_buf_t *db, void *end, uint64_t obj, static void ztest_log_create(ztest_ds_t *zd, dmu_tx_t *tx, lr_create_t *lr) { - char *name = (void *)(lr + 1); /* name follows lr */ + char *name = (char *)&lr->lr_data[0]; /* name follows lr */ size_t namesize = strlen(name) + 1; itx_t *itx; @@ -1869,7 +1869,7 @@ ztest_log_create(ztest_ds_t *zd, dmu_tx_t *tx, lr_create_t *lr) return; itx = zil_itx_create(TX_CREATE, sizeof (*lr) + namesize); - memcpy(&itx->itx_lr + 1, &lr->lr_common + 1, + memcpy(&itx->itx_lr + 1, &lr->lr_create.lr_common + 1, sizeof (*lr) + namesize - sizeof (lr_t)); zil_itx_assign(zd->zd_zilog, itx, tx); @@ -1878,7 +1878,7 @@ ztest_log_create(ztest_ds_t *zd, dmu_tx_t *tx, lr_create_t *lr) static void ztest_log_remove(ztest_ds_t *zd, dmu_tx_t *tx, lr_remove_t *lr, uint64_t object) { - char *name = (void *)(lr + 1); /* name follows lr */ + char *name = (char *)&lr->lr_data[0]; /* name follows lr */ size_t namesize = strlen(name) + 1; itx_t *itx; @@ -1964,8 +1964,9 @@ static int ztest_replay_create(void *arg1, void *arg2, boolean_t byteswap) { ztest_ds_t *zd = arg1; - lr_create_t *lr = arg2; - char *name = (void *)(lr + 1); /* name follows lr */ + lr_create_t *lrc = arg2; + _lr_create_t *lr = &lrc->lr_create; + char *name = (char *)&lrc->lr_data[0]; /* name follows lr */ objset_t *os = zd->zd_os; ztest_block_tag_t *bbt; dmu_buf_t *db; @@ -2043,7 +2044,7 @@ ztest_replay_create(void *arg1, void *arg2, boolean_t byteswap) VERIFY0(zap_add(os, lr->lr_doid, name, sizeof (uint64_t), 1, &lr->lr_foid, tx)); - (void) ztest_log_create(zd, tx, lr); + (void) ztest_log_create(zd, tx, lrc); dmu_tx_commit(tx); @@ -2055,7 +2056,7 @@ ztest_replay_remove(void *arg1, void *arg2, boolean_t byteswap) { ztest_ds_t *zd = arg1; lr_remove_t *lr = arg2; - char *name = (void *)(lr + 1); /* name follows lr */ + char *name = (char *)&lr->lr_data[0]; /* name follows lr */ objset_t *os = zd->zd_os; dmu_object_info_t doi; dmu_tx_t *tx; @@ -2109,9 +2110,9 @@ ztest_replay_write(void *arg1, void *arg2, boolean_t byteswap) ztest_ds_t *zd = arg1; lr_write_t *lr = arg2; objset_t *os = zd->zd_os; - void *data = lr + 1; /* data follows lr */ + uint8_t *data = &lr->lr_data[0]; /* data follows lr */ uint64_t offset, length; - ztest_block_tag_t *bt = data; + ztest_block_tag_t *bt = (ztest_block_tag_t *)data; ztest_block_tag_t *bbt; uint64_t gen, txg, lrtxg, crtxg; dmu_object_info_t doi; @@ -2563,7 +2564,8 @@ ztest_create(ztest_ds_t *zd, ztest_od_t *od, int count) continue; } - lr_create_t *lr = ztest_lr_alloc(sizeof (*lr), od->od_name); + lr_create_t *lrc = ztest_lr_alloc(sizeof (*lrc), od->od_name); + _lr_create_t *lr = &lrc->lr_create; lr->lr_doid = od->od_dir; lr->lr_foid = 0; /* 0 to allocate, > 0 to claim */ @@ -2647,7 +2649,7 @@ ztest_write(ztest_ds_t *zd, uint64_t object, uint64_t offset, uint64_t size, lr->lr_blkoff = 0; BP_ZERO(&lr->lr_blkptr); - memcpy(lr + 1, data, size); + memcpy(&lr->lr_data[0], data, size); error = ztest_replay_write(zd, lr, B_FALSE); diff --git a/include/sys/zil.h b/include/sys/zil.h index 4747ecc067a9..bbe973bcee7b 100644 --- a/include/sys/zil.h +++ b/include/sys/zil.h @@ -248,6 +248,7 @@ typedef struct { uint32_t lr_attr_masksize; /* number of elements in array */ uint32_t lr_attr_bitmap; /* First entry of array */ /* remainder of array and additional lr_attr_end_t fields */ + uint8_t lr_attr_data[]; } lr_attr_t; /* @@ -264,9 +265,14 @@ typedef struct { uint64_t lr_gen; /* generation (txg of creation) */ uint64_t lr_crtime[2]; /* creation time */ uint64_t lr_rdev; /* rdev of object to create */ +} _lr_create_t; + +typedef struct { + _lr_create_t lr_create; /* common create portion */ /* name of object to create follows this */ /* for symlinks, link content follows name */ /* for creates with xvattr data, the name follows the xvattr info */ + uint8_t lr_data[]; } lr_create_t; /* @@ -293,18 +299,20 @@ typedef struct { * and group will be in lr_create. Name follows ACL data. */ typedef struct { - lr_create_t lr_create; /* common create portion */ + _lr_create_t lr_create; /* common create portion */ uint64_t lr_aclcnt; /* number of ACEs in ACL */ uint64_t lr_domcnt; /* number of unique domains */ uint64_t lr_fuidcnt; /* number of real fuids */ uint64_t lr_acl_bytes; /* number of bytes in ACL */ uint64_t lr_acl_flags; /* ACL flags */ + uint8_t lr_data[]; } lr_acl_create_t; typedef struct { lr_t lr_common; /* common portion of log record */ uint64_t lr_doid; /* obj id of directory */ /* name of object to remove follows this */ + uint8_t lr_data[]; } lr_remove_t; typedef struct { @@ -312,18 +320,24 @@ typedef struct { uint64_t lr_doid; /* obj id of directory */ uint64_t lr_link_obj; /* obj id of link */ /* name of object to link follows this */ + uint8_t lr_data[]; } lr_link_t; typedef struct { lr_t lr_common; /* common portion of log record */ uint64_t lr_sdoid; /* obj id of source directory */ uint64_t lr_tdoid; /* obj id of target directory */ +} _lr_rename_t; + +typedef struct { + _lr_rename_t lr_rename; /* common rename portion */ /* 2 strings: names of source and destination follow this */ + uint8_t lr_data[]; } lr_rename_t; typedef struct { - lr_rename_t lr_rename; /* common rename portion */ - /* members related to the whiteout file (based on lr_create_t) */ + _lr_rename_t lr_rename; /* common rename portion */ + /* members related to the whiteout file (based on _lr_create_t) */ uint64_t lr_wfoid; /* obj id of the new whiteout file */ uint64_t lr_wmode; /* mode of object */ uint64_t lr_wuid; /* uid of whiteout */ @@ -332,6 +346,7 @@ typedef struct { uint64_t lr_wcrtime[2]; /* creation time */ uint64_t lr_wrdev; /* always makedev(0, 0) */ /* 2 strings: names of source and destination follow this */ + uint8_t lr_data[]; } lr_rename_whiteout_t; typedef struct { @@ -342,6 +357,7 @@ typedef struct { uint64_t lr_blkoff; /* no longer used */ blkptr_t lr_blkptr; /* spa block pointer for replay */ /* write data will follow for small writes */ + uint8_t lr_data[]; } lr_write_t; typedef struct { @@ -362,6 +378,7 @@ typedef struct { uint64_t lr_atime[2]; /* access time */ uint64_t lr_mtime[2]; /* modification time */ /* optional attribute lr_attr_t may be here */ + uint8_t lr_data[]; } lr_setattr_t; typedef struct { @@ -369,6 +386,7 @@ typedef struct { uint64_t lr_foid; /* file object to change attributes */ uint64_t lr_size; /* xattr name and value follows */ + uint8_t lr_data[]; } lr_setsaxattr_t; typedef struct { @@ -376,6 +394,7 @@ typedef struct { uint64_t lr_foid; /* obj id of file */ uint64_t lr_aclcnt; /* number of acl entries */ /* lr_aclcnt number of ace_t entries follow this */ + uint8_t lr_data[]; } lr_acl_v0_t; typedef struct { @@ -387,6 +406,7 @@ typedef struct { uint64_t lr_acl_bytes; /* number of bytes in ACL */ uint64_t lr_acl_flags; /* ACL flags */ /* lr_acl_bytes number of variable sized ace's follows */ + uint8_t lr_data[]; } lr_acl_t; typedef struct { @@ -396,8 +416,8 @@ typedef struct { uint64_t lr_length; /* length of the blocks to clone */ uint64_t lr_blksz; /* file's block size */ uint64_t lr_nbps; /* number of block pointers */ - blkptr_t lr_bps[]; /* block pointers of the blocks to clone follows */ + blkptr_t lr_bps[]; } lr_clone_range_t; /* @@ -448,7 +468,7 @@ typedef struct itx { uint64_t itx_oid; /* object id */ uint64_t itx_gen; /* gen number for zfs_get_data */ lr_t itx_lr; /* common part of log record */ - /* followed by type-specific part of lr_xx_t and its immediate data */ + uint8_t itx_lr_data[]; /* type-specific part of lr_xx_t */ } itx_t; /* diff --git a/module/zfs/zfs_log.c b/module/zfs/zfs_log.c index 6dc28499ad7e..19c65100659f 100644 --- a/module/zfs/zfs_log.c +++ b/module/zfs/zfs_log.c @@ -300,14 +300,13 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, zfs_fuid_info_t *fuidp, vattr_t *vap) { itx_t *itx; - lr_create_t *lr; - lr_acl_create_t *lracl; + _lr_create_t *lr; + lr_acl_create_t *lracl = NULL; + uint8_t *lrdata; size_t aclsize = 0; size_t xvatsize = 0; size_t txsize; xvattr_t *xvap = (xvattr_t *)vap; - void *end; - size_t lrsize; size_t namesize = strlen(name) + 1; size_t fuidsz = 0; @@ -329,18 +328,21 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, if ((int)txtype == TX_CREATE_ATTR || (int)txtype == TX_MKDIR_ATTR || (int)txtype == TX_CREATE || (int)txtype == TX_MKDIR || (int)txtype == TX_MKXATTR) { - txsize = sizeof (*lr) + namesize + fuidsz + xvatsize; - lrsize = sizeof (*lr); + txsize = sizeof (lr_create_t) + namesize + fuidsz + xvatsize; + itx = zil_itx_create(txtype, txsize); + lr_create_t *lrc = (lr_create_t *)&itx->itx_lr; + lrdata = &lrc->lr_data[0]; } else { txsize = sizeof (lr_acl_create_t) + namesize + fuidsz + ZIL_ACE_LENGTH(aclsize) + xvatsize; - lrsize = sizeof (lr_acl_create_t); + itx = zil_itx_create(txtype, txsize); + lracl = (lr_acl_create_t *)&itx->itx_lr; + lrdata = &lracl->lr_data[0]; } - itx = zil_itx_create(txtype, txsize); - lr = (lr_create_t *)&itx->itx_lr; + lr = (_lr_create_t *)&itx->itx_lr; lr->lr_doid = dzp->z_id; lr->lr_foid = zp->z_id; /* Store dnode slot count in 8 bits above object id. */ @@ -369,16 +371,14 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, * Fill in xvattr info if any */ if (vap->va_mask & ATTR_XVATTR) { - zfs_log_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), xvap); - end = (caddr_t)lr + lrsize + xvatsize; - } else { - end = (caddr_t)lr + lrsize; + zfs_log_xvattr((lr_attr_t *)lrdata, xvap); + lrdata = &lrdata[xvatsize]; } /* Now fill in any ACL info */ if (vsecp) { - lracl = (lr_acl_create_t *)&itx->itx_lr; + ASSERT3P(lracl, !=, NULL); lracl->lr_aclcnt = vsecp->vsa_aclcnt; lracl->lr_acl_bytes = aclsize; lracl->lr_domcnt = fuidp ? fuidp->z_domain_cnt : 0; @@ -388,19 +388,19 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, else lracl->lr_acl_flags = 0; - memcpy(end, vsecp->vsa_aclentp, aclsize); - end = (caddr_t)end + ZIL_ACE_LENGTH(aclsize); + memcpy(lrdata, vsecp->vsa_aclentp, aclsize); + lrdata = &lrdata[ZIL_ACE_LENGTH(aclsize)]; } /* drop in FUID info */ if (fuidp) { - end = zfs_log_fuid_ids(fuidp, end); - end = zfs_log_fuid_domains(fuidp, end); + lrdata = zfs_log_fuid_ids(fuidp, lrdata); + lrdata = zfs_log_fuid_domains(fuidp, lrdata); } /* * Now place file name in log record */ - memcpy(end, name, namesize); + memcpy(lrdata, name, namesize); zil_itx_assign(zilog, itx, tx); } @@ -422,7 +422,7 @@ zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, itx = zil_itx_create(txtype, sizeof (*lr) + namesize); lr = (lr_remove_t *)&itx->itx_lr; lr->lr_doid = dzp->z_id; - memcpy(lr + 1, name, namesize); + memcpy(&lr->lr_data[0], name, namesize); itx->itx_oid = foid; @@ -458,7 +458,7 @@ zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, lr = (lr_link_t *)&itx->itx_lr; lr->lr_doid = dzp->z_id; lr->lr_link_obj = zp->z_id; - memcpy(lr + 1, name, namesize); + memcpy(&lr->lr_data[0], name, namesize); zil_itx_assign(zilog, itx, tx); } @@ -471,15 +471,17 @@ zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, znode_t *dzp, znode_t *zp, const char *name, const char *link) { itx_t *itx; - lr_create_t *lr; + _lr_create_t *lr; + lr_create_t *lrc; size_t namesize = strlen(name) + 1; size_t linksize = strlen(link) + 1; if (zil_replaying(zilog, tx)) return; - itx = zil_itx_create(txtype, sizeof (*lr) + namesize + linksize); - lr = (lr_create_t *)&itx->itx_lr; + itx = zil_itx_create(txtype, sizeof (*lrc) + namesize + linksize); + lrc = (lr_create_t *)&itx->itx_lr; + lr = &lrc->lr_create; lr->lr_doid = dzp->z_id; lr->lr_foid = zp->z_id; lr->lr_uid = KUID_TO_SUID(ZTOUID(zp)); @@ -489,8 +491,8 @@ zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, sizeof (uint64_t)); (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)), lr->lr_crtime, sizeof (uint64_t) * 2); - memcpy((char *)(lr + 1), name, namesize); - memcpy((char *)(lr + 1) + namesize, link, linksize); + memcpy(&lrc->lr_data[0], name, namesize); + memcpy(&lrc->lr_data[namesize], link, linksize); zil_itx_assign(zilog, itx, tx); } @@ -500,7 +502,8 @@ do_zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, znode_t *sdzp, const char *sname, znode_t *tdzp, const char *dname, znode_t *szp) { itx_t *itx; - lr_rename_t *lr; + _lr_rename_t *lr; + lr_rename_t *lrr; size_t snamesize = strlen(sname) + 1; size_t dnamesize = strlen(dname) + 1; @@ -508,11 +511,12 @@ do_zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, znode_t *sdzp, return; itx = zil_itx_create(txtype, sizeof (*lr) + snamesize + dnamesize); - lr = (lr_rename_t *)&itx->itx_lr; + lrr = (lr_rename_t *)&itx->itx_lr; + lr = &lrr->lr_rename; lr->lr_sdoid = sdzp->z_id; lr->lr_tdoid = tdzp->z_id; - memcpy((char *)(lr + 1), sname, snamesize); - memcpy((char *)(lr + 1) + snamesize, dname, dnamesize); + memcpy(&lrr->lr_data[0], sname, snamesize); + memcpy(&lrr->lr_data[snamesize], dname, dnamesize); itx->itx_oid = szp->z_id; zil_itx_assign(zilog, itx, tx); @@ -590,8 +594,8 @@ zfs_log_rename_whiteout(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, (void) sa_lookup(wzp->z_sa_hdl, SA_ZPL_RDEV(ZTOZSB(wzp)), &lr->lr_wrdev, sizeof (lr->lr_wrdev)); - memcpy((char *)(lr + 1), sname, snamesize); - memcpy((char *)(lr + 1) + snamesize, dname, dnamesize); + memcpy(&lr->lr_data[0], sname, snamesize); + memcpy(&lr->lr_data[snamesize], dname, dnamesize); itx->itx_oid = szp->z_id; zil_itx_assign(zilog, itx, tx); @@ -668,8 +672,8 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype, if (wr_state == WR_COPIED) { int err; DB_DNODE_ENTER(db); - err = dmu_read_by_dnode(DB_DNODE(db), off, len, lr + 1, - DMU_READ_NO_PREFETCH); + err = dmu_read_by_dnode(DB_DNODE(db), off, len, + &lr->lr_data[0], DMU_READ_NO_PREFETCH); DB_DNODE_EXIT(db); if (err != 0) { zil_itx_destroy(itx); @@ -741,7 +745,7 @@ zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype, lr_setattr_t *lr; xvattr_t *xvap = (xvattr_t *)vap; size_t recsize = sizeof (lr_setattr_t); - void *start; + uint8_t *start; if (zil_replaying(zilog, tx) || zp->z_unlinked) return; @@ -775,10 +779,10 @@ zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype, lr->lr_size = (uint64_t)vap->va_size; ZFS_TIME_ENCODE(&vap->va_atime, lr->lr_atime); ZFS_TIME_ENCODE(&vap->va_mtime, lr->lr_mtime); - start = (lr_setattr_t *)(lr + 1); + start = &lr->lr_data[0]; if (vap->va_mask & ATTR_XVATTR) { zfs_log_xvattr((lr_attr_t *)start, xvap); - start = (caddr_t)start + ZIL_XVAT_SIZE(xvap->xva_mapsize); + start = &lr->lr_data[ZIL_XVAT_SIZE(xvap->xva_mapsize)]; } /* @@ -802,7 +806,6 @@ zfs_log_setsaxattr(zilog_t *zilog, dmu_tx_t *tx, int txtype, itx_t *itx; lr_setsaxattr_t *lr; size_t recsize = sizeof (lr_setsaxattr_t); - void *xattrstart; int namelen; if (zil_replaying(zilog, tx) || zp->z_unlinked) @@ -813,10 +816,9 @@ zfs_log_setsaxattr(zilog_t *zilog, dmu_tx_t *tx, int txtype, itx = zil_itx_create(txtype, recsize); lr = (lr_setsaxattr_t *)&itx->itx_lr; lr->lr_foid = zp->z_id; - xattrstart = (char *)(lr + 1); - memcpy(xattrstart, name, namelen); + memcpy(&lr->lr_data[0], name, namelen); if (value != NULL) { - memcpy((char *)xattrstart + namelen, value, size); + memcpy(&lr->lr_data[namelen], value, size); lr->lr_size = size; } else { lr->lr_size = 0; @@ -874,13 +876,13 @@ zfs_log_acl(zilog_t *zilog, dmu_tx_t *tx, znode_t *zp, if (txtype == TX_ACL_V0) { lrv0 = (lr_acl_v0_t *)lr; - memcpy(lrv0 + 1, vsecp->vsa_aclentp, aclbytes); + memcpy(&lrv0->lr_data[0], vsecp->vsa_aclentp, aclbytes); } else { - void *start = (ace_t *)(lr + 1); + uint8_t *start = &lr->lr_data[0]; memcpy(start, vsecp->vsa_aclentp, aclbytes); - start = (caddr_t)start + ZIL_ACE_LENGTH(aclbytes); + start = &lr->lr_data[ZIL_ACE_LENGTH(aclbytes)]; if (fuidp) { start = zfs_log_fuid_ids(fuidp, start); diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c index 2e0af60f6db4..3d735b5fb441 100644 --- a/module/zfs/zfs_replay.c +++ b/module/zfs/zfs_replay.c @@ -293,16 +293,16 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) { zfsvfs_t *zfsvfs = arg1; lr_acl_create_t *lracl = arg2; + _lr_create_t *lr = &lracl->lr_create; char *name = NULL; /* location determined later */ - lr_create_t *lr = (lr_create_t *)lracl; znode_t *dzp; znode_t *zp; xvattr_t xva; int vflg = 0; vsecattr_t vsec = { 0 }; lr_attr_t *lrattr; - void *aclstart; - void *fuidstart; + uint8_t *aclstart; + uint8_t *fuidstart; size_t xvatlen = 0; uint64_t txtype; uint64_t objid; @@ -316,17 +316,18 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) byteswap_uint64_array(lracl, sizeof (*lracl)); if (txtype == TX_CREATE_ACL_ATTR || txtype == TX_MKDIR_ACL_ATTR) { - lrattr = (lr_attr_t *)(caddr_t)(lracl + 1); + lrattr = (lr_attr_t *)&lracl->lr_data[0]; zfs_replay_swap_attrs(lrattr); xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize); } - aclstart = (caddr_t)(lracl + 1) + xvatlen; + aclstart = &lracl->lr_data[xvatlen]; zfs_ace_byteswap(aclstart, lracl->lr_acl_bytes, B_FALSE); + /* swap fuids */ if (lracl->lr_fuidcnt) { - byteswap_uint64_array((caddr_t)aclstart + - ZIL_ACE_LENGTH(lracl->lr_acl_bytes), + byteswap_uint64_array( + &aclstart[ZIL_ACE_LENGTH(lracl->lr_acl_bytes)], lracl->lr_fuidcnt * sizeof (uint64_t)); } } @@ -361,28 +362,27 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) vflg |= FIGNORECASE; switch (txtype) { case TX_CREATE_ACL: - aclstart = (caddr_t)(lracl + 1); - fuidstart = (caddr_t)aclstart + - ZIL_ACE_LENGTH(lracl->lr_acl_bytes); + aclstart = &lracl->lr_data[0]; + fuidstart = &aclstart[ZIL_ACE_LENGTH(lracl->lr_acl_bytes)]; zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart, (void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt, lr->lr_uid, lr->lr_gid); zfs_fallthrough; case TX_CREATE_ACL_ATTR: if (name == NULL) { - lrattr = (lr_attr_t *)(caddr_t)(lracl + 1); + lrattr = (lr_attr_t *)&lracl->lr_data[0]; xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize); xva.xva_vattr.va_mask |= ATTR_XVATTR; zfs_replay_xvattr(lrattr, &xva); } vsec.vsa_mask = VSA_ACE | VSA_ACE_ACLFLAGS; - vsec.vsa_aclentp = (caddr_t)(lracl + 1) + xvatlen; + vsec.vsa_aclentp = &lracl->lr_data[xvatlen]; vsec.vsa_aclcnt = lracl->lr_aclcnt; vsec.vsa_aclentsz = lracl->lr_acl_bytes; vsec.vsa_aclflags = lracl->lr_acl_flags; if (zfsvfs->z_fuid_replay == NULL) { - fuidstart = (caddr_t)(lracl + 1) + xvatlen + - ZIL_ACE_LENGTH(lracl->lr_acl_bytes); + fuidstart = &lracl->lr_data[xvatlen + + ZIL_ACE_LENGTH(lracl->lr_acl_bytes)]; zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart, (void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt, @@ -398,9 +398,8 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) #endif break; case TX_MKDIR_ACL: - aclstart = (caddr_t)(lracl + 1); - fuidstart = (caddr_t)aclstart + - ZIL_ACE_LENGTH(lracl->lr_acl_bytes); + aclstart = &lracl->lr_data[0]; + fuidstart = &aclstart[ZIL_ACE_LENGTH(lracl->lr_acl_bytes)]; zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart, (void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt, lr->lr_uid, lr->lr_gid); @@ -412,13 +411,13 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) zfs_replay_xvattr(lrattr, &xva); } vsec.vsa_mask = VSA_ACE | VSA_ACE_ACLFLAGS; - vsec.vsa_aclentp = (caddr_t)(lracl + 1) + xvatlen; + vsec.vsa_aclentp = &lracl->lr_data[xvatlen]; vsec.vsa_aclcnt = lracl->lr_aclcnt; vsec.vsa_aclentsz = lracl->lr_acl_bytes; vsec.vsa_aclflags = lracl->lr_acl_flags; if (zfsvfs->z_fuid_replay == NULL) { - fuidstart = (caddr_t)(lracl + 1) + xvatlen + - ZIL_ACE_LENGTH(lracl->lr_acl_bytes); + fuidstart = &lracl->lr_data[xvatlen + + ZIL_ACE_LENGTH(lracl->lr_acl_bytes)]; zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart, (void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt, @@ -456,14 +455,14 @@ static int zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) { zfsvfs_t *zfsvfs = arg1; - lr_create_t *lr = arg2; + lr_create_t *lrc = arg2; + _lr_create_t *lr = &lrc->lr_create; char *name = NULL; /* location determined later */ char *link; /* symlink content follows name */ znode_t *dzp; znode_t *zp = NULL; xvattr_t xva; int vflg = 0; - size_t lrsize = sizeof (lr_create_t); lr_attr_t *lrattr; void *start; size_t xvatlen; @@ -476,9 +475,9 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) txtype = (lr->lr_common.lrc_txtype & ~TX_CI); if (byteswap) { - byteswap_uint64_array(lr, sizeof (*lr)); + byteswap_uint64_array(lrc, sizeof (*lrc)); if (txtype == TX_CREATE_ATTR || txtype == TX_MKDIR_ATTR) - zfs_replay_swap_attrs((lr_attr_t *)(lr + 1)); + zfs_replay_swap_attrs((lr_attr_t *)&lrc->lr_data[0]); } @@ -520,7 +519,7 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) if (txtype != TX_SYMLINK && txtype != TX_MKDIR_ATTR && txtype != TX_CREATE_ATTR) { - start = (lr + 1); + start = (void *)&lrc->lr_data[0]; zfsvfs->z_fuid_replay = zfs_replay_fuid_domain(start, &start, lr->lr_uid, lr->lr_gid); @@ -528,10 +527,10 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) switch (txtype) { case TX_CREATE_ATTR: - lrattr = (lr_attr_t *)(caddr_t)(lr + 1); + lrattr = (lr_attr_t *)&lrc->lr_data[0]; xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize); - zfs_replay_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), &xva); - start = (caddr_t)(lr + 1) + xvatlen; + zfs_replay_xvattr(lrattr, &xva); + start = (void *)&lrc->lr_data[xvatlen]; zfsvfs->z_fuid_replay = zfs_replay_fuid_domain(start, &start, lr->lr_uid, lr->lr_gid); @@ -551,10 +550,10 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) #endif break; case TX_MKDIR_ATTR: - lrattr = (lr_attr_t *)(caddr_t)(lr + 1); + lrattr = (lr_attr_t *)&lrc->lr_data[0]; xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize); - zfs_replay_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), &xva); - start = (caddr_t)(lr + 1) + xvatlen; + zfs_replay_xvattr(lrattr, &xva); + start = &lrc->lr_data[xvatlen]; zfsvfs->z_fuid_replay = zfs_replay_fuid_domain(start, &start, lr->lr_uid, lr->lr_gid); @@ -563,7 +562,7 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) case TX_MKDIR: if (name == NULL) - name = (char *)(lr + 1); + name = (char *)&lrc->lr_data[0]; #if defined(__linux__) error = zfs_mkdir(dzp, name, &xva.xva_vattr, @@ -578,8 +577,8 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) error = zfs_make_xattrdir(dzp, &xva.xva_vattr, &zp, kcred); break; case TX_SYMLINK: - name = (char *)(lr + 1); - link = name + strlen(name) + 1; + name = &lrc->lr_data[0]; + link = &lrc->lr_data[strlen(name) + 1]; #if defined(__linux__) error = zfs_symlink(dzp, name, &xva.xva_vattr, link, &zp, kcred, vflg, zfs_init_idmap); @@ -612,7 +611,7 @@ zfs_replay_remove(void *arg1, void *arg2, boolean_t byteswap) { zfsvfs_t *zfsvfs = arg1; lr_remove_t *lr = arg2; - char *name = (char *)(lr + 1); /* name follows lr_remove_t */ + char *name = (char *)&lr->lr_data[0]; /* name follows lr_remove_t */ znode_t *dzp; int error; int vflg = 0; @@ -649,7 +648,7 @@ zfs_replay_link(void *arg1, void *arg2, boolean_t byteswap) { zfsvfs_t *zfsvfs = arg1; lr_link_t *lr = arg2; - char *name = (char *)(lr + 1); /* name follows lr_link_t */ + char *name = &lr->lr_data[0]; /* name follows lr_link_t */ znode_t *dzp, *zp; int error; int vflg = 0; @@ -678,7 +677,7 @@ zfs_replay_link(void *arg1, void *arg2, boolean_t byteswap) } static int -do_zfs_replay_rename(zfsvfs_t *zfsvfs, lr_rename_t *lr, char *sname, +do_zfs_replay_rename(zfsvfs_t *zfsvfs, _lr_rename_t *lr, char *sname, char *tname, uint64_t rflags, vattr_t *wo_vap) { znode_t *sdzp, *tdzp; @@ -722,15 +721,17 @@ static int zfs_replay_rename(void *arg1, void *arg2, boolean_t byteswap) { zfsvfs_t *zfsvfs = arg1; - lr_rename_t *lr = arg2; + lr_rename_t *lrr = arg2; + _lr_rename_t *lr = &lrr->lr_rename; ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr)); if (byteswap) - byteswap_uint64_array(lr, sizeof (*lr)); + byteswap_uint64_array(lrr, sizeof (*lrr)); - char *sname = (char *)(lr + 1); /* sname and tname follow lr_rename_t */ - char *tname = sname + strlen(sname) + 1; + /* sname and tname follow lr_rename_t */ + char *sname = (char *)&lrr->lr_data[0]; + char *tname = (char *)&lrr->lr_data[strlen(sname)+1]; return (do_zfs_replay_rename(zfsvfs, lr, sname, tname, 0, NULL)); } @@ -739,15 +740,17 @@ zfs_replay_rename_exchange(void *arg1, void *arg2, boolean_t byteswap) { #ifdef __linux__ zfsvfs_t *zfsvfs = arg1; - lr_rename_t *lr = arg2; + lr_rename_t *lrr = arg2; + _lr_rename_t *lr = &lrr->lr_rename; ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr)); if (byteswap) - byteswap_uint64_array(lr, sizeof (*lr)); + byteswap_uint64_array(lrr, sizeof (*lrr)); - char *sname = (char *)(lr + 1); /* sname and tname follow lr_rename_t */ - char *tname = sname + strlen(sname) + 1; + /* sname and tname follow lr_rename_t */ + char *sname = (char *)&lrr->lr_data[0]; + char *tname = (char *)&lrr->lr_data[strlen(sname)+1]; return (do_zfs_replay_rename(zfsvfs, lr, sname, tname, RENAME_EXCHANGE, NULL)); #else @@ -760,24 +763,26 @@ zfs_replay_rename_whiteout(void *arg1, void *arg2, boolean_t byteswap) { #ifdef __linux__ zfsvfs_t *zfsvfs = arg1; - lr_rename_whiteout_t *lr = arg2; + lr_rename_whiteout_t *lrrw = arg2; + _lr_rename_t *lr = &lrrw->lr_rename; int error; /* For the whiteout file. */ xvattr_t xva; uint64_t objid; uint64_t dnodesize; - ASSERT3U(lr->lr_rename.lr_common.lrc_reclen, >, sizeof (*lr)); + ASSERT3U(lr->lr_common.lrc_reclen, >, sizeof (*lr)); if (byteswap) - byteswap_uint64_array(lr, sizeof (*lr)); + byteswap_uint64_array(lrrw, sizeof (*lrrw)); - objid = LR_FOID_GET_OBJ(lr->lr_wfoid); - dnodesize = LR_FOID_GET_SLOTS(lr->lr_wfoid) << DNODE_SHIFT; + objid = LR_FOID_GET_OBJ(lrrw->lr_wfoid); + dnodesize = LR_FOID_GET_SLOTS(lrrw->lr_wfoid) << DNODE_SHIFT; xva_init(&xva); zfs_init_vattr(&xva.xva_vattr, ATTR_MODE | ATTR_UID | ATTR_GID, - lr->lr_wmode, lr->lr_wuid, lr->lr_wgid, lr->lr_wrdev, objid); + lrrw->lr_wmode, lrrw->lr_wuid, lrrw->lr_wgid, lrrw->lr_wrdev, + objid); /* * As with TX_CREATE, RENAME_WHITEOUT ends up in zfs_mknode(), which @@ -786,8 +791,8 @@ zfs_replay_rename_whiteout(void *arg1, void *arg2, boolean_t byteswap) * attributes, so we smuggle the values inside the vattr's otherwise * unused va_ctime, va_nblocks, and va_fsid fields. */ - ZFS_TIME_DECODE(&xva.xva_vattr.va_ctime, lr->lr_wcrtime); - xva.xva_vattr.va_nblocks = lr->lr_wgen; + ZFS_TIME_DECODE(&xva.xva_vattr.va_ctime, lrrw->lr_wcrtime); + xva.xva_vattr.va_nblocks = lrrw->lr_wgen; xva.xva_vattr.va_fsid = dnodesize; error = dnode_try_claim(zfsvfs->z_os, objid, dnodesize >> DNODE_SHIFT); @@ -795,9 +800,9 @@ zfs_replay_rename_whiteout(void *arg1, void *arg2, boolean_t byteswap) 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, + char *sname = (char *)&lrrw->lr_data[0]; + char *tname = (char *)&lrrw->lr_data[strlen(sname)+1]; + return (do_zfs_replay_rename(zfsvfs, lr, sname, tname, RENAME_WHITEOUT, &xva.xva_vattr)); #else return (SET_ERROR(ENOTSUP)); @@ -809,7 +814,7 @@ zfs_replay_write(void *arg1, void *arg2, boolean_t byteswap) { zfsvfs_t *zfsvfs = arg1; lr_write_t *lr = arg2; - char *data = (char *)(lr + 1); /* data follows lr_write_t */ + char *data = &lr->lr_data[0]; /* data follows lr_write_t */ znode_t *zp; int error; uint64_t eod, offset, length; @@ -968,7 +973,7 @@ zfs_replay_setattr(void *arg1, void *arg2, boolean_t byteswap) if ((lr->lr_mask & ATTR_XVATTR) && zfsvfs->z_version >= ZPL_VERSION_INITIAL) - zfs_replay_swap_attrs((lr_attr_t *)(lr + 1)); + zfs_replay_swap_attrs((lr_attr_t *)&lr->lr_data[0]); } if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0) @@ -987,11 +992,11 @@ zfs_replay_setattr(void *arg1, void *arg2, boolean_t byteswap) * Fill in xvattr_t portions if necessary. */ - start = (lr_setattr_t *)(lr + 1); + start = (void *)&lr->lr_data[0]; if (vap->va_mask & ATTR_XVATTR) { zfs_replay_xvattr((lr_attr_t *)start, &xva); - start = (caddr_t)start + - ZIL_XVAT_SIZE(((lr_attr_t *)start)->lr_attr_masksize); + start = &lr->lr_data[ + ZIL_XVAT_SIZE(((lr_attr_t *)start)->lr_attr_masksize)]; } else xva.xva_vattr.va_mask &= ~ATTR_XVATTR; @@ -1049,12 +1054,12 @@ zfs_replay_setsaxattr(void *arg1, void *arg2, boolean_t byteswap) /* Get xattr name, value and size from log record */ size = lr->lr_size; - name = (char *)(lr + 1); + name = (char *)&lr->lr_data[0]; if (size == 0) { value = NULL; error = nvlist_remove(nvl, name, DATA_TYPE_BYTE_ARRAY); } else { - value = name + strlen(name) + 1; + value = &lr->lr_data[strlen(name) + 1]; /* Limited to 32k to keep nvpair memory allocations small */ if (size > DXATTR_MAX_ENTRY_SIZE) { error = SET_ERROR(EFBIG); @@ -1099,7 +1104,7 @@ zfs_replay_acl_v0(void *arg1, void *arg2, boolean_t byteswap) { zfsvfs_t *zfsvfs = arg1; lr_acl_v0_t *lr = arg2; - ace_t *ace = (ace_t *)(lr + 1); /* ace array follows lr_acl_t */ + ace_t *ace = (ace_t *)&lr->lr_data[0]; vsecattr_t vsa = {0}; znode_t *zp; int error; @@ -1148,7 +1153,7 @@ zfs_replay_acl(void *arg1, void *arg2, boolean_t byteswap) { zfsvfs_t *zfsvfs = arg1; lr_acl_t *lr = arg2; - ace_t *ace = (ace_t *)(lr + 1); + ace_t *ace = (ace_t *)&lr->lr_data[0]; vsecattr_t vsa = {0}; znode_t *zp; int error; @@ -1160,8 +1165,8 @@ zfs_replay_acl(void *arg1, void *arg2, boolean_t byteswap) byteswap_uint64_array(lr, sizeof (*lr)); zfs_ace_byteswap(ace, lr->lr_acl_bytes, B_FALSE); if (lr->lr_fuidcnt) { - byteswap_uint64_array((caddr_t)ace + - ZIL_ACE_LENGTH(lr->lr_acl_bytes), + byteswap_uint64_array(&lr->lr_data[ + ZIL_ACE_LENGTH(lr->lr_acl_bytes)], lr->lr_fuidcnt * sizeof (uint64_t)); } } @@ -1176,8 +1181,8 @@ zfs_replay_acl(void *arg1, void *arg2, boolean_t byteswap) vsa.vsa_aclflags = lr->lr_acl_flags; if (lr->lr_fuidcnt) { - void *fuidstart = (caddr_t)ace + - ZIL_ACE_LENGTH(lr->lr_acl_bytes); + void *fuidstart = &lr->lr_data[ + ZIL_ACE_LENGTH(lr->lr_acl_bytes)]; zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart, &fuidstart, From 3fb66475617c0171aa51313724e1480660d1d9e2 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 2 Aug 2024 22:33:17 +1000 Subject: [PATCH 003/223] META: set Linux minimum version to 4.18 This sets RHEL8's base kernel[1] as the floor, and includes the oldest kernel.org LTS (4.19). 1. https://access.redhat.com/articles/3078#RHEL8 Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- META | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META b/META index 40376428ba95..a8aa0641ed26 100644 --- a/META +++ b/META @@ -7,4 +7,4 @@ Release-Tags: relext License: CDDL Author: OpenZFS Linux-Maximum: 6.10 -Linux-Minimum: 3.10 +Linux-Minimum: 4.18 From d66412884ac80d66950ac36148d166357977c3fa Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 30 Sep 2024 19:59:33 -0700 Subject: [PATCH 004/223] Linux 6.11 compat: META Update the META file to reflect compatibility with the 6.11 kernel. Reviewed-by: Rob Norris Signed-off-by: Brian Behlendorf Closes #16586 --- META | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META b/META index a8aa0641ed26..c52afcfc560a 100644 --- a/META +++ b/META @@ -6,5 +6,5 @@ Release: 1 Release-Tags: relext License: CDDL Author: OpenZFS -Linux-Maximum: 6.10 +Linux-Maximum: 6.11 Linux-Minimum: 4.18 From 8ca4319f605e59aeddd753a69ec20cdf03a676c6 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 18 Jul 2024 19:53:35 +1000 Subject: [PATCH 005/223] ZTS: remove skips for zvol_misc tests Last commit should fix the underlying problem, so these should be passing reliably again. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris Closes #16364 --- tests/test-runner/bin/zts-report.py.in | 4 ---- .../tests/functional/zvol/zvol_misc/zvol_misc_fua.ksh | 9 --------- .../tests/functional/zvol/zvol_misc/zvol_misc_trim.ksh | 9 --------- 3 files changed, 22 deletions(-) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index 3370f9b4e350..5fcaa01d1f35 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -352,10 +352,6 @@ elif sys.platform.startswith('linux'): 'mmp/mmp_active_import': ['FAIL', known_reason], 'mmp/mmp_exported_import': ['FAIL', known_reason], 'mmp/mmp_inactive_import': ['FAIL', known_reason], - 'zvol/zvol_misc/zvol_misc_fua': ['SKIP', 14872], - 'zvol/zvol_misc/zvol_misc_snapdev': ['FAIL', 12621], - 'zvol/zvol_misc/zvol_misc_trim': ['SKIP', 14872], - 'zvol/zvol_misc/zvol_misc_volmode': ['FAIL', known_reason], }) # Not all Github actions runners have scsi_debug module, so we may skip diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_fua.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_fua.ksh index 619d8d0e8f07..9ebd5b149118 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_fua.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_fua.ksh @@ -45,15 +45,6 @@ fi if ! is_linux ; then log_unsupported "Only linux supports dd with oflag=dsync for FUA writes" -else - if [[ $(linux_version) -gt $(linux_version "6.2") ]]; then - log_unsupported "Disabled while issue #14872 is being worked" - fi - - # Disabled for the CentOS 9 kernel - if [[ $(linux_version) -eq $(linux_version "5.14") ]]; then - log_unsupported "Disabled while issue #14872 is being worked" - fi fi typeset datafile1="$(mktemp zvol_misc_fua1.XXXXXX)" diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_trim.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_trim.ksh index c0b191aafd45..47cc42b9be7d 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_trim.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_trim.ksh @@ -44,15 +44,6 @@ verify_runnable "global" if is_linux ; then - if [[ $(linux_version) -gt $(linux_version "6.2") ]]; then - log_unsupported "Disabled while issue #14872 is being worked" - fi - - # Disabled for the CentOS 9 kernel - if [[ $(linux_version) -eq $(linux_version "5.14") ]]; then - log_unsupported "Disabled while issue #14872 is being worked" - fi - # We need '--force' here since the prior tests may leave a filesystem # on the zvol, and blkdiscard will see that filesystem and print a # warning unless you force it. From b0cfb480ca42da78e07d1410ce3f7720a96a427e Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 29 May 2024 10:46:41 -0700 Subject: [PATCH 006/223] zed: Add deadman-slot_off.sh zedlet Optionally turn off disk's enclosure slot if an I/O is hung triggering the deadman. It's possible for outstanding I/O to a misbehaving SCSI disk to neither promptly complete or return an error. This can occur due to retry and recovery actions taken by the SCSI layer, driver, or disk. When it occurs the pool will be unresponsive even though there may be sufficient redundancy configured to proceeded without this single disk. When a hung I/O is detected by the kmods it will be posted as a deadman event. By default an I/O is considered to be hung after 5 minutes. This value can be changed with the zfs_deadman_ziotime_ms module parameter. If ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN is set the disk's enclosure slot will be powered off causing the outstanding I/O to fail. The ZED will then handle this like a normal disk failure. By default ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN is not set. As part of this change `zfs_deadman_events_per_second` is added to control the ratelimitting of deadman events independantly of delay events. In practice, a single deadman event is sufficient and more aren't particularly useful. Alphabetize the zfs_deadman_* entries in zfs.4. Reviewed-by: Tony Hutter Signed-off-by: Brian Behlendorf Closes #16226 --- cmd/zed/zed.d/Makefile.am | 2 + cmd/zed/zed.d/deadman-slot_off.sh | 71 +++++++++++++++++++ cmd/zed/zed.d/zed.rc | 7 ++ man/man4/zfs.4 | 21 +++--- module/zfs/vdev.c | 10 ++- tests/zfs-tests/include/tunables.cfg | 1 + .../functional/deadman/deadman_ratelimit.ksh | 8 +-- 7 files changed, 106 insertions(+), 14 deletions(-) create mode 100755 cmd/zed/zed.d/deadman-slot_off.sh diff --git a/cmd/zed/zed.d/Makefile.am b/cmd/zed/zed.d/Makefile.am index 812558cf6d0f..093a04c4636a 100644 --- a/cmd/zed/zed.d/Makefile.am +++ b/cmd/zed/zed.d/Makefile.am @@ -9,6 +9,7 @@ dist_zedexec_SCRIPTS = \ %D%/all-debug.sh \ %D%/all-syslog.sh \ %D%/data-notify.sh \ + %D%/deadman-slot_off.sh \ %D%/generic-notify.sh \ %D%/pool_import-led.sh \ %D%/resilver_finish-notify.sh \ @@ -29,6 +30,7 @@ SUBSTFILES += $(nodist_zedexec_SCRIPTS) zedconfdefaults = \ all-syslog.sh \ data-notify.sh \ + deadman-slot_off.sh \ history_event-zfs-list-cacher.sh \ pool_import-led.sh \ resilver_finish-notify.sh \ diff --git a/cmd/zed/zed.d/deadman-slot_off.sh b/cmd/zed/zed.d/deadman-slot_off.sh new file mode 100755 index 000000000000..7b339b3add01 --- /dev/null +++ b/cmd/zed/zed.d/deadman-slot_off.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# shellcheck disable=SC3014,SC2154,SC2086,SC2034 +# +# Turn off disk's enclosure slot if an I/O is hung triggering the deadman. +# +# It's possible for outstanding I/O to a misbehaving SCSI disk to neither +# promptly complete or return an error. This can occur due to retry and +# recovery actions taken by the SCSI layer, driver, or disk. When it occurs +# the pool will be unresponsive even though there may be sufficient redundancy +# configured to proceeded without this single disk. +# +# When a hung I/O is detected by the kmods it will be posted as a deadman +# event. By default an I/O is considered to be hung after 5 minutes. This +# value can be changed with the zfs_deadman_ziotime_ms module parameter. +# If ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN is set the disk's enclosure +# slot will be powered off causing the outstanding I/O to fail. The ZED +# will then handle this like a normal disk failure and FAULT the vdev. +# +# We assume the user will be responsible for turning the slot back on +# after replacing the disk. +# +# Note that this script requires that your enclosure be supported by the +# Linux SCSI Enclosure services (SES) driver. The script will do nothing +# if you have no enclosure, or if your enclosure isn't supported. +# +# Exit codes: +# 0: slot successfully powered off +# 1: enclosure not available +# 2: ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN disabled +# 3: System not configured to wait on deadman +# 4: The enclosure sysfs path passed from ZFS does not exist +# 5: Enclosure slot didn't actually turn off after we told it to + +[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc" +. "${ZED_ZEDLET_DIR}/zed-functions.sh" + +if [ ! -d /sys/class/enclosure ] ; then + # No JBOD enclosure or NVMe slots + exit 1 +fi + +if [ "${ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN}" != "1" ] ; then + exit 2 +fi + +if [ "$ZEVENT_POOL_FAILMODE" != "wait" ] ; then + exit 3 +fi + +if [ ! -f "$ZEVENT_VDEV_ENC_SYSFS_PATH/power_status" ] ; then + exit 4 +fi + +# Turn off the slot and wait for sysfs to report that the slot is off. +# It can take ~400ms on some enclosures and multiple retries may be needed. +for i in $(seq 1 20) ; do + echo "off" | tee "$ZEVENT_VDEV_ENC_SYSFS_PATH/power_status" + + for j in $(seq 1 5) ; do + if [ "$(cat $ZEVENT_VDEV_ENC_SYSFS_PATH/power_status)" == "off" ] ; then + break 2 + fi + sleep 0.1 + done +done + +if [ "$(cat $ZEVENT_VDEV_ENC_SYSFS_PATH/power_status)" != "off" ] ; then + exit 5 +fi + +zed_log_msg "powered down slot $ZEVENT_VDEV_ENC_SYSFS_PATH for $ZEVENT_VDEV_PATH" diff --git a/cmd/zed/zed.d/zed.rc b/cmd/zed/zed.d/zed.rc index bc269b155d76..859c6f9cb662 100644 --- a/cmd/zed/zed.d/zed.rc +++ b/cmd/zed/zed.d/zed.rc @@ -148,6 +148,13 @@ ZED_SYSLOG_SUBCLASS_EXCLUDE="history_event" # supports slot power control via sysfs. #ZED_POWER_OFF_ENCLOSURE_SLOT_ON_FAULT=1 +## +# Power off the drive's slot in the enclosure if there is a hung I/O which +# exceeds the deadman timeout. This can help prevent a single misbehaving +# drive from rendering a redundant pool unavailable. This assumes your drive +# enclosure fully supports slot power control via sysfs. +#ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN=1 + ## # Ntfy topic # This defines which topic will receive the ntfy notification. diff --git a/man/man4/zfs.4 b/man/man4/zfs.4 index c17bfb80bf09..902d73c16eb7 100644 --- a/man/man4/zfs.4 +++ b/man/man4/zfs.4 @@ -889,6 +889,13 @@ Historically used for controlling what reporting was available under .Pa /proc/spl/kstat/zfs . No effect. . +.It Sy zfs_deadman_checktime_ms Ns = Ns Sy 60000 Ns ms Po 1 min Pc Pq u64 +Check time in milliseconds. +This defines the frequency at which we check for hung I/O requests +and potentially invoke the +.Sy zfs_deadman_failmode +behavior. +. .It Sy zfs_deadman_enabled Ns = Ns Sy 1 Ns | Ns 0 Pq int When a pool sync operation takes longer than .Sy zfs_deadman_synctime_ms , @@ -904,6 +911,10 @@ By default, the deadman is enabled and set to which results in "hung" I/O operations only being logged. The deadman is automatically disabled when a pool gets suspended. . +.It Sy zfs_deadman_events_per_second Ns = Ns Sy 1 Ns /s Pq int +Rate limit deadman zevents (which report hung I/O operations) to this many per +second. +. .It Sy zfs_deadman_failmode Ns = Ns Sy wait Pq charp Controls the failure behavior when the deadman detects a "hung" I/O operation. Valid values are: @@ -921,13 +932,6 @@ This can be used to facilitate automatic fail-over to a properly configured fail-over partner. .El . -.It Sy zfs_deadman_checktime_ms Ns = Ns Sy 60000 Ns ms Po 1 min Pc Pq u64 -Check time in milliseconds. -This defines the frequency at which we check for hung I/O requests -and potentially invoke the -.Sy zfs_deadman_failmode -behavior. -. .It Sy zfs_deadman_synctime_ms Ns = Ns Sy 600000 Ns ms Po 10 min Pc Pq u64 Interval in milliseconds after which the deadman is triggered and also the interval after which a pool sync operation is considered to be "hung". @@ -985,8 +989,7 @@ will result in objects waiting when there is not actually contention on the same object. . .It Sy zfs_slow_io_events_per_second Ns = Ns Sy 20 Ns /s Pq int -Rate limit delay and deadman zevents (which report slow I/O operations) to this -many per +Rate limit delay zevents (which report slow I/O operations) to this many per second. . .It Sy zfs_unflushed_max_mem_amt Ns = Ns Sy 1073741824 Ns B Po 1 GiB Pc Pq u64 diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 224493a86e76..f8055e69c916 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -111,6 +111,11 @@ int zfs_vdev_dtl_sm_blksz = (1 << 12); */ static unsigned int zfs_slow_io_events_per_second = 20; +/* + * Rate limit deadman "hung IO" events to this many per second. + */ +static unsigned int zfs_deadman_events_per_second = 1; + /* * Rate limit checksum events after this many checksum errors per second. */ @@ -665,7 +670,7 @@ vdev_alloc_common(spa_t *spa, uint_t id, uint64_t guid, vdev_ops_t *ops) */ zfs_ratelimit_init(&vd->vdev_delay_rl, &zfs_slow_io_events_per_second, 1); - zfs_ratelimit_init(&vd->vdev_deadman_rl, &zfs_slow_io_events_per_second, + zfs_ratelimit_init(&vd->vdev_deadman_rl, &zfs_deadman_events_per_second, 1); zfs_ratelimit_init(&vd->vdev_checksum_rl, &zfs_checksum_events_per_second, 1); @@ -6433,6 +6438,9 @@ ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, ms_count_limit, UINT, ZMOD_RW, ZFS_MODULE_PARAM(zfs, zfs_, slow_io_events_per_second, UINT, ZMOD_RW, "Rate limit slow IO (delay) events to this many per second"); +ZFS_MODULE_PARAM(zfs, zfs_, deadman_events_per_second, UINT, ZMOD_RW, + "Rate limit hung IO (deadman) events to this many per second"); + /* BEGIN CSTYLED */ ZFS_MODULE_PARAM(zfs, zfs_, checksum_events_per_second, UINT, ZMOD_RW, "Rate limit checksum events to this many checksum errors per second " diff --git a/tests/zfs-tests/include/tunables.cfg b/tests/zfs-tests/include/tunables.cfg index 718c4cf2d8ab..da271686afef 100644 --- a/tests/zfs-tests/include/tunables.cfg +++ b/tests/zfs-tests/include/tunables.cfg @@ -29,6 +29,7 @@ CONDENSE_INDIRECT_OBSOLETE_PCT condense.indirect_obsolete_pct zfs_condense_indir CONDENSE_MIN_MAPPING_BYTES condense.min_mapping_bytes zfs_condense_min_mapping_bytes DBUF_CACHE_SHIFT dbuf.cache_shift dbuf_cache_shift DEADMAN_CHECKTIME_MS deadman.checktime_ms zfs_deadman_checktime_ms +DEADMAN_EVENTS_PER_SECOND deadman_events_per_second zfs_deadman_events_per_second DEADMAN_FAILMODE deadman.failmode zfs_deadman_failmode DEADMAN_SYNCTIME_MS deadman.synctime_ms zfs_deadman_synctime_ms DEADMAN_ZIOTIME_MS deadman.ziotime_ms zfs_deadman_ziotime_ms diff --git a/tests/zfs-tests/tests/functional/deadman/deadman_ratelimit.ksh b/tests/zfs-tests/tests/functional/deadman/deadman_ratelimit.ksh index 4dd4c5b9a76c..d851d03e1a87 100755 --- a/tests/zfs-tests/tests/functional/deadman/deadman_ratelimit.ksh +++ b/tests/zfs-tests/tests/functional/deadman/deadman_ratelimit.ksh @@ -28,7 +28,7 @@ # Verify spa deadman events are rate limited # # STRATEGY: -# 1. Reduce the zfs_slow_io_events_per_second to 1. +# 1. Reduce the zfs_deadman_events_per_second to 1. # 2. Reduce the zfs_deadman_ziotime_ms to 1ms. # 3. Write data to a pool and read it back. # 4. Verify deadman events have been produced at a reasonable rate. @@ -44,15 +44,15 @@ function cleanup zinject -c all default_cleanup_noexit - set_tunable64 SLOW_IO_EVENTS_PER_SECOND $OLD_SLOW_IO_EVENTS + set_tunable64 DEADMAN_EVENTS_PER_SECOND $OLD_DEADMAN_EVENTS set_tunable64 DEADMAN_ZIOTIME_MS $ZIOTIME_DEFAULT } log_assert "Verify spa deadman events are rate limited" log_onexit cleanup -OLD_SLOW_IO_EVENTS=$(get_tunable SLOW_IO_EVENTS_PER_SECOND) -log_must set_tunable64 SLOW_IO_EVENTS_PER_SECOND 1 +OLD_DEADMAN_EVENTS=$(get_tunable DEADMAN_EVENTS_PER_SECOND) +log_must set_tunable64 DEADMAN_EVENTS_PER_SECOND 1 log_must set_tunable64 DEADMAN_ZIOTIME_MS 1 # Create a new pool in order to use the updated deadman settings. From 55468ccc3e2140f8380e1e05e0e9772818b87ff2 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Wed, 7 Aug 2024 18:52:37 +0200 Subject: [PATCH 007/223] ZTS: small fix for SEEK_DATA/SEEK_HOLE tests (#16413) Some libc's like uClibc lag the proper definition of SEEK_DATA and SEEK_HOLE. Since we have only two files in ZTS which use these definitons, let's define them by hand: ``` #ifndef SEEK_DATA #define SEEK_DATA 3 #endif #ifndef SEEK_HOLE #define SEEK_HOLE 4 #endif ``` There should be no failures, because: - FreeBSD has support for SEEK_DATA/SEEK_HOLE since FreeBSD 8 - Linux has it since Linux 3.1 - the libc will submit the parameters unchanged to the kernel Signed-off-by: Tino Reichardt Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf --- tests/zfs-tests/cmd/mmap_seek.c | 10 ++++++++++ tests/zfs-tests/tests/functional/cp_files/seekflood.c | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/tests/zfs-tests/cmd/mmap_seek.c b/tests/zfs-tests/cmd/mmap_seek.c index 7be92d109565..2d250554a13f 100644 --- a/tests/zfs-tests/cmd/mmap_seek.c +++ b/tests/zfs-tests/cmd/mmap_seek.c @@ -35,6 +35,16 @@ #include #endif +/* some older uClibc's lack the defines, so we'll manually define them */ +#ifdef __UCLIBC__ +#ifndef SEEK_DATA +#define SEEK_DATA 3 +#endif +#ifndef SEEK_HOLE +#define SEEK_HOLE 4 +#endif +#endif + static void seek_data(int fd, off_t offset, off_t expected) { diff --git a/tests/zfs-tests/tests/functional/cp_files/seekflood.c b/tests/zfs-tests/tests/functional/cp_files/seekflood.c index 02c2c8e6eca5..f832db85970d 100644 --- a/tests/zfs-tests/tests/functional/cp_files/seekflood.c +++ b/tests/zfs-tests/tests/functional/cp_files/seekflood.c @@ -36,6 +36,13 @@ #include #include +/* some older uClibc's lack the defines, so we'll manually define them */ +#ifdef __UCLIBC__ +#ifndef SEEK_DATA +#define SEEK_DATA 3 +#endif +#endif + #define DATASIZE (4096) char data[DATASIZE]; From b4502ac3428193804f4771db9f2460708ccbeb95 Mon Sep 17 00:00:00 2001 From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Fri, 31 May 2024 16:02:06 +0200 Subject: [PATCH 008/223] tests: user_property: Clarify comments Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Tino Reichardt Reviewed-by: Allan Jude Signed-off-by: Mateusz Piotrowski <0mp@FreeBSD.org> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #16248 --- .../zpool_set/user_property_002_neg.ksh | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_set/user_property_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_set/user_property_002_neg.ksh index 7c8fcba6e471..e9c7e01708b0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_set/user_property_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_set/user_property_002_neg.ksh @@ -51,13 +51,23 @@ log_onexit cleanup_user_prop $TESTPOOL typeset -a names=() typeset -a values=() -# Too long property name (256 bytes, which is the 256-byte limit minus 1 byte -# for the null byte plus 1 byte to reach back over the limit) -names+=("$(awk 'BEGIN { printf "x:"; while (c++ < (256 - 2 - 1 + 1)) printf "a" }')") +# A property name that is too long consists of 256 or more bytes (which is (1) +# the 256-byte limit (2) minus 1 byte for the null byte (3) plus 1 byte to +# reach back over the limit). +names+=("$(awk ' + BEGIN { + # Print a 2-byte prefix of the name. + printf "x:"; + # Print the remaining 254 bytes. + while (c++ < (256 - 2 - 1 + 1)) + printf "a" + }' +)") values+=("too-long-property-name") -# Too long property value (the limits are 1024 on FreeBSD and 4096 on Linux, so -# pick the right one; the too long value is, e.g., the limit minus 1 bytes for the -# null byte plus 1 byte to reach back over the limit) +# A property value that is too long consists of at least 1024 bytes on FreeBSD +# and 4096 bytes on Linux. +# The smallest too-long value is (1) the limit (2) minus 1 byte for the null +# byte (2) plus 1 byte to reach back over the limit). if is_linux; then typeset ZFS_MAXPROPLEN=4096 else From 00dd5ea9e6b7ba614fb44447a80ff5bdf76b1473 Mon Sep 17 00:00:00 2001 From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Mon, 3 Jun 2024 12:17:22 +0200 Subject: [PATCH 009/223] tests: user_property_001_pos: Remove unnecessary evals Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Tino Reichardt Reviewed-by: Allan Jude Signed-off-by: Mateusz Piotrowski <0mp@FreeBSD.org> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #16248 --- .../functional/cli_root/zpool_set/user_property_001_pos.ksh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_set/user_property_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_set/user_property_001_pos.ksh index 4b9097933f37..ce8c78fa57d2 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_set/user_property_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_set/user_property_001_pos.ksh @@ -80,8 +80,8 @@ while ((i < ${#names[@]})); do typeset name="${names[$i]}" typeset value="${values[$i]}" - log_must eval "zpool set $name='$value' $TESTPOOL" - log_must eval "check_user_prop $TESTPOOL $name '$value'" + log_must zpool set "$name=$value" "$TESTPOOL" + log_must check_user_prop "$TESTPOOL" "$name" "$value" ((i += 1)) done From 66bb2a83899e58825ddaa48f63cf09c8cd00ab99 Mon Sep 17 00:00:00 2001 From: Ameer Hamza Date: Sat, 10 Aug 2024 04:49:19 +0500 Subject: [PATCH 010/223] Github workflow: fix typo in `zloop` artifact Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: Ameer Hamza Closes #16432 --- .github/workflows/zfs-linux-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/zfs-linux-tests.yml b/.github/workflows/zfs-linux-tests.yml index 753f3cd0214e..74f94ab8f2a4 100644 --- a/.github/workflows/zfs-linux-tests.yml +++ b/.github/workflows/zfs-linux-tests.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/upload-artifact@v4 if: failure() with: - name: Zpool-logs-${{ inputs.os }} + name: Zloop-logs-${{ inputs.os }} path: | /var/tmp/zloop/*/ !/var/tmp/zloop/*/vdev/ @@ -46,7 +46,7 @@ jobs: - uses: actions/upload-artifact@v4 if: failure() with: - name: Zpool-files-${{ inputs.os }} + name: Zloop-files-${{ inputs.os }} path: | /var/tmp/zloop/*/vdev/ retention-days: 14 From d6ec55963ae85ab509341a358d8b2962e974ab55 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 10 Sep 2024 10:49:14 +1000 Subject: [PATCH 011/223] zts-report: don't crash on non-UTF-8 chars in the log (#16497) The report generator expects the log to be clean and tidy UTF-8. That can be a problem if you use some of the verbose/debug test runner options, which sends all sorts of weird output from arbitrary programs to the log. This just makes Python a little more relaxed about such things. It shouldn't matter in practice, as those lines didn't match the test result regex anyway, and are discarded immediately. Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Rob Norris Reviewed-by: Alexander Motin Reviewed-by: Tony Hutter --- tests/test-runner/bin/zts-report.py.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index 5fcaa01d1f35..4d39c5a6958e 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -388,7 +388,7 @@ if os.environ.get('CI') == 'true': def process_results(pathname): try: - f = open(pathname) + f = open(pathname, errors='replace') except IOError as e: print('Error opening file:', e) sys.exit(1) From e29e7a0502c93232e81fc0dc9a1e1b12f7a5600c Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Tue, 6 Aug 2024 16:48:45 +0200 Subject: [PATCH 012/223] ZTS: fix zpool_status_008_pos test on qemu vm's The test needs some adjusting within the timings. Reviewed by: Brian Behlendorf Signed-off-by: Tony Hutter Co-authored-by: Tino Reichardt Closes #16537 --- .../cli_root/zpool_status/zpool_status_008_pos.ksh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh index 6be2ad5a7410..4fb900c73cf6 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh @@ -69,12 +69,12 @@ for raid_type in "draid2:3d:6c:1s" "raidz2"; do log_mustnot eval "zpool status -e $TESTPOOL2 | grep ONLINE" # Check no ONLINE slow vdevs are show. Then mark IOs greater than - # 10ms slow, delay IOs 20ms to vdev6, check slow IOs. + # 160ms slow, delay IOs 320ms to vdev6, check slow IOs. log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev6 "ONLINE" log_mustnot eval "zpool status -es $TESTPOOL2 | grep ONLINE" - log_must set_tunable64 ZIO_SLOW_IO_MS 10 - log_must zinject -d $TESTDIR/vdev6 -D20:100 $TESTPOOL2 + log_must set_tunable64 ZIO_SLOW_IO_MS 160 + log_must zinject -d $TESTDIR/vdev6 -D320:100 $TESTPOOL2 log_must mkfile 1048576 /$TESTPOOL2/testfile sync_pool $TESTPOOL2 log_must set_tunable64 ZIO_SLOW_IO_MS $OLD_SLOW_IO From 36bac59fbcede9daba2dc40f7d57d37cf7f389c0 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Sun, 15 Sep 2024 09:42:55 +0200 Subject: [PATCH 013/223] ZTS: increase timeout of mmap_sync_001_pos On load the test needs sometimes a bit more time then just one second. Doubling the time will help on the QEMU based testings. Reviewed by: Brian Behlendorf Reviewed-by: Tony Hutter Signed-off-by: Tino Reichardt Closes #16537 --- tests/zfs-tests/cmd/mmap_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/zfs-tests/cmd/mmap_sync.c b/tests/zfs-tests/cmd/mmap_sync.c index 226e71be2f57..f9008eeaf31a 100644 --- a/tests/zfs-tests/cmd/mmap_sync.c +++ b/tests/zfs-tests/cmd/mmap_sync.c @@ -64,7 +64,7 @@ main(int argc, char *argv[]) run_time_mins = atoi(argv[1]); } - int max_msync_time_ms = 1000; + int max_msync_time_ms = 2000; if (argc >= 3) { max_msync_time_ms = atoi(argv[2]); } From 66db2237781e881f32508b10be718a4ce0bb286f Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Mon, 17 Jun 2024 16:52:58 +0200 Subject: [PATCH 014/223] ZTS: Use QEMU for tests on Linux and FreeBSD This commit adds functional tests for these systems: - AlmaLinux 8, AlmaLinux 9, ArchLinux - CentOS Stream 9, Fedora 39, Fedora 40 - Debian 11, Debian 12 - FreeBSD 13, FreeBSD 14, FreeBSD 15 - Ubuntu 20.04, Ubuntu 22.04, Ubuntu 24.04 - enabled by default: - AlmaLinux 8, AlmaLinux 9 - Debian 11, Debian 12 - Fedora 39, Fedora 40 - FreeBSD 13, FreeBSD 14 Workflow for each operating system: - install qemu on the github runner - download current cloud image of operating system - start and init that image via cloud-init - install dependencies and poweroff system - start system and build openzfs and then poweroff again - clone build system and start 2 instances of it - run functional testings and complete in around 3h - when tests are done, do some logfile preparing - show detailed results for each system - in the end, generate the job summary Real-world benefits from this PR: 1. The github runner scripts are in the zfs repo itself. That means you can just open a PR against zfs, like "Add Fedora 41 tester", and see the results directly in the PR. ZFS admins no longer need manually to login to the buildbot server to update the buildbot config with new version of Fedora/Almalinux. 2. Github runners allow you to run the entire test suite against your private branch before submitting a formal PR to openzfs. Just open a PR against your private zfs repo, and the exact same Fedora/Alma/FreeBSD runners will fire up and run ZTS. This can be useful if you want to iterate on a ZTS change before submitting a formal PR. 3. buildbot is incredibly cumbersome. Our buildbot config files alone are ~1500 lines (not including any build/setup scripts)! It's a huge pain to setup. 4. We're running the super ancient buildbot 0.8.12. It's so ancient it requires python2. We actually have to build python2 from source for almalinux9 just to get it to run. Ugrading to a more modern buildbot is a huge undertaking, and the UI on the newer versions is worse. 5. Buildbot uses EC2 instances. EC2 is a pain because: * It costs money * They throttle IOPS and CPU usage, leading to mysterious, * hard-to-diagnose, failures and timeouts in ZTS. * EC2 is high maintenance. We have to setup security groups, SSH * keys, networking, users, etc, in AWS and it's a pain. We also * have to periodically go in an kill zombie EC2 instances that * buildbot is unable to kill off. 6. Buildbot doesn't always handle failures well. One of the things we saw in the past was the FreeBSD builders would often die, and each builder death would take up a "slot" in buildbot. So we would periodically have to restart buildbot via a cron job to get the slots back. 7. This PR divides up the ZTS test list into two parts, launches two VMs, and on each VM runs half the test suite. The test results are then merged and shown in the sumary page. So we're basically parallelizing ZTS on the same github runner. This leads to lower overall ZTS runtimes (2.5-3 hours vs 4+ hours on buildbot), and one unified set of results per runner, which is nice. 8. Since the tests are running on a VM, we have much more control over what happens. We can capture the serial console output even if the test completely brings down the VM. In the future, we could also restart the test on the VM where it left off, so that if a single test panics the VM, we can just restart it and run the remaining ZTS tests (this functionaly is not yet implemented though, just an idea). 9. Using the runners, users can manually kill or restart a test run via the github IU. That really isn't possible with buildbot unless you're an admin. 10. Anecdotally, the tests seem to be more stable and constant under the QEMU runners. Reviewed by: Brian Behlendorf Signed-off-by: Tino Reichardt Signed-off-by: Tony Hutter Closes #16537 --- .github/workflows/scripts/README.md | 14 ++ .github/workflows/scripts/merge_summary.awk | 109 +++++++++ .github/workflows/scripts/qemu-1-setup.sh | 91 ++++++++ .github/workflows/scripts/qemu-2-start.sh | 213 +++++++++++++++++ .github/workflows/scripts/qemu-3-deps.sh | 218 ++++++++++++++++++ .github/workflows/scripts/qemu-4-build.sh | 153 ++++++++++++ .github/workflows/scripts/qemu-5-setup.sh | 121 ++++++++++ .github/workflows/scripts/qemu-6-tests.sh | 102 ++++++++ .github/workflows/scripts/qemu-7-prepare.sh | 119 ++++++++++ .github/workflows/scripts/qemu-8-summary.sh | 73 ++++++ .../workflows/scripts/qemu-9-summary-page.sh | 54 +++++ .github/workflows/zfs-qemu.yml | 141 +++++++++++ scripts/zfs-tests.sh | 73 +++++- tests/test-runner/bin/test-runner.py.in | 12 + 14 files changed, 1490 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/scripts/README.md create mode 100755 .github/workflows/scripts/merge_summary.awk create mode 100755 .github/workflows/scripts/qemu-1-setup.sh create mode 100755 .github/workflows/scripts/qemu-2-start.sh create mode 100755 .github/workflows/scripts/qemu-3-deps.sh create mode 100755 .github/workflows/scripts/qemu-4-build.sh create mode 100755 .github/workflows/scripts/qemu-5-setup.sh create mode 100755 .github/workflows/scripts/qemu-6-tests.sh create mode 100755 .github/workflows/scripts/qemu-7-prepare.sh create mode 100755 .github/workflows/scripts/qemu-8-summary.sh create mode 100755 .github/workflows/scripts/qemu-9-summary-page.sh create mode 100644 .github/workflows/zfs-qemu.yml diff --git a/.github/workflows/scripts/README.md b/.github/workflows/scripts/README.md new file mode 100644 index 000000000000..811d23d93875 --- /dev/null +++ b/.github/workflows/scripts/README.md @@ -0,0 +1,14 @@ + +Workflow for each operating system: +- install qemu on the github runner +- download current cloud image of operating system +- start and init that image via cloud-init +- install dependencies and poweroff system +- start system and build openzfs and then poweroff again +- clone build system and start 2 instances of it +- run functional testings and complete in around 3h +- when tests are done, do some logfile preparing +- show detailed results for each system +- in the end, generate the job summary + +/TR 14.09.2024 diff --git a/.github/workflows/scripts/merge_summary.awk b/.github/workflows/scripts/merge_summary.awk new file mode 100755 index 000000000000..2b00d00226c9 --- /dev/null +++ b/.github/workflows/scripts/merge_summary.awk @@ -0,0 +1,109 @@ +#!/bin/awk -f +# +# Merge multiple ZTS tests results summaries into a single summary. This is +# needed when you're running different parts of ZTS on different tests +# runners or VMs. +# +# Usage: +# +# ./merge_summary.awk summary1.txt [summary2.txt] [summary3.txt] ... +# +# or: +# +# cat summary*.txt | ./merge_summary.awk +# +BEGIN { + i=-1 + pass=0 + fail=0 + skip=0 + state="" + cl=0 + el=0 + upl=0 + ul=0 + + # Total seconds of tests runtime + total=0; +} + +# Skip empty lines +/^\s*$/{next} + +# Skip Configuration and Test lines +/^Test:/{state=""; next} +/Configuration/{state="";next} + +# When we see "test-runner.py" stop saving config lines, and +# save test runner lines +/test-runner.py/{state="testrunner"; runner=runner$0"\n"; next} + +# We need to differentiate the PASS counts from test result lines that start +# with PASS, like: +# +# PASS mv_files/setup +# +# Use state="pass_count" to differentiate +# +/Results Summary/{state="pass_count"; next} +/PASS/{ if (state=="pass_count") {pass += $2}} +/FAIL/{ if (state=="pass_count") {fail += $2}} +/SKIP/{ if (state=="pass_count") {skip += $2}} +/Running Time/{ + state=""; + running[i]=$3; + split($3, arr, ":") + total += arr[1] * 60 * 60; + total += arr[2] * 60; + total += arr[3] + next; +} + +/Tests with results other than PASS that are expected/{state="expected_lines"; next} +/Tests with result of PASS that are unexpected/{state="unexpected_pass_lines"; next} +/Tests with results other than PASS that are unexpected/{state="unexpected_lines"; next} +{ + if (state == "expected_lines") { + expected_lines[el] = $0 + el++ + } + + if (state == "unexpected_pass_lines") { + unexpected_pass_lines[upl] = $0 + upl++ + } + if (state == "unexpected_lines") { + unexpected_lines[ul] = $0 + ul++ + } +} + +# Reproduce summary +END { + print runner; + print "\nResults Summary" + print "PASS\t"pass + print "FAIL\t"fail + print "SKIP\t"skip + print "" + print "Running Time:\t"strftime("%T", total, 1) + if (pass+fail+skip > 0) { + percent_passed=(pass/(pass+fail+skip) * 100) + } + printf "Percent passed:\t%3.2f%", percent_passed + + print "\n\nTests with results other than PASS that are expected:" + asort(expected_lines, sorted) + for (j in sorted) + print sorted[j] + + print "\n\nTests with result of PASS that are unexpected:" + asort(unexpected_pass_lines, sorted) + for (j in sorted) + print sorted[j] + + print "\n\nTests with results other than PASS that are unexpected:" + asort(unexpected_lines, sorted) + for (j in sorted) + print sorted[j] +} diff --git a/.github/workflows/scripts/qemu-1-setup.sh b/.github/workflows/scripts/qemu-1-setup.sh new file mode 100755 index 000000000000..ebd80a2f98c1 --- /dev/null +++ b/.github/workflows/scripts/qemu-1-setup.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +###################################################################### +# 1) setup qemu instance on action runner +###################################################################### + +set -eu + +# install needed packages +export DEBIAN_FRONTEND="noninteractive" +sudo apt-get -y update +sudo apt-get install -y axel cloud-image-utils daemonize guestfs-tools \ + ksmtuned virt-manager linux-modules-extra-$(uname -r) zfsutils-linux + +# generate ssh keys +rm -f ~/.ssh/id_ed25519 +ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -q -N "" + +# we expect RAM shortage +cat << EOF | sudo tee /etc/ksmtuned.conf > /dev/null +# https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/chap-ksm +KSM_MONITOR_INTERVAL=60 + +# Millisecond sleep between ksm scans for 16Gb server. +# Smaller servers sleep more, bigger sleep less. +KSM_SLEEP_MSEC=10 +KSM_NPAGES_BOOST=300 +KSM_NPAGES_DECAY=-50 +KSM_NPAGES_MIN=64 +KSM_NPAGES_MAX=2048 + +KSM_THRES_COEF=25 +KSM_THRES_CONST=2048 + +LOGFILE=/var/log/ksmtuned.log +DEBUG=1 +EOF +sudo systemctl restart ksm +sudo systemctl restart ksmtuned + +# not needed +sudo systemctl stop docker.socket +sudo systemctl stop multipathd.socket + +# remove default swapfile and /mnt +sudo swapoff -a +sudo umount -l /mnt +DISK="/dev/disk/cloud/azure_resource-part1" +sudo sed -e "s|^$DISK.*||g" -i /etc/fstab +sudo wipefs -aq $DISK +sudo systemctl daemon-reload + +sudo modprobe loop +sudo modprobe zfs + +# partition the disk as needed +DISK="/dev/disk/cloud/azure_resource" +sudo sgdisk --zap-all $DISK +sudo sgdisk -p \ + -n 1:0:+16G -c 1:"swap" \ + -n 2:0:0 -c 2:"tests" \ +$DISK +sync +sleep 1 + +# swap with same size as RAM +sudo mkswap $DISK-part1 +sudo swapon $DISK-part1 + +# 60GB data disk +SSD1="$DISK-part2" + +# 10GB data disk on ext4 +sudo fallocate -l 10G /test.ssd1 +SSD2=$(sudo losetup -b 4096 -f /test.ssd1 --show) + +# adjust zfs module parameter and create pool +exec 1>/dev/null +ARC_MIN=$((1024*1024*256)) +ARC_MAX=$((1024*1024*512)) +echo $ARC_MIN | sudo tee /sys/module/zfs/parameters/zfs_arc_min +echo $ARC_MAX | sudo tee /sys/module/zfs/parameters/zfs_arc_max +echo 1 | sudo tee /sys/module/zfs/parameters/zvol_use_blk_mq +sudo zpool create -f -o ashift=12 zpool $SSD1 $SSD2 \ + -O relatime=off -O atime=off -O xattr=sa -O compression=lz4 \ + -O mountpoint=/mnt/tests + +# no need for some scheduler +for i in /sys/block/s*/queue/scheduler; do + echo "none" | sudo tee $i > /dev/null +done diff --git a/.github/workflows/scripts/qemu-2-start.sh b/.github/workflows/scripts/qemu-2-start.sh new file mode 100755 index 000000000000..923c38c0f937 --- /dev/null +++ b/.github/workflows/scripts/qemu-2-start.sh @@ -0,0 +1,213 @@ +#!/usr/bin/env bash + +###################################################################### +# 2) start qemu with some operating system, init via cloud-init +###################################################################### + +set -eu + +# short name used in zfs-qemu.yml +OS="$1" + +# OS variant (virt-install --os-variant list) +OSv=$OS + +# compressed with .zst extension +REPO="https://github.com/mcmilk/openzfs-freebsd-images" +FREEBSD="$REPO/releases/download/v2024-09-16" +URLzs="" + +# Ubuntu mirrors +#UBMIRROR="https://cloud-images.ubuntu.com" +#UBMIRROR="https://mirrors.cloud.tencent.com/ubuntu-cloud-images" +UBMIRROR="https://mirror.citrahost.com/ubuntu-cloud-images" + +# default nic model for vm's +NIC="virtio" + +case "$OS" in + almalinux8) + OSNAME="AlmaLinux 8" + URL="https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2" + ;; + almalinux9) + OSNAME="AlmaLinux 9" + URL="https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2" + ;; + archlinux) + OSNAME="Archlinux" + URL="https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2" + # dns sometimes fails with that url :/ + echo "89.187.191.12 geo.mirror.pkgbuild.com" | sudo tee /etc/hosts > /dev/null + ;; + centos-stream9) + OSNAME="CentOS Stream 9" + URL="https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2" + ;; + debian11) + OSNAME="Debian 11" + URL="https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2" + ;; + debian12) + OSNAME="Debian 12" + URL="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2" + ;; + fedora39) + OSNAME="Fedora 39" + OSv="fedora39" + URL="https://download.fedoraproject.org/pub/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-39-1.5.x86_64.qcow2" + ;; + fedora40) + OSNAME="Fedora 40" + OSv="fedora39" + URL="https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2" + ;; + freebsd13r) + OSNAME="FreeBSD 13.4-RELEASE" + OSv="freebsd13.0" + URLzs="$FREEBSD/amd64-freebsd-13.4-RELEASE.qcow2.zst" + BASH="/usr/local/bin/bash" + NIC="rtl8139" + ;; + freebsd13) + OSNAME="FreeBSD 13.4-STABLE" + OSv="freebsd13.0" + URLzs="$FREEBSD/amd64-freebsd-13.4-STABLE.qcow2.zst" + BASH="/usr/local/bin/bash" + NIC="rtl8139" + ;; + freebsd14r) + OSNAME="FreeBSD 14.1-RELEASE" + OSv="freebsd14.0" + URLzs="$FREEBSD/amd64-freebsd-14.1-RELEASE.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + freebsd14) + OSNAME="FreeBSD 14.1-STABLE" + OSv="freebsd14.0" + URLzs="$FREEBSD/amd64-freebsd-14.1-STABLE.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + freebsd15) + OSNAME="FreeBSD 15.0-CURRENT" + OSv="freebsd14.0" + URLzs="$FREEBSD/amd64-freebsd-15.0-CURRENT.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + tumbleweed) + OSNAME="openSUSE Tumbleweed" + OSv="opensusetumbleweed" + MIRROR="http://opensuse-mirror-gce-us.susecloud.net" + URL="$MIRROR/tumbleweed/appliances/openSUSE-MicroOS.x86_64-OpenStack-Cloud.qcow2" + ;; + ubuntu20) + OSNAME="Ubuntu 20.04" + OSv="ubuntu20.04" + URL="$UBMIRROR/focal/current/focal-server-cloudimg-amd64.img" + ;; + ubuntu22) + OSNAME="Ubuntu 22.04" + OSv="ubuntu22.04" + URL="$UBMIRROR/jammy/current/jammy-server-cloudimg-amd64.img" + ;; + ubuntu24) + OSNAME="Ubuntu 24.04" + OSv="ubuntu24.04" + URL="$UBMIRROR/noble/current/noble-server-cloudimg-amd64.img" + ;; + *) + echo "Wrong value for OS variable!" + exit 111 + ;; +esac + +# environment file +ENV="/var/tmp/env.txt" +echo "ENV=$ENV" >> $ENV + +# result path +echo 'RESPATH="/var/tmp/test_results"' >> $ENV + +# FreeBSD 13 has problems with: e1000+virtio +echo "NIC=$NIC" >> $ENV + +# freebsd15 -> used in zfs-qemu.yml +echo "OS=$OS" >> $ENV + +# freebsd14.0 -> used for virt-install +echo "OSv=\"$OSv\"" >> $ENV + +# FreeBSD 15 (Current) -> used for summary +echo "OSNAME=\"$OSNAME\"" >> $ENV + +sudo mkdir -p "/mnt/tests" +sudo chown -R $(whoami) /mnt/tests + +# we are downloading via axel, curl and wget are mostly slower and +# require more return value checking +IMG="/mnt/tests/cloudimg.qcow2" +if [ ! -z "$URLzs" ]; then + echo "Loading image $URLzs ..." + time axel -q -o "$IMG.zst" "$URLzs" + zstd -q -d --rm "$IMG.zst" +else + echo "Loading image $URL ..." + time axel -q -o "$IMG" "$URL" +fi + +DISK="/dev/zvol/zpool/openzfs" +FORMAT="raw" +sudo zfs create -ps -b 64k -V 80g zpool/openzfs +while true; do test -b $DISK && break; sleep 1; done +echo "Importing VM image to zvol..." +sudo qemu-img dd -f qcow2 -O raw if=$IMG of=$DISK bs=4M +rm -f $IMG + +PUBKEY=$(cat ~/.ssh/id_ed25519.pub) +cat < /tmp/user-data +#cloud-config + +fqdn: $OS + +users: +- name: root + shell: $BASH +- name: zfs + sudo: ALL=(ALL) NOPASSWD:ALL + shell: $BASH + ssh_authorized_keys: + - $PUBKEY + +growpart: + mode: auto + devices: ['/'] + ignore_growroot_disabled: false +EOF + +sudo virsh net-update default add ip-dhcp-host \ + "" --live --config + +sudo virt-install \ + --os-variant $OSv \ + --name "openzfs" \ + --cpu host-passthrough \ + --virt-type=kvm --hvm \ + --vcpus=4,sockets=1 \ + --memory $((1024*12)) \ + --memballoon model=virtio \ + --graphics none \ + --network bridge=virbr0,model=$NIC,mac='52:54:00:83:79:00' \ + --cloud-init user-data=/tmp/user-data \ + --disk $DISK,bus=virtio,cache=none,format=$FORMAT,driver.discard=unmap \ + --import --noautoconsole >/dev/null + +# in case the directory isn't there already +mkdir -p $HOME/.ssh + +cat <> $HOME/.ssh/config +# no questions please +StrictHostKeyChecking no + +# small timeout, used in while loops later +ConnectTimeout 1 +EOF diff --git a/.github/workflows/scripts/qemu-3-deps.sh b/.github/workflows/scripts/qemu-3-deps.sh new file mode 100755 index 000000000000..c07e9445259b --- /dev/null +++ b/.github/workflows/scripts/qemu-3-deps.sh @@ -0,0 +1,218 @@ +#!/usr/bin/env bash + +###################################################################### +# 3) install dependencies for compiling and loading +###################################################################### + +set -eu + +function archlinux() { + echo "##[group]Running pacman -Syu" + sudo btrfs filesystem resize max / + sudo pacman -Syu --noconfirm + echo "##[endgroup]" + + echo "##[group]Install Development Tools" + sudo pacman -Sy --noconfirm base-devel bc cpio dhclient dkms fakeroot \ + fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils parted \ + pax perf python-packaging python-setuptools qemu-guest-agent ksh samba \ + sysstat rng-tools rsync wget + echo "##[endgroup]" +} + +function debian() { + export DEBIAN_FRONTEND="noninteractive" + + echo "##[group]Running apt-get update+upgrade" + sudo apt-get update -y + sudo apt-get upgrade -y + echo "##[endgroup]" + + echo "##[group]Install Development Tools" + sudo apt-get install -y \ + acl alien attr autoconf bc cpio curl dbench dh-python dkms fakeroot \ + fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev libaio-dev \ + libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev \ + libelf-dev libffi-dev libmount-dev libpam0g-dev libselinux-dev \ + libssl-dev libtool libtool-bin libudev-dev linux-headers-$(uname -r) \ + lsscsi nfs-kernel-server pamtester parted python3 python3-all-dev \ + python3-cffi python3-dev python3-distlib python3-packaging \ + python3-setuptools python3-sphinx qemu-guest-agent rng-tools rpm2cpio \ + rsync samba sysstat uuid-dev watchdog wget xfslibs-dev zlib1g-dev + echo "##[endgroup]" +} + +function freebsd() { + export ASSUME_ALWAYS_YES="YES" + + echo "##[group]Install Development Tools" + sudo pkg install -y autoconf automake autotools base64 checkbashisms fio \ + gdb gettext gettext-runtime git gmake gsed jq ksh93 lcov libtool lscpu \ + pkgconf python python3 pamtester pamtester qemu-guest-agent rsync \ + sysutils/coreutils + sudo pkg install -xy \ + '^samba4[[:digit:]]+$' \ + '^py3[[:digit:]]+-cffi$' \ + '^py3[[:digit:]]+-sysctl$' \ + '^py3[[:digit:]]+-packaging$' + echo "##[endgroup]" +} + +# common packages for: almalinux, centos, redhat +function rhel() { + echo "##[group]Running dnf update" + echo "max_parallel_downloads=10" | sudo -E tee -a /etc/dnf/dnf.conf + sudo dnf clean all + sudo dnf update -y --setopt=fastestmirror=1 --refresh + echo "##[endgroup]" + + echo "##[group]Install Development Tools" + sudo dnf group install -y "Development Tools" + sudo dnf install -y \ + acl attr bc bzip2 curl dbench dkms elfutils-libelf-devel fio gdb git \ + jq kernel-rpm-macros ksh libacl-devel libaio-devel libargon2-devel \ + libattr-devel libblkid-devel libcurl-devel libffi-devel ncompress \ + libselinux-devel libtirpc-devel libtool libudev-devel libuuid-devel \ + lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester parted perf \ + python3 python3-cffi python3-devel python3-packaging kernel-devel \ + python3-setuptools qemu-guest-agent rng-tools rpcgen rpm-build rsync \ + samba sysstat systemd watchdog wget xfsprogs-devel zlib-devel + echo "##[endgroup]" +} + +function tumbleweed() { + echo "##[group]Running zypper is TODO!" + sleep 23456 + echo "##[endgroup]" +} + +# Install dependencies +case "$1" in + almalinux8) + echo "##[group]Enable epel and powertools repositories" + sudo dnf config-manager -y --set-enabled powertools + sudo dnf install -y epel-release + echo "##[endgroup]" + rhel + echo "##[group]Install kernel-abi-whitelists" + sudo dnf install -y kernel-abi-whitelists + echo "##[endgroup]" + ;; + almalinux9|centos-stream9) + echo "##[group]Enable epel and crb repositories" + sudo dnf config-manager -y --set-enabled crb + sudo dnf install -y epel-release + echo "##[endgroup]" + rhel + echo "##[group]Install kernel-abi-stablelists" + sudo dnf install -y kernel-abi-stablelists + echo "##[endgroup]" + ;; + archlinux) + archlinux + ;; + debian*) + debian + echo "##[group]Install Debian specific" + sudo apt-get install -yq linux-perf dh-sequence-dkms + echo "##[endgroup]" + ;; + fedora*) + rhel + ;; + freebsd*) + freebsd + ;; + tumbleweed) + tumbleweed + ;; + ubuntu*) + debian + echo "##[group]Install Ubuntu specific" + sudo apt-get install -yq linux-tools-common libtirpc-dev \ + linux-modules-extra-$(uname -r) + if [ "$1" != "ubuntu20" ]; then + sudo apt-get install -yq dh-sequence-dkms + fi + echo "##[endgroup]" + echo "##[group]Delete Ubuntu OpenZFS modules" + for i in $(find /lib/modules -name zfs -type d); do sudo rm -rvf $i; done + echo "##[endgroup]" + ;; +esac + +# Start services +echo "##[group]Enable services" +case "$1" in + freebsd*) + # add virtio things + echo 'virtio_load="YES"' | sudo -E tee -a /boot/loader.conf + for i in balloon blk console random scsi; do + echo "virtio_${i}_load=\"YES\"" | sudo -E tee -a /boot/loader.conf + done + echo "fdescfs /dev/fd fdescfs rw 0 0" | sudo -E tee -a /etc/fstab + sudo -E mount /dev/fd + sudo -E touch /etc/zfs/exports + sudo -E sysrc mountd_flags="/etc/zfs/exports" + echo '[global]' | sudo -E tee /usr/local/etc/smb4.conf >/dev/null + sudo -E service nfsd enable + sudo -E service qemu-guest-agent enable + sudo -E service samba_server enable + ;; + debian*|ubuntu*) + sudo -E systemctl enable nfs-kernel-server + sudo -E systemctl enable qemu-guest-agent + sudo -E systemctl enable smbd + ;; + *) + # All other linux distros + sudo -E systemctl enable nfs-server + sudo -E systemctl enable qemu-guest-agent + sudo -E systemctl enable smb + ;; +esac +echo "##[endgroup]" + +# Setup Kernel cmdline +CMDLINE="console=tty0 console=ttyS0,115200n8" +CMDLINE="$CMDLINE selinux=0" +CMDLINE="$CMDLINE random.trust_cpu=on" +CMDLINE="$CMDLINE no_timer_check" +case "$1" in + almalinux*|centos*|fedora*) + GRUB_CFG="/boot/grub2/grub.cfg" + GRUB_MKCONFIG="grub2-mkconfig" + CMDLINE="$CMDLINE biosdevname=0 net.ifnames=0" + echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' \ + | sudo tee -a /etc/default/grub >/dev/null + ;; + ubuntu24) + GRUB_CFG="/boot/grub/grub.cfg" + GRUB_MKCONFIG="grub-mkconfig" + echo 'GRUB_DISABLE_OS_PROBER="false"' \ + | sudo tee -a /etc/default/grub >/dev/null + ;; + *) + GRUB_CFG="/boot/grub/grub.cfg" + GRUB_MKCONFIG="grub-mkconfig" + ;; +esac + +case "$1" in + archlinux|freebsd*) + true + ;; + *) + echo "##[group]Edit kernel cmdline" + sudo sed -i -e '/^GRUB_CMDLINE_LINUX/d' /etc/default/grub || true + echo "GRUB_CMDLINE_LINUX=\"$CMDLINE\"" \ + | sudo tee -a /etc/default/grub >/dev/null + sudo $GRUB_MKCONFIG -o $GRUB_CFG + echo "##[endgroup]" + ;; +esac + +# reset cloud-init configuration and poweroff +sudo cloud-init clean --logs +sleep 2 && sudo poweroff & +exit 0 diff --git a/.github/workflows/scripts/qemu-4-build.sh b/.github/workflows/scripts/qemu-4-build.sh new file mode 100755 index 000000000000..1051ee1f4deb --- /dev/null +++ b/.github/workflows/scripts/qemu-4-build.sh @@ -0,0 +1,153 @@ +#!/usr/bin/env bash + +###################################################################### +# 4) configure and build openzfs modules +###################################################################### + +set -eu + +function run() { + LOG="/var/tmp/build-stderr.txt" + echo "****************************************************" + echo "$(date) ($*)" + echo "****************************************************" + ($@ || echo $? > /tmp/rv) 3>&1 1>&2 2>&3 | stdbuf -eL -oL tee -a $LOG + if [ -f /tmp/rv ]; then + RV=$(cat /tmp/rv) + echo "****************************************************" + echo "exit with value=$RV ($*)" + echo "****************************************************" + echo 1 > /var/tmp/build-exitcode.txt + exit $RV + fi +} + +function freebsd() { + export MAKE="gmake" + echo "##[group]Autogen.sh" + run ./autogen.sh + echo "##[endgroup]" + + echo "##[group]Configure" + run ./configure \ + --prefix=/usr/local \ + --with-libintl-prefix=/usr/local \ + --enable-pyzfs \ + --enable-debug \ + --enable-debuginfo + echo "##[endgroup]" + + echo "##[group]Build" + run gmake -j$(sysctl -n hw.ncpu) + echo "##[endgroup]" + + echo "##[group]Install" + run sudo gmake install + echo "##[endgroup]" +} + +function linux() { + echo "##[group]Autogen.sh" + run ./autogen.sh + echo "##[endgroup]" + + echo "##[group]Configure" + run ./configure \ + --prefix=/usr \ + --enable-pyzfs \ + --enable-debug \ + --enable-debuginfo + echo "##[endgroup]" + + echo "##[group]Build" + run make -j$(nproc) + echo "##[endgroup]" + + echo "##[group]Install" + run sudo make install + echo "##[endgroup]" +} + +function rpm_build_and_install() { + EXTRA_CONFIG="${1:-}" + echo "##[group]Autogen.sh" + run ./autogen.sh + echo "##[endgroup]" + + echo "##[group]Configure" + run ./configure --enable-debug --enable-debuginfo $EXTRA_CONFIG + echo "##[endgroup]" + + echo "##[group]Build" + run make pkg-kmod pkg-utils + echo "##[endgroup]" + + echo "##[group]Install" + run sudo dnf -y --skip-broken localinstall $(ls *.rpm | grep -v src.rpm) + echo "##[endgroup]" + +} + +function deb_build_and_install() { +echo "##[group]Autogen.sh" + run ./autogen.sh + echo "##[endgroup]" + + echo "##[group]Configure" + run ./configure \ + --prefix=/usr \ + --enable-pyzfs \ + --enable-debug \ + --enable-debuginfo + echo "##[endgroup]" + + echo "##[group]Build" + run make native-deb-kmod native-deb-utils + echo "##[endgroup]" + + echo "##[group]Install" + # Do kmod install. Note that when you build the native debs, the + # packages themselves are placed in parent directory '../' rather than + # in the source directory like the rpms are. + run sudo apt-get -y install $(find ../ | grep -E '\.deb$' \ + | grep -Ev 'dkms|dracut') + echo "##[endgroup]" +} + +# Debug: show kernel cmdline +if [ -f /proc/cmdline ] ; then + cat /proc/cmdline || true +fi + +# save some sysinfo +uname -a > /var/tmp/uname.txt + +cd $HOME/zfs +export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin" + +# build +case "$1" in + freebsd*) + freebsd + ;; + alma*|centos*) + rpm_build_and_install "--with-spec=redhat" + ;; + fedora*) + rpm_build_and_install + ;; + debian*|ubuntu*) + deb_build_and_install + ;; + *) + linux + ;; +esac + +# building the zfs module was ok +echo 0 > /var/tmp/build-exitcode.txt + +# reset cloud-init configuration and poweroff +sudo cloud-init clean --logs +sync && sleep 2 && sudo poweroff & +exit 0 diff --git a/.github/workflows/scripts/qemu-5-setup.sh b/.github/workflows/scripts/qemu-5-setup.sh new file mode 100755 index 000000000000..7acb67a27920 --- /dev/null +++ b/.github/workflows/scripts/qemu-5-setup.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash + +###################################################################### +# 5) start test machines and load openzfs module +###################################################################### + +set -eu + +# read our defined variables +source /var/tmp/env.txt + +# wait for poweroff to succeed +PID=$(pidof /usr/bin/qemu-system-x86_64) +tail --pid=$PID -f /dev/null +sudo virsh undefine openzfs + +# definitions of per operating system +case "$OS" in + freebsd*) + VMs=2 + CPU=3 + RAM=6 + ;; + *) + VMs=2 + CPU=3 + RAM=7 + ;; +esac + +# this can be different for each distro +echo "VMs=$VMs" >> $ENV + +# create snapshot we can clone later +sudo zfs snapshot zpool/openzfs@now + +# setup the testing vm's +PUBKEY=$(cat ~/.ssh/id_ed25519.pub) +for i in $(seq 1 $VMs); do + + echo "Creating disk for vm$i..." + DISK="/dev/zvol/zpool/vm$i" + FORMAT="raw" + sudo zfs clone zpool/openzfs@now zpool/vm$i + sudo zfs create -ps -b 64k -V 80g zpool/vm$i-2 + + cat < /tmp/user-data +#cloud-config + +fqdn: vm$i + +users: +- name: root + shell: $BASH +- name: zfs + sudo: ALL=(ALL) NOPASSWD:ALL + shell: $BASH + ssh_authorized_keys: + - $PUBKEY + +growpart: + mode: auto + devices: ['/'] + ignore_growroot_disabled: false +EOF + + sudo virsh net-update default add ip-dhcp-host \ + "" --live --config + + sudo virt-install \ + --os-variant $OSv \ + --name "vm$i" \ + --cpu host-passthrough \ + --virt-type=kvm --hvm \ + --vcpus=$CPU,sockets=1 \ + --memory $((1024*RAM)) \ + --memballoon model=virtio \ + --graphics none \ + --cloud-init user-data=/tmp/user-data \ + --network bridge=virbr0,model=$NIC,mac="52:54:00:83:79:0$i" \ + --disk $DISK,bus=virtio,cache=none,format=$FORMAT,driver.discard=unmap \ + --disk $DISK-2,bus=virtio,cache=none,format=$FORMAT,driver.discard=unmap \ + --import --noautoconsole >/dev/null +done + +# check the memory state from time to time +cat < cronjob.sh +# $OS +exec 1>>/var/tmp/stats.txt +exec 2>&1 +echo "*******************************************************" +date +uptime +free -m +df -h /mnt/tests +zfs list +EOF +sudo chmod +x cronjob.sh +sudo mv -f cronjob.sh /root/cronjob.sh +echo '*/5 * * * * /root/cronjob.sh' > crontab.txt +sudo crontab crontab.txt +rm crontab.txt + +# check if the machines are okay +echo "Waiting for vm's to come up... (${VMs}x CPU=$CPU RAM=$RAM)" +for i in $(seq 1 $VMs); do + while true; do + ssh 2>/dev/null zfs@192.168.122.1$i "uname -a" && break + done +done +echo "All $VMs VMs are up now." + +# Save the VM's serial output (ttyS0) to /var/tmp/console.txt +# - ttyS0 on the VM corresponds to a local /dev/pty/N entry +# - use 'virsh ttyconsole' to lookup the /dev/pty/N entry +for i in $(seq 1 $VMs); do + mkdir -p $RESPATH/vm$i + read "pty" <<< $(sudo virsh ttyconsole vm$i) + sudo nohup bash -c "cat $pty > $RESPATH/vm$i/console.txt" & +done +echo "Console logging for ${VMs}x $OS started." diff --git a/.github/workflows/scripts/qemu-6-tests.sh b/.github/workflows/scripts/qemu-6-tests.sh new file mode 100755 index 000000000000..fac953c8fa56 --- /dev/null +++ b/.github/workflows/scripts/qemu-6-tests.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash + +###################################################################### +# 6) load openzfs module and run the tests +# +# called on runner: qemu-6-tests.sh +# called on qemu-vm: qemu-6-tests.sh $OS $2/$3 +###################################################################### + +set -eu + +function prefix() { + ID="$1" + LINE="$2" + CURRENT=$(date +%s) + TSSTART=$(cat /tmp/tsstart) + DIFF=$((CURRENT-TSSTART)) + H=$((DIFF/3600)) + DIFF=$((DIFF-(H*3600))) + M=$((DIFF/60)) + S=$((DIFF-(M*60))) + + CTR=$(cat /tmp/ctr) + echo $LINE| grep -q "^Test[: ]" && CTR=$((CTR+1)) && echo $CTR > /tmp/ctr + + BASE="$HOME/work/zfs/zfs" + COLOR="$BASE/scripts/zfs-tests-color.sh" + CLINE=$(echo $LINE| grep "^Test[ :]" | sed -e 's|/usr/local|/usr|g' \ + | sed -e 's| /usr/share/zfs/zfs-tests/tests/| |g' | $COLOR) + if [ -z "$CLINE" ]; then + printf "vm${ID}: %s\n" "$LINE" + else + # [vm2: 00:15:54 256] Test: functional/checksum/setup (run as root) [00:00] [PASS] + printf "[vm${ID}: %02d:%02d:%02d %4d] %s\n" \ + "$H" "$M" "$S" "$CTR" "$CLINE" + fi +} + +# called directly on the runner +if [ -z ${1:-} ]; then + cd "/var/tmp" + source env.txt + SSH=$(which ssh) + TESTS='$HOME/zfs/.github/workflows/scripts/qemu-6-tests.sh' + echo 0 > /tmp/ctr + date "+%s" > /tmp/tsstart + + for i in $(seq 1 $VMs); do + IP="192.168.122.1$i" + daemonize -c /var/tmp -p vm${i}.pid -o vm${i}log.txt -- \ + $SSH zfs@$IP $TESTS $OS $i $VMs + # handly line by line and add info prefix + stdbuf -oL tail -fq vm${i}log.txt \ + | while read -r line; do prefix "$i" "$line"; done & + echo $! > vm${i}log.pid + # don't mix up the initial --- Configuration --- part + sleep 0.13 + done + + # wait for all vm's to finish + for i in $(seq 1 $VMs); do + tail --pid=$(cat vm${i}.pid) -f /dev/null + pid=$(cat vm${i}log.pid) + rm -f vm${i}log.pid + kill $pid + done + + exit 0 +fi + +# this part runs inside qemu vm +export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin" +case "$1" in + freebsd*) + sudo kldstat -n zfs 2>/dev/null && sudo kldunload zfs + sudo -E ./zfs/scripts/zfs.sh + TDIR="/usr/local/share/zfs" + ;; + *) + # use xfs @ /var/tmp for all distros + sudo mv -f /var/tmp/*.txt /tmp + sudo mkfs.xfs -fq /dev/vdb + sudo mount -o noatime /dev/vdb /var/tmp + sudo chmod 1777 /var/tmp + sudo mv -f /tmp/*.txt /var/tmp + sudo -E modprobe zfs + TDIR="/usr/share/zfs" + ;; +esac + +# run functional testings and save exitcode +cd /var/tmp +TAGS=$2/$3 +sudo dmesg -c > dmesg-prerun.txt +mount > mount.txt +df -h > df-prerun.txt +$TDIR/zfs-tests.sh -vK -s 3GB -T $TAGS +RV=$? +df -h > df-postrun.txt +echo $RV > tests-exitcode.txt +sync +exit 0 diff --git a/.github/workflows/scripts/qemu-7-prepare.sh b/.github/workflows/scripts/qemu-7-prepare.sh new file mode 100755 index 000000000000..3dc5c7efd02c --- /dev/null +++ b/.github/workflows/scripts/qemu-7-prepare.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash + +###################################################################### +# 7) prepare output of the results +# - this script pre-creates all needed logfiles for later summary +###################################################################### + +set -eu + +# read our defined variables +cd /var/tmp +source env.txt + +mkdir -p $RESPATH + +# check if building the module has failed +if [ -z ${VMs:-} ]; then + cd $RESPATH + echo ":exclamation: ZFS module didn't build successfully :exclamation:" \ + | tee summary.txt | tee /tmp/summary.txt + tar cf /tmp/qemu-$OS.tar -C $RESPATH -h . || true + exit 0 +fi + +# build was okay +BASE="$HOME/work/zfs/zfs" +MERGE="$BASE/.github/workflows/scripts/merge_summary.awk" + +# catch result files of testings (vm's should be there) +for i in $(seq 1 $VMs); do + rsync -arL zfs@192.168.122.1$i:$RESPATH/current $RESPATH/vm$i || true + scp zfs@192.168.122.1$i:"/var/tmp/*.txt" $RESPATH/vm$i || true +done +cp -f /var/tmp/*.txt $RESPATH || true +cd $RESPATH + +# prepare result files for summary +for i in $(seq 1 $VMs); do + file="vm$i/build-stderr.txt" + test -s $file && mv -f $file build-stderr.txt + + file="vm$i/build-exitcode.txt" + test -s $file && mv -f $file build-exitcode.txt + + file="vm$i/uname.txt" + test -s $file && mv -f $file uname.txt + + file="vm$i/tests-exitcode.txt" + test -s $file || echo 1 > $file + rv=$(cat vm$i/tests-exitcode.txt) + test $rv != 0 && touch /tmp/have_failed_tests + + file="vm$i/current/log" + if [ -s $file ]; then + cat $file >> log + awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }; \ + /\[SKIP\]|\[PASS\]/{ show=0; } show' \ + $file > /tmp/vm${i}dbg.txt + fi + + file="vm${i}log.txt" + fileC="/tmp/vm${i}log.txt" + if [ -s $file ]; then + cat $file >> summary + cat $file | $BASE/scripts/zfs-tests-color.sh > $fileC + fi +done + +# create summary of tests +if [ -s summary ]; then + $MERGE summary | grep -v '^/' > summary.txt + $MERGE summary | $BASE/scripts/zfs-tests-color.sh > /tmp/summary.txt + rm -f summary +else + touch summary.txt /tmp/summary.txt +fi + +# create file for debugging +if [ -s log ]; then + awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }; \ + /\[SKIP\]|\[PASS\]/{ show=0; } show' \ + log > summary-failure-logs.txt + rm -f log +else + touch summary-failure-logs.txt +fi + +# create debug overview for failed tests +cat summary.txt \ + | awk '/\(expected PASS\)/{ if ($1!="SKIP") print $2; next; } show' \ + | while read t; do + echo "check: $t" + cat summary-failure-logs.txt \ + | awk '$0~/Test[: ]/{ show=0; } $0~v{ show=1; } show' v="$t" \ + > /tmp/fail.txt + SIZE=$(stat --printf="%s" /tmp/fail.txt) + SIZE=$((SIZE/1024)) + # Test Summary: + echo "##[group]$t ($SIZE KiB)" >> /tmp/failed.txt + cat /tmp/fail.txt | $BASE/scripts/zfs-tests-color.sh >> /tmp/failed.txt + echo "##[endgroup]" >> /tmp/failed.txt + # Job Summary: + echo -e "\n
\n$t ($SIZE KiB)
" >> failed.txt
+  cat /tmp/fail.txt >> failed.txt
+  echo "
" >> failed.txt +done + +if [ -e /tmp/have_failed_tests ]; then + echo ":warning: Some tests failed!" >> failed.txt +else + echo ":thumbsup: All tests passed." >> failed.txt +fi + +if [ ! -s uname.txt ]; then + echo ":interrobang: Panic - where is my uname.txt?" > uname.txt +fi + +# artifact ready now +tar cf /tmp/qemu-$OS.tar -C $RESPATH -h . || true diff --git a/.github/workflows/scripts/qemu-8-summary.sh b/.github/workflows/scripts/qemu-8-summary.sh new file mode 100755 index 000000000000..0bf1b0a2d194 --- /dev/null +++ b/.github/workflows/scripts/qemu-8-summary.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +###################################################################### +# 8) show colored output of results +###################################################################### + +set -eu + +# read our defined variables +source /var/tmp/env.txt +cd $RESPATH + +# helper function for showing some content with headline +function showfile() { + content=$(dd if=$1 bs=1024 count=400k 2>/dev/null) + if [ -z "$2" ]; then + group1="" + group2="" + else + SIZE=$(stat --printf="%s" "$file") + SIZE=$((SIZE/1024)) + group1="##[group]$2 ($SIZE KiB)" + group2="##[endgroup]" + fi +cat < tmp$$ +$group1 +$content +$group2 +EOF + cat tmp$$ + rm -f tmp$$ +} + +# overview +cat /tmp/summary.txt +echo "" + +if [ -e /tmp/have_failed_tests ]; then + RV=1 + echo "Debuginfo of failed tests:" + cat /tmp/failed.txt + echo "" + cat /tmp/summary.txt | grep -v '^/' + echo "" +else + RV=0 +fi + +echo -e "\nFull logs for download:\n $1\n" + +for i in $(seq 1 $VMs); do + rv=$(cat vm$i/tests-exitcode.txt) + + if [ $rv = 0 ]; then + vm="vm$i" + else + vm="vm$i" + fi + + file="vm$i/dmesg-prerun.txt" + test -s "$file" && showfile "$file" "$vm: dmesg kernel" + + file="/tmp/vm${i}log.txt" + test -s "$file" && showfile "$file" "$vm: test results" + + file="vm$i/console.txt" + test -s "$file" && showfile "$file" "$vm: serial console" + + file="/tmp/vm${i}dbg.txt" + test -s "$file" && showfile "$file" "$vm: failure logfile" +done + +exit $RV diff --git a/.github/workflows/scripts/qemu-9-summary-page.sh b/.github/workflows/scripts/qemu-9-summary-page.sh new file mode 100755 index 000000000000..036004882fec --- /dev/null +++ b/.github/workflows/scripts/qemu-9-summary-page.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +###################################################################### +# 9) generate github summary page of all the testings +###################################################################### + +set -eu + +function output() { + echo -e $* >> "out-$logfile.md" +} + +function outfile() { + cat "$1" >> "out-$logfile.md" +} + +function outfile_plain() { + output "
"
+  cat "$1" >> "out-$logfile.md"
+  output "
" +} + +function send2github() { + test -f "$1" || exit 0 + dd if="$1" bs=1023k count=1 >> $GITHUB_STEP_SUMMARY +} + +# https://docs.github.com/en/enterprise-server@3.6/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits +# Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB. +# [ ] can not show all error findings here +# [x] split files into smaller ones and create additional steps + +# first call, generate all summaries +if [ ! -f out-1.md ]; then + logfile="1" + for tarfile in Logs-functional-*/qemu-*.tar; do + if [ ! -s "$tarfile" ]; then + output "\n## Functional Tests: unknown\n" + output ":exclamation: Tarfile $tarfile is empty :exclamation:" + continue + fi + rm -rf vm* *.txt + tar xf "$tarfile" + source env.txt + output "\n## Functional Tests: $OSNAME\n" + outfile_plain uname.txt + outfile_plain summary.txt + outfile failed.txt + logfile=$((logfile+1)) + done + send2github out-1.md +else + send2github out-$1.md +fi diff --git a/.github/workflows/zfs-qemu.yml b/.github/workflows/zfs-qemu.yml new file mode 100644 index 000000000000..a3381a955e94 --- /dev/null +++ b/.github/workflows/zfs-qemu.yml @@ -0,0 +1,141 @@ +name: zfs-qemu + +on: + push: + pull_request: + +jobs: + + qemu-vm: + name: qemu-x86 + strategy: + fail-fast: false + matrix: + # all: + # os: [almalinux8, almalinux9, archlinux, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] + # openzfs: + os: [almalinux8, almalinux9, centos-stream9, debian11, debian12, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r] + # freebsd: + # os: [freebsd13, freebsd14] + # small test: + # os: [archlinux] + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup QEMU + timeout-minutes: 10 + run: .github/workflows/scripts/qemu-1-setup.sh + + - name: Start build machine + timeout-minutes: 10 + run: .github/workflows/scripts/qemu-2-start.sh ${{ matrix.os }} + + - name: Install dependencies + timeout-minutes: 20 + run: | + echo "Install dependencies in QEMU machine" + IP=192.168.122.10 + while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do + ssh 2>/dev/null zfs@$IP "uname -a" && break + done + scp .github/workflows/scripts/qemu-3-deps.sh zfs@$IP:qemu-3-deps.sh + PID=`pidof /usr/bin/qemu-system-x86_64` + ssh zfs@$IP '$HOME/qemu-3-deps.sh' ${{ matrix.os }} + # wait for poweroff to succeed + tail --pid=$PID -f /dev/null + sleep 5 # avoid this: "error: Domain is already active" + rm -f $HOME/.ssh/known_hosts + + - name: Build modules + timeout-minutes: 30 + run: | + echo "Build modules in QEMU machine" + sudo virsh start openzfs + IP=192.168.122.10 + while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do + ssh 2>/dev/null zfs@$IP "uname -a" && break + done + rsync -ar $HOME/work/zfs/zfs zfs@$IP:./ + ssh zfs@$IP '$HOME/zfs/.github/workflows/scripts/qemu-4-build.sh' ${{ matrix.os }} + + - name: Setup testing machines + timeout-minutes: 5 + run: .github/workflows/scripts/qemu-5-setup.sh + + - name: Run tests + timeout-minutes: 270 + run: .github/workflows/scripts/qemu-6-tests.sh + + - name: Prepare artifacts + if: always() + timeout-minutes: 10 + run: .github/workflows/scripts/qemu-7-prepare.sh + + - uses: actions/upload-artifact@v4 + id: artifact-upload + if: always() + with: + name: Logs-functional-${{ matrix.os }} + path: /tmp/qemu-${{ matrix.os }}.tar + if-no-files-found: ignore + + - name: Test Summary + if: always() + run: .github/workflows/scripts/qemu-8-summary.sh '${{ steps.artifact-upload.outputs.artifact-url }}' + + cleanup: + if: always() + name: Cleanup + runs-on: ubuntu-latest + needs: [ qemu-vm ] + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/download-artifact@v4 + - name: Generating summary + run: .github/workflows/scripts/qemu-9-summary-page.sh + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 2 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 3 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 4 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 5 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 6 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 7 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 8 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 9 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 10 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 11 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 12 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 13 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 14 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 15 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 16 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 17 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 18 + - name: Generating summary... + run: .github/workflows/scripts/qemu-9-summary-page.sh 19 + - uses: actions/upload-artifact@v4 + with: + name: Summary Files + path: out-* diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index c25903ea1bee..2906d73442c2 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -1,5 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash # shellcheck disable=SC2154 +# shellcheck disable=SC2292 # # CDDL HEADER START # @@ -208,6 +209,49 @@ find_runfile() { fi } +# Given a TAGS with a format like "1/3" or "2/3" then divide up the test list +# into portions and print that portion. So "1/3" for "the first third of the +# test tags". +# +# +split_tags() { + # Get numerator and denominator + NUM=$(echo "$TAGS" | cut -d/ -f1) + DEN=$(echo "$TAGS" | cut -d/ -f2) + # At the point this is called, RUNFILES will contain a comma separated + # list of full paths to the runfiles, like: + # + # "/home/hutter/qemu/tests/runfiles/common.run,/home/hutter/qemu/tests/runfiles/linux.run" + # + # So to get tags for our selected tests we do: + # + # 1. Remove unneeded chars: [],\ + # 2. Print out the last field of each tag line. This will be the tag + # for the test (like 'zpool_add'). + # 3. Remove duplicates between the runfiles. If the same tag is defined + # in multiple runfiles, then when you do '-T ' ZTS is smart + # enough to know to run the tag in each runfile. So '-T zpool_add' + # will run the zpool_add from common.run and linux.run. + # 4. Ignore the 'functional' tag since we only want individual tests + # 5. Print out the tests in our faction of all tests. This uses modulus + # so "1/3" will run tests 1,3,6,9 etc. That way the tests are + # interleaved so, say, "3/4" isn't running all the zpool_* tests that + # appear alphabetically at the end. + # 6. Remove trailing comma from list + # + # TAGS will then look like: + # + # "append,atime,bootfs,cachefile,checksum,cp_files,deadman,dos_attributes, ..." + + # Change the comma to a space for easy processing + _RUNFILES=${RUNFILES//","/" "} + # shellcheck disable=SC2002,SC2086 + cat $_RUNFILES | tr -d "[],\'" | awk '/tags = /{print $NF}' | sort | \ + uniq | grep -v functional | \ + awk -v num="$NUM" -v den="$DEN" '{ if(NR % den == (num - 1)) {printf "%s,",$0}}' | \ + sed -E 's/,$//' +} + # # Symlink file if it appears under any of the given paths. # @@ -331,10 +375,14 @@ OPTIONS: -t PATH|NAME Run single test at PATH relative to test suite, or search for test by NAME -T TAGS Comma separated list of tags (default: 'functional') + Alternately, specify a fraction like "1/3" or "2/3" to + run the first third of tests or 2nd third of the tests. This + is useful for splitting up the test amongst different + runners. -u USER Run single test as USER (default: root) EXAMPLES: -# Run the default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and output the configuration used. +# Run the default ${DEFAULT_RUNFILES//\.run/} suite of tests and output the configuration used. $0 -v # Run a smaller suite of tests designed to run more quickly. @@ -347,7 +395,7 @@ $0 -t tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh $0 -t zfs_bookmark_cliargs # Cleanup a previous run of the test suite prior to testing, run the -# default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and perform no cleanup on exit. +# default ${DEFAULT_RUNFILES//\.run//} suite of tests and perform no cleanup on exit. $0 -x EOF @@ -489,6 +537,8 @@ fi # TAGS=${TAGS:='functional'} + + # # Attempt to locate the runfiles describing the test workload. # @@ -509,6 +559,23 @@ done unset IFS RUNFILES=${R#,} +# The tag can be a fraction to indicate which portion of ZTS to run, Like +# +# "1/3": Run first one third of all tests in runfiles +# "2/3": Run second one third of all test in runfiles +# "6/10": Run 6th tenth of all tests in runfiles +# +# This is useful for splitting up the test across multiple runners. +# +# After this code block, TAGS will be transformed from something like +# "1/3" to a comma separate taglist, like: +# +# "append,atime,bootfs,cachefile,checksum,cp_files,deadman,dos_attributes, ..." +# +if echo "$TAGS" | grep -Eq '^[0-9]+/[0-9]+$' ; then + TAGS=$(split_tags) +fi + # # This script should not be run as root. Instead the test user, which may # be a normal user account, needs to be configured such that it can diff --git a/tests/test-runner/bin/test-runner.py.in b/tests/test-runner/bin/test-runner.py.in index 65247f4f06fc..ea01b473b590 100755 --- a/tests/test-runner/bin/test-runner.py.in +++ b/tests/test-runner/bin/test-runner.py.in @@ -295,6 +295,18 @@ User: %s except Exception: pass + """ + Log each test we run to /dev/ttyu0 (on FreeBSD), so if there's a kernel + warning we'll be able to match it up to a particular test. + """ + if options.kmsg is True and exists("/dev/ttyu0"): + try: + kp = Popen([SUDO, "sh", "-c", + f"echo ZTS run {self.pathname} > /dev/ttyu0"]) + kp.wait() + except Exception: + pass + self.result.starttime = monotonic_time() if kmemleak: From 1cbb695dccd63b9d9f1175934aefd85770ee0b16 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Fri, 20 Sep 2024 00:53:57 +0200 Subject: [PATCH 015/223] ZTS: use openssl for md5digest and sha256digest On larger files this should improve the speed. Sample values of my system: [mcmilk@xz]$ time dd if=/dev/zero bs=128k count=1k | sha256sum 254bcc3fc4f27172636df4bf32de9f107f620d559b20d760197e452b97453917 - real 0m1,050s user 0m0,985s sys 0m0,153s [mcmilk@xz]$ time dd if=/dev/zero bs=128k count=1k | openssl sha256 -r 254bcc3fc4f27172636df4bf32de9f107f620d559b20d760197e452b97453917 *stdin real 0m0,254s user 0m0,206s sys 0m0,160s I think cli_root/zdb/zdb_backup.ksh runs also an FreeBSD and I needed to include the sysutils/coreutils package for the FreeBSD tests within the QEMU patchset. This could be reverted, when this pull request gets upstream Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: Tino Reichardt Closes #16543 --- tests/zfs-tests/include/libtest.shlib | 26 ++----------------- .../functional/cli_root/zdb/zdb_backup.ksh | 4 +-- .../fault/suspend_resume_single.ksh | 4 +-- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index a2f42999a31e..275872ded7f5 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -3460,18 +3460,7 @@ function tunable_exists # function md5digest { - typeset file=$1 - - case "$UNAME" in - FreeBSD) - md5 -q $file - ;; - *) - typeset sum _ - read -r sum _ < <(md5sum -b $file) - echo $sum - ;; - esac + openssl md5 -r $1 | awk '{print $1}' } # @@ -3480,18 +3469,7 @@ function md5digest # function sha256digest { - typeset file=$1 - - case "$UNAME" in - FreeBSD) - sha256 -q $file - ;; - *) - typeset sum _ - read -r sum _ < <(sha256sum -b $file) - echo $sum - ;; - esac + openssl sha256 -r $1 | awk '{print $1}' } function new_fs # diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh index d98ab86ab667..b591b209ab6b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh @@ -47,8 +47,8 @@ sync_pool $TESTPOOL log_must eval "zfs send -ecL $snap > $tmpfile.1" log_must eval "zdb -B $TESTPOOL/$objsetid ecL > $tmpfile.2" -typeset sum1=$(cat $tmpfile.1 | md5sum) -typeset sum2=$(cat $tmpfile.2 | md5sum) +typeset sum1=$(md5digest $tmpfile.1) +typeset sum2=$(md5digest $tmpfile.2) log_must test "$sum1" = "$sum2" diff --git a/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh b/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh index 05f3ac708477..6998df78ac7c 100755 --- a/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh +++ b/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh @@ -43,7 +43,7 @@ log_assert "ensure single-disk pool resumes properly after suspend and clear" # create a file, and take a checksum, so we can compare later log_must dd if=/dev/urandom of=$DATAFILE bs=128K count=1 -typeset sum1=$(cat $DATAFILE | md5sum) +typeset sum1=$(md5digest $DATAFILE) # make a debug device that we can "unplug" load_scsi_debug 100 1 1 1 '512b' @@ -94,7 +94,7 @@ log_must zpool export $TESTPOOL log_must zpool import $TESTPOOL # sum the file we wrote earlier -typeset sum2=$(cat /$TESTPOOL/file | md5sum) +typeset sum2=$(md5digest /$TESTPOOL/file) # make sure the checksums match log_must test "$sum1" = "$sum2" From 53879c4ecc4af4c59efef8c5b8bc2a3829377ca4 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Wed, 18 Sep 2024 06:40:49 +0200 Subject: [PATCH 016/223] ZTS: Fix Test Summary page generation Fix that error: "cat /tmp/failed.txt: No such file or directory" Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Signed-off-by: Tino Reichardt Closes #16549 --- .github/workflows/scripts/qemu-7-prepare.sh | 7 +++++-- .github/workflows/scripts/qemu-8-summary.sh | 8 +++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/scripts/qemu-7-prepare.sh b/.github/workflows/scripts/qemu-7-prepare.sh index 3dc5c7efd02c..4e2583731d70 100755 --- a/.github/workflows/scripts/qemu-7-prepare.sh +++ b/.github/workflows/scripts/qemu-7-prepare.sh @@ -46,7 +46,11 @@ for i in $(seq 1 $VMs); do test -s $file && mv -f $file uname.txt file="vm$i/tests-exitcode.txt" - test -s $file || echo 1 > $file + if [ ! -s $file ]; then + # XXX - add some tests for kernel panic's here + # tail -n 80 vm$i/console.txt | grep XYZ + echo 1 > $file + fi rv=$(cat vm$i/tests-exitcode.txt) test $rv != 0 && touch /tmp/have_failed_tests @@ -89,7 +93,6 @@ fi cat summary.txt \ | awk '/\(expected PASS\)/{ if ($1!="SKIP") print $2; next; } show' \ | while read t; do - echo "check: $t" cat summary-failure-logs.txt \ | awk '$0~/Test[: ]/{ show=0; } $0~v{ show=1; } show' v="$t" \ > /tmp/fail.txt diff --git a/.github/workflows/scripts/qemu-8-summary.sh b/.github/workflows/scripts/qemu-8-summary.sh index 0bf1b0a2d194..26dbab28323b 100755 --- a/.github/workflows/scripts/qemu-8-summary.sh +++ b/.github/workflows/scripts/qemu-8-summary.sh @@ -35,15 +35,12 @@ EOF cat /tmp/summary.txt echo "" -if [ -e /tmp/have_failed_tests ]; then - RV=1 +if [ -f /tmp/have_failed_tests -a -s /tmp/failed.txt ]; then echo "Debuginfo of failed tests:" cat /tmp/failed.txt echo "" cat /tmp/summary.txt | grep -v '^/' echo "" -else - RV=0 fi echo -e "\nFull logs for download:\n $1\n" @@ -70,4 +67,5 @@ for i in $(seq 1 $VMs); do test -s "$file" && showfile "$file" "$vm: failure logfile" done -exit $RV +test -f /tmp/have_failed_tests && exit 1 +exit 0 From ca5652c4205fc776e2078eb839a47217b67891e0 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Wed, 18 Sep 2024 23:24:12 +0200 Subject: [PATCH 017/223] ZTS: Remove functional tests via matrix This commit changes the workflow of the github actions. - Ubuntu 20.04, 22.04, 24.04 will be tested via QEMU now - remove unused scripts of this commit: b7bc334d1 - re-add the zloop standalone testings via zloop.yml Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Signed-off-by: Tino Reichardt Closes #16549 --- .github/workflows/build-dependencies.txt | 57 -------- .github/workflows/checkstyle-dependencies.txt | 5 - .github/workflows/checkstyle.yaml | 19 +-- .github/workflows/scripts/generate-summary.sh | 119 ----------------- .github/workflows/scripts/qemu-3-deps.sh | 4 + .../workflows/scripts/setup-dependencies.sh | 88 ------------- .github/workflows/scripts/setup-functional.sh | 24 ---- .github/workflows/zfs-linux-tests.yml | 124 ------------------ .github/workflows/zfs-linux.yml | 64 --------- .github/workflows/zfs-qemu.yml | 6 +- .github/workflows/zloop.yml | 61 +++++++++ 11 files changed, 76 insertions(+), 495 deletions(-) delete mode 100644 .github/workflows/build-dependencies.txt delete mode 100644 .github/workflows/checkstyle-dependencies.txt delete mode 100755 .github/workflows/scripts/generate-summary.sh delete mode 100755 .github/workflows/scripts/setup-dependencies.sh delete mode 100755 .github/workflows/scripts/setup-functional.sh delete mode 100644 .github/workflows/zfs-linux-tests.yml delete mode 100644 .github/workflows/zfs-linux.yml create mode 100644 .github/workflows/zloop.yml diff --git a/.github/workflows/build-dependencies.txt b/.github/workflows/build-dependencies.txt deleted file mode 100644 index 73921865c42a..000000000000 --- a/.github/workflows/build-dependencies.txt +++ /dev/null @@ -1,57 +0,0 @@ -acl -alien -attr -autoconf -bc -build-essential -curl -dbench -debhelper-compat -dh-python -dkms -fakeroot -fio -gdb -gdebi -git -ksh -lcov -libacl1-dev -libaio-dev -libattr1-dev -libblkid-dev -libcurl4-openssl-dev -libdevmapper-dev -libelf-dev -libffi-dev -libmount-dev -libpam0g-dev -libselinux1-dev -libssl-dev -libtool -libudev-dev -linux-headers-generic -lsscsi -mdadm -nfs-kernel-server -pamtester -parted -po-debconf -python3 -python3-all-dev -python3-cffi -python3-dev -python3-packaging -python3-pip -python3-setuptools -python3-sphinx -rng-tools-debian -rsync -samba -sysstat -uuid-dev -watchdog -wget -xfslibs-dev -xz-utils -zlib1g-dev diff --git a/.github/workflows/checkstyle-dependencies.txt b/.github/workflows/checkstyle-dependencies.txt deleted file mode 100644 index 879d3dbc5553..000000000000 --- a/.github/workflows/checkstyle-dependencies.txt +++ /dev/null @@ -1,5 +0,0 @@ -cppcheck -devscripts -mandoc -pax-utils -shellcheck diff --git a/.github/workflows/checkstyle.yaml b/.github/workflows/checkstyle.yaml index abcb358fc04f..088d28d52a90 100644 --- a/.github/workflows/checkstyle.yaml +++ b/.github/workflows/checkstyle.yaml @@ -13,15 +13,11 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: Install dependencies run: | - # https://github.com/orgs/community/discussions/47863 - sudo apt-mark hold grub-efi-amd64-signed - sudo apt-get update --fix-missing - sudo apt-get upgrade - sudo xargs --arg-file=${{ github.workspace }}/.github/workflows/build-dependencies.txt apt-get install -qq - sudo xargs --arg-file=${{ github.workspace }}/.github/workflows/checkstyle-dependencies.txt apt-get install -qq - sudo python3 -m pip install --quiet flake8 - sudo apt-get clean - + # for x in lxd core20 snapd; do sudo snap remove $x; done + sudo apt-get purge -y snapd google-chrome-stable firefox + ONLY_DEPS=1 .github/workflows/scripts/qemu-3-deps.sh ubuntu22 + sudo apt-get install -y cppcheck devscripts mandoc pax-utils shellcheck + sudo python -m pipx install --quiet flake8 # confirm that the tools are installed # the build system doesn't fail when they are not checkbashisms --version @@ -31,8 +27,13 @@ jobs: shellcheck --version - name: Prepare run: | + sed -i '/DEBUG_CFLAGS="-Werror"/s/^/#/' config/zfs-build.m4 ./autogen.sh + - name: Configure + run: | ./configure + - name: Make + run: | make -j$(nproc) --no-print-directory --silent - name: Checkstyle run: | diff --git a/.github/workflows/scripts/generate-summary.sh b/.github/workflows/scripts/generate-summary.sh deleted file mode 100755 index b5d89208a5d8..000000000000 --- a/.github/workflows/scripts/generate-summary.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env bash - -# for runtime reasons we split functional testings into N parts -# - use a define to check for missing tarfiles -FUNCTIONAL_PARTS="4" - -ZTS_REPORT="tests/test-runner/bin/zts-report.py" -chmod +x $ZTS_REPORT - -function output() { - echo -e $* >> Summary.md -} - -function error() { - output ":bangbang: $* :bangbang:\n" -} - -# this function generates the real summary -# - expects a logfile "log" in current directory -function generate() { - # we issued some error already - test ! -s log && return - - # for overview and zts-report - cat log | grep '^Test' > list - - # error details - awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; } - /\[SKIP\]|\[PASS\]/{ show=0; } show' log > err - - # summary of errors - if [ -s err ]; then - output "
"
-    $ZTS_REPORT --no-maybes ./list >> Summary.md
-    output "
" - - # generate seperate error logfile - ERRLOGS=$((ERRLOGS+1)) - errfile="err-$ERRLOGS.md" - echo -e "\n## $headline (debugging)\n" >> $errfile - echo "
Error Listing - with dmesg and dbgmsg
" >> $errfile
-    dd if=err bs=999k count=1 >> $errfile
-    echo "
" >> $errfile - else - output "All tests passed :thumbsup:" - fi - - output "
Full Listing
"
-  cat list >> Summary.md
-  output "
" - - # remove tmp files - rm -f err list log -} - -# check tarfiles and untar -function check_tarfile() { - if [ -f "$1" ]; then - tar xf "$1" || error "Tarfile $1 returns some error" - else - error "Tarfile $1 not found" - fi -} - -# check logfile and concatenate test results -function check_logfile() { - if [ -f "$1" ]; then - cat "$1" >> log - else - error "Logfile $1 not found" - fi -} - -# sanity -function summarize_s() { - headline="$1" - output "\n## $headline\n" - rm -rf testfiles - check_tarfile "$2/sanity.tar" - check_logfile "testfiles/log" - generate -} - -# functional -function summarize_f() { - headline="$1" - output "\n## $headline\n" - rm -rf testfiles - for i in $(seq 1 $FUNCTIONAL_PARTS); do - tarfile="$2-part$i/part$i.tar" - check_tarfile "$tarfile" - check_logfile "testfiles/log" - done - generate -} - -# https://docs.github.com/en/enterprise-server@3.6/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits -# Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB. -# [ ] can not show all error findings here -# [x] split files into smaller ones and create additional steps - -ERRLOGS=0 -if [ ! -f Summary/Summary.md ]; then - # first call, we do the default summary (~500k) - echo -n > Summary.md - summarize_s "Sanity Tests Ubuntu 20.04" Logs-20.04-sanity - summarize_s "Sanity Tests Ubuntu 22.04" Logs-22.04-sanity - summarize_f "Functional Tests Ubuntu 20.04" Logs-20.04-functional - summarize_f "Functional Tests Ubuntu 22.04" Logs-22.04-functional - - cat Summary.md >> $GITHUB_STEP_SUMMARY - mkdir -p Summary - mv *.md Summary -else - # here we get, when errors where returned in first call - test -f Summary/err-$1.md && cat Summary/err-$1.md >> $GITHUB_STEP_SUMMARY -fi - -exit 0 diff --git a/.github/workflows/scripts/qemu-3-deps.sh b/.github/workflows/scripts/qemu-3-deps.sh index c07e9445259b..02bff954fd5b 100755 --- a/.github/workflows/scripts/qemu-3-deps.sh +++ b/.github/workflows/scripts/qemu-3-deps.sh @@ -141,6 +141,10 @@ case "$1" in ;; esac +# This script is used for checkstyle + zloop deps also. +# Install only the needed packages and exit - when used this way. +test -z "${ONLY_DEPS:-}" || exit 0 + # Start services echo "##[group]Enable services" case "$1" in diff --git a/.github/workflows/scripts/setup-dependencies.sh b/.github/workflows/scripts/setup-dependencies.sh deleted file mode 100755 index b40f9290f914..000000000000 --- a/.github/workflows/scripts/setup-dependencies.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash - -set -eu - -function prerun() { - echo "::group::Install build dependencies" - # remove snap things, update+upgrade will be faster then - for x in lxd core20 snapd; do sudo snap remove $x; done - sudo apt-get purge snapd google-chrome-stable firefox - # https://github.com/orgs/community/discussions/47863 - sudo apt-get remove grub-efi-amd64-bin grub-efi-amd64-signed shim-signed --allow-remove-essential - sudo apt-get update - sudo apt upgrade - sudo xargs --arg-file=.github/workflows/build-dependencies.txt apt-get install -qq - sudo apt-get clean - sudo dmesg -c > /var/tmp/dmesg-prerun - echo "::endgroup::" -} - -function mod_build() { - echo "::group::Generate debian packages" - ./autogen.sh - ./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan - make --no-print-directory --silent native-deb-utils native-deb-kmod - mv ../*.deb . - rm ./openzfs-zfs-dracut*.deb ./openzfs-zfs-dkms*.deb - echo "$ImageOS-$ImageVersion" > tests/ImageOS.txt - echo "::endgroup::" -} - -function mod_install() { - # install the pre-built module only on the same runner image - MOD=`cat tests/ImageOS.txt` - if [ "$MOD" != "$ImageOS-$ImageVersion" ]; then - rm -f *.deb - mod_build - fi - - echo "::group::Install and load modules" - # don't use kernel-shipped zfs modules - sudo sed -i.bak 's/updates/extra updates/' /etc/depmod.d/ubuntu.conf - sudo apt-get install --fix-missing ./*.deb - - # Native Debian packages enable and start the services - # Stop zfs-zed daemon, as it may interfere with some ZTS test cases - sudo systemctl stop zfs-zed - sudo depmod -a - sudo modprobe zfs - sudo dmesg - sudo dmesg -c > /var/tmp/dmesg-module-load - echo "::endgroup::" - - echo "::group::Report CPU information" - lscpu - cat /proc/spl/kstat/zfs/chksum_bench - echo "::endgroup::" - - echo "::group::Optimize storage for ZFS testings" - # remove swap and umount fast storage - # 89GiB -> rootfs + bootfs with ~80MB/s -> don't care - # 64GiB -> /mnt with 420MB/s -> new testing ssd - sudo swapoff -a - - # this one is fast and mounted @ /mnt - # -> we reformat with ext4 + move it to /var/tmp - DEV="/dev/disk/azure/resource-part1" - sudo umount /mnt - sudo mkfs.ext4 -O ^has_journal -F $DEV - sudo mount -o noatime,barrier=0 $DEV /var/tmp - sudo chmod 1777 /var/tmp - - # disk usage afterwards - sudo df -h / - sudo df -h /var/tmp - sudo fstrim -a - echo "::endgroup::" -} - -case "$1" in - build) - prerun - mod_build - ;; - tests) - prerun - mod_install - ;; -esac diff --git a/.github/workflows/scripts/setup-functional.sh b/.github/workflows/scripts/setup-functional.sh deleted file mode 100755 index 08c4d872abdf..000000000000 --- a/.github/workflows/scripts/setup-functional.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -eu - -TDIR="/usr/share/zfs/zfs-tests/tests/functional" -echo -n "TODO=" -case "$1" in - part1) - # ~1h 20m - echo "cli_root" - ;; - part2) - # ~1h - ls $TDIR|grep '^[a-m]'|grep -v "cli_root"|xargs|tr -s ' ' ',' - ;; - part3) - # ~1h - ls $TDIR|grep '^[n-qs-z]'|xargs|tr -s ' ' ',' - ;; - part4) - # ~1h - ls $TDIR|grep '^r'|xargs|tr -s ' ' ',' - ;; -esac diff --git a/.github/workflows/zfs-linux-tests.yml b/.github/workflows/zfs-linux-tests.yml deleted file mode 100644 index 74f94ab8f2a4..000000000000 --- a/.github/workflows/zfs-linux-tests.yml +++ /dev/null @@ -1,124 +0,0 @@ -name: zfs-linux-tests - -on: - workflow_call: - inputs: - os: - description: 'The ubuntu version: 20.02 or 22.04' - required: true - type: string - -jobs: - - zloop: - runs-on: ubuntu-${{ inputs.os }} - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/download-artifact@v4 - with: - name: modules-${{ inputs.os }} - - name: Install modules - run: | - tar xzf modules-${{ inputs.os }}.tgz - .github/workflows/scripts/setup-dependencies.sh tests - - name: Tests - timeout-minutes: 30 - run: | - sudo mkdir -p /var/tmp/zloop - # run for 10 minutes or at most 2 iterations for a maximum runner - # time of 20 minutes. - sudo /usr/share/zfs/zloop.sh -t 600 -I 2 -l -m1 -- -T 120 -P 60 - - name: Prepare artifacts - if: failure() - run: | - sudo chmod +r -R /var/tmp/zloop/ - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: Zloop-logs-${{ inputs.os }} - path: | - /var/tmp/zloop/*/ - !/var/tmp/zloop/*/vdev/ - retention-days: 14 - if-no-files-found: ignore - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: Zloop-files-${{ inputs.os }} - path: | - /var/tmp/zloop/*/vdev/ - retention-days: 14 - if-no-files-found: ignore - - sanity: - runs-on: ubuntu-${{ inputs.os }} - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/download-artifact@v4 - with: - name: modules-${{ inputs.os }} - - name: Install modules - run: | - tar xzf modules-${{ inputs.os }}.tgz - .github/workflows/scripts/setup-dependencies.sh tests - - name: Tests - timeout-minutes: 60 - shell: bash - run: | - set -o pipefail - /usr/share/zfs/zfs-tests.sh -vKR -s 3G -r sanity | scripts/zfs-tests-color.sh - - name: Prepare artifacts - if: success() || failure() - run: | - RESPATH="/var/tmp/test_results" - mv -f $RESPATH/current $RESPATH/testfiles - tar cf $RESPATH/sanity.tar -h -C $RESPATH testfiles - - uses: actions/upload-artifact@v4 - if: success() || failure() - with: - name: Logs-${{ inputs.os }}-sanity - path: /var/tmp/test_results/sanity.tar - if-no-files-found: ignore - - functional: - runs-on: ubuntu-${{ inputs.os }} - strategy: - fail-fast: false - matrix: - tests: [ part1, part2, part3, part4 ] - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/download-artifact@v4 - with: - name: modules-${{ inputs.os }} - - name: Install modules - run: | - tar xzf modules-${{ inputs.os }}.tgz - .github/workflows/scripts/setup-dependencies.sh tests - - name: Setup tests - run: | - .github/workflows/scripts/setup-functional.sh ${{ matrix.tests }} >> $GITHUB_ENV - - name: Tests - timeout-minutes: 120 - shell: bash - run: | - set -o pipefail - /usr/share/zfs/zfs-tests.sh -vKR -s 3G -T ${{ env.TODO }} | scripts/zfs-tests-color.sh - - name: Prepare artifacts - if: success() || failure() - run: | - RESPATH="/var/tmp/test_results" - mv -f $RESPATH/current $RESPATH/testfiles - tar cf $RESPATH/${{ matrix.tests }}.tar -h -C $RESPATH testfiles - - uses: actions/upload-artifact@v4 - if: success() || failure() - with: - name: Logs-${{ inputs.os }}-functional-${{ matrix.tests }} - path: /var/tmp/test_results/${{ matrix.tests }}.tar - if-no-files-found: ignore diff --git a/.github/workflows/zfs-linux.yml b/.github/workflows/zfs-linux.yml deleted file mode 100644 index e6b705c86055..000000000000 --- a/.github/workflows/zfs-linux.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: zfs-linux - -on: - push: - pull_request: - -jobs: - - build: - name: Build - strategy: - fail-fast: false - matrix: - os: [20.04, 22.04] - runs-on: ubuntu-${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - name: Build modules - run: .github/workflows/scripts/setup-dependencies.sh build - - name: Prepare modules upload - run: tar czf modules-${{ matrix.os }}.tgz *.deb .github tests/test-runner tests/ImageOS.txt - - uses: actions/upload-artifact@v4 - with: - name: modules-${{ matrix.os }} - path: modules-${{ matrix.os }}.tgz - retention-days: 14 - - testings: - name: Testing - strategy: - fail-fast: false - matrix: - os: [20.04, 22.04] - needs: build - uses: ./.github/workflows/zfs-linux-tests.yml - with: - os: ${{ matrix.os }} - - cleanup: - if: always() - name: Cleanup - runs-on: ubuntu-22.04 - needs: testings - steps: - - uses: actions/download-artifact@v4 - - name: Generating summary - run: | - tar xzf modules-22.04/modules-22.04.tgz .github tests - .github/workflows/scripts/generate-summary.sh - # up to 4 steps, each can have 1 MiB output (for debugging log files) - - name: Summary for errors #1 - run: .github/workflows/scripts/generate-summary.sh 1 - - name: Summary for errors #2 - run: .github/workflows/scripts/generate-summary.sh 2 - - name: Summary for errors #3 - run: .github/workflows/scripts/generate-summary.sh 3 - - name: Summary for errors #4 - run: .github/workflows/scripts/generate-summary.sh 4 - - uses: actions/upload-artifact@v4 - with: - name: Summary Files - path: Summary/ diff --git a/.github/workflows/zfs-qemu.yml b/.github/workflows/zfs-qemu.yml index a3381a955e94..18004c489479 100644 --- a/.github/workflows/zfs-qemu.yml +++ b/.github/workflows/zfs-qemu.yml @@ -14,11 +14,7 @@ jobs: # all: # os: [almalinux8, almalinux9, archlinux, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] # openzfs: - os: [almalinux8, almalinux9, centos-stream9, debian11, debian12, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r] - # freebsd: - # os: [freebsd13, freebsd14] - # small test: - # os: [archlinux] + os: [almalinux8, almalinux9, centos-stream9, debian11, debian12, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r, ubuntu20, ubuntu22, ubuntu24] runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/zloop.yml b/.github/workflows/zloop.yml new file mode 100644 index 000000000000..bf0762ff9ac3 --- /dev/null +++ b/.github/workflows/zloop.yml @@ -0,0 +1,61 @@ +name: zloop + +on: + push: + pull_request: + +jobs: + zloop: + runs-on: ubuntu-24.04 + env: + TEST_DIR: /var/tmp/zloop + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Install dependencies + run: | + sudo apt-get purge -y snapd google-chrome-stable firefox + ONLY_DEPS=1 .github/workflows/scripts/qemu-3-deps.sh ubuntu24 + - name: Autogen.sh + run: | + sed -i '/DEBUG_CFLAGS="-Werror"/s/^/#/' config/zfs-build.m4 + ./autogen.sh + - name: Configure + run: | + ./configure --prefix=/usr --enable-debug --enable-debuginfo \ + --enable-asan --enable-ubsan \ + --enable-debug-kmem --enable-debug-kmem-tracking + - name: Make + run: | + make -j$(nproc) + - name: Install + run: | + sudo make install + sudo depmod + sudo modprobe zfs + - name: Tests + run: | + sudo mkdir -p $TEST_DIR + # run for 10 minutes or at most 6 iterations for a maximum runner + # time of 60 minutes. + sudo /usr/share/zfs/zloop.sh -t 600 -I 6 -l -m1 -- -T 120 -P 60 + - name: Prepare artifacts + if: failure() + run: | + sudo chmod +r -R $TEST_DIR/ + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: Logs + path: | + /var/tmp/zloop/*/ + !/var/tmp/zloop/*/vdev/ + if-no-files-found: ignore + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: Pool files + path: | + /var/tmp/zloop/*/vdev/ + if-no-files-found: ignore From e2bded28ea17211a3e8e55c4376f329f66a3d782 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Fri, 20 Sep 2024 23:06:19 +0500 Subject: [PATCH 018/223] ZTS: Fix skipping over comment lines in zpool_create.shlib In zpool_create.shlib, check_feature_set iterates over all features mentioned in provided compatibility file to check if only those features are enabled on the pool. This commit fixes skipping over comment lines correctly. Otherwise, the test case fails as comment lines are also treated as feature names by check_feature_set function. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Umer Saleem Closes #15909 --- .../functional/cli_root/zpool_create/zpool_create.shlib | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib index 4987bc3a9dac..765be8ac0dd1 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib @@ -119,9 +119,8 @@ function check_feature_set while read line; do typeset flag=1 - if [[ "$line" == "#*" ]]; then - continue - fi + # Skip comments + [[ $line = \#* ]] && continue for set in "$@"; do if ! grep -q "$line" $ZPOOL_COMPAT_DIR/$set; then From 484f92b8fa36c3d00c99b51df5074bedcf41f417 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Sun, 22 Sep 2024 20:21:42 +0400 Subject: [PATCH 019/223] ZTS: Fix Summary Page The qemu-9-summary-page.sh script reads the file env.txt in the first lines. When the module didn't build, this file was not copied into the tarfile - causing the scipt to abort. Fix: copy needed files into the tarfile in case of module build failures. The fix ignores also empty tarfiles in future. Reviewed-by: Brian Behlendorf Signed-off-by: Tino Reichardt Closes #16555 --- .github/workflows/scripts/qemu-7-prepare.sh | 1 + .github/workflows/scripts/qemu-9-summary-page.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scripts/qemu-7-prepare.sh b/.github/workflows/scripts/qemu-7-prepare.sh index 4e2583731d70..a5fbd7213161 100755 --- a/.github/workflows/scripts/qemu-7-prepare.sh +++ b/.github/workflows/scripts/qemu-7-prepare.sh @@ -18,6 +18,7 @@ if [ -z ${VMs:-} ]; then cd $RESPATH echo ":exclamation: ZFS module didn't build successfully :exclamation:" \ | tee summary.txt | tee /tmp/summary.txt + cp /var/tmp/*.txt . tar cf /tmp/qemu-$OS.tar -C $RESPATH -h . || true exit 0 fi diff --git a/.github/workflows/scripts/qemu-9-summary-page.sh b/.github/workflows/scripts/qemu-9-summary-page.sh index 036004882fec..2f4c21f9910a 100755 --- a/.github/workflows/scripts/qemu-9-summary-page.sh +++ b/.github/workflows/scripts/qemu-9-summary-page.sh @@ -34,13 +34,14 @@ function send2github() { if [ ! -f out-1.md ]; then logfile="1" for tarfile in Logs-functional-*/qemu-*.tar; do + rm -rf vm* *.txt if [ ! -s "$tarfile" ]; then output "\n## Functional Tests: unknown\n" output ":exclamation: Tarfile $tarfile is empty :exclamation:" continue fi - rm -rf vm* *.txt tar xf "$tarfile" + test -s env.txt || continue source env.txt output "\n## Functional Tests: $OSNAME\n" outfile_plain uname.txt From b69c7f38476a8814318205b7944a421a241a8a3e Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 20 Sep 2024 17:10:11 -0700 Subject: [PATCH 020/223] ZTS: Retire "ci_reason" exceptions There is no longer be a need for the ci_reason exception with the update CI GitHub Actions infrastruture. Retire it. Reviewed-by: Tino Reichardt Reviewed-by: George Melikov Signed-off-by: Brian Behlendorf Closes #16553 --- tests/test-runner/bin/zts-report.py.in | 36 -------------------------- 1 file changed, 36 deletions(-) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index 4d39c5a6958e..b068bc2edada 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -124,11 +124,6 @@ fspacectl_reason = 'fspacectl(2) and truncate -d support required' # na_reason = "Not applicable" -# -# Some test cases doesn't have all requirements to run on Github actions CI. -# -ci_reason = 'CI runner doesn\'t have all requirements' - # # Idmapped mount is only supported in kernel version >= 5.12 # @@ -354,37 +349,6 @@ elif sys.platform.startswith('linux'): 'mmp/mmp_inactive_import': ['FAIL', known_reason], }) -# Not all Github actions runners have scsi_debug module, so we may skip -# some tests which use it. -if os.environ.get('CI') == 'true': - known.update({ - 'cli_root/zpool_expand/zpool_expand_001_pos': ['SKIP', ci_reason], - 'cli_root/zpool_expand/zpool_expand_003_neg': ['SKIP', ci_reason], - 'cli_root/zpool_expand/zpool_expand_005_pos': ['SKIP', ci_reason], - 'cli_root/zpool_reopen/setup': ['SKIP', ci_reason], - 'cli_root/zpool_reopen/zpool_reopen_001_pos': ['SKIP', ci_reason], - 'cli_root/zpool_reopen/zpool_reopen_002_pos': ['SKIP', ci_reason], - 'cli_root/zpool_reopen/zpool_reopen_003_pos': ['SKIP', ci_reason], - 'cli_root/zpool_reopen/zpool_reopen_004_pos': ['SKIP', ci_reason], - 'cli_root/zpool_reopen/zpool_reopen_005_pos': ['SKIP', ci_reason], - 'cli_root/zpool_reopen/zpool_reopen_006_neg': ['SKIP', ci_reason], - 'cli_root/zpool_reopen/zpool_reopen_007_pos': ['SKIP', ci_reason], - 'cli_root/zpool_split/zpool_split_wholedisk': ['SKIP', ci_reason], - 'fault/auto_offline_001_pos': ['SKIP', ci_reason], - 'fault/auto_online_001_pos': ['SKIP', ci_reason], - 'fault/auto_online_002_pos': ['SKIP', ci_reason], - 'fault/auto_replace_001_pos': ['SKIP', ci_reason], - 'fault/auto_replace_002_pos': ['SKIP', ci_reason], - 'fault/auto_spare_ashift': ['SKIP', ci_reason], - 'fault/auto_spare_shared': ['SKIP', ci_reason], - 'fault/suspend_resume_single': ['SKIP', ci_reason], - 'procfs/pool_state': ['SKIP', ci_reason], - }) - - maybe.update({ - 'events/events_002_pos': ['FAIL', 11546], - }) - def process_results(pathname): try: From 46b0d5c486e58d2d57d7aa36af42cb3979c64bbe Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 20 Sep 2024 17:37:55 -0700 Subject: [PATCH 021/223] ZTS: Retire "tmpfile_reason" exception All supported Linux kernels, 4.18 and newer, provide O_TMPFILE. Reviewed-by: Tino Reichardt Reviewed-by: George Melikov Signed-off-by: Brian Behlendorf Closes #16553 --- tests/test-runner/bin/zts-report.py.in | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index b068bc2edada..8ecddb4427ad 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -66,12 +66,6 @@ exec_reason = 'Test user execute permissions required for utilities' # renameat2_reason = 'Kernel renameat2 support required' -# -# Some tests require the O_TMPFILE flag which was first introduced in the -# 3.11 kernel. -# -tmpfile_reason = 'Kernel O_TMPFILE support required' - # # Some tests require the statx(2) system call on Linux which was first # introduced in the 4.11 kernel. @@ -246,7 +240,6 @@ maybe = { 'snapshot/snapshot_009_pos': ['FAIL', 7961], 'snapshot/snapshot_010_pos': ['FAIL', 7961], 'snapused/snapused_004_pos': ['FAIL', 5513], - 'tmpfile/setup': ['SKIP', tmpfile_reason], 'trim/setup': ['SKIP', trim_reason], 'upgrade/upgrade_projectquota_001_pos': ['SKIP', project_id_reason], 'user_namespace/setup': ['SKIP', user_ns_reason], From ce3ad59c27fe3581c452571d2c354a13ee430e21 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 20 Sep 2024 17:33:05 -0700 Subject: [PATCH 022/223] ZTS: Add additional exceptions The following tests have been observed to occasionally fail when running under the CI. Updated our exceptions list to track them. Reviewed-by: Tino Reichardt Reviewed-by: George Melikov Signed-off-by: Brian Behlendorf Closes #16553 --- tests/test-runner/bin/zts-report.py.in | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index 8ecddb4427ad..09557e4be789 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -201,6 +201,7 @@ maybe = { 'chattr/setup': ['SKIP', exec_reason], 'crtime/crtime_001_pos': ['SKIP', statx_reason], 'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason], + 'cli_root/zfs_copies/zfs_copies_006_pos': ['FAIL', known_reason], 'cli_root/zfs_destroy/zfs_destroy_dev_removal_condense': ['FAIL', known_reason], 'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason], @@ -215,11 +216,18 @@ maybe = { 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', 6839], 'cli_root/zpool_initialize/zpool_initialize_import_export': ['FAIL', 11948], + 'cli_root/zpool_initialize/zpool_initialize_suspend_resume': + ['FAIL', known_reason], 'cli_root/zpool_labelclear/zpool_labelclear_removed': ['FAIL', known_reason], 'cli_root/zpool_trim/setup': ['SKIP', trim_reason], + 'cli_root/zpool_trim/zpool_trim_fault_export_import_online': + ['FAIL', known_reason], 'cli_root/zpool_upgrade/zpool_upgrade_004_pos': ['FAIL', 6141], + 'cli_user/misc/arc_summary_001_pos': ['FAIL', known_reason], 'delegate/setup': ['SKIP', exec_reason], + 'events/zed_cksum_config': ['FAIL', known_reason], + 'fault/auto_replace_002_pos': ['FAIL', known_reason], 'fallocate/fallocate_punch-hole': ['SKIP', fspacectl_reason], 'history/history_004_pos': ['FAIL', 7026], 'history/history_005_neg': ['FAIL', 6680], @@ -227,16 +235,24 @@ maybe = { 'history/history_008_pos': ['FAIL', known_reason], 'history/history_010_pos': ['SKIP', exec_reason], 'io/mmap': ['SKIP', fio_reason], + 'l2arc/l2arc_l2miss_pos': ['FAIL', known_reason], + 'l2arc/persist_l2arc_005_pos': ['FAIL', known_reason], 'largest_pool/largest_pool_001_pos': ['FAIL', known_reason], + 'mmap/mmap_sync_001_pos': ['FAIL', known_reason], 'mmp/mmp_on_uberblocks': ['FAIL', known_reason], 'pam/setup': ['SKIP', "pamtester might be not available"], 'pool_checkpoint/checkpoint_discard_busy': ['FAIL', 11946], 'projectquota/setup': ['SKIP', exec_reason], + 'raidz/raidz_002_pos': ['FAIL', known_reason], + 'raidz/raidz_expand_001_pos': ['FAIL', 16421], + 'redundancy/redundancy_draid_spare1': ['FAIL', known_reason], + 'redundancy/redundancy_draid_spare3': ['FAIL', known_reason], 'removal/removal_condense_export': ['FAIL', known_reason], 'renameat2/setup': ['SKIP', renameat2_reason], 'reservation/reservation_008_pos': ['FAIL', 7741], 'reservation/reservation_018_pos': ['FAIL', 5642], 'snapshot/clone_001_pos': ['FAIL', known_reason], + 'snapshot/snapshot_006_pos': ['FAIL', known_reason], 'snapshot/snapshot_009_pos': ['FAIL', 7961], 'snapshot/snapshot_010_pos': ['FAIL', 7961], 'snapused/snapused_004_pos': ['FAIL', 5513], From af0a2bef4035dad65d94241beb8b4ca65316501c Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 23 Sep 2024 17:07:29 -0700 Subject: [PATCH 023/223] ZTS: CodeQL Action v3 update Switch from v2 to v3 CodeQL Actions. The v2 actions will no longer be supported as of Dec '24 so we need to move to v3. According to the release notes they should be functionally equivalent. Note that the only difference between v2 and v3 of the CodeQL Action is the node version they support, ... For example 3.22.11 was the first v3 release and is functionally identical to 2.22.11. https://github.com/github/codeql-action/blob/main/CHANGELOG.md Reviewed-by: George Melikov Signed-off-by: Brian Behlendorf Closes #16560 --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index e015b2cb71d9..f70f6bf86ea8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -27,15 +27,15 @@ jobs: uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: config-file: .github/codeql-${{ matrix.language }}.yml languages: ${{ matrix.language }} - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" From 1b27b76f6f594112de8b38ddda5d188c7b08a314 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 23 Sep 2024 22:04:27 -0700 Subject: [PATCH 024/223] ZTS: CI Documentation Updates Update the CONTRIBUTING.md documentation to refer to the GitHub Actions workflows which have replaced the buildbot infrastructure. Signed-off-by: Brian Behlendorf Closes #16561 --- .github/CONTRIBUTING.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f28a747e82c4..217c9b22ce68 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -145,22 +145,15 @@ Once everything is in good shape and the details have been worked out you can re Any required reviews can then be finalized and the pull request merged. #### Tests and Benchmarks -* Every pull request will by tested by the buildbot on multiple platforms by running the [zfs-tests.sh and zloop.sh]( +* Every pull request is tested using a GitHub Actions workflow on multiple platforms by running the [zfs-tests.sh and zloop.sh]( https://openzfs.github.io/openzfs-docs/Developer%20Resources/Building%20ZFS.html#running-zloop-sh-and-zfs-tests-sh) test suites. * To verify your changes conform to the [style guidelines]( https://github.com/openzfs/zfs/blob/master/.github/CONTRIBUTING.md#style-guides ), please run `make checkstyle` and resolve any warnings. -* Static code analysis of each pull request is performed by the buildbot; run `make lint` to check your changes. -* Test cases should be provided when appropriate. -This includes making sure new features have adequate code coverage. +* Code analysis is performed by [CodeQL](https://codeql.github.com/) for each pull request. +* Test cases should be provided when appropriate. This includes making sure new features have adequate code coverage. * If your pull request improves performance, please include some benchmarks. -* The pull request must pass all required [ZFS -Buildbot](http://build.zfsonlinux.org/) builders before -being accepted. If you are experiencing intermittent TEST -builder failures, you may be experiencing a [test suite -issue](https://github.com/openzfs/zfs/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Test+Suite%22). -There are also various [buildbot options](https://openzfs.github.io/openzfs-docs/Developer%20Resources/Buildbot%20Options.html) -to control how changes are tested. +* The pull request must pass all CI checks before being accepted. ### Testing All help is appreciated! If you're in a position to run the latest code From 040be2504a32bd48c3e86da5fcb55e94ee602dd6 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 24 Sep 2024 09:02:01 -0700 Subject: [PATCH 025/223] CI: cancel workflows when PRs are updated (#16562) For checkstyle, zloop, zfs-qemu, and codeql workflows cancel in-progress jobs when the PR is updated. Relevant GitHub Actions documentation: The following concurrency group cancels in-progress jobs or run on pull_request events only; if github.head_ref is undefined, the concurrency group will fallback to the run ID, which is guaranteed to be both unique and defined for the run. https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value Signed-off-by: Brian Behlendorf Closes #16562 --- .github/workflows/checkstyle.yaml | 4 ++++ .github/workflows/codeql.yml | 4 ++++ .github/workflows/zfs-qemu.yml | 5 ++++- .github/workflows/zloop.yml | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checkstyle.yaml b/.github/workflows/checkstyle.yaml index 088d28d52a90..b34ca1302873 100644 --- a/.github/workflows/checkstyle.yaml +++ b/.github/workflows/checkstyle.yaml @@ -4,6 +4,10 @@ on: push: pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: checkstyle: runs-on: ubuntu-22.04 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f70f6bf86ea8..2656a20fea0d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -4,6 +4,10 @@ on: push: pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: analyze: name: Analyze diff --git a/.github/workflows/zfs-qemu.yml b/.github/workflows/zfs-qemu.yml index 18004c489479..67d915adfef5 100644 --- a/.github/workflows/zfs-qemu.yml +++ b/.github/workflows/zfs-qemu.yml @@ -4,8 +4,11 @@ on: push: pull_request: -jobs: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +jobs: qemu-vm: name: qemu-x86 strategy: diff --git a/.github/workflows/zloop.yml b/.github/workflows/zloop.yml index bf0762ff9ac3..35d8cc977af0 100644 --- a/.github/workflows/zloop.yml +++ b/.github/workflows/zloop.yml @@ -4,6 +4,10 @@ on: push: pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: zloop: runs-on: ubuntu-24.04 From 92c384cbac1fae51e14efa000e3c47fea3a989c3 Mon Sep 17 00:00:00 2001 From: Shengqi Chen Date: Wed, 25 Sep 2024 22:46:52 +0800 Subject: [PATCH 026/223] CI: run only sanity check on limited OSes for nonbehavioral changes The commit uses heuristics to determine whether a PR is behavioral: It runs "quick" CI (i.e., only use sanity.run on fewer OSes) if (explicitly requested by user): - the *last* commit message contains a line 'ZFS-CI-Type: quick', or if (by heuristics): - the files changed are not in the list of specified directory, and - all commit messages does not contain 'ZFS-CI-Type: full'. It runs "full" CI otherwise. Reviewed-by: Brian Behlendorf Reviewed-by: Tino Reichardt Signed-off-by: Shengqi Chen Closes #16564 --- .github/CONTRIBUTING.md | 3 + .github/workflows/scripts/generate-ci-type.py | 107 ++++++++++++++++++ .github/workflows/scripts/qemu-6-tests.sh | 5 +- .github/workflows/zfs-qemu.yml | 37 +++++- 4 files changed, 150 insertions(+), 2 deletions(-) create mode 100755 .github/workflows/scripts/generate-ci-type.py diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 217c9b22ce68..7e8d1bafb0f3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -147,6 +147,9 @@ Any required reviews can then be finalized and the pull request merged. #### Tests and Benchmarks * Every pull request is tested using a GitHub Actions workflow on multiple platforms by running the [zfs-tests.sh and zloop.sh]( https://openzfs.github.io/openzfs-docs/Developer%20Resources/Building%20ZFS.html#running-zloop-sh-and-zfs-tests-sh) test suites. +`.github/workflows/scripts/generate-ci-type.py` is used to determine whether the pull request is nonbehavior, i.e., not introducing behavior changes of any code, configuration or tests. If so, the CI will run on fewer platforms and only essential sanity tests will run. You can always override this by adding `ZFS-CI-Type` line to your commit message: + * If your last commit (or `HEAD` in git terms) contains a line `ZFS-CI-Type: quick`, quick mode is forced regardless of what files are changed. + * Otherwise, if any commit in a PR contains a line `ZFS-CI-Type: full`, full mode is forced. * To verify your changes conform to the [style guidelines]( https://github.com/openzfs/zfs/blob/master/.github/CONTRIBUTING.md#style-guides ), please run `make checkstyle` and resolve any warnings. diff --git a/.github/workflows/scripts/generate-ci-type.py b/.github/workflows/scripts/generate-ci-type.py new file mode 100755 index 000000000000..943aae254469 --- /dev/null +++ b/.github/workflows/scripts/generate-ci-type.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 + +""" +Determine the CI type based on the change list and commit message. + +Prints "quick" if (explicity required by user): +- the *last* commit message contains 'ZFS-CI-Type: quick' +or if (heuristics): +- the files changed are not in the list of specified directories, and +- all commit messages do not contain 'ZFS-CI-Type: full' + +Otherwise prints "full". +""" + +import sys +import subprocess +import re + +""" +Patterns of files that are not considered to trigger full CI. +Note: not using pathlib.Path.match() because it does not support '**' +""" +FULL_RUN_IGNORE_REGEX = list(map(re.compile, [ + r'.*\.md', + r'.*\.gitignore' +])) + +""" +Patterns of files that are considered to trigger full CI. +""" +FULL_RUN_REGEX = list(map(re.compile, [ + r'cmd.*', + r'configs/.*', + r'META', + r'.*\.am', + r'.*\.m4', + r'autogen\.sh', + r'configure\.ac', + r'copy-builtin', + r'contrib', + r'etc', + r'include', + r'lib/.*', + r'module/.*', + r'scripts/.*', + r'tests/.*', + r'udev/.*' +])) + +if __name__ == '__main__': + + prog = sys.argv[0] + + if len(sys.argv) != 3: + print(f'Usage: {prog} ') + sys.exit(1) + + head, base = sys.argv[1:3] + + def output_type(type, reason): + print(f'{prog}: will run {type} CI: {reason}', file=sys.stderr) + print(type) + sys.exit(0) + + # check last (HEAD) commit message + last_commit_message_raw = subprocess.run([ + 'git', 'show', '-s', '--format=%B', 'HEAD' + ], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + for line in last_commit_message_raw.stdout.decode().splitlines(): + if line.strip().lower() == 'zfs-ci-type: quick': + output_type('quick', f'explicitly requested by HEAD commit {head}') + + # check all commit messages + all_commit_message_raw = subprocess.run([ + 'git', 'show', '-s', + '--format=ZFS-CI-Commit: %H%n%B', f'{head}...{base}' + ], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + all_commit_message = all_commit_message_raw.stdout.decode().splitlines() + + commit_ref = head + for line in all_commit_message: + if line.startswith('ZFS-CI-Commit:'): + commit_ref = line.lstrip('ZFS-CI-Commit:').rstrip() + if line.strip().lower() == 'zfs-ci-type: full': + output_type('full', f'explicitly requested by commit {commit_ref}') + + # check changed files + changed_files_raw = subprocess.run([ + 'git', 'diff', '--name-only', head, base + ], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + changed_files = changed_files_raw.stdout.decode().splitlines() + + for f in changed_files: + for r in FULL_RUN_IGNORE_REGEX: + if r.match(f): + break + else: + for r in FULL_RUN_REGEX: + if r.match(f): + output_type( + 'full', + f'changed file "{f}" matches pattern "{r.pattern}"' + ) + + # catch-all + output_type('quick', 'no changed file matches full CI patterns') diff --git a/.github/workflows/scripts/qemu-6-tests.sh b/.github/workflows/scripts/qemu-6-tests.sh index fac953c8fa56..2f023198bbf6 100755 --- a/.github/workflows/scripts/qemu-6-tests.sh +++ b/.github/workflows/scripts/qemu-6-tests.sh @@ -48,7 +48,7 @@ if [ -z ${1:-} ]; then for i in $(seq 1 $VMs); do IP="192.168.122.1$i" daemonize -c /var/tmp -p vm${i}.pid -o vm${i}log.txt -- \ - $SSH zfs@$IP $TESTS $OS $i $VMs + $SSH zfs@$IP $TESTS $OS $i $VMs $CI_TYPE # handly line by line and add info prefix stdbuf -oL tail -fq vm${i}log.txt \ | while read -r line; do prefix "$i" "$line"; done & @@ -91,6 +91,9 @@ esac # run functional testings and save exitcode cd /var/tmp TAGS=$2/$3 +if [ "$4" == "quick" ]; then + export RUNFILES="sanity.run" +fi sudo dmesg -c > dmesg-prerun.txt mount > mount.txt df -h > df-prerun.txt diff --git a/.github/workflows/zfs-qemu.yml b/.github/workflows/zfs-qemu.yml index 67d915adfef5..8922701f9899 100644 --- a/.github/workflows/zfs-qemu.yml +++ b/.github/workflows/zfs-qemu.yml @@ -9,15 +9,48 @@ concurrency: cancel-in-progress: true jobs: + test-config: + name: Setup + runs-on: ubuntu-24.04 + outputs: + test_os: ${{ steps.os.outputs.os }} + ci_type: ${{ steps.os.outputs.ci_type }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Generate OS config and CI type + id: os + run: | + FULL_OS='["almalinux8", "almalinux9", "centos-stream9", "debian11", "debian12", "fedora39", "fedora40", "freebsd13", "freebsd13r", "freebsd14", "freebsd14r", "ubuntu20", "ubuntu22", "ubuntu24"]' + QUICK_OS='["almalinux8", "almalinux9", "debian12", "fedora40", "freebsd13", "freebsd14", "ubuntu24"]' + # determine CI type when running on PR + ci_type="full" + if ${{ github.event_name == 'pull_request' }}; then + head=${{ github.event.pull_request.head.sha }} + base=${{ github.event.pull_request.base.sha }} + ci_type=$(python3 .github/workflows/scripts/generate-ci-type.py $head $base) + fi + if [ "$ci_type" == "quick" ]; then + os_selection="$QUICK_OS" + else + os_selection="$FULL_OS" + fi + os_json=$(echo ${os_selection} | jq -c) + echo "os=$os_json" >> $GITHUB_OUTPUT + echo "ci_type=$ci_type" >> $GITHUB_OUTPUT + qemu-vm: name: qemu-x86 + needs: [ test-config ] strategy: fail-fast: false matrix: # all: # os: [almalinux8, almalinux9, archlinux, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] # openzfs: - os: [almalinux8, almalinux9, centos-stream9, debian11, debian12, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r, ubuntu20, ubuntu22, ubuntu24] + # os: [almalinux8, almalinux9, centos-stream9, debian11, debian12, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r, ubuntu20, ubuntu22, ubuntu24] + os: ${{ fromJson(needs.test-config.outputs.test_os) }} runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -67,6 +100,8 @@ jobs: - name: Run tests timeout-minutes: 270 run: .github/workflows/scripts/qemu-6-tests.sh + env: + CI_TYPE: ${{ needs.test-config.outputs.ci_type }} - name: Prepare artifacts if: always() From f407add033e36b48773baf4db5e8bb412cca1b93 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 26 Sep 2024 09:58:11 -0700 Subject: [PATCH 027/223] ZTS: Fix zpool_import_hostid_changed_cachefile_unclean_export Update the test case to freeze the pool then export it to better simulate a hard failure. This is preferable to copying the vdev while the pool's imported since with a copy we're not guaranteed the on-disk state will be consistent. That can in turn result in a pool import failure and a spurious test failure. Reviewed-by: Alexander Motin Signed-off-by: Brian Behlendorf Closes #16570 --- ..._import_hostid_changed_cachefile_unclean_export.ksh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh index dcb1ac1ab69f..c4273d050422 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh @@ -28,9 +28,8 @@ # 2. Create a pool. # 3. Backup the cachefile. # 4. Simulate the pool being torn down without export: -# 4.1. Copy the underlying device state. -# 4.2. Export the pool. -# 4.3. Restore the device state from the copy. +# 4.1. Sync then freeze the pool. +# 4.2. Export the pool (uncleanly). # 5. Change the hostid. # 6. Verify that importing the pool from the cachefile fails. # 7. Verify that importing the pool from the cachefile with force @@ -57,10 +56,9 @@ log_must zpool create -o cachefile=$CPATH $TESTPOOL1 $VDEV0 log_must cp $CPATH $CPATHBKP # 4. Simulate the pool being torn down without export. -log_must cp $VDEV0 $VDEV0.bak +sync_pool $TESTPOOL1 +log_must zpool freeze $TESTPOOL1 log_must zpool export $TESTPOOL1 -log_must cp -f $VDEV0.bak $VDEV0 -log_must rm -f $VDEV0.bak # 5. Change the hostid. log_must zgenhostid -f $HOSTID2 From ad739614ccf0e205706b1c3c0e7ac95f00817741 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 27 Sep 2024 09:05:49 -0700 Subject: [PATCH 028/223] CI: Add logs to zloop workflow On failure attempt to include the most relevant portions of the ztest logs in the CI output. This full logs are still available for download but often a backtrace and the last output is enough. Install libunwind to improve the odds of a useful backtrace. Reviewed-by: Tino Reichardt Signed-off-by: Brian Behlendorf Closes #16573 --- .github/workflows/scripts/qemu-3-deps.sh | 6 +++--- .github/workflows/zloop.yml | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/qemu-3-deps.sh b/.github/workflows/scripts/qemu-3-deps.sh index 02bff954fd5b..35fa5016e9f6 100755 --- a/.github/workflows/scripts/qemu-3-deps.sh +++ b/.github/workflows/scripts/qemu-3-deps.sh @@ -32,9 +32,9 @@ function debian() { sudo apt-get install -y \ acl alien attr autoconf bc cpio curl dbench dh-python dkms fakeroot \ fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev libaio-dev \ - libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev \ - libelf-dev libffi-dev libmount-dev libpam0g-dev libselinux-dev \ - libssl-dev libtool libtool-bin libudev-dev linux-headers-$(uname -r) \ + libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev libelf-dev \ + libffi-dev libmount-dev libpam0g-dev libselinux-dev libssl-dev libtool \ + libtool-bin libudev-dev libunwind-dev linux-headers-$(uname -r) \ lsscsi nfs-kernel-server pamtester parted python3 python3-all-dev \ python3-cffi python3-dev python3-distlib python3-packaging \ python3-setuptools python3-sphinx qemu-guest-agent rng-tools rpm2cpio \ diff --git a/.github/workflows/zloop.yml b/.github/workflows/zloop.yml index 35d8cc977af0..90d93c48e4bd 100644 --- a/.github/workflows/zloop.yml +++ b/.github/workflows/zloop.yml @@ -43,11 +43,23 @@ jobs: sudo mkdir -p $TEST_DIR # run for 10 minutes or at most 6 iterations for a maximum runner # time of 60 minutes. - sudo /usr/share/zfs/zloop.sh -t 600 -I 6 -l -m1 -- -T 120 -P 60 + sudo /usr/share/zfs/zloop.sh -t 600 -I 6 -l -m 1 -- -T 120 -P 60 - name: Prepare artifacts if: failure() run: | sudo chmod +r -R $TEST_DIR/ + - name: Ztest log + if: failure() + run: | + grep -B10 -A1000 'ASSERT' $TEST_DIR/*/ztest.out || tail -n 1000 $TEST_DIR/*/ztest.out + - name: Gdb log + if: failure() + run: | + sed -n '/Backtraces (full)/q;p' $TEST_DIR/*/ztest.gdb + - name: Zdb log + if: failure() + run: | + cat $TEST_DIR/*/ztest.zdb - uses: actions/upload-artifact@v4 if: failure() with: From 54244d263a8211fbe5221dd5be77c0e4558fa335 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 27 Sep 2024 09:14:13 -0700 Subject: [PATCH 029/223] ZTS: Update deadman_sync threshold Lower the minimum number of expected deadman events from 4 to 3. All that is strictly required is a single event to consider the test a pass. However, since I've never seen a count of less than 3 reported by the CI that should be sufficient. Reviewed-by: Alexander Motin Reviewed-by: George Melikov Reviewed-by: Tino Reichardt Signed-off-by: Brian Behlendorf Closes #16575 --- tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh b/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh index 34a8821725a6..f1561b7282e5 100755 --- a/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh +++ b/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh @@ -62,7 +62,7 @@ log_must set_tunable64 DEADMAN_FAILMODE "wait" default_setup_noexit $DISK1 log_must zpool events -c -# Force each IO to take 10s by allow them to run concurrently. +# Force each IO to take 10s but allow them to run concurrently. log_must zinject -d $DISK1 -D10000:10 $TESTPOOL mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS) @@ -80,11 +80,11 @@ else fi log_must zpool events -# Verify at least 4 deadman events were logged. The first after 5 seconds, +# Verify at least 3 deadman events were logged. The first after 5 seconds, # and another each second thereafter until the delay is clearer. events=$(zpool events | grep -c ereport.fs.zfs.deadman) -if [ "$events" -lt 4 ]; then - log_fail "Expect >=5 deadman events, $events found" +if [ "$events" -lt 3 ]; then + log_fail "Expect >=3 deadman events, $events found" fi log_pass "Verify spa deadman detected a hung txg and $events deadman events" From a44a15d318195e25ce712d690f7f61c66232d585 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Sat, 28 Sep 2024 09:18:21 -0700 Subject: [PATCH 030/223] ZTS: Fix zpool_import_hostid_changed_unclean_export Update the test case to freeze the pool then export it to better simulate a hard failure. This is preferable to copying the vdev while the pool's imported since with a copy we're not guaranteed the on-disk state will be consistent. That can in turn result in a pool import failure and a spurious test failure. Reviewed-by: Tino Reichardt Signed-off-by: Brian Behlendorf Closes #16578 --- .../zpool_import_hostid_changed_unclean_export.ksh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_unclean_export.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_unclean_export.ksh index ad8cca642dbc..abbe9acff629 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_unclean_export.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_unclean_export.ksh @@ -27,8 +27,8 @@ # 1. Set a hostid. # 2. Create a pool. # 3. Simulate the pool being torn down without export: -# 3.1. Copy the underlying device state. -# 3.2. Export the pool. +# 3.1. Sync then freeze the pool. +# 3.2. Export the pool (uncleanly). # 3.3. Restore the device state from the copy. # 4. Change the hostid. # 5. Verify that importing the pool fails. @@ -52,10 +52,9 @@ log_must zgenhostid -f $HOSTID1 log_must zpool create $TESTPOOL1 $VDEV0 # 3. Simulate the pool being torn down without export. -log_must cp $VDEV0 $VDEV0.bak +sync_pool $TESTPOOL1 +log_must zpool freeze $TESTPOOL1 log_must zpool export $TESTPOOL1 -log_must cp -f $VDEV0.bak $VDEV0 -log_must rm -f $VDEV0.bak # 4. Change the hostid. log_must zgenhostid -f $HOSTID2 From e55e9468f7caa9f03c63b452339f924f630ded2a Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Sat, 28 Sep 2024 20:24:05 +0400 Subject: [PATCH 031/223] ZTS: Replace MD5 and SHA256 wit XXH128 For data integrity checks as done in ZTS, the verification for unintended data corruption with xxhash128 should be a lot faster and perfectly usable. Reviewed-by: Brian Behlendorf Signed-off-by: Tino Reichardt Closes #16577 --- .github/workflows/scripts/qemu-3-deps.sh | 9 +++-- tests/zfs-tests/include/commands.cfg | 7 ++-- tests/zfs-tests/include/libtest.shlib | 19 ++++++----- .../functional/bclone/bclone_common.kshlib | 4 +-- .../bclone/bclone_corner_cases.kshlib | 6 ++-- .../block_cloning/block_cloning.kshlib | 4 +-- .../block_cloning_cross_enc_dataset.ksh | 8 ++--- .../functional/cli_root/zdb/zdb_backup.ksh | 4 +-- .../zfs_receive_compressed_corrective.ksh | 4 +-- .../zfs_receive/zfs_receive_corrective.ksh | 6 ++-- .../zfs_receive_from_encrypted.ksh | 6 ++-- .../zfs_receive/zfs_receive_from_zstd.ksh | 4 +-- .../zfs_receive_large_block_corrective.ksh | 4 +-- .../cli_root/zfs_receive/zfs_receive_raw.ksh | 6 ++-- .../zfs_receive_raw_incremental.ksh | 4 +-- .../import_cachefile_shared_device.ksh | 2 +- .../zpool_import/import_devices_missing.ksh | 8 ++--- .../import_rewind_config_changed.ksh | 4 +-- .../import_rewind_device_replaced.ksh | 6 ++-- .../cli_root/zpool_import/zpool_import.cfg | 4 +-- .../cli_root/zpool_import/zpool_import.kshlib | 34 +++++++++---------- .../zpool_reopen/zpool_reopen_003_pos.ksh | 4 +-- .../functional/cp_files/cp_files_002_pos.ksh | 4 +-- .../fault/suspend_resume_single.ksh | 4 +-- .../functional/history/history_003_pos.ksh | 6 ++-- .../functional/no_space/enospc_ganging.ksh | 6 ++-- .../tests/functional/rsend/rsend.kshlib | 14 ++++---- .../tests/functional/rsend/send-c_volume.ksh | 12 +++---- .../rsend/send-wR_encrypted_zvol.ksh | 6 ++-- .../functional/rsend/send_encrypted_props.ksh | 14 ++++---- .../rsend/send_encrypted_truncated_files.ksh | 12 ++----- .../functional/rsend/send_hole_birth.ksh | 2 +- .../functional/slog/slog_replay_fs_001.ksh | 4 +-- .../functional/slog/slog_replay_volume.ksh | 4 +-- 34 files changed, 118 insertions(+), 127 deletions(-) diff --git a/.github/workflows/scripts/qemu-3-deps.sh b/.github/workflows/scripts/qemu-3-deps.sh index 35fa5016e9f6..a2fb5e38249a 100755 --- a/.github/workflows/scripts/qemu-3-deps.sh +++ b/.github/workflows/scripts/qemu-3-deps.sh @@ -16,7 +16,7 @@ function archlinux() { sudo pacman -Sy --noconfirm base-devel bc cpio dhclient dkms fakeroot \ fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils parted \ pax perf python-packaging python-setuptools qemu-guest-agent ksh samba \ - sysstat rng-tools rsync wget + sysstat rng-tools rsync wget xxhash echo "##[endgroup]" } @@ -38,7 +38,7 @@ function debian() { lsscsi nfs-kernel-server pamtester parted python3 python3-all-dev \ python3-cffi python3-dev python3-distlib python3-packaging \ python3-setuptools python3-sphinx qemu-guest-agent rng-tools rpm2cpio \ - rsync samba sysstat uuid-dev watchdog wget xfslibs-dev zlib1g-dev + rsync samba sysstat uuid-dev watchdog wget xfslibs-dev xxhash zlib1g-dev echo "##[endgroup]" } @@ -48,8 +48,7 @@ function freebsd() { echo "##[group]Install Development Tools" sudo pkg install -y autoconf automake autotools base64 checkbashisms fio \ gdb gettext gettext-runtime git gmake gsed jq ksh93 lcov libtool lscpu \ - pkgconf python python3 pamtester pamtester qemu-guest-agent rsync \ - sysutils/coreutils + pkgconf python python3 pamtester pamtester qemu-guest-agent rsync xxhash sudo pkg install -xy \ '^samba4[[:digit:]]+$' \ '^py3[[:digit:]]+-cffi$' \ @@ -76,7 +75,7 @@ function rhel() { lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester parted perf \ python3 python3-cffi python3-devel python3-packaging kernel-devel \ python3-setuptools qemu-guest-agent rng-tools rpcgen rpm-build rsync \ - samba sysstat systemd watchdog wget xfsprogs-devel zlib-devel + samba sysstat systemd watchdog wget xfsprogs-devel xxhash zlib-devel echo "##[endgroup]" } diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index daa794551682..2fd002ed3a42 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -99,7 +99,8 @@ export SYSTEM_FILES_COMMON='awk uniq vmstat wc - xargs' + xargs + xxh128sum' export SYSTEM_FILES_FREEBSD='chflags compress @@ -111,13 +112,11 @@ export SYSTEM_FILES_FREEBSD='chflags jexec jls lsextattr - md5 mdconfig newfs pw rmextattr setextattr - sha256 showmount swapctl sysctl @@ -145,7 +144,6 @@ export SYSTEM_FILES_LINUX='attr lscpu lsmod lsscsi - md5sum mkswap modprobe mountpoint @@ -155,7 +153,6 @@ export SYSTEM_FILES_LINUX='attr perf setfattr setpriv - sha256sum udevadm unshare useradd diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 275872ded7f5..9cf919c3dd0f 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -3455,21 +3455,24 @@ function tunable_exists } # -# Compute MD5 digest for given file or stdin if no file given. +# Compute xxh128sum for given file or stdin if no file given. # Note: file path must not contain spaces # -function md5digest +function xxh128digest { - openssl md5 -r $1 | awk '{print $1}' + xxh128sum $1 | awk '{print $1}' } # -# Compute SHA256 digest for given file or stdin if no file given. -# Note: file path must not contain spaces +# Compare the xxhash128 digest of two files. # -function sha256digest -{ - openssl sha256 -r $1 | awk '{print $1}' +function cmp_xxh128 { + typeset file1=$1 + typeset file2=$2 + + typeset sum1=$(xxh128digest $file1) + typeset sum2=$(xxh128digest $file2) + test "$sum1" = "$sum2" } function new_fs # diff --git a/tests/zfs-tests/tests/functional/bclone/bclone_common.kshlib b/tests/zfs-tests/tests/functional/bclone/bclone_common.kshlib index 84b92b4dcdc9..4c52bebad081 100644 --- a/tests/zfs-tests/tests/functional/bclone/bclone_common.kshlib +++ b/tests/zfs-tests/tests/functional/bclone/bclone_common.kshlib @@ -77,7 +77,7 @@ function test_file_integrity typeset -r clone=$2 typeset -r filesize=$3 - typeset -r clone_checksum=$(sha256digest $clone) + typeset -r clone_checksum=$(xxh128digest $clone) if [[ $original_checksum != $clone_checksum ]]; then log_fail "Clone $clone is corrupted with file size $filesize" @@ -171,7 +171,7 @@ function bclone_test dsize=0 fi - typeset -r original_checksum=$(sha256digest $original) + typeset -r original_checksum=$(xxh128digest $original) sync_pool $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/bclone/bclone_corner_cases.kshlib b/tests/zfs-tests/tests/functional/bclone/bclone_corner_cases.kshlib index aeb8efe91715..dbb47563bebf 100644 --- a/tests/zfs-tests/tests/functional/bclone/bclone_corner_cases.kshlib +++ b/tests/zfs-tests/tests/functional/bclone/bclone_corner_cases.kshlib @@ -32,14 +32,14 @@ function first_half_checksum { typeset -r file=$1 - dd if=$file bs=$HALFRECORDSIZE count=1 2>/dev/null | sha256digest + dd if=$file bs=$HALFRECORDSIZE count=1 2>/dev/null | xxh128digest } function second_half_checksum { typeset -r file=$1 - dd if=$file bs=$HALFRECORDSIZE count=1 skip=1 2>/dev/null | sha256digest + dd if=$file bs=$HALFRECORDSIZE count=1 skip=1 2>/dev/null | xxh128digest } function bclone_corner_cases_init @@ -66,7 +66,7 @@ function bclone_corner_cases_init export SECOND_HALF_ORIG0_CHECKSUM=$(second_half_checksum $ORIG0) export SECOND_HALF_ORIG1_CHECKSUM=$(second_half_checksum $ORIG1) export SECOND_HALF_ORIG2_CHECKSUM=$(second_half_checksum $ORIG2) - export ZEROS_CHECKSUM=$(dd if=/dev/zero bs=$HALFRECORDSIZE count=1 2>/dev/null | sha256digest) + export ZEROS_CHECKSUM=$(dd if=/dev/zero bs=$HALFRECORDSIZE count=1 2>/dev/null | xxh128digest) export FIRST_HALF_CHECKSUM="" export SECOND_HALF_CHECKSUM="" } diff --git a/tests/zfs-tests/tests/functional/block_cloning/block_cloning.kshlib b/tests/zfs-tests/tests/functional/block_cloning/block_cloning.kshlib index 50f3a3d262c0..d59329d8748e 100644 --- a/tests/zfs-tests/tests/functional/block_cloning/block_cloning.kshlib +++ b/tests/zfs-tests/tests/functional/block_cloning/block_cloning.kshlib @@ -28,8 +28,8 @@ function have_same_content { - typeset hash1=$(md5digest $1) - typeset hash2=$(md5digest $2) + typeset hash1=$(xxh128digest $1) + typeset hash2=$(xxh128digest $2) log_must [ "$hash1" = "$hash2" ] } diff --git a/tests/zfs-tests/tests/functional/block_cloning/block_cloning_cross_enc_dataset.ksh b/tests/zfs-tests/tests/functional/block_cloning/block_cloning_cross_enc_dataset.ksh index 702e23267f7e..f85e4f038a3e 100755 --- a/tests/zfs-tests/tests/functional/block_cloning/block_cloning_cross_enc_dataset.ksh +++ b/tests/zfs-tests/tests/functional/block_cloning/block_cloning_cross_enc_dataset.ksh @@ -110,9 +110,9 @@ log_note "Cloning entire file with copy_file_range across different enc" \ clone_and_check "file" "clone" $DS1 $DS2 "" true log_note "check if the file is still readable and the same after" \ "unmount and key unload, shouldn't fail" -typeset hash1=$(md5digest "/$DS1/file") +typeset hash1=$(xxh128digest "/$DS1/file") log_must zfs umount $DS1 && zfs unload-key $DS1 -typeset hash2=$(md5digest "/$DS2/clone") +typeset hash2=$(xxh128digest "/$DS2/clone") log_must [ "$hash1" = "$hash2" ] cleanup_enc @@ -144,12 +144,12 @@ log_must sync_pool $TESTPOOL log_must rm -f "/$DS1/file" "/$DS2/file" log_must sync_pool $TESTPOOL clone_and_check "file" "clone" "$DS2" "$DS1" "" true "s1" -typeset hash1=$(md5digest "/$DS1/.zfs/snapshot/s1/file") +typeset hash1=$(xxh128digest "/$DS1/.zfs/snapshot/s1/file") log_note "destroy the snapshot and check if the file is still readable and" \ "has the same content" log_must zfs destroy -r $DS2@s1 log_must sync_pool $TESTPOOL -typeset hash2=$(md5digest "/$DS1/file") +typeset hash2=$(xxh128digest "/$DS1/file") log_must [ "$hash1" = "$hash2" ] cleanup_enc diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh index b591b209ab6b..bd025c925496 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh @@ -47,8 +47,8 @@ sync_pool $TESTPOOL log_must eval "zfs send -ecL $snap > $tmpfile.1" log_must eval "zdb -B $TESTPOOL/$objsetid ecL > $tmpfile.2" -typeset sum1=$(md5digest $tmpfile.1) -typeset sum2=$(md5digest $tmpfile.2) +typeset sum1=$(xxh128digest $tmpfile.1) +typeset sum2=$(xxh128digest $tmpfile.2) log_must test "$sum1" = "$sum2" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_compressed_corrective.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_compressed_corrective.ksh index 7f8eb0b138ee..fec6fc041b47 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_compressed_corrective.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_compressed_corrective.ksh @@ -73,7 +73,7 @@ function test_corrective_recv log_must zpool status -v $TESTPOOL log_mustnot eval "zpool status -v $TESTPOOL | \ grep \"Permanent errors have been detected\"" - typeset cksum=$(md5digest $file) + typeset cksum=$(xxh128digest $file) [[ "$cksum" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum != $checksum)" } @@ -95,7 +95,7 @@ log_must zfs create -o primarycache=none \ log_must dd if=/dev/urandom of=$file bs=1024 count=1024 oflag=sync log_must eval "echo 'aaaaaaaa' >> "$file -typeset checksum=$(md5digest $file) +typeset checksum=$(xxh128digest $file) log_must zfs snapshot $TESTPOOL/$TESTFS1@snap1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_corrective.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_corrective.ksh index 261fc5eed8cb..44d4e2fa6ded 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_corrective.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_corrective.ksh @@ -72,7 +72,7 @@ function test_corrective_recv log_must zpool status -v $TESTPOOL log_mustnot eval "zpool status -v $TESTPOOL | \ grep \"Permanent errors have been detected\"" - typeset cksum=$(md5digest $file) + typeset cksum=$(xxh128digest $file) [[ "$cksum" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum != $checksum)" } @@ -94,7 +94,7 @@ log_must zfs create -o primarycache=none \ log_must dd if=/dev/urandom of=$file bs=1024 count=1024 oflag=sync log_must eval "echo 'aaaaaaaa' >> "$file -typeset checksum=$(md5digest $file) +typeset checksum=$(xxh128digest $file) log_must zfs snapshot $TESTPOOL/$TESTFS1@snap1 @@ -177,7 +177,7 @@ log_must zpool scrub -w $TESTPOOL log_must zpool status -v $TESTPOOL log_mustnot eval "zpool status -v $TESTPOOL | \ grep \"Permanent errors have been detected\"" -typeset cksum=$(md5digest $file) +typeset cksum=$(xxh128digest $file) [[ "$cksum" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum != $checksum)" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh index 891432685287..fe9c0f1803a7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh @@ -59,7 +59,7 @@ log_must eval "echo $passphrase | zfs create -o encryption=on" \ "-o keyformat=passphrase $TESTPOOL/$TESTFS2" log_must mkfile 1M /$TESTPOOL/$TESTFS2/$TESTFILE0 -typeset checksum=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0) +typeset checksum=$(xxh128digest /$TESTPOOL/$TESTFS2/$TESTFILE0) log_must zfs snapshot $snap @@ -69,14 +69,14 @@ log_must eval "zfs send $snap | zfs receive $TESTPOOL/$TESTFS1/c1" crypt=$(get_prop encryption $TESTPOOL/$TESTFS1/c1) [[ "$crypt" == "off" ]] || log_fail "Received unencrypted stream as encrypted" -typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS1/c1/$TESTFILE0) +typeset cksum1=$(xxh128digest /$TESTPOOL/$TESTFS1/c1/$TESTFILE0) [[ "$cksum1" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum1 != $checksum)" log_note "Verify ZFS can receive into an encrypted child" log_must eval "zfs send $snap | zfs receive $TESTPOOL/$TESTFS2/c1" -typeset cksum2=$(md5digest /$TESTPOOL/$TESTFS2/c1/$TESTFILE0) +typeset cksum2=$(xxh128digest /$TESTPOOL/$TESTFS2/c1/$TESTFILE0) [[ "$cksum2" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum2 != $checksum)" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh index 05c2ece4654f..e078103a1be2 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh @@ -60,7 +60,7 @@ log_must zfs create -o compress=zstd-$random_level $TESTPOOL/$TESTFS1 # Make a 5kb compressible file log_must eval cat $src_data $src_data $src_data $src_data $src_data \ "> /$TESTPOOL/$TESTFS1/$TESTFILE0" -typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0) +typeset checksum=$(xxh128digest /$TESTPOOL/$TESTFS1/$TESTFILE0) log_must zfs snapshot $snap @@ -79,7 +79,7 @@ log_note "ZSTD src: size=$zstd_size1 version=$zstd_version1 level=$zstd_level1" log_note "Verify ZFS can receive the ZSTD compressed stream" log_must eval "zfs send -ec $snap | zfs receive $TESTPOOL/$TESTFS2" -typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0) +typeset cksum1=$(xxh128digest /$TESTPOOL/$TESTFS2/$TESTFILE0) [[ "$cksum1" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum1 != $checksum)" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_large_block_corrective.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_large_block_corrective.ksh index fbcd33f60704..0958b7c1bbf3 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_large_block_corrective.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_large_block_corrective.ksh @@ -73,7 +73,7 @@ function test_corrective_recv log_must zpool status -v $TESTPOOL log_mustnot eval "zpool status -v $TESTPOOL | \ grep \"Permanent errors have been detected\"" - typeset cksum=$(md5digest $file) + typeset cksum=$(xxh128digest $file) [[ "$cksum" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum != $checksum)" } @@ -96,7 +96,7 @@ log_must zfs create -o recordsize=1m -o primarycache=none \ log_must dd if=/dev/urandom of=$file bs=1024 count=1024 oflag=sync log_must eval "echo 'aaaaaaaa' >> "$file -typeset checksum=$(md5digest $file) +typeset checksum=$(xxh128digest $file) log_must zfs snapshot $TESTPOOL/$TESTFS1@snap1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh index 32b05e527ad3..6b4425fd1db2 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh @@ -61,7 +61,7 @@ log_must eval "echo $passphrase | zfs create -o encryption=on" \ "-o keyformat=passphrase $TESTPOOL/$TESTFS1" log_must mkfile 1M /$TESTPOOL/$TESTFS1/$TESTFILE0 -typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0) +typeset checksum=$(xxh128digest /$TESTPOOL/$TESTFS1/$TESTFILE0) log_must zfs snapshot $snap @@ -74,7 +74,7 @@ keystatus=$(get_prop keystatus $TESTPOOL/$TESTFS2) log_must eval "echo $passphrase | zfs mount -l $TESTPOOL/$TESTFS2" -typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0) +typeset cksum1=$(xxh128digest /$TESTPOOL/$TESTFS2/$TESTFILE0) [[ "$cksum1" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum1 != $checksum)" @@ -85,7 +85,7 @@ keystatus=$(get_prop keystatus $TESTPOOL/$TESTFS1/c1) log_fail "Expected keystatus unavailable, got $keystatus" log_must eval "echo $passphrase | zfs mount -l $TESTPOOL/$TESTFS1/c1" -typeset cksum2=$(md5digest /$TESTPOOL/$TESTFS1/c1/$TESTFILE0) +typeset cksum2=$(xxh128digest /$TESTPOOL/$TESTFS1/c1/$TESTFILE0) [[ "$cksum2" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum2 != $checksum)" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh index 7826ec9a4890..c33bba53291a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh @@ -69,7 +69,7 @@ log_must eval "echo $passphrase | zfs create -o encryption=on" \ log_must zfs snapshot $snap1 log_must mkfile 1M /$TESTPOOL/$TESTFS1/$TESTFILE0 -typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0) +typeset checksum=$(xxh128digest /$TESTPOOL/$TESTFS1/$TESTFILE0) log_must zfs snapshot $snap2 @@ -89,7 +89,7 @@ log_must zfs unload-key $TESTPOOL/$TESTFS2 log_must eval "zfs receive $TESTPOOL/$TESTFS2 < $ibackup" log_must eval "echo $passphrase2 | zfs mount -l $TESTPOOL/$TESTFS2" -typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0) +typeset cksum1=$(xxh128digest /$TESTPOOL/$TESTFS2/$TESTFILE0) [[ "$cksum1" == "$checksum" ]] || \ log_fail "Checksums differ ($cksum1 != $checksum)" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh index ce9885904b01..5d0bcfc222df 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh @@ -50,7 +50,7 @@ function dev_checksum log_note "Compute checksum of '$dev'" - md5digest $dev || + xxh128digest $dev || log_fail "Failed to compute checksum of '$dev'" } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_devices_missing.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_devices_missing.ksh index af6ac8d78e4e..e63b82be84bd 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_devices_missing.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_devices_missing.ksh @@ -79,11 +79,11 @@ function test_devices_missing log_must set_spa_load_verify_data 0 log_must zpool import -o readonly=on -d $DEVICE_DIR $TESTPOOL1 - log_must verify_data_md5sums $MD5FILE + log_must verify_data_hashsums $MD5FILE log_note "Try reading second batch of data, make sure pool doesn't" \ "get suspended." - verify_data_md5sums $MD5FILE >/dev/null 2>&1 + verify_data_hashsums $MD5FILE >/dev/null 2>&1 log_must_busy zpool export $TESTPOOL1 @@ -95,8 +95,8 @@ function test_devices_missing log_must set_zfs_max_missing_tvds 0 log_must zpool import -d $DEVICE_DIR $TESTPOOL1 - log_must verify_data_md5sums $MD5FILE - log_must verify_data_md5sums $MD5FILE2 + log_must verify_data_hashsums $MD5FILE + log_must verify_data_hashsums $MD5FILE2 # Cleanup log_must zpool destroy $TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh index 4b6fcbd80af1..ee0403135dfc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh @@ -23,7 +23,7 @@ # # STRATEGY: # 1. Create a pool. -# 2. Generate files and remember their md5sum. +# 2. Generate files and remember their hashsum. # 3. Note last synced txg. # 4. Take a snapshot to make sure old blocks are not overwritten. # 5. Perform zpool add/attach/detach/remove operation. @@ -134,7 +134,7 @@ function test_common log_must zpool export $TESTPOOL1 if zpool import -d $DEVICE_DIR -T $txg $TESTPOOL1; then - verify_data_md5sums $MD5FILE && retval=0 + verify_data_hashsums $MD5FILE && retval=0 log_must check_pool_config $TESTPOOL1 "$poolcheck" log_must zpool destroy $TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh index b03b39d178ca..6fdb9b26f26c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_device_replaced.ksh @@ -23,7 +23,7 @@ # # STRATEGY: # 1. Create a pool. -# 2. Generate files and remember their md5sum. +# 2. Generate files and remember their hashsum. # 3. Sync a few times and note last synced txg. # 4. Take a snapshot to make sure old blocks are not overwritten. # 5. Initiate device replacement and export the pool. Special care must @@ -117,7 +117,7 @@ function test_replace_vdev log_must zpool import -d $DEVICE_DIR -o readonly=on -T $txg $TESTPOOL1 log_must check_pool_config $TESTPOOL1 "$poolcreate" - log_must verify_data_md5sums $MD5FILE + log_must verify_data_hashsums $MD5FILE log_must zpool export $TESTPOOL1 @@ -137,7 +137,7 @@ function test_replace_vdev log_must zpool import -d $DEVICE_DIR -T $txg $TESTPOOL1 log_must check_pool_config $TESTPOOL1 "$poolcreate" - log_must verify_data_md5sums $MD5FILE + log_must verify_data_hashsums $MD5FILE # Cleanup log_must zpool destroy $TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.cfg index cf9c6a8499af..df951be0864e 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.cfg @@ -45,8 +45,8 @@ export MYTESTFILE=$STF_SUITE/include/libtest.shlib export CPATH=$TEST_BASE_DIR/cachefile.$$ export CPATHBKP=$TEST_BASE_DIR/cachefile.$$.bkp export CPATHBKP2=$TEST_BASE_DIR/cachefile.$$.bkp2 -export MD5FILE=$TEST_BASE_DIR/md5sums.$$ -export MD5FILE2=$TEST_BASE_DIR/md5sums.$$.2 +export MD5FILE=$TEST_BASE_DIR/hashsums.$$ +export MD5FILE2=$TEST_BASE_DIR/hashsums.$$.2 export GROUP_NUM=3 typeset -i num=0 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib index 50157fa80578..7f9eb43e79b1 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib @@ -79,29 +79,29 @@ function write_some_data # Checksum all the files and store digests in a file. # # newdata: overwrite existing files if false. -# md5file: file where to store md5 digests +# hashfile: file where to store xxh128 digests # datasetname: base name for datasets # function _generate_data_common { typeset pool=$1 typeset newdata=$2 - typeset md5file=$3 + typeset hashfile=$3 typeset datasetname=$4 typeset -i datasets=3 typeset -i files=5 typeset -i blocks=10 - [[ -n $md5file ]] && rm -f $md5file + [[ -n $hashfile ]] && rm -f $hashfile for i in {1..$datasets}; do ( $newdata ) && log_must zfs create "$pool/$datasetname$i" for j in {1..$files}; do typeset file="/$pool/$datasetname$i/file$j" dd if=/dev/urandom of=$file bs=128k count=$blocks > /dev/null - if [[ -n $md5file ]]; then - typeset cksum=$(md5digest $file) - echo $cksum $file >> $md5file + if [[ -n $hashfile ]]; then + typeset cksum=$(xxh128digest $file) + echo $cksum $file >> $hashfile fi done ( $newdata ) && sync_pool "$pool" @@ -113,39 +113,39 @@ function _generate_data_common function generate_data { typeset pool=$1 - typeset md5file="$2" + typeset hashfile="$2" typeset datasetname=${3:-ds} - _generate_data_common $pool true "$md5file" $datasetname + _generate_data_common $pool true "$hashfile" $datasetname } function overwrite_data { typeset pool=$1 - typeset md5file="$2" + typeset hashfile="$2" typeset datasetname=${3:-ds} - _generate_data_common $1 false "$md5file" $datasetname + _generate_data_common $1 false "$hashfile" $datasetname } # -# Verify md5sums of every file in md5sum file $1. +# Verify hashsums of every file in hashsum file $1. # -function verify_data_md5sums +function verify_data_hashsums { - typeset md5file=$1 + typeset hashfile=$1 - if [[ ! -f $md5file ]]; then - log_note "md5 sums file '$md5file' doesn't exist" + if [[ ! -f $hashfile ]]; then + log_note "md5 sums file '$hashfile' doesn't exist" return 1 fi while read -r digest file; do - typeset digest1=$(md5digest $file) + typeset digest1=$(xxh128digest $file) if [[ "$digest1" != "$digest" ]]; then return 1 fi - done < $md5file + done < $hashfile return 0 } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen_003_pos.ksh index 6ce054cdb4a1..3b9851d0d079 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen_003_pos.ksh @@ -65,7 +65,7 @@ log_must check_state $TESTPOOL "$REMOVED_DISK_ID" "unavail" TESTFILE=/$TESTPOOL/data log_must generate_random_file /$TESTPOOL/data $LARGE_FILE_SIZE sync_pool $TESTPOOL -TESTFILE_MD5=$(md5digest $TESTFILE) +TESTFILE_MD5=$(xxh128digest $TESTFILE) # 4. Execute scrub. # add delay to I/O requests for remaining disk in pool @@ -89,7 +89,7 @@ log_must is_scan_restarted $TESTPOOL # 8. Put another device offline and check if the test file checksum is correct. log_must zpool offline $TESTPOOL $DISK2 -CHECK_MD5=$(md5digest $TESTFILE) +CHECK_MD5=$(xxh128digest $TESTFILE) [[ $CHECK_MD5 == $TESTFILE_MD5 ]] || \ log_fail "Checksums differ ($CHECK_MD5 != $TESTFILE_MD5)" log_must zpool online $TESTPOOL $DISK2 diff --git a/tests/zfs-tests/tests/functional/cp_files/cp_files_002_pos.ksh b/tests/zfs-tests/tests/functional/cp_files/cp_files_002_pos.ksh index 4db968ffae05..418c41fe659a 100755 --- a/tests/zfs-tests/tests/functional/cp_files/cp_files_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cp_files/cp_files_002_pos.ksh @@ -61,8 +61,8 @@ function cleanup function verify_copy { - src_cksum=$(sha256digest $1) - dst_cksum=$(sha256digest $2) + src_cksum=$(xxh128digest $1) + dst_cksum=$(xxh128digest $2) if [[ "$src_cksum" != "$dst_cksum" ]]; then log_must ls -l $CP_TESTDIR diff --git a/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh b/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh index 6998df78ac7c..b67059158a57 100755 --- a/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh +++ b/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh @@ -43,7 +43,7 @@ log_assert "ensure single-disk pool resumes properly after suspend and clear" # create a file, and take a checksum, so we can compare later log_must dd if=/dev/urandom of=$DATAFILE bs=128K count=1 -typeset sum1=$(md5digest $DATAFILE) +typeset sum1=$(xxh128digest $DATAFILE) # make a debug device that we can "unplug" load_scsi_debug 100 1 1 1 '512b' @@ -94,7 +94,7 @@ log_must zpool export $TESTPOOL log_must zpool import $TESTPOOL # sum the file we wrote earlier -typeset sum2=$(md5digest /$TESTPOOL/file) +typeset sum2=$(xxh128digest /$TESTPOOL/file) # make sure the checksums match log_must test "$sum1" = "$sum2" diff --git a/tests/zfs-tests/tests/functional/history/history_003_pos.ksh b/tests/zfs-tests/tests/functional/history/history_003_pos.ksh index 9f27785d64f9..efaf022153a8 100755 --- a/tests/zfs-tests/tests/functional/history/history_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_003_pos.ksh @@ -64,7 +64,7 @@ log_must zpool create $spool $VDEV0 log_must zfs create $spool/$sfs typeset -i orig_count=$(zpool history $spool | wc -l) -typeset orig_md5=$(zpool history $spool | head -2 | md5digest) +typeset orig_hash=$(zpool history $spool | head -2 | xxh128digest) typeset -i i=0 while ((i < 300)); do zfs set compression=off $spool/$sfs @@ -79,7 +79,7 @@ done TMPFILE=$TEST_BASE_DIR/spool.$$ zpool history $spool >$TMPFILE typeset -i entry_count=$(wc -l < $TMPFILE) -typeset final_md5=$(head -2 $TMPFILE | md5digest) +typeset final_hash=$(head -2 $TMPFILE | xxh128digest) grep -q 'zpool create' $TMPFILE || log_fail "'zpool create' was not found in pool history" @@ -91,7 +91,7 @@ grep -q 'zfs set compress' $TMPFILE || log_fail "'zfs set compress' was found in pool history" # Verify that the creation of the pool was preserved in the history. -if [[ $orig_md5 != $final_md5 ]]; then +if [[ $orig_hash != $final_hash ]]; then log_fail "zpool creation history was not preserved." fi diff --git a/tests/zfs-tests/tests/functional/no_space/enospc_ganging.ksh b/tests/zfs-tests/tests/functional/no_space/enospc_ganging.ksh index 1d35fba5dbfa..9b285ac5f31f 100755 --- a/tests/zfs-tests/tests/functional/no_space/enospc_ganging.ksh +++ b/tests/zfs-tests/tests/functional/no_space/enospc_ganging.ksh @@ -41,7 +41,7 @@ bs=1024k count=512 log_must dd if=/dev/urandom of=$TESTDIR/data bs=$bs count=$count -data_checksum=$(sha256digest $TESTDIR/data) +data_checksum=$(xxh128digest $TESTDIR/data) # Test common large block configuration. log_must zfs create -o recordsize=1m -o primarycache=metadata $TESTPOOL/gang @@ -50,7 +50,7 @@ mntpnt=$(get_prop mountpoint $TESTPOOL/gang) log_must dd if=$TESTDIR/data of=$mntpnt/file bs=$bs count=$count sync_pool $TESTPOOL log_must dd if=$mntpnt/file of=$TESTDIR/out bs=$bs count=$count -out_checksum=$(sha256digest $TESTDIR/out) +out_checksum=$(xxh128digest $TESTDIR/out) if [[ "$data_checksum" != "$out_checksum" ]]; then log_fail "checksum mismatch ($data_checksum != $out_checksum)" @@ -74,7 +74,7 @@ mntpnt=$(get_prop mountpoint $TESTPOOL/gang) log_must dd if=$TESTDIR/data of=$mntpnt/file bs=$bs count=$count sync_pool $TESTPOOL log_must dd if=$mntpnt/file of=$TESTDIR/out bs=$bs count=$count -out_checksum=$(sha256digest $TESTDIR/out) +out_checksum=$(xxh128digest $TESTDIR/out) if [[ "$data_checksum" != "$out_checksum" ]]; then log_fail "checksum mismatch ($data_checksum != $out_checksum)" diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 26e7c2cc25bc..42222795f485 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -808,15 +808,15 @@ function recursive_cksum { case "$(uname)" in FreeBSD) - find $1 -type f -exec sh -c 'sha256 -q {}; lsextattr -q \ - system {} | sha256 -q; lsextattr -q user {} | sha256 -q' \ - \; | sort | sha256 -q + find $1 -type f -exec sh -c 'xxh128sum {}; \ + lsextattr -q system {} | xxh128sum; \ + lsextattr -q user {} | xxh128sum' \; \ + | sort -k 2 | awk '{ print $1 }' | xxh128digest ;; *) - find $1 -type f -exec sh -c 'sha256sum {}; getfattr \ - --absolute-names --only-values -d {} | sha256sum' \; | \ - sort -k 2 | awk '{ print $1 }' | sha256sum | \ - awk '{ print $1 }' + find $1 -type f -exec sh -c 'xxh128sum {}; getfattr \ + --absolute-names --only-values -d {} | xxh128sum' \ + \; | sort -k 2 | awk '{ print $1 }' | xxh128digest ;; esac } diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_volume.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_volume.ksh index 1bf234823459..6a29d964500d 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_volume.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_volume.ksh @@ -50,8 +50,8 @@ typeset megs=8 log_must zfs create -V 256m -o compress=lz4 $vol write_compressible $BACKDIR ${megs}m 2 -md5_1=$(md5digest $data1) -md5_2=$(md5digest $data2) +hash1=$(xxh128digest $data1) +hash2=$(xxh128digest $data2) log_must dd if=$data1 of=$voldev bs=1024k log_must zfs snapshot $vol@snap @@ -63,8 +63,8 @@ verify_stream_size $BACKDIR/full $vol verify_stream_size $BACKDIR/full $vol2 block_device_wait $voldev2 log_must dd if=$voldev2 of=$BACKDIR/copy bs=1024k count=$megs -md5=$(md5digest $BACKDIR/copy) -[[ $md5 = $md5_1 ]] || log_fail "md5 mismatch: $md5 != $md5_1" +hash=$(xxh128digest $BACKDIR/copy) +[[ $hash = $hash1 ]] || log_fail "hash mismatch: $hash != $hash1" # Repeat, for an incremental send log_must dd seek=$megs if=$data2 of=$voldev bs=1024k @@ -77,7 +77,7 @@ verify_stream_size $BACKDIR/inc $vol 90 $vol@snap verify_stream_size $BACKDIR/inc $vol2 90 $vol2@snap block_device_wait $voldev2 log_must dd skip=$megs if=$voldev2 of=$BACKDIR/copy bs=1024k count=$megs -md5=$(md5digest $BACKDIR/copy) -[[ $md5 = $md5_2 ]] || log_fail "md5 mismatch: $md5 != $md5_2" +hash=$(xxh128digest $BACKDIR/copy) +[[ $hash = $hash2 ]] || log_fail "hash mismatch: $hash != $hash2" log_pass "Verify compressed send works with volumes" diff --git a/tests/zfs-tests/tests/functional/rsend/send-wR_encrypted_zvol.ksh b/tests/zfs-tests/tests/functional/rsend/send-wR_encrypted_zvol.ksh index 64ee6293c7a4..7db9892da583 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-wR_encrypted_zvol.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-wR_encrypted_zvol.ksh @@ -101,8 +101,8 @@ block_device_wait log_must mount $recvdev $recvmnt -md5_1=$(cat $mntpnt/* | md5digest) -md5_2=$(cat $recvmnt/* | md5digest) -[[ "$md5_1" == "$md5_2" ]] || log_fail "md5 mismatch: $md5_1 != $md5_2" +hash1=$(cat $mntpnt/* | xxh128digest) +hash2=$(cat $recvmnt/* | xxh128digest) +[[ "$hash1" == "$hash2" ]] || log_fail "hash mismatch: $hash1 != $hash2" log_pass "zfs can receive raw, recursive send streams" diff --git a/tests/zfs-tests/tests/functional/rsend/send_encrypted_props.ksh b/tests/zfs-tests/tests/functional/rsend/send_encrypted_props.ksh index c0c7b682def9..3b20f0a99a4a 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_encrypted_props.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_encrypted_props.ksh @@ -76,7 +76,7 @@ log_must zfs create -o keyformat=passphrase -o keylocation=file://$keyfile \ log_must mkfile 1M /$TESTPOOL/ds/$TESTFILE0 log_must cp /$TESTPOOL/ds/$TESTFILE0 /$TESTPOOL/crypt/$TESTFILE0 -typeset cksum=$(md5digest /$TESTPOOL/ds/$TESTFILE0) +typeset cksum=$(xxh128digest /$TESTPOOL/ds/$TESTFILE0) log_must zfs snap -r $snap log_must zfs snap -r $snap2 @@ -129,7 +129,7 @@ log_must test "$(get_prop 'encryptionroot' $ds)" == "$ds" log_must test "$(get_prop 'keyformat' $ds)" == "passphrase" log_must test "$(get_prop 'keylocation' $ds)" == "file://$keyfile" log_must test "$(get_prop 'mounted' $ds)" == "yes" -recv_cksum=$(md5digest /$ds/$TESTFILE0) +recv_cksum=$(xxh128digest /$ds/$TESTFILE0) log_must test "$recv_cksum" == "$cksum" log_must zfs destroy -r $ds @@ -153,7 +153,7 @@ log_must test "$(get_prop 'encryptionroot' $ds)" == "$ds" log_must test "$(get_prop 'keyformat' $ds)" == "passphrase" log_must test "$(get_prop 'keylocation' $ds)" == "file://$keyfile" log_must test "$(get_prop 'mounted' $ds)" == "yes" -recv_cksum=$(md5digest /$ds/$TESTFILE0) +recv_cksum=$(xxh128digest /$ds/$TESTFILE0) log_must test "$recv_cksum" == "$cksum" log_must zfs destroy -r $ds @@ -171,7 +171,7 @@ log_must test "$(get_prop 'encryptionroot' $ds)" == "$ds" log_must test "$(get_prop 'keyformat' $ds)" == "passphrase" log_must test "$(get_prop 'keylocation' $ds)" == "file://$keyfile" log_must test "$(get_prop 'mounted' $ds)" == "yes" -recv_cksum=$(md5digest /$ds/$TESTFILE0) +recv_cksum=$(xxh128digest /$ds/$TESTFILE0) log_must test "$recv_cksum" == "$cksum" log_must zfs destroy -r $ds @@ -185,7 +185,7 @@ log_must test "$(get_prop 'encryptionroot' $ds)" == "$TESTPOOL/crypt" log_must test "$(get_prop 'encryption' $ds)" == "aes-256-gcm" log_must test "$(get_prop 'keyformat' $ds)" == "passphrase" log_must test "$(get_prop 'mounted' $ds)" == "yes" -recv_cksum=$(md5digest /$ds/$TESTFILE0) +recv_cksum=$(xxh128digest /$ds/$TESTFILE0) log_must test "$recv_cksum" == "$cksum" log_must zfs destroy -r $ds @@ -199,7 +199,7 @@ log_must test "$(get_prop 'encryptionroot' $ds)" == "$TESTPOOL/crypt" log_must test "$(get_prop 'encryption' $ds)" == "aes-256-gcm" log_must test "$(get_prop 'keyformat' $ds)" == "passphrase" log_must test "$(get_prop 'mounted' $ds)" == "yes" -recv_cksum=$(md5digest /$ds/$TESTFILE0) +recv_cksum=$(xxh128digest /$ds/$TESTFILE0) log_must test "$recv_cksum" == "$cksum" log_must zfs destroy -r $ds @@ -213,7 +213,7 @@ log_must test "$(get_prop 'encryptionroot' $ds)" == "$TESTPOOL/crypt" log_must test "$(get_prop 'encryption' $ds)" == "aes-256-gcm" log_must test "$(get_prop 'keyformat' $ds)" == "passphrase" log_must test "$(get_prop 'mounted' $ds)" == "yes" -recv_cksum=$(md5digest /$ds/$TESTFILE0) +recv_cksum=$(xxh128digest /$ds/$TESTFILE0) log_must test "$recv_cksum" == "$cksum" log_must zfs destroy -r $ds diff --git a/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh b/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh index aff54e3a7d69..a6223f05a65a 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh @@ -52,16 +52,8 @@ log_onexit cleanup function recursive_cksum { - case "$(uname)" in - FreeBSD) - find $1 -type f -exec sha256 -q {} + | \ - sort | sha256digest - ;; - *) - find $1 -type f -exec sha256sum {} + | \ - sort -k 2 | awk '{ print $1 }' | sha256digest - ;; - esac + find $1 -type f -exec xxh128sum {} + | \ + sort -k 2 | awk '{ print $1 }' | xxh128digest } log_assert "Verify 'zfs send -w' works with many different file layouts" diff --git a/tests/zfs-tests/tests/functional/rsend/send_hole_birth.ksh b/tests/zfs-tests/tests/functional/rsend/send_hole_birth.ksh index 6754fb0f44bb..72b83505d5e8 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_hole_birth.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_hole_birth.ksh @@ -65,7 +65,7 @@ function send_and_verify ">$BACKDIR/pool-snap1-snap2" log_must eval "zfs receive $recvfs < $BACKDIR/pool-snap1-snap2" - log_must cmp_md5s /$sendfs/file1 /$recvfs/file1 + log_must cmp_xxh128 /$sendfs/file1 /$recvfs/file1 } # By default sending hole_birth times is disabled. This functionality needs diff --git a/tests/zfs-tests/tests/functional/slog/slog_replay_fs_001.ksh b/tests/zfs-tests/tests/functional/slog/slog_replay_fs_001.ksh index 8f3585a5997f..4b6d08eaffa2 100755 --- a/tests/zfs-tests/tests/functional/slog/slog_replay_fs_001.ksh +++ b/tests/zfs-tests/tests/functional/slog/slog_replay_fs_001.ksh @@ -110,7 +110,7 @@ log_must rmdir /$TESTPOOL/$TESTFS/dir_to_delete log_must mkdir -p $TESTDIR log_must dd if=/dev/urandom of=/$TESTPOOL/$TESTFS/payload \ oflag=sync bs=1k count=8 -typeset checksum=$(sha256digest /$TESTPOOL/$TESTFS/payload) +typeset checksum=$(xxh128digest /$TESTPOOL/$TESTFS/payload) # TX_WRITE (small file with ordering) log_must dd if=/dev/urandom of=/$TESTPOOL/$TESTFS/small_file \ @@ -239,7 +239,7 @@ log_note "Verify working set diff:" log_must replay_directory_diff $TESTDIR/copy /$TESTPOOL/$TESTFS log_note "Verify file checksum:" -typeset checksum1=$(sha256digest /$TESTPOOL/$TESTFS/payload) +typeset checksum1=$(xxh128digest /$TESTPOOL/$TESTFS/payload) [[ "$checksum1" == "$checksum" ]] || \ log_fail "checksum mismatch ($checksum1 != $checksum)" diff --git a/tests/zfs-tests/tests/functional/slog/slog_replay_volume.ksh b/tests/zfs-tests/tests/functional/slog/slog_replay_volume.ksh index e99d40570c39..4728f8389ad0 100755 --- a/tests/zfs-tests/tests/functional/slog/slog_replay_volume.ksh +++ b/tests/zfs-tests/tests/functional/slog/slog_replay_volume.ksh @@ -140,7 +140,7 @@ fi # # 4. Generate checksums for all ext4 files. # -typeset checksum=$(cat $MNTPNT/* | sha256digest) +typeset checksum=$(cat $MNTPNT/* | xxh128digest) # # 5. Unmount filesystem and export the pool @@ -172,7 +172,7 @@ log_note "Verify current block usage:" log_must zdb -bcv $TESTPOOL log_note "Verify checksums" -typeset checksum1=$(cat $MNTPNT/* | sha256digest) +typeset checksum1=$(cat $MNTPNT/* | xxh128digest) [[ "$checksum1" == "$checksum" ]] || \ log_fail "checksum mismatch ($checksum1 != $checksum)" From 903db66793486b483e02ccffd44ccb083fd3204b Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Thu, 3 Oct 2024 20:42:25 +0200 Subject: [PATCH 032/223] ZTS: Fix summary page creation There are cases, where some needed files for the summary page aren't created. Currently the whole Summary Page creation will fail then. Sample run: https://github.com/openzfs/zfs/actions/runs/11148248072/job/30999748588 Fix this, by properly checking for existence of the needed files. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Reviewed-by: Rob Norris Signed-off-by: Tino Reichardt Closes #16599 --- .github/workflows/scripts/qemu-9-summary-page.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/scripts/qemu-9-summary-page.sh b/.github/workflows/scripts/qemu-9-summary-page.sh index 2f4c21f9910a..cae287ac1073 100755 --- a/.github/workflows/scripts/qemu-9-summary-page.sh +++ b/.github/workflows/scripts/qemu-9-summary-page.sh @@ -11,10 +11,12 @@ function output() { } function outfile() { + test -s "$1" || return cat "$1" >> "out-$logfile.md" } function outfile_plain() { + test -s "$1" || return output "
"
   cat "$1" >> "out-$logfile.md"
   output "
" From f52b725e643bce7b074cf18dace8edffa451819c Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Sun, 6 Oct 2024 23:29:20 +0200 Subject: [PATCH 033/223] ZTS: Remove FreeBSD 13.4-STABLE Current CI is failing on FreeBSD 13.4-STABLE, because samba4 can't be installed there. Lets remove it for now. Update also the FreeBSD version definitions a bit. The naming is like this now: FreeBSD variants: - freebsd13-3r, freebsd13-4r, freebsd14-0r, freebsd14-1r (RELEASE) - freebsd13-4s, freebsd14-1s (STABLE) - freebsd15-0c (CURRENT) RHL based distros: - almalinux8, almalinux9, centos-stream9, fedora39, fedora40 Debian based: - debian11, debian12, ubuntu20, ubuntu22, ubuntu24 Misc Linux distros: - archlinux, tumbleweed Reviewed-by: Brian Behlendorf Signed-off-by: Tino Reichardt Closes #16610 --- .github/workflows/scripts/qemu-2-start.sh | 32 ++++++++++++++++------- .github/workflows/zfs-qemu.yml | 14 +++++----- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/scripts/qemu-2-start.sh b/.github/workflows/scripts/qemu-2-start.sh index 923c38c0f937..84e13832d10f 100755 --- a/.github/workflows/scripts/qemu-2-start.sh +++ b/.github/workflows/scripts/qemu-2-start.sh @@ -14,7 +14,7 @@ OSv=$OS # compressed with .zst extension REPO="https://github.com/mcmilk/openzfs-freebsd-images" -FREEBSD="$REPO/releases/download/v2024-09-16" +FREEBSD="$REPO/releases/download/v2024-10-05" URLzs="" # Ubuntu mirrors @@ -62,33 +62,45 @@ case "$OS" in OSv="fedora39" URL="https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2" ;; - freebsd13r) - OSNAME="FreeBSD 13.4-RELEASE" + freebsd13-3r) + OSNAME="FreeBSD 13.3-RELEASE" OSv="freebsd13.0" - URLzs="$FREEBSD/amd64-freebsd-13.4-RELEASE.qcow2.zst" + URLzs="$FREEBSD/amd64-freebsd-13.3-RELEASE.qcow2.zst" BASH="/usr/local/bin/bash" NIC="rtl8139" ;; - freebsd13) - OSNAME="FreeBSD 13.4-STABLE" + freebsd13-4r) + OSNAME="FreeBSD 13.4-RELEASE" OSv="freebsd13.0" - URLzs="$FREEBSD/amd64-freebsd-13.4-STABLE.qcow2.zst" + URLzs="$FREEBSD/amd64-freebsd-13.4-RELEASE.qcow2.zst" BASH="/usr/local/bin/bash" NIC="rtl8139" ;; - freebsd14r) + freebsd14-0r) + OSNAME="FreeBSD 14.0-RELEASE" + OSv="freebsd14.0" + URLzs="$FREEBSD/amd64-freebsd-14.0-RELEASE.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + freebsd14-1r) OSNAME="FreeBSD 14.1-RELEASE" OSv="freebsd14.0" URLzs="$FREEBSD/amd64-freebsd-14.1-RELEASE.qcow2.zst" BASH="/usr/local/bin/bash" ;; - freebsd14) + freebsd13-4s) + OSNAME="FreeBSD 13.4-STABLE" + OSv="freebsd13.0" + URLzs="$FREEBSD/amd64-freebsd-13.4-STABLE.qcow2.zst" + BASH="/usr/local/bin/bash" + ;; + freebsd14-1s) OSNAME="FreeBSD 14.1-STABLE" OSv="freebsd14.0" URLzs="$FREEBSD/amd64-freebsd-14.1-STABLE.qcow2.zst" BASH="/usr/local/bin/bash" ;; - freebsd15) + freebsd15-0c) OSNAME="FreeBSD 15.0-CURRENT" OSv="freebsd14.0" URLzs="$FREEBSD/amd64-freebsd-15.0-CURRENT.qcow2.zst" diff --git a/.github/workflows/zfs-qemu.yml b/.github/workflows/zfs-qemu.yml index 8922701f9899..f819e9938e31 100644 --- a/.github/workflows/zfs-qemu.yml +++ b/.github/workflows/zfs-qemu.yml @@ -22,8 +22,8 @@ jobs: - name: Generate OS config and CI type id: os run: | - FULL_OS='["almalinux8", "almalinux9", "centos-stream9", "debian11", "debian12", "fedora39", "fedora40", "freebsd13", "freebsd13r", "freebsd14", "freebsd14r", "ubuntu20", "ubuntu22", "ubuntu24"]' - QUICK_OS='["almalinux8", "almalinux9", "debian12", "fedora40", "freebsd13", "freebsd14", "ubuntu24"]' + FULL_OS='["almalinux8", "almalinux9", "centos-stream9", "debian11", "debian12", "fedora39", "fedora40", "freebsd13-4r", "freebsd14-0r", "freebsd14-1s", "ubuntu20", "ubuntu22", "ubuntu24"]' + QUICK_OS='["almalinux8", "almalinux9", "debian12", "fedora40", "freebsd13-3r", "freebsd14-1r", "ubuntu24"]' # determine CI type when running on PR ci_type="full" if ${{ github.event_name == 'pull_request' }}; then @@ -46,10 +46,12 @@ jobs: strategy: fail-fast: false matrix: - # all: - # os: [almalinux8, almalinux9, archlinux, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24] - # openzfs: - # os: [almalinux8, almalinux9, centos-stream9, debian11, debian12, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r, ubuntu20, ubuntu22, ubuntu24] + # rhl: almalinux8, almalinux9, centos-stream9, fedora39, fedora40 + # debian: debian11, debian12, ubuntu20, ubuntu22, ubuntu24 + # misc: archlinux, tumbleweed + # FreeBSD Release: freebsd13-3r, freebsd13-4r, freebsd14-0r, freebsd14-1r + # FreeBSD Stable: freebsd13-4s, freebsd14-1s + # FreeBSD Current: freebsd15-0c os: ${{ fromJson(needs.test-config.outputs.test_os) }} runs-on: ubuntu-24.04 steps: From 8457bab268ec1069d3650d5b5f21338261e44657 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Sun, 6 Oct 2024 23:32:08 +0200 Subject: [PATCH 034/223] ZTS: Fix summary page creation again - second try In PR #16599 I used 'return' like in C - which is wrong :/ This fix generates the summary as needed. Reviewed-by: Brian Behlendorf Signed-off-by: Tino Reichardt Closes #16611 --- .github/workflows/scripts/qemu-9-summary-page.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/qemu-9-summary-page.sh b/.github/workflows/scripts/qemu-9-summary-page.sh index cae287ac1073..737dda01b565 100755 --- a/.github/workflows/scripts/qemu-9-summary-page.sh +++ b/.github/workflows/scripts/qemu-9-summary-page.sh @@ -11,12 +11,10 @@ function output() { } function outfile() { - test -s "$1" || return cat "$1" >> "out-$logfile.md" } function outfile_plain() { - test -s "$1" || return output "
"
   cat "$1" >> "out-$logfile.md"
   output "
" @@ -45,6 +43,8 @@ if [ ! -f out-1.md ]; then tar xf "$tarfile" test -s env.txt || continue source env.txt + # when uname.txt is there, the other files are also ok + test -s uname.txt || continue output "\n## Functional Tests: $OSNAME\n" outfile_plain uname.txt outfile_plain summary.txt From 09f7432f83e3e2fbd4f10812dc6a997160e3f4f5 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 11 Oct 2024 14:16:00 -0700 Subject: [PATCH 035/223] CI: Stick with ubuntu-22.04 for CodeQL analysis The ubuntu-latest alias now refers to ubuntu-24.04 instead of ubuntu-22.04 which causes CodeQL's autobuild to fail with: cpp/autobuilder: deptrace not supported in ubuntu 24.04 Until deptrace is supported by ubuntu-24.04 hosted runners request ubuntu-22.04 which is supported. Signed-off-by: Brian Behlendorf Reviewed-by: Tino Reichardt Reviewed-by: George Melikov Closes #16639 --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2656a20fea0d..e975d7dd00b9 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -11,7 +11,7 @@ concurrency: jobs: analyze: name: Analyze - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 permissions: actions: read contents: read From 34537bd9c7d8bffda34fcd925d6ed437681fc0cf Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Sat, 12 Oct 2024 09:53:32 +0200 Subject: [PATCH 036/223] ZTS: Optimize Kernel Same-page Merging (KSM) Kernel same-page Merging (KSM) allows KVM guests to share identical memory pages. These shared pages are usually common libraries or other identical, high-use data. The current configuration was a bit to lazy - so KSM didn't work very well. With the new configuration I could run 3 Linux VMs in parralel. FreeBSD can't benefit from it. But FreeBSD is not so memory hungry in general, so there is no need for it ;) Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: Tino Reichardt Closes #16641 --- .github/workflows/scripts/qemu-1-setup.sh | 18 ++++++++++-------- .github/workflows/scripts/qemu-5-setup.sh | 12 +++++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/scripts/qemu-1-setup.sh b/.github/workflows/scripts/qemu-1-setup.sh index ebd80a2f98c1..f838da34efff 100755 --- a/.github/workflows/scripts/qemu-1-setup.sh +++ b/.github/workflows/scripts/qemu-1-setup.sh @@ -18,19 +18,21 @@ ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -q -N "" # we expect RAM shortage cat << EOF | sudo tee /etc/ksmtuned.conf > /dev/null +# /etc/ksmtuned.conf - Configuration file for ksmtuned # https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/chap-ksm KSM_MONITOR_INTERVAL=60 # Millisecond sleep between ksm scans for 16Gb server. # Smaller servers sleep more, bigger sleep less. -KSM_SLEEP_MSEC=10 -KSM_NPAGES_BOOST=300 -KSM_NPAGES_DECAY=-50 -KSM_NPAGES_MIN=64 -KSM_NPAGES_MAX=2048 - -KSM_THRES_COEF=25 -KSM_THRES_CONST=2048 +KSM_SLEEP_MSEC=30 + +KSM_NPAGES_BOOST=0 +KSM_NPAGES_DECAY=0 +KSM_NPAGES_MIN=1000 +KSM_NPAGES_MAX=25000 + +KSM_THRES_COEF=80 +KSM_THRES_CONST=8192 LOGFILE=/var/log/ksmtuned.log DEBUG=1 diff --git a/.github/workflows/scripts/qemu-5-setup.sh b/.github/workflows/scripts/qemu-5-setup.sh index 7acb67a27920..5034c1896304 100755 --- a/.github/workflows/scripts/qemu-5-setup.sh +++ b/.github/workflows/scripts/qemu-5-setup.sh @@ -14,17 +14,19 @@ PID=$(pidof /usr/bin/qemu-system-x86_64) tail --pid=$PID -f /dev/null sudo virsh undefine openzfs +# default values per test vm: +VMs=2 +CPU=2 + # definitions of per operating system case "$OS" in + # FreeBSD can't be optimized via ksmtuned freebsd*) - VMs=2 - CPU=3 RAM=6 ;; *) - VMs=2 - CPU=3 - RAM=7 + # Linux can be optimized via ksmtuned + RAM=8 ;; esac From aa32ee6838e3e362327f7544066cf62ec13dd617 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Sat, 12 Oct 2024 09:54:50 +0200 Subject: [PATCH 037/223] ZTS: Make use of optimal CPU pinning With CPU pinning, we should get some speedup because of better cpu cache re-use. Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: Tino Reichardt Closes #16641 --- .github/workflows/scripts/qemu-5-setup.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/qemu-5-setup.sh b/.github/workflows/scripts/qemu-5-setup.sh index 5034c1896304..bc40e8894b22 100755 --- a/.github/workflows/scripts/qemu-5-setup.sh +++ b/.github/workflows/scripts/qemu-5-setup.sh @@ -18,10 +18,12 @@ sudo virsh undefine openzfs VMs=2 CPU=2 -# definitions of per operating system +# cpu pinning +CPUSET=("0,1" "2,3") + case "$OS" in - # FreeBSD can't be optimized via ksmtuned freebsd*) + # FreeBSD can't be optimized via ksmtuned RAM=6 ;; *) @@ -75,6 +77,7 @@ EOF --cpu host-passthrough \ --virt-type=kvm --hvm \ --vcpus=$CPU,sockets=1 \ + --cpuset=${CPUSET[$((i-1))]} \ --memory $((1024*RAM)) \ --memballoon model=virtio \ --graphics none \ From 51996dcaee60c1df5ca4232c31674fd52a452aa7 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 21 Oct 2024 14:46:20 -0400 Subject: [PATCH 038/223] ZTS: Add additional exceptions The following tests have been observed to occasionally fail when running under the CI. Updated our exceptions list to track them. Signed-off-by: Brian Behlendorf Closes #16670 --- tests/test-runner/bin/zts-report.py.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index 09557e4be789..206479ea8952 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -213,6 +213,7 @@ maybe = { 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason], 'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason], 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', 6145], + 'cli_root/zpool_import/import_devices_missing': ['FAIL', 16669], 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', 6839], 'cli_root/zpool_initialize/zpool_initialize_import_export': ['FAIL', 11948], @@ -274,7 +275,8 @@ if sys.platform.startswith('freebsd'): 'pool_checkpoint/checkpoint_big_rewind': ['FAIL', 12622], 'pool_checkpoint/checkpoint_indirect': ['FAIL', 12623], 'resilver/resilver_restart_001': ['FAIL', known_reason], - 'snapshot/snapshot_002_pos': ['FAIL', '14831'], + 'snapshot/snapshot_002_pos': ['FAIL', 14831], + 'zvol/zvol_misc/zvol_misc_volmode': ['FAIL', 16668], 'bclone/bclone_crossfs_corner_cases': ['SKIP', cfr_cross_reason], 'bclone/bclone_crossfs_corner_cases_limited': ['SKIP', cfr_cross_reason], From bdd1f72d9dff75237e65e2e88d859478ddf54872 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Thu, 24 Oct 2024 23:05:45 +0200 Subject: [PATCH 039/223] Fix dependency install on Debian 11 (#16683) Adding cryptsetup breaks some dialog things on Debian 11. Apply some workaround for it. Signed-off-by: Tino Reichardt Reviewed-by: George Melikov Reviewed-by: Tony Hutter --- .github/workflows/scripts/qemu-3-deps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/scripts/qemu-3-deps.sh b/.github/workflows/scripts/qemu-3-deps.sh index a2fb5e38249a..4c6227b88ed0 100755 --- a/.github/workflows/scripts/qemu-3-deps.sh +++ b/.github/workflows/scripts/qemu-3-deps.sh @@ -111,6 +111,7 @@ case "$1" in archlinux ;; debian*) + echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections debian echo "##[group]Install Debian specific" sudo apt-get install -yq linux-perf dh-sequence-dkms From f2633144e9313cc5a5ba238ce535ba3b2de6b4f5 Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Fri, 25 Oct 2024 09:07:44 -0700 Subject: [PATCH 040/223] ZTS: Add LUKS sanity test Add a LUKS sanity test to trigger: #16631 Reviewed-by: Tino Reichardt Reviewed-by: Rob Norris Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Tony Hutter Closes #16681 --- .github/workflows/scripts/qemu-3-deps.sh | 35 ++++---- tests/runfiles/linux.run | 6 ++ tests/zfs-tests/include/commands.cfg | 1 + tests/zfs-tests/tests/Makefile.am | 3 +- .../tests/functional/luks/luks_sanity.ksh | 90 +++++++++++++++++++ 5 files changed, 117 insertions(+), 18 deletions(-) create mode 100755 tests/zfs-tests/tests/functional/luks/luks_sanity.ksh diff --git a/.github/workflows/scripts/qemu-3-deps.sh b/.github/workflows/scripts/qemu-3-deps.sh index 4c6227b88ed0..bf06c1892ceb 100755 --- a/.github/workflows/scripts/qemu-3-deps.sh +++ b/.github/workflows/scripts/qemu-3-deps.sh @@ -13,10 +13,10 @@ function archlinux() { echo "##[endgroup]" echo "##[group]Install Development Tools" - sudo pacman -Sy --noconfirm base-devel bc cpio dhclient dkms fakeroot \ - fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils parted \ - pax perf python-packaging python-setuptools qemu-guest-agent ksh samba \ - sysstat rng-tools rsync wget xxhash + sudo pacman -Sy --noconfirm base-devel bc cpio cryptsetup dhclient dkms \ + fakeroot fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils \ + parted pax perf python-packaging python-setuptools qemu-guest-agent ksh \ + samba sysstat rng-tools rsync wget xxhash echo "##[endgroup]" } @@ -30,11 +30,11 @@ function debian() { echo "##[group]Install Development Tools" sudo apt-get install -y \ - acl alien attr autoconf bc cpio curl dbench dh-python dkms fakeroot \ - fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev libaio-dev \ - libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev libelf-dev \ - libffi-dev libmount-dev libpam0g-dev libselinux-dev libssl-dev libtool \ - libtool-bin libudev-dev libunwind-dev linux-headers-$(uname -r) \ + acl alien attr autoconf bc cpio cryptsetup curl dbench dh-python dkms \ + fakeroot fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev \ + libaio-dev libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev \ + libelf-dev libffi-dev libmount-dev libpam0g-dev libselinux-dev libssl-dev \ + libtool libtool-bin libudev-dev libunwind-dev linux-headers-$(uname -r) \ lsscsi nfs-kernel-server pamtester parted python3 python3-all-dev \ python3-cffi python3-dev python3-distlib python3-packaging \ python3-setuptools python3-sphinx qemu-guest-agent rng-tools rpm2cpio \ @@ -68,14 +68,15 @@ function rhel() { echo "##[group]Install Development Tools" sudo dnf group install -y "Development Tools" sudo dnf install -y \ - acl attr bc bzip2 curl dbench dkms elfutils-libelf-devel fio gdb git \ - jq kernel-rpm-macros ksh libacl-devel libaio-devel libargon2-devel \ - libattr-devel libblkid-devel libcurl-devel libffi-devel ncompress \ - libselinux-devel libtirpc-devel libtool libudev-devel libuuid-devel \ - lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester parted perf \ - python3 python3-cffi python3-devel python3-packaging kernel-devel \ - python3-setuptools qemu-guest-agent rng-tools rpcgen rpm-build rsync \ - samba sysstat systemd watchdog wget xfsprogs-devel xxhash zlib-devel + acl attr bc bzip2 cryptsetup curl dbench dkms elfutils-libelf-devel fio \ + gdb git jq kernel-rpm-macros ksh libacl-devel libaio-devel \ + libargon2-devel libattr-devel libblkid-devel libcurl-devel libffi-devel \ + ncompress libselinux-devel libtirpc-devel libtool libudev-devel \ + libuuid-devel lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester \ + parted perf python3 python3-cffi python3-devel python3-packaging \ + kernel-devel python3-setuptools qemu-guest-agent rng-tools rpcgen \ + rpm-build rsync samba sysstat systemd watchdog wget xfsprogs-devel xxhash \ + zlib-devel echo "##[endgroup]" } diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index bd6cc56f3589..5217a39ac1ed 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -138,6 +138,12 @@ pre = post = tags = ['functional', 'largest_pool'] +[tests/functional/luks:Linux] +pre = +post = +tests = ['luks_sanity'] +tags = ['functional', 'luks'] + [tests/functional/mmap:Linux] tests = ['mmap_libaio_001_pos', 'mmap_sync_001_pos'] tags = ['functional', 'mmap'] diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index 2fd002ed3a42..fed6f6b74c2c 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -128,6 +128,7 @@ export SYSTEM_FILES_LINUX='attr blkdiscard blockdev chattr + cryptsetup exportfs fallocate flock diff --git a/tests/zfs-tests/tests/Makefile.am b/tests/zfs-tests/tests/Makefile.am index a896a21093ca..2747e24cad9c 100644 --- a/tests/zfs-tests/tests/Makefile.am +++ b/tests/zfs-tests/tests/Makefile.am @@ -80,7 +80,8 @@ if BUILD_LINUX nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ functional/simd/simd_supported.ksh \ functional/tmpfile/cleanup.ksh \ - functional/tmpfile/setup.ksh + functional/tmpfile/setup.ksh \ + functional/luks/luks_sanity.ksh endif nobase_dist_datadir_zfs_tests_tests_DATA += \ diff --git a/tests/zfs-tests/tests/functional/luks/luks_sanity.ksh b/tests/zfs-tests/tests/functional/luks/luks_sanity.ksh new file mode 100755 index 000000000000..9cee26503de7 --- /dev/null +++ b/tests/zfs-tests/tests/functional/luks/luks_sanity.ksh @@ -0,0 +1,90 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2024 by Lawrence Livermore National Security, LLC. +# Use is subject to license terms. +# + +# DESCRIPTION: +# Verify ZFS works on a LUKS-backed pool +# +# STRATEGY: +# 1. Create a LUKS device +# 2. Make a pool with it +# 3. Write files to the pool +# 4. Verify no errors + +. $STF_SUITE/include/libtest.shlib + +verify_runnable "both" + +VDEV=$(mktemp --suffix=luks_sanity) +TESTPOOL=testpool + +function cleanup +{ + log_must zpool destroy $TESTPOOL + + log_must cryptsetup luksClose /dev/mapper/luksdev + log_must rm -f $VDEV +} + +log_assert "Verify ZFS on LUKS works" +log_onexit cleanup + +PASS="fdsjfosdijfsdkjsldfjdlk" + +# Make a small LUKS device since LUKS formatting takes time and we want to +# make this test run as quickly as possible. +truncate -s 100M $VDEV + +log_must cryptsetup luksFormat --type luks2 $VDEV <<< $PASS +log_must cryptsetup luksOpen $VDEV luksdev <<< $PASS + +log_must zpool create $TESTPOOL /dev/mapper/luksdev + +CPUS=$(get_num_cpus) + +# Use these specific size and offset ranges as they often cause errors with +# https://github.com/openzfs/zfs/issues/16631 +# and we want to try to test for that. +for SIZE in {70..100} ; do + for OFF in {70..100} ; do + for i in {1..$CPUS} ; do + dd if=/dev/urandom of=/$TESTPOOL/file$i-bs$SIZE-off$OFF \ + seek=$OFF bs=$SIZE count=1 &>/dev/null & + done + wait + done + sync_pool $TESTPOOL + rm -f /$TESTPOOL/file* +done + +# Verify no read/write/checksum errors. Don't use JSON here so that we could +# could potentially backport this test case to the 2.2.x branch. +if zpool status -e | grep -q "luksdev" ; then + log_note "$(zpool status -v)" + log_fail "Saw errors writing to LUKS device" +fi + +log_pass "Verified ZFS on LUKS works" From bb946ff2325cc4d646417870f73ca636701353de Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Fri, 1 Nov 2024 10:02:03 -0700 Subject: [PATCH 041/223] ZTS: Add Fedora 41, remove Fedora 39 Fedora 41 was released 10/29/24, and Fedora 39 will be EOL on 11/12/24. Update Fedora runners in the test suite. Some minor tweaks also needed to support ksh 1.0.10. Reviewed-by: Brian Behlendorf Reviewed-by: George Melikov Signed-off-by: Tony Hutter Closes #16700 --- .github/workflows/scripts/qemu-2-start.sh | 12 ++++++------ .github/workflows/scripts/qemu-3-deps.sh | 8 +++++++- .github/workflows/scripts/qemu-4-build.sh | 2 +- .github/workflows/zfs-qemu.yml | 6 +++--- .../cli_root/zpool_add/zpool_add_dryrun_output.ksh | 6 +++--- .../zpool_create/zpool_create_dryrun_output.ksh | 4 ++-- .../zpool_split/zpool_split_dryrun_output.ksh | 6 +++--- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/scripts/qemu-2-start.sh b/.github/workflows/scripts/qemu-2-start.sh index 84e13832d10f..39ac92107b71 100755 --- a/.github/workflows/scripts/qemu-2-start.sh +++ b/.github/workflows/scripts/qemu-2-start.sh @@ -52,16 +52,16 @@ case "$OS" in OSNAME="Debian 12" URL="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2" ;; - fedora39) - OSNAME="Fedora 39" - OSv="fedora39" - URL="https://download.fedoraproject.org/pub/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-39-1.5.x86_64.qcow2" - ;; fedora40) OSNAME="Fedora 40" - OSv="fedora39" + OSv="fedora-unknown" URL="https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2" ;; + fedora41) + OSNAME="Fedora 41" + OSv="fedora-unknown" + URL="https://download.fedoraproject.org/pub/fedora/linux/releases/41/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-41-1.4.x86_64.qcow2" + ;; freebsd13-3r) OSNAME="FreeBSD 13.3-RELEASE" OSv="freebsd13.0" diff --git a/.github/workflows/scripts/qemu-3-deps.sh b/.github/workflows/scripts/qemu-3-deps.sh index bf06c1892ceb..96979cd02e09 100755 --- a/.github/workflows/scripts/qemu-3-deps.sh +++ b/.github/workflows/scripts/qemu-3-deps.sh @@ -66,7 +66,13 @@ function rhel() { echo "##[endgroup]" echo "##[group]Install Development Tools" - sudo dnf group install -y "Development Tools" + + # Alma wants "Development Tools", Fedora 41 wants "development-tools" + if ! sudo dnf group install -y "Development Tools" ; then + echo "Trying 'development-tools' instead of 'Development Tools'" + sudo dnf group install -y development-tools + fi + sudo dnf install -y \ acl attr bc bzip2 cryptsetup curl dbench dkms elfutils-libelf-devel fio \ gdb git jq kernel-rpm-macros ksh libacl-devel libaio-devel \ diff --git a/.github/workflows/scripts/qemu-4-build.sh b/.github/workflows/scripts/qemu-4-build.sh index 1051ee1f4deb..955f605f5bce 100755 --- a/.github/workflows/scripts/qemu-4-build.sh +++ b/.github/workflows/scripts/qemu-4-build.sh @@ -83,7 +83,7 @@ function rpm_build_and_install() { echo "##[endgroup]" echo "##[group]Install" - run sudo dnf -y --skip-broken localinstall $(ls *.rpm | grep -v src.rpm) + run sudo dnf -y --nobest install $(ls *.rpm | grep -v src.rpm) echo "##[endgroup]" } diff --git a/.github/workflows/zfs-qemu.yml b/.github/workflows/zfs-qemu.yml index f819e9938e31..e90030f4c02e 100644 --- a/.github/workflows/zfs-qemu.yml +++ b/.github/workflows/zfs-qemu.yml @@ -22,8 +22,8 @@ jobs: - name: Generate OS config and CI type id: os run: | - FULL_OS='["almalinux8", "almalinux9", "centos-stream9", "debian11", "debian12", "fedora39", "fedora40", "freebsd13-4r", "freebsd14-0r", "freebsd14-1s", "ubuntu20", "ubuntu22", "ubuntu24"]' - QUICK_OS='["almalinux8", "almalinux9", "debian12", "fedora40", "freebsd13-3r", "freebsd14-1r", "ubuntu24"]' + FULL_OS='["almalinux8", "almalinux9", "centos-stream9", "debian11", "debian12", "fedora40", "fedora41", "freebsd13-4r", "freebsd14-0r", "freebsd14-1s", "ubuntu20", "ubuntu22", "ubuntu24"]' + QUICK_OS='["almalinux8", "almalinux9", "debian12", "fedora41", "freebsd13-3r", "freebsd14-1r", "ubuntu24"]' # determine CI type when running on PR ci_type="full" if ${{ github.event_name == 'pull_request' }}; then @@ -46,7 +46,7 @@ jobs: strategy: fail-fast: false matrix: - # rhl: almalinux8, almalinux9, centos-stream9, fedora39, fedora40 + # rhl: almalinux8, almalinux9, centos-stream9, fedora40, fedora41 # debian: debian11, debian12, ubuntu20, ubuntu22, ubuntu24 # misc: archlinux, tumbleweed # FreeBSD Release: freebsd13-3r, freebsd13-4r, freebsd14-0r, freebsd14-1r diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh index fa1ce9c64d33..3b06e8c35c77 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh @@ -148,9 +148,9 @@ done # Foreach test create pool, add -n devices and check output. for (( i=0; i < ${#tests[@]}; i+=1 )); do - typeset tree="${tests[$i].tree}" - typeset add="${tests[$i].add}" - typeset want="${tests[$i].want}" + tree="${tests[$i].tree}" + add="${tests[$i].add}" + want="${tests[$i].want}" log_must eval zpool create "$TESTPOOL" $tree log_must poolexists "$TESTPOOL" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh index 485891c945a3..0671ea618e05 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh @@ -124,8 +124,8 @@ done # Foreach test create pool, add -n devices and check output. for (( i=0; i < ${#tests[@]}; i+=1 )); do - typeset tree="${tests[$i].tree}" - typeset want="${tests[$i].want}" + tree="${tests[$i].tree}" + want="${tests[$i].want}" typeset out="$(log_must eval "zpool create -n '$TESTPOOL' $tree" | \ sed /^SUCCESS/d)" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh index 410b1fe7a03e..def1d154387d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh @@ -133,9 +133,9 @@ done # Foreach test create pool, add -n devices and check output. for (( i=0; i < ${#tests[@]}; i+=1 )); do - typeset tree="${tests[$i].tree}" - typeset devs="${tests[$i].devs}" - typeset want="${tests[$i].want}" + tree="${tests[$i].tree}" + devs="${tests[$i].devs}" + want="${tests[$i].want}" log_must eval zpool create "$TESTPOOL" $tree log_must poolexists "$TESTPOOL" From 25ec9a9034a26d78ce826de2783e01eec93efb04 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 19 Jul 2024 03:51:27 +1000 Subject: [PATCH 042/223] zdb: fix BRT dump (#16335) BRT refcounts are stored as eight uint8_ts rather than a single uint64_t. This means that za_first_integer is only the first byte, so max 256. This fixes it by doing a lookup for the whole value. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris Reviewed-by: Tony Hutter Reviewed-by: Alexander Motin --- cmd/zdb/zdb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 2caa83f5c636..a8a3cd9dc3bc 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -2208,8 +2208,13 @@ dump_brt(spa_t *spa) for (zap_cursor_init(&zc, brt->brt_mos, brtvd->bv_mos_entries); zap_cursor_retrieve(&zc, &za) == 0; zap_cursor_advance(&zc)) { - uint64_t offset = *(uint64_t *)za.za_name; - uint64_t refcnt = za.za_first_integer; + uint64_t refcnt; + VERIFY0(zap_lookup_uint64(brt->brt_mos, + brtvd->bv_mos_entries, + (const uint64_t *)za.za_name, 1, + za.za_integer_length, za.za_num_integers, &refcnt)); + + uint64_t offset = *(const uint64_t *)za.za_name; snprintf(dva, sizeof (dva), "%" PRIu64 ":%llx", vdevid, (u_longlong_t)offset); From bc0d89bfc1303c625cfadfab55f4b8e50515b5e7 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 10 Sep 2024 10:08:45 -0600 Subject: [PATCH 043/223] Fix an uninitialized data access (#16511) zfs_acl_node_alloc allocates an uninitialized data buffer, but upstack zfs_acl_chmod only partially initializes it. KMSAN reported that this memory remained uninitialized at the point when it was read by lzjb_compress, which suggests a possible kernel memory disclosure bug. The full KMSAN warning may be found in the PR. https://github.com/openzfs/zfs/pull/16511 Signed-off-by: Alan Somers Sponsored by: Axcient Reviewed-by: Alexander Motin Reviewed-by: Tony Hutter --- module/os/freebsd/zfs/zfs_acl.c | 2 +- module/os/linux/zfs/zfs_acl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module/os/freebsd/zfs/zfs_acl.c b/module/os/freebsd/zfs/zfs_acl.c index 20466aeaaa05..1f1ac3a38d7a 100644 --- a/module/os/freebsd/zfs/zfs_acl.c +++ b/module/os/freebsd/zfs/zfs_acl.c @@ -473,7 +473,7 @@ zfs_acl_node_alloc(size_t bytes) aclnode = kmem_zalloc(sizeof (zfs_acl_node_t), KM_SLEEP); if (bytes) { - aclnode->z_acldata = kmem_alloc(bytes, KM_SLEEP); + aclnode->z_acldata = kmem_zalloc(bytes, KM_SLEEP); aclnode->z_allocdata = aclnode->z_acldata; aclnode->z_allocsize = bytes; aclnode->z_size = bytes; diff --git a/module/os/linux/zfs/zfs_acl.c b/module/os/linux/zfs/zfs_acl.c index a1fd3c9856cc..7c86cf9a8b33 100644 --- a/module/os/linux/zfs/zfs_acl.c +++ b/module/os/linux/zfs/zfs_acl.c @@ -471,7 +471,7 @@ zfs_acl_node_alloc(size_t bytes) aclnode = kmem_zalloc(sizeof (zfs_acl_node_t), KM_SLEEP); if (bytes) { - aclnode->z_acldata = kmem_alloc(bytes, KM_SLEEP); + aclnode->z_acldata = kmem_zalloc(bytes, KM_SLEEP); aclnode->z_allocdata = aclnode->z_acldata; aclnode->z_allocsize = bytes; aclnode->z_size = bytes; From c25d5140b0a554392a40317c43a89f0490d6df86 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 18 Sep 2024 06:53:39 +1000 Subject: [PATCH 044/223] sa_impl: fix SA header bitfield docs Off by one, confused me a while! Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16500 --- include/sys/sa_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sys/sa_impl.h b/include/sys/sa_impl.h index 744c8dcb7dfb..46a7cbf8080e 100644 --- a/include/sys/sa_impl.h +++ b/include/sys/sa_impl.h @@ -167,8 +167,8 @@ typedef struct sa_hdr_phys { * | hdrsz |layout | * +--------+-------+ * - * Bits 0-10 are the layout number - * Bits 11-16 are the size of the header. + * Bits 0-9 (10 bits) are the layout number (0-1023) + * Bits 10-15 (6 bits) are the size of the header (0-63) * The hdrsize is the number * 8 * * For example. From 2dc8529d9a6b390c4da7a2d6386b74f2f351fb2b Mon Sep 17 00:00:00 2001 From: rmacklem <64620010+rmacklem@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:56:26 -0700 Subject: [PATCH 045/223] Fix handling of DNS names with '-' in them for sharenfs An old FreeBSD bugzilla report PR#168158 notes that DNS names with '-'s in them cannot be used for the sharenfs property. This patch fixes the parsing of these DNS names. The only negative affect this patch might have is that, if a user has incorrectly separated options with a '-' the sharenfs setting will no longer work once this patch is applied. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rick Macklem Closes #16529 --- lib/libshare/os/freebsd/nfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c index d9fc66106369..dbfc86f2a36b 100644 --- a/lib/libshare/os/freebsd/nfs.c +++ b/lib/libshare/os/freebsd/nfs.c @@ -85,7 +85,9 @@ translate_opts(const char *shareopts, FILE *out) strlcpy(oldopts, shareopts, sizeof (oldopts)); newopts[0] = '\0'; s = oldopts; - while ((o = strsep(&s, "-, ")) != NULL) { + while ((o = strsep(&s, ", ")) != NULL) { + if (o[0] == '-') + o++; if (o[0] == '\0') continue; for (i = 0; i < ARRAY_SIZE(known_opts); ++i) { From 94a571b3d90a8a254d60e27149cf778795208330 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Fri, 20 Sep 2024 22:19:57 +0500 Subject: [PATCH 046/223] Add compatibility file for GRUB versions up to v2.06 GRUB is not able to detect ZFS pool if snaphsot of top level boot pool is created. This issue is observed with GRUB versions up to v2.06 if extensible_dataset feature is enabled on ZFS boot pool. compatibility=grub2-2.06 would enable all read-only compatible zpool features except extensible_dataset and other features that depend on it. The existing grub2 compatibility file is now renamed to grub2-2.12 to reflect the appropriate grub2 version. grub2-2.12 lists all read-only features that can be enabled on boot pool for grub2 with version 2.12 onwards. A new symlink grub2 is created that currently points to the grub2-2.12 compatibility file. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Umer Saleem Closes #13873 Closes #15261 Closes #15909 --- cmd/zpool/Makefile.am | 4 ++- cmd/zpool/compatibility.d/grub2-2.06 | 23 +++++++++++++++ .../compatibility.d/{grub2 => grub2-2.12} | 2 +- man/man7/zpool-features.7 | 29 +++++++++++++++++-- 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 cmd/zpool/compatibility.d/grub2-2.06 rename cmd/zpool/compatibility.d/{grub2 => grub2-2.12} (81%) diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am index d08b8e1791b6..8a218d365893 100644 --- a/cmd/zpool/Makefile.am +++ b/cmd/zpool/Makefile.am @@ -140,7 +140,8 @@ dist_zpoolcompat_DATA = \ %D%/compatibility.d/freebsd-11.2 \ %D%/compatibility.d/freebsd-11.3 \ %D%/compatibility.d/freenas-9.10.2 \ - %D%/compatibility.d/grub2 \ + %D%/compatibility.d/grub2-2.06 \ + %D%/compatibility.d/grub2-2.12 \ %D%/compatibility.d/openzfs-2.0-freebsd \ %D%/compatibility.d/openzfs-2.0-linux \ %D%/compatibility.d/openzfs-2.1-freebsd \ @@ -171,6 +172,7 @@ zpoolcompatlinks = \ "freebsd-11.3 freebsd-12.2" \ "freebsd-11.3 freebsd-12.3" \ "freebsd-11.3 freebsd-12.4" \ + "grub2-2.12 grub2" \ "openzfs-2.1-freebsd freebsd-13.0" \ "openzfs-2.1-freebsd freebsd-13.1" \ "openzfs-2.1-freebsd freebsd-13.2" \ diff --git a/cmd/zpool/compatibility.d/grub2-2.06 b/cmd/zpool/compatibility.d/grub2-2.06 new file mode 100644 index 000000000000..ea7468dbcc78 --- /dev/null +++ b/cmd/zpool/compatibility.d/grub2-2.06 @@ -0,0 +1,23 @@ +# Features which are supported by GRUB2 versions prior to v2.12. +# +# GRUB is not able to detect ZFS pool if snaphsot of top level boot pool +# is created. This issue is observed with GRUB versions before v2.12 if +# extensible_dataset feature is enabled on ZFS boot pool. +# +# This file lists all read-only comaptible features except +# extensible_dataset and any other feature that depends on it. +# +allocation_classes +async_destroy +block_cloning +device_rebuild +embedded_data +empty_bpobj +enabled_txg +hole_birth +log_spacemap +lz4_compress +resilver_defer +spacemap_histogram +spacemap_v2 +zpool_checkpoint diff --git a/cmd/zpool/compatibility.d/grub2 b/cmd/zpool/compatibility.d/grub2-2.12 similarity index 81% rename from cmd/zpool/compatibility.d/grub2 rename to cmd/zpool/compatibility.d/grub2-2.12 index 6d60e643593b..86cce6338bb8 100644 --- a/cmd/zpool/compatibility.d/grub2 +++ b/cmd/zpool/compatibility.d/grub2-2.12 @@ -1,4 +1,4 @@ -# Features which are supported by GRUB2 +# Features which are supported by GRUB2 versions from v2.12 onwards. allocation_classes async_destroy block_cloning diff --git a/man/man7/zpool-features.7 b/man/man7/zpool-features.7 index 8456a9aa7648..92d933e1e8ef 100644 --- a/man/man7/zpool-features.7 +++ b/man/man7/zpool-features.7 @@ -218,7 +218,7 @@ to the end of the line is ignored. .Sy Example : .Bd -literal -compact -offset 4n .No example# Nm cat Pa /usr/share/zfs/compatibility.d/grub2 -# Features which are supported by GRUB2 +# Features which are supported by GRUB2 versions from v2.12 onwards. allocation_classes async_destroy block_cloning @@ -242,6 +242,31 @@ userobj_accounting zilsaxattr zpool_checkpoint +.No example# Nm cat Pa /usr/share/zfs/compatibility.d/grub2-2.06 +# Features which are supported by GRUB2 versions prior to v2.12. +# +# GRUB is not able to detect ZFS pool if snaphsot of top level boot pool +# is created. This issue is observed with GRUB versions before v2.12 if +# extensible_dataset feature is enabled on ZFS boot pool. +# +# This file lists all read-only comaptible features except +# extensible_dataset and any other feature that depends on it. +# +allocation_classes +async_destroy +block_cloning +device_rebuild +embedded_data +empty_bpobj +enabled_txg +hole_birth +log_spacemap +lz4_compress +resilver_defer +spacemap_histogram +spacemap_v2 +zpool_checkpoint + .No example# Nm zpool Cm create Fl o Sy compatibility Ns = Ns Ar grub2 Ar bootpool Ar vdev .Ed .Pp @@ -666,7 +691,7 @@ are destroyed. Large dnodes allow more data to be stored in the bonus buffer, thus potentially improving performance by avoiding the use of spill blocks. . -.feature com.delphix livelist yes +.feature com.delphix livelist yes extensible_dataset This feature allows clones to be deleted faster than the traditional method when a large number of random/sparse writes have been made to the clone. All blocks allocated and freed after a clone is created are tracked by the From 54278533a4b20d2ecf026c04304829272f4130dc Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 21 Sep 2024 13:36:25 -0400 Subject: [PATCH 047/223] Reduce and handle EAGAIN errors on AIO label reads At least FreeBSD has a limit of 256 simultaneous AIO requests per process. Attempt to issue more results in EAGAIN errors. Since we issue 4 requests per disk/partition from 2xCPUs threads, it is quite easy to reach that limit on large systems, that results in random pool import failures. It annoyed me for quite a while on a system with 64 CPUs and 70+ partitioned disks. This patch from one side limits the number of threads to avoid the error, while from another should softly fall back to sync reads in case of error. It takes into account _SC_AIO_MAX as a system-wide AIO limit and _SC_AIO_LISTIO_MAX as a closest value to per-process limit. The last not exactly right, but it is the best I found. Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16551 --- lib/libzutil/zutil_import.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c index eb9131190458..b49153c67f7b 100644 --- a/lib/libzutil/zutil_import.c +++ b/lib/libzutil/zutil_import.c @@ -1071,6 +1071,7 @@ zpool_read_label(int fd, nvlist_t **config, int *num_labels) * Try the slow method. */ zfs_fallthrough; + case EAGAIN: case EOPNOTSUPP: case ENOSYS: do_slow = B_TRUE; @@ -1464,7 +1465,21 @@ zpool_find_import_impl(libpc_handle_t *hdl, importargs_t *iarg, * validating labels, a large number of threads can be used due to * minimal contention. */ - t = tpool_create(1, 2 * sysconf(_SC_NPROCESSORS_ONLN), 0, NULL); + long threads = 2 * sysconf(_SC_NPROCESSORS_ONLN); +#ifdef HAVE_AIO_H + long am; +#ifdef _SC_AIO_LISTIO_MAX + am = sysconf(_SC_AIO_LISTIO_MAX); + if (am >= VDEV_LABELS) + threads = MIN(threads, am / VDEV_LABELS); +#endif +#ifdef _SC_AIO_MAX + am = sysconf(_SC_AIO_MAX); + if (am >= VDEV_LABELS) + threads = MIN(threads, am / VDEV_LABELS); +#endif +#endif + t = tpool_create(1, threads, 0, NULL); for (slice = avl_first(cache); slice; (slice = avl_walk(cache, slice, AVL_AFTER))) (void) tpool_dispatch(t, zpool_open_func, slice); From 098789216023bec08cd90b2a2ce9893611bbf790 Mon Sep 17 00:00:00 2001 From: "Theera K." Date: Tue, 24 Sep 2024 12:12:56 +0700 Subject: [PATCH 048/223] Evicting too many bytes from MFU metadata Without updating 'm' we evict from MFU metadata all that we wanted to evict from all metadata, including already evicted MRU metadata ('m' is the total amount of metadata we had at the beginning, and 'w' is the total amount of metadata we want to have). Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Theera K. Closes #16521 Closes #16546 --- module/zfs/arc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index d7ee9d32a75b..f40de4cb9ef7 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -4311,7 +4311,7 @@ arc_evict(void) /* Evict MFU metadata. */ w = wt * (int64_t)(arc_meta >> 16) >> 16; - e = MIN((int64_t)(asize - arc_c), (int64_t)(m - w)); + e = MIN((int64_t)(asize - arc_c), (int64_t)(m - bytes - w)); bytes = arc_evict_impl(arc_mfu, ARC_BUFC_METADATA, e); total_evicted += bytes; mfum -= bytes; From 96162750216529fc2aec73d3c24df37fd18e8680 Mon Sep 17 00:00:00 2001 From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> Date: Fri, 20 Sep 2024 11:16:44 -0400 Subject: [PATCH 049/223] Add SIMD metadata in /proc on Linux Too many times, people's performance problems have amounted to "somehow your SIMD support isn't working", and determining that at runtime is difficult to describe to people. This adds a /proc/spl/kstat/zfs/simd node, which exposes metadata about which instructions ZFS thinks it can use, on AArch64 and x86_64 Linux, to make investigating things like this much easier. Reviewed-by: Brian Behlendorf Signed-off-by: Rich Ercolani Closes #16530 --- include/os/freebsd/spl/sys/simd.h | 3 + include/os/linux/kernel/linux/simd.h | 4 + lib/libspl/include/sys/simd.h | 3 + lib/libzpool/Makefile.am | 1 + module/Kbuild.in | 1 + module/zcommon/simd_stat.c | 189 +++++++++++++++++++++++++++ module/zcommon/zfs_prop.c | 6 + 7 files changed, 207 insertions(+) create mode 100644 module/zcommon/simd_stat.c diff --git a/include/os/freebsd/spl/sys/simd.h b/include/os/freebsd/spl/sys/simd.h index 4560bb05e978..6bc46755c4e3 100644 --- a/include/os/freebsd/spl/sys/simd.h +++ b/include/os/freebsd/spl/sys/simd.h @@ -50,4 +50,7 @@ #define kfpu_fini() do {} while (0) #endif +#define simd_stat_init() 0 +#define simd_stat_fini() 0 + #endif diff --git a/include/os/linux/kernel/linux/simd.h b/include/os/linux/kernel/linux/simd.h index f4376b218a55..e7d7a4f2255e 100644 --- a/include/os/linux/kernel/linux/simd.h +++ b/include/os/linux/kernel/linux/simd.h @@ -45,4 +45,8 @@ #define kfpu_fini() ((void) 0) #endif + +void simd_stat_init(void); +void simd_stat_fini(void); + #endif /* _LINUX_SIMD_H */ diff --git a/lib/libspl/include/sys/simd.h b/lib/libspl/include/sys/simd.h index 41f9df506468..2926dc680764 100644 --- a/lib/libspl/include/sys/simd.h +++ b/lib/libspl/include/sys/simd.h @@ -592,4 +592,7 @@ zfs_isa207_available(void) #endif +extern void simd_stat_init(void); +extern void simd_stat_fini(void); + #endif /* _LIBSPL_SYS_SIMD_H */ diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 58d7f07527aa..99621b60e6c3 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -49,6 +49,7 @@ nodist_libzpool_la_SOURCES = \ module/os/linux/zfs/zio_crypt.c \ \ module/zcommon/cityhash.c \ + module/zcommon/simd_stat.c \ module/zcommon/zfeature_common.c \ module/zcommon/zfs_comutil.c \ module/zcommon/zfs_deleg.c \ diff --git a/module/Kbuild.in b/module/Kbuild.in index 3d980819291c..e6b3ffd8f319 100644 --- a/module/Kbuild.in +++ b/module/Kbuild.in @@ -236,6 +236,7 @@ zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS)) ZCOMMON_OBJS := \ cityhash.o \ + simd_stat.o \ zfeature_common.o \ zfs_comutil.o \ zfs_deleg.o \ diff --git a/module/zcommon/simd_stat.c b/module/zcommon/simd_stat.c new file mode 100644 index 000000000000..538f8317acc4 --- /dev/null +++ b/module/zcommon/simd_stat.c @@ -0,0 +1,189 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2024 Google, Inc. All rights reserved. + */ +#include +#include +#include + + +#ifdef _KERNEL +#ifdef __linux__ +#include +#endif /* __linux__ */ +kstat_t *simd_stat_kstat; +#endif /* _KERNEL */ + +#ifdef _KERNEL +#define SIMD_STAT_PRINT(s, feat, val) \ + kmem_scnprintf(s + off, MAX(4095-off, 0), "%-16s\t%1d\n", feat, (val)) + +static int +simd_stat_kstat_data(char *buf, size_t size, void *data) +{ + (void) data; + + static char simd_stat_kstat_payload[4096] = {0}; + static int off = 0; +#ifdef __linux__ + if (off == 0) { + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "kfpu_allowed", kfpu_allowed()); +#ifdef __x86__ + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "kfpu", HAVE_KERNEL_FPU); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "kfpu_internal", HAVE_KERNEL_FPU_INTERNAL); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "__kernel_fpu", HAVE_UNDERSCORE_KERNEL_FPU); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "sse", zfs_sse_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "sse2", zfs_sse2_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "sse3", zfs_sse3_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "ssse3", zfs_ssse3_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "sse41", zfs_sse4_1_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "sse42", zfs_sse4_2_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx", zfs_avx_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx2", zfs_avx2_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512f", zfs_avx512f_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512cd", zfs_avx512cd_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512er", zfs_avx512er_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512pf", zfs_avx512pf_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512bw", zfs_avx512bw_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512dq", zfs_avx512dq_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512vl", zfs_avx512vl_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512ifma", zfs_avx512ifma_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "avx512vbmi", zfs_avx512vbmi_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "ymm", __ymm_enabled()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "zmm", __zmm_enabled()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "bmi1", zfs_bmi1_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "bmi2", zfs_bmi2_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "aes", zfs_aes_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "pclmulqdq", zfs_pclmulqdq_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "movbe", zfs_movbe_available()); + + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "osxsave", boot_cpu_has(X86_FEATURE_OSXSAVE)); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "xsaves", static_cpu_has(X86_FEATURE_XSAVES)); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "xsaveopt", static_cpu_has(X86_FEATURE_XSAVEOPT)); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "xsave", static_cpu_has(X86_FEATURE_XSAVE)); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "fxsr", static_cpu_has(X86_FEATURE_FXSR)); +#endif /* __x86__ */ +#if defined(__arm__) || defined(__aarch64__) + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "kernel_neon", HAVE_KERNEL_NEON); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "kernel_mode_neon", CONFIG_KERNEL_MODE_NEON); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "neon", zfs_neon_available()); + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "sha256", zfs_sha256_available()); +#if defined(__aarch64__) + /* + * This technically can exist on 32b ARM but we don't + * define hooks to check for it and I didn't want to + * learn enough ARM ASM to add one. + */ + off += SIMD_STAT_PRINT(simd_stat_kstat_payload, + "sha512", zfs_sha512_available()); +#endif /* __aarch64__ */ +#endif /* __arm__ */ + /* We want to short-circuit this on unsupported platforms. */ + off += 1; + } + + kmem_scnprintf(buf, MIN(off, size), "%s", simd_stat_kstat_payload); +#endif /* __linux__ */ + return (0); +} +#endif /* _KERNEL */ + +void +simd_stat_init(void) +{ + static boolean_t simd_stat_initialized = B_FALSE; + + if (!simd_stat_initialized) { +#if defined(_KERNEL) + /* Install kstats for all implementations */ + simd_stat_kstat = kstat_create("zfs", 0, "simd", "misc", + KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL); + + + if (simd_stat_kstat != NULL) { + simd_stat_kstat->ks_data = (void*)(uintptr_t)1; + simd_stat_kstat->ks_ndata = 1; + simd_stat_kstat->ks_flags |= KSTAT_FLAG_NO_HEADERS; + kstat_set_raw_ops(simd_stat_kstat, + NULL, + simd_stat_kstat_data, + NULL); + kstat_install(simd_stat_kstat); + } +#endif /* _KERNEL */ + } + /* Finish initialization */ + simd_stat_initialized = B_TRUE; +} + +void +simd_stat_fini(void) +{ +#if defined(_KERNEL) + if (simd_stat_kstat != NULL) { + kstat_delete(simd_stat_kstat); + simd_stat_kstat = NULL; + } +#endif +} + +#ifdef _KERNEL +EXPORT_SYMBOL(simd_stat_init); +EXPORT_SYMBOL(simd_stat_fini); +#endif diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 29764674a31b..a14e14e3633a 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "zfs_prop.h" #include "zfs_deleg.h" @@ -1060,6 +1061,9 @@ EXPORT_SYMBOL(zfs_kfpu_fpregs); extern int __init zcommon_init(void); extern void zcommon_fini(void); +extern void simd_stat_init(void); +extern void simd_stat_fini(void); + int __init zcommon_init(void) { @@ -1068,6 +1072,7 @@ zcommon_init(void) return (error); fletcher_4_init(); + simd_stat_init(); return (0); } @@ -1075,6 +1080,7 @@ zcommon_init(void) void zcommon_fini(void) { + simd_stat_fini(); fletcher_4_fini(); kfpu_fini(); } From 948704cb37f75711a4955c17ef0d3f4605d9fe96 Mon Sep 17 00:00:00 2001 From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:11:19 -0400 Subject: [PATCH 050/223] Fix /proc/spl/kstat/simd on x86 Evidently while reworking it on aarch64, I broke it on x86 and didn't notice. Reviewed-by: Brian Behlendorf Signed-off-by: Rich Ercolani Closes #16556 --- module/zcommon/simd_stat.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/module/zcommon/simd_stat.c b/module/zcommon/simd_stat.c index 538f8317acc4..f2d100d84e4b 100644 --- a/module/zcommon/simd_stat.c +++ b/module/zcommon/simd_stat.c @@ -34,6 +34,14 @@ kstat_t *simd_stat_kstat; #endif /* _KERNEL */ #ifdef _KERNEL +/* Sometimes, we don't define these at all. */ +#ifndef HAVE_KERNEL_FPU +#define HAVE_KERNEL_FPU (0) +#endif +#ifndef HAVE_UNDERSCORE_KERNEL_FPU +#define HAVE_UNDERSCORE_KERNEL_FPU (0) +#endif + #define SIMD_STAT_PRINT(s, feat, val) \ kmem_scnprintf(s + off, MAX(4095-off, 0), "%-16s\t%1d\n", feat, (val)) @@ -48,7 +56,7 @@ simd_stat_kstat_data(char *buf, size_t size, void *data) if (off == 0) { off += SIMD_STAT_PRINT(simd_stat_kstat_payload, "kfpu_allowed", kfpu_allowed()); -#ifdef __x86__ +#if defined(__x86_64__) || defined(__i386__) off += SIMD_STAT_PRINT(simd_stat_kstat_payload, "kfpu", HAVE_KERNEL_FPU); off += SIMD_STAT_PRINT(simd_stat_kstat_payload, From b9658f9a67eab8de14408fa32d1374fe8f48e1a7 Mon Sep 17 00:00:00 2001 From: w0xel Date: Tue, 24 Sep 2024 18:07:26 +0200 Subject: [PATCH 051/223] Add missing guard defines for simd_stat This adds the HAVE_KERNEL_NEON and HAVE_KERNEL_FPU_INTERNAL guards to simd_stat.c defaulted to 0 to make it build again. Reviewed-by: Brian Behlendorf Reviewed-by: Shengqi Chen Signed-off-by: Sebastian Wuerl Closes #16558 --- module/zcommon/simd_stat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/module/zcommon/simd_stat.c b/module/zcommon/simd_stat.c index f2d100d84e4b..33c15140cdb9 100644 --- a/module/zcommon/simd_stat.c +++ b/module/zcommon/simd_stat.c @@ -38,6 +38,12 @@ kstat_t *simd_stat_kstat; #ifndef HAVE_KERNEL_FPU #define HAVE_KERNEL_FPU (0) #endif +#ifndef HAVE_KERNEL_NEON +#define HAVE_KERNEL_NEON (0) +#endif +#ifndef HAVE_KERNEL_FPU_INTERNAL +#define HAVE_KERNEL_FPU_INTERNAL (0) +#endif #ifndef HAVE_UNDERSCORE_KERNEL_FPU #define HAVE_UNDERSCORE_KERNEL_FPU (0) #endif From 21c40e6d9e8427679cba05f35db21c85f2723592 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 24 Sep 2024 19:29:18 -0400 Subject: [PATCH 052/223] FreeBSD: Sync taskq_cancel_id() returns with Linux Couple places in the code depend on 0 returned only if the task was actually cancelled. Doing otherwise could lead to extra references being dropped. The race could be small, but I believe CI hit it from time to time. Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16565 --- module/os/freebsd/spl/spl_taskq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/os/freebsd/spl/spl_taskq.c b/module/os/freebsd/spl/spl_taskq.c index 842b80ade1fb..266fe9a9a56d 100644 --- a/module/os/freebsd/spl/spl_taskq.c +++ b/module/os/freebsd/spl/spl_taskq.c @@ -283,7 +283,7 @@ taskq_cancel_id(taskq_t *tq, taskqid_t tid) taskq_ent_t *ent; if ((ent = taskq_lookup(tid)) == NULL) - return (0); + return (ENOENT); if (ent->tqent_type == NORMAL_TASK) { rc = taskqueue_cancel(tq->tq_queue, &ent->tqent_task, &pend); @@ -306,7 +306,7 @@ taskq_cancel_id(taskq_t *tq, taskqid_t tid) } /* Free the extra reference we added with taskq_lookup. */ taskq_free(ent); - return (rc); + return (pend ? 0 : ENOENT); } static void From 48482bb2f4f12e99a3ffda994cf9e6778b56bc95 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 25 Sep 2024 10:40:17 -0400 Subject: [PATCH 053/223] Properly release key in spa_keystore_dsl_key_hold_dd() Since dsl_crypto_key_open() references the key, 0d23f5e2e4 should have called dsl_crypto_key_rele() to drop it first instead of calling dsl_crypto_key_free() directly. The final result should actually be the same, but without triggering dck_holds assertion. Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16567 --- module/zfs/dsl_crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zfs/dsl_crypt.c b/module/zfs/dsl_crypt.c index 8e1055d9bcb1..8e7bf07bbda1 100644 --- a/module/zfs/dsl_crypt.c +++ b/module/zfs/dsl_crypt.c @@ -717,7 +717,7 @@ spa_keystore_dsl_key_hold_dd(spa_t *spa, dsl_dir_t *dd, const void *tag, avl_insert(&spa->spa_keystore.sk_dsl_keys, dck_io, where); *dck_out = dck_io; } else { - dsl_crypto_key_free(dck_io); + dsl_crypto_key_rele(dck_io, tag); *dck_out = dck_ks; } From 2bd540d273db8c2699e6d664afcc5a0957e1b9a7 Mon Sep 17 00:00:00 2001 From: George Melikov Date: Sun, 29 Sep 2024 23:19:52 +0300 Subject: [PATCH 054/223] man: update recordsize max size info Reflect https://github.com/openzfs/zfs/commit/f2330bd1568489ae1fb16d975a5a9bcfe12ed219 change in our man pages and add some context. Wording is primarily copy-pasted from code comments. Reviewed-by: Brian Behlendorf Reviewed-by: Tino Reichardt Signed-off-by: George Melikov Closes #16581 --- man/man4/zfs.4 | 5 +++++ man/man7/zfsprops.7 | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/man/man4/zfs.4 b/man/man4/zfs.4 index 902d73c16eb7..a20924002d4c 100644 --- a/man/man4/zfs.4 +++ b/man/man4/zfs.4 @@ -1607,6 +1607,11 @@ Therefore, we formerly forbade creating blocks larger than 1M. Larger blocks could be created by changing it, and pools with larger blocks can always be imported and used, regardless of this setting. +.Pp +Note that it is still limited by default to +.Ar 1 MiB +on x86_32, because Linux's +3/1 memory split doesn't leave much room for 16M chunks. . .It Sy zfs_allow_redacted_dataset_mount Ns = Ns Sy 0 Ns | Ns 1 Pq int Allow datasets received with redacted send/receive to be mounted. diff --git a/man/man7/zfsprops.7 b/man/man7/zfsprops.7 index 59f6404379af..779ec1bad2d0 100644 --- a/man/man7/zfsprops.7 +++ b/man/man7/zfsprops.7 @@ -1463,11 +1463,22 @@ and less than or equal to If the .Sy large_blocks feature is enabled on the pool, the size may be up to -.Ar 1 MiB . +.Ar 16 MiB . See .Xr zpool-features 7 for details on ZFS feature flags. .Pp +However, blocks larger than +.Ar 1 MiB +can have an impact on i/o latency (e.g. tying up a spinning disk for +~300ms), and also potentially on the memory allocator. +.Pp +Note that maximum size is still limited by default to +.Ar 1 MiB +on x86_32, see +.Sy zfs_max_recordsize +module parameter. +.Pp Changing the file system's .Sy recordsize affects only files created afterward; existing files are unaffected. From 4adc97ae15f29444703c6bda76e13711f8e6f1a2 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 1 Oct 2024 03:30:03 +1000 Subject: [PATCH 055/223] lua: add flex array field to TString type Linux 6.10+ with CONFIG_FORTIFY_SOURCE notices memcpy() accessing past the end of TString, because it has no indication that there there may be an additional allocation there. There's no appropriate upstream change for this (ancient) version of Lua, so this is the narrowest change I could come up with to add a flex array field to the end of TString to satisfy the check. It's loosely based on changes from lua/lua@ca41b43f and lua/lua@9514abc2. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Alexander Motin Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16541 Closes #16583 --- module/lua/lobject.h | 21 ++++++++++++--------- module/lua/lstate.h | 2 +- module/lua/lstring.c | 2 +- module/lua/lstring.h | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/module/lua/lobject.h b/module/lua/lobject.h index b7c6b41ac7f4..06fdcdcbcb84 100644 --- a/module/lua/lobject.h +++ b/module/lua/lobject.h @@ -404,19 +404,22 @@ typedef TValue *StkId; /* index to stack elements */ /* ** Header for string value; string bytes follow the end of this structure */ -typedef union TString { - L_Umaxalign dummy; /* ensures maximum alignment for strings */ - struct { - CommonHeader; - lu_byte extra; /* reserved words for short strings; "has hash" for longs */ - unsigned int hash; - size_t len; /* number of characters in string */ - } tsv; +typedef struct TString { + union { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte extra; /* reserved words for short strings; "has hash" for longs */ + unsigned int hash; + size_t len; /* number of characters in string */ + } tsv; + }; + char contents[]; } TString; /* get the actual string (array of bytes) from a TString */ -#define getstr(ts) cast(const char *, (ts) + 1) +#define getstr(ts) ((ts)->contents) /* get the actual string (array of bytes) from a Lua value */ #define svalue(o) getstr(rawtsvalue(o)) diff --git a/module/lua/lstate.h b/module/lua/lstate.h index 75c6ceda6d33..c5fa59335a9b 100644 --- a/module/lua/lstate.h +++ b/module/lua/lstate.h @@ -185,7 +185,7 @@ struct lua_State { */ union GCObject { GCheader gch; /* common header */ - union TString ts; + struct TString ts; union Udata u; union Closure cl; struct Table h; diff --git a/module/lua/lstring.c b/module/lua/lstring.c index 15a73116bb77..149a4ffc5023 100644 --- a/module/lua/lstring.c +++ b/module/lua/lstring.c @@ -103,7 +103,7 @@ static TString *createstrobj (lua_State *L, const char *str, size_t l, ts->tsv.len = l; ts->tsv.hash = h; ts->tsv.extra = 0; - sbuf = (char *)(TString *)(ts + 1); + sbuf = ts->contents; memcpy(sbuf, str, l*sizeof(char)); sbuf[l] = '\0'; /* ending 0 */ return ts; diff --git a/module/lua/lstring.h b/module/lua/lstring.h index 260e7f169bd0..257b384172ec 100644 --- a/module/lua/lstring.h +++ b/module/lua/lstring.h @@ -12,7 +12,7 @@ #include "lstate.h" -#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) +#define sizestring(s) (sizeof(struct TString)+((s)->len+1)*sizeof(char)) #define sizeudata(u) (sizeof(union Udata)+(u)->len) From e8f4592a19917e77aa3e86707280933c72738f6a Mon Sep 17 00:00:00 2001 From: rilysh Date: Wed, 2 Oct 2024 21:40:06 +0530 Subject: [PATCH 056/223] Avoid computing strlen() inside loops Compiling with -O0 (no proper optimizations), strlen() call in loops for comparing the size, isn't being called/initialized before the actual loop gets started, which causes n-numbers of strlen() calls (as long as the string is). Keeping the length before entering in the loop is a good idea. On some places, even with -O2, both GCC and Clang can't recognize this pattern, which seem to happen in an array of char pointer. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: rilysh Closes #16584 --- cmd/zdb/zdb.c | 12 +++++++----- cmd/ztest.c | 8 +++++--- lib/libzfs/libzfs_util.c | 8 +++++--- module/zcommon/zfs_prop.c | 5 +++-- module/zcommon/zpool_prop.c | 5 +++-- udev/zvol_id.c | 7 +++++-- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index a8a3cd9dc3bc..da3cb983f4cc 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -8661,7 +8661,7 @@ zdb_read_block(char *thing, spa_t *spa) void *lbuf, *buf; char *s, *p, *dup, *flagstr, *sizes, *tmp = NULL; const char *vdev, *errmsg = NULL; - int i, error; + int i, len, error; boolean_t borrowed = B_FALSE, found = B_FALSE; dup = strdup(thing); @@ -8689,7 +8689,8 @@ zdb_read_block(char *thing, spa_t *spa) for (s = strtok_r(flagstr, ":", &tmp); s != NULL; s = strtok_r(NULL, ":", &tmp)) { - for (i = 0; i < strlen(flagstr); i++) { + len = strlen(flagstr); + for (i = 0; i < len; i++) { int bit = flagbits[(uchar_t)flagstr[i]]; if (bit == 0) { @@ -8960,13 +8961,14 @@ zdb_embedded_block(char *thing) static boolean_t zdb_numeric(char *str) { - int i = 0; + int i = 0, len; - if (strlen(str) == 0) + len = strlen(str); + if (len == 0) return (B_FALSE); if (strncmp(str, "0x", 2) == 0 || strncmp(str, "0X", 2) == 0) i = 2; - for (; i < strlen(str); i++) { + for (; i < len; i++) { if (!isxdigit(str[i])) return (B_FALSE); } diff --git a/cmd/ztest.c b/cmd/ztest.c index 66b9c06bd4f0..2601b2796875 100644 --- a/cmd/ztest.c +++ b/cmd/ztest.c @@ -663,15 +663,17 @@ static int str2shift(const char *buf) { const char *ends = "BKMGTPEZ"; - int i; + int i, len; if (buf[0] == '\0') return (0); - for (i = 0; i < strlen(ends); i++) { + + len = strlen(ends); + for (i = 0; i < len; i++) { if (toupper(buf[0]) == ends[i]) break; } - if (i == strlen(ends)) { + if (i == len) { (void) fprintf(stderr, "ztest: invalid bytes suffix: %s\n", buf); usage(B_FALSE); diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 60e9262f6b71..d36a7999b64a 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -1487,15 +1487,17 @@ static int str2shift(libzfs_handle_t *hdl, const char *buf) { const char *ends = "BKMGTPEZ"; - int i; + int i, len; if (buf[0] == '\0') return (0); - for (i = 0; i < strlen(ends); i++) { + + len = strlen(ends); + for (i = 0; i < len; i++) { if (toupper(buf[0]) == ends[i]) break; } - if (i == strlen(ends)) { + if (i == len) { if (hdl) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "invalid numeric suffix '%s'"), buf); diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index a14e14e3633a..4eb0cf38aeb2 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -790,11 +790,12 @@ zfs_name_to_prop(const char *propname) boolean_t zfs_prop_user(const char *name) { - int i; + int i, len; char c; boolean_t foundsep = B_FALSE; - for (i = 0; i < strlen(name); i++) { + len = strlen(name); + for (i = 0; i < len; i++) { c = name[i]; if (!zprop_valid_char(c)) return (B_FALSE); diff --git a/module/zcommon/zpool_prop.c b/module/zcommon/zpool_prop.c index ff70c0e3c35b..8080dd38eb31 100644 --- a/module/zcommon/zpool_prop.c +++ b/module/zcommon/zpool_prop.c @@ -473,11 +473,12 @@ vdev_name_to_prop(const char *propname) boolean_t vdev_prop_user(const char *name) { - int i; + int i, len; char c; boolean_t foundsep = B_FALSE; - for (i = 0; i < strlen(name); i++) { + len = strlen(name); + for (i = 0; i < len; i++) { c = name[i]; if (!zprop_valid_char(c)) return (B_FALSE); diff --git a/udev/zvol_id.c b/udev/zvol_id.c index 609349594767..0d1da9956749 100644 --- a/udev/zvol_id.c +++ b/udev/zvol_id.c @@ -56,6 +56,7 @@ main(int argc, const char *const *argv) return (1); } const char *dev_name = argv[1]; + size_t i, len; int fd; struct stat sb; @@ -73,11 +74,13 @@ main(int argc, const char *const *argv) } const char *dev_part = strrchr(dev_name, 'p'); + len = strlen(zvol_name); if (dev_part != NULL) { - sprintf(zvol_name + strlen(zvol_name), "-part%s", dev_part + 1); + sprintf(zvol_name + len, "-part%s", dev_part + 1); + len = strlen(zvol_name); } - for (size_t i = 0; i < strlen(zvol_name); ++i) + for (i = 0; i < len; ++i) if (isblank(zvol_name[i])) zvol_name[i] = '+'; From acc8a31863eed629632d80590a0c2bb8ca9406e6 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 4 Oct 2024 13:56:43 -0400 Subject: [PATCH 057/223] ARC: Cache arc_c value during arc_evict() Since arc_evict() run can take some time, arc_c change during it may result in undesired shift in ARC states balance. Primarily in case of arc_c reduction it may cause eviction from MFU data state despite its being below the target already. Instead we should evict as originally planned and if needed do another round after. Reviewed-by: Theera K. Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16576 Closes #16605 --- module/zfs/arc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index f40de4cb9ef7..370500ef096b 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -4240,7 +4240,7 @@ arc_evict_adj(uint64_t frac, uint64_t total, uint64_t up, uint64_t down, static uint64_t arc_evict(void) { - uint64_t asize, bytes, total_evicted = 0; + uint64_t bytes, total_evicted = 0; int64_t e, mrud, mrum, mfud, mfum, w; static uint64_t ogrd, ogrm, ogfd, ogfm; static uint64_t gsrd, gsrm, gsfd, gsfm; @@ -4277,8 +4277,9 @@ arc_evict(void) arc_pd = arc_evict_adj(arc_pd, gsrd + gsfd, grd, gfd, 100); arc_pm = arc_evict_adj(arc_pm, gsrm + gsfm, grm, gfm, 100); - asize = aggsum_value(&arc_sums.arcstat_size); - int64_t wt = t - (asize - arc_c); + uint64_t asize = aggsum_value(&arc_sums.arcstat_size); + uint64_t ac = arc_c; + int64_t wt = t - (asize - ac); /* * Try to reduce pinned dnodes if more than 3/4 of wanted metadata @@ -4303,7 +4304,7 @@ arc_evict(void) /* Evict MRU metadata. */ w = wt * (int64_t)(arc_meta * arc_pm >> 48) >> 16; - e = MIN((int64_t)(asize - arc_c), (int64_t)(mrum - w)); + e = MIN((int64_t)(asize - ac), (int64_t)(mrum - w)); bytes = arc_evict_impl(arc_mru, ARC_BUFC_METADATA, e); total_evicted += bytes; mrum -= bytes; @@ -4311,7 +4312,7 @@ arc_evict(void) /* Evict MFU metadata. */ w = wt * (int64_t)(arc_meta >> 16) >> 16; - e = MIN((int64_t)(asize - arc_c), (int64_t)(m - bytes - w)); + e = MIN((int64_t)(asize - ac), (int64_t)(m - bytes - w)); bytes = arc_evict_impl(arc_mfu, ARC_BUFC_METADATA, e); total_evicted += bytes; mfum -= bytes; @@ -4320,14 +4321,14 @@ arc_evict(void) /* Evict MRU data. */ wt -= m - total_evicted; w = wt * (int64_t)(arc_pd >> 16) >> 16; - e = MIN((int64_t)(asize - arc_c), (int64_t)(mrud - w)); + e = MIN((int64_t)(asize - ac), (int64_t)(mrud - w)); bytes = arc_evict_impl(arc_mru, ARC_BUFC_DATA, e); total_evicted += bytes; mrud -= bytes; asize -= bytes; /* Evict MFU data. */ - e = asize - arc_c; + e = asize - ac; bytes = arc_evict_impl(arc_mfu, ARC_BUFC_DATA, e); mfud -= bytes; total_evicted += bytes; From 18e355670dfd336dff914c147a82ccfa8eee4994 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Thu, 3 Oct 2024 20:45:10 +0500 Subject: [PATCH 058/223] Fix missing packaging files from release tarballs Properly distribute files for native Debian packages. This fixes the issue with broken release tarballs. Reviewed-by: Brian Behlendorf Signed-off-by: Umer Saleem Closes#15404 Closes#15586 --- contrib/Makefile.am | 1 + contrib/debian/Makefile.am | 48 +++++++++++++++++++ contrib/debian/openzfs-zfs-zed.zfs-zed.init | 1 - .../debian/openzfs-zfsutils.zfs-import.init | 1 - .../debian/openzfs-zfsutils.zfs-load-key.init | 1 - .../debian/openzfs-zfsutils.zfs-mount.init | 1 - .../debian/openzfs-zfsutils.zfs-share.init | 1 - contrib/debian/rules.in | 6 +++ 8 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 contrib/debian/Makefile.am delete mode 120000 contrib/debian/openzfs-zfs-zed.zfs-zed.init delete mode 120000 contrib/debian/openzfs-zfsutils.zfs-import.init delete mode 120000 contrib/debian/openzfs-zfsutils.zfs-load-key.init delete mode 120000 contrib/debian/openzfs-zfsutils.zfs-mount.init delete mode 120000 contrib/debian/openzfs-zfsutils.zfs-share.init diff --git a/contrib/Makefile.am b/contrib/Makefile.am index fa51bd941d27..5b8c1810bbe2 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -1,4 +1,5 @@ include $(srcdir)/%D%/bash_completion.d/Makefile.am +include $(srcdir)/%D%/debian/Makefile.am include $(srcdir)/%D%/pyzfs/Makefile.am include $(srcdir)/%D%/zcp/Makefile.am diff --git a/contrib/debian/Makefile.am b/contrib/debian/Makefile.am new file mode 100644 index 000000000000..f76b59645ead --- /dev/null +++ b/contrib/debian/Makefile.am @@ -0,0 +1,48 @@ +dist_noinst_DATA += %D%/changelog.in +dist_noinst_DATA += %D%/clean +dist_noinst_DATA += %D%/control +dist_noinst_DATA += %D%/control.modules.in +dist_noinst_DATA += %D%/copyright +dist_noinst_DATA += %D%/Makefile.am +dist_noinst_DATA += %D%/not-installed +dist_noinst_DATA += %D%/openzfs-libnvpair3.docs +dist_noinst_DATA += %D%/openzfs-libnvpair3.install.in +dist_noinst_DATA += %D%/openzfs-libpam-zfs.install +dist_noinst_DATA += %D%/openzfs-libpam-zfs.postinst +dist_noinst_DATA += %D%/openzfs-libpam-zfs.prerm +dist_noinst_DATA += %D%/openzfs-libuutil3.docs +dist_noinst_DATA += %D%/openzfs-libuutil3.install.in +dist_noinst_DATA += %D%/openzfs-libzfs4.docs +dist_noinst_DATA += %D%/openzfs-libzfs4.install.in +dist_noinst_DATA += %D%/openzfs-libzfsbootenv1.docs +dist_noinst_DATA += %D%/openzfs-libzfsbootenv1.install.in +dist_noinst_DATA += %D%/openzfs-libzfs-dev.docs +dist_noinst_DATA += %D%/openzfs-libzfs-dev.install.in +dist_noinst_DATA += %D%/openzfs-libzpool5.docs +dist_noinst_DATA += %D%/openzfs-libzpool5.install.in +dist_noinst_DATA += %D%/openzfs-python3-pyzfs.install +dist_noinst_DATA += %D%/openzfs-zfs-dkms.config +dist_noinst_DATA += %D%/openzfs-zfs-dkms.dkms +dist_noinst_DATA += %D%/openzfs-zfs-dkms.docs +dist_noinst_DATA += %D%/openzfs-zfs-dkms.install +dist_noinst_DATA += %D%/openzfs-zfs-dkms.postinst +dist_noinst_DATA += %D%/openzfs-zfs-dkms.prerm +dist_noinst_DATA += %D%/openzfs-zfs-dkms.templates +dist_noinst_DATA += %D%/openzfs-zfs-dkms.triggers +dist_noinst_DATA += %D%/openzfs-zfs-dracut.install +dist_noinst_DATA += %D%/openzfs-zfs-initramfs.install +dist_noinst_DATA += %D%/openzfs-zfs-modules-_KVERS_-di.install.in +dist_noinst_DATA += %D%/openzfs-zfs-modules-_KVERS_.install.in +dist_noinst_DATA += %D%/openzfs-zfs-modules-_KVERS_.postinst.in +dist_noinst_DATA += %D%/openzfs-zfs-modules-_KVERS_.postrm.in +dist_noinst_DATA += %D%/openzfs-zfs-test.install +dist_noinst_DATA += %D%/openzfs-zfsutils.docs +dist_noinst_DATA += %D%/openzfs-zfsutils.examples +dist_noinst_DATA += %D%/openzfs-zfsutils.install +dist_noinst_DATA += %D%/openzfs-zfsutils.postinst +dist_noinst_DATA += %D%/openzfs-zfs-zed.install +dist_noinst_DATA += %D%/openzfs-zfs-zed.postinst +dist_noinst_DATA += %D%/openzfs-zfs-zed.postrm +dist_noinst_DATA += %D%/rules.in +dist_noinst_DATA += %D%/source +dist_noinst_DATA += %D%/tree diff --git a/contrib/debian/openzfs-zfs-zed.zfs-zed.init b/contrib/debian/openzfs-zfs-zed.zfs-zed.init deleted file mode 120000 index 3f41f6813577..000000000000 --- a/contrib/debian/openzfs-zfs-zed.zfs-zed.init +++ /dev/null @@ -1 +0,0 @@ -../etc/init.d/zfs-zed \ No newline at end of file diff --git a/contrib/debian/openzfs-zfsutils.zfs-import.init b/contrib/debian/openzfs-zfsutils.zfs-import.init deleted file mode 120000 index bfc368fd3426..000000000000 --- a/contrib/debian/openzfs-zfsutils.zfs-import.init +++ /dev/null @@ -1 +0,0 @@ -../etc/init.d/zfs-import \ No newline at end of file diff --git a/contrib/debian/openzfs-zfsutils.zfs-load-key.init b/contrib/debian/openzfs-zfsutils.zfs-load-key.init deleted file mode 120000 index 3f3e97f811bb..000000000000 --- a/contrib/debian/openzfs-zfsutils.zfs-load-key.init +++ /dev/null @@ -1 +0,0 @@ -../etc/init.d/zfs-load-key \ No newline at end of file diff --git a/contrib/debian/openzfs-zfsutils.zfs-mount.init b/contrib/debian/openzfs-zfsutils.zfs-mount.init deleted file mode 120000 index 62a544332422..000000000000 --- a/contrib/debian/openzfs-zfsutils.zfs-mount.init +++ /dev/null @@ -1 +0,0 @@ -../etc/init.d/zfs-mount \ No newline at end of file diff --git a/contrib/debian/openzfs-zfsutils.zfs-share.init b/contrib/debian/openzfs-zfsutils.zfs-share.init deleted file mode 120000 index 3f069f9baaaf..000000000000 --- a/contrib/debian/openzfs-zfsutils.zfs-share.init +++ /dev/null @@ -1 +0,0 @@ -../etc/init.d/zfs-share \ No newline at end of file diff --git a/contrib/debian/rules.in b/contrib/debian/rules.in index a3a05efacb50..3dbf88a69458 100755 --- a/contrib/debian/rules.in +++ b/contrib/debian/rules.in @@ -56,6 +56,12 @@ override_dh_auto_configure: sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' "$$i" > "$${i%%.in}" ; \ done + ln -s '$(CURDIR)/etc/init.d/zfs-import' '$(CURDIR)/debian/openzfs-zfsutils.zfs-import.init' + ln -s '$(CURDIR)/etc/init.d/zfs-load-key' '$(CURDIR)/debian/openzfs-zfsutils.zfs-load-key.init' + ln -s '$(CURDIR)/etc/init.d/zfs-mount' '$(CURDIR)/debian/openzfs-zfsutils.zfs-mount.init' + ln -s '$(CURDIR)/etc/init.d/zfs-share' '$(CURDIR)/debian/openzfs-zfsutils.zfs-share.init' + ln -s '$(CURDIR)/etc/init.d/zfs-zed' '$(CURDIR)/debian/openzfs-zfs-zed.zfs-zed.init' + override_dh_gencontrol: dh_gencontrol -- -Vlinux:Recommends="linux-libc-dev (<< $(LINUX_NEXT)~), linux-libc-dev (>= $(LINUX_MIN)~)," From e63023738ed25ed29791de75c9f3628391f50b74 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Fri, 4 Oct 2024 00:11:57 +0500 Subject: [PATCH 059/223] Disable parallel build for native-deb* targets Running native-deb* targets in parallel via make is not supported. Reviewed-by: Brian Behlendorf Signed-off-by: Umer Saleem Closes#14736 --- config/deb.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/deb.am b/config/deb.am index 1379e58c40a8..4d86a1b70615 100644 --- a/config/deb.am +++ b/config/deb.am @@ -101,3 +101,5 @@ native-deb-kmod: native-deb-local debian fakeroot debian/rules override_dh_binary-modules; native-deb: native-deb-utils native-deb-kmod + +.NOTPARALLEL: native-deb native-deb-utils native-deb-kmod From d29f257b030a6d00ee88713b38edb67cb25455a7 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Fri, 4 Oct 2024 12:21:28 +0500 Subject: [PATCH 060/223] Update path for zed in zfs-zed.service for native debian packages Reviewed-by: Brian Behlendorf Signed-off-by: Umer Saleem Closes#15638 --- contrib/debian/rules.in | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/debian/rules.in b/contrib/debian/rules.in index 3dbf88a69458..35853f4dc30c 100755 --- a/contrib/debian/rules.in +++ b/contrib/debian/rules.in @@ -88,6 +88,7 @@ override_dh_auto_install: @# Zed has dependencies outside of the system root. mv '$(CURDIR)/debian/tmp/sbin/zed' '$(CURDIR)/debian/tmp/usr/sbin/zed' + sed -i 's|ExecStart=/sbin/|ExecStart=/usr/sbin/|g' '$(CURDIR)/debian/tmp/lib/systemd/system/zfs-zed.service' @# Install the DKMS source. @# We only want the files needed to build the modules From f53f3c3e6ad45f2d95ef046c81c5cc6772b0dce3 Mon Sep 17 00:00:00 2001 From: JKDingwall Date: Sun, 6 Oct 2024 22:36:33 +0100 Subject: [PATCH 061/223] Fix generation of kernel uevents for snapshot rename on linux `zvol_rename_minors()` needs to be given the full path not just the snapshot name. Use code removed in a0bd735ad as a guide to providing the necessary values. Add ZTS check for /dev changes after snapshot rename. After renaming a snapshot with 'snapdev=visible' ensure that the /dev entries are updated to reflect the rename. Reviewed-by: Brian Behlendorf Signed-off-by: James Dingwall Closes #14223 Closes #16600 --- module/zfs/dsl_dataset.c | 11 +++++++++-- .../functional/zvol/zvol_misc/zvol_misc_snapdev.ksh | 13 +++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index 94c25e67487a..85b598df3f49 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -2975,6 +2975,7 @@ dsl_dataset_rename_snapshot_sync_impl(dsl_pool_t *dp, dsl_dataset_t *ds; uint64_t val; dmu_tx_t *tx = ddrsa->ddrsa_tx; + char *oldname, *newname; int error; error = dsl_dataset_snap_lookup(hds, ddrsa->ddrsa_oldsnapname, &val); @@ -2999,8 +3000,14 @@ dsl_dataset_rename_snapshot_sync_impl(dsl_pool_t *dp, VERIFY0(zap_add(dp->dp_meta_objset, dsl_dataset_phys(hds)->ds_snapnames_zapobj, ds->ds_snapname, 8, 1, &ds->ds_object, tx)); - zvol_rename_minors(dp->dp_spa, ddrsa->ddrsa_oldsnapname, - ddrsa->ddrsa_newsnapname, B_TRUE); + + oldname = kmem_asprintf("%s@%s", ddrsa->ddrsa_fsname, + ddrsa->ddrsa_oldsnapname); + newname = kmem_asprintf("%s@%s", ddrsa->ddrsa_fsname, + ddrsa->ddrsa_newsnapname); + zvol_rename_minors(dp->dp_spa, oldname, newname, B_TRUE); + kmem_strfree(oldname); + kmem_strfree(newname); dsl_dataset_rele(ds, FTAG); return (0); diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_snapdev.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_snapdev.ksh index 1fc2d2780b1c..af780b628ce4 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_snapdev.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_snapdev.ksh @@ -117,5 +117,18 @@ log_must zfs set snapdev=visible $TESTPOOL verify_inherited 'snapdev' 'hidden' $SUBZVOL $VOLFS blockdev_missing $SUBSNAPDEV blockdev_exists $SNAPDEV +log_must zfs destroy $SNAP + +# 4. Verify "rename" is correctly reflected when "snapdev=visible" +# 4.1 First create a snapshot and verify the device is present +log_must zfs snapshot $SNAP +log_must zfs set snapdev=visible $ZVOL +blockdev_exists $SNAPDEV +# 4.2 rename the snapshot and verify the devices are updated +log_must zfs rename $SNAP $SNAP-new +blockdev_missing $SNAPDEV +blockdev_exists $SNAPDEV-new +# 4.3 cleanup +log_must zfs destroy $SNAP-new log_pass "ZFS volume property 'snapdev' works as expected" From 18c8abc8aa0c18c7fc2710c5668303c69b53c9fa Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Tue, 8 Oct 2024 21:27:38 +0500 Subject: [PATCH 062/223] Only serialize native-deb* targets .NOTPARALLEL target is being forced on userspace as well. This commit removes .NOTPARALEL target and only serializes the execution of native-deb* targets. Reviewed-by: Brian Behlendorf Signed-off-by: Umer Saleem Closes #16622 --- config/deb.am | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/config/deb.am b/config/deb.am index 4d86a1b70615..c47c8f24e7e6 100644 --- a/config/deb.am +++ b/config/deb.am @@ -93,13 +93,17 @@ debian: cp -r contrib/debian debian; chmod +x debian/rules; native-deb-utils: native-deb-local debian + while [ -f debian/deb-build.lock ]; do sleep 1; done; \ + echo "native-deb-utils" > debian/deb-build.lock; \ cp contrib/debian/control debian/control; \ - $(DPKGBUILD) -b -rfakeroot -us -uc; + $(DPKGBUILD) -b -rfakeroot -us -uc; \ + $(RM) -f debian/deb-build.lock native-deb-kmod: native-deb-local debian + while [ -f debian/deb-build.lock ]; do sleep 1; done; \ + echo "native-deb-kmod" > debian/deb-build.lock; \ sh scripts/make_gitrev.sh; \ - fakeroot debian/rules override_dh_binary-modules; + fakeroot debian/rules override_dh_binary-modules; \ + $(RM) -f debian/deb-build.lock native-deb: native-deb-utils native-deb-kmod - -.NOTPARALLEL: native-deb native-deb-utils native-deb-kmod From a1ea40af86e93432f68c6e4cab4b7b06e2075021 Mon Sep 17 00:00:00 2001 From: Richard Kojedzinszky Date: Tue, 23 Jan 2024 00:28:18 +0100 Subject: [PATCH 063/223] libzfs: use zfs_strerror() in place of strerror() Reviewed-by: Brian Behlendorf Reviewed-by: Tino Reichardt Signed-off-by: Richard Kojedzinszky Closes #15793 --- include/libzutil.h | 10 ++++++++++ lib/libshare/nfs.c | 21 ++++++++++++--------- lib/libspl/os/freebsd/getmntany.c | 5 +++-- lib/libspl/os/linux/getmntany.c | 3 ++- lib/libzfs/libzfs_crypto.c | 9 +++++---- lib/libzfs/libzfs_dataset.c | 2 +- lib/libzfs/libzfs_diff.c | 17 +++++++++-------- lib/libzfs/libzfs_mount.c | 5 +++-- lib/libzfs/libzfs_sendrecv.c | 20 ++++++++++---------- lib/libzfs/libzfs_util.c | 6 +++--- lib/libzfs/os/freebsd/libzfs_compat.c | 2 +- lib/libzutil/zutil_import.c | 12 ++++++------ 12 files changed, 65 insertions(+), 47 deletions(-) diff --git a/include/libzutil.h b/include/libzutil.h index 839486fb62bf..d9a9a65753dd 100644 --- a/include/libzutil.h +++ b/include/libzutil.h @@ -26,6 +26,8 @@ #ifndef _LIBZUTIL_H #define _LIBZUTIL_H extern __attribute__((visibility("default"))) +#include +#include #include #include @@ -267,6 +269,14 @@ int for_each_vdev_in_nvlist(nvlist_t *nvroot, pool_vdev_iter_f func, void update_vdevs_config_dev_sysfs_path(nvlist_t *config); _LIBZUTIL_H void update_vdev_config_dev_sysfs_path(nvlist_t *nv, const char *path, const char *key); + +/* + * Thread-safe strerror() for use in ZFS libraries + */ +static inline char *zfs_strerror(int errnum) { + return (strerror_l(errnum, uselocale(0))); +} + #ifdef __cplusplus } #endif diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 3962c87453d4..77ed14f322ed 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "nfs.h" @@ -45,7 +46,8 @@ nfs_exports_lock(const char *name, int *nfs_lock_fd) *nfs_lock_fd = open(name, O_RDWR | O_CREAT | O_CLOEXEC, 0600); if (*nfs_lock_fd == -1) { err = errno; - fprintf(stderr, "failed to lock %s: %s\n", name, strerror(err)); + fprintf(stderr, "failed to lock %s: %s\n", name, + zfs_strerror(err)); return (err); } @@ -53,7 +55,8 @@ nfs_exports_lock(const char *name, int *nfs_lock_fd) ; if (err != 0) { err = errno; - fprintf(stderr, "failed to lock %s: %s\n", name, strerror(err)); + fprintf(stderr, "failed to lock %s: %s\n", name, + zfs_strerror(err)); (void) close(*nfs_lock_fd); *nfs_lock_fd = -1; return (err); @@ -69,7 +72,7 @@ nfs_exports_unlock(const char *name, int *nfs_lock_fd) if (flock(*nfs_lock_fd, LOCK_UN) != 0) fprintf(stderr, "failed to unlock %s: %s\n", - name, strerror(errno)); + name, zfs_strerror(errno)); (void) close(*nfs_lock_fd); *nfs_lock_fd = -1; @@ -92,7 +95,7 @@ nfs_init_tmpfile(const char *prefix, const char *mdir, struct tmpfile *tmpf) errno != EEXIST) { fprintf(stderr, "failed to create %s: %s\n", // cppcheck-suppress uninitvar - mdir, strerror(errno)); + mdir, zfs_strerror(errno)); return (B_FALSE); } @@ -102,14 +105,14 @@ nfs_init_tmpfile(const char *prefix, const char *mdir, struct tmpfile *tmpf) int fd = mkostemp(tmpf->name, O_CLOEXEC); if (fd == -1) { fprintf(stderr, "Unable to create temporary file: %s", - strerror(errno)); + zfs_strerror(errno)); return (B_FALSE); } tmpf->fp = fdopen(fd, "w+"); if (tmpf->fp == NULL) { fprintf(stderr, "Unable to reopen temporary file: %s", - strerror(errno)); + zfs_strerror(errno)); close(fd); return (B_FALSE); } @@ -129,14 +132,14 @@ nfs_fini_tmpfile(const char *exports, struct tmpfile *tmpf) { if (fflush(tmpf->fp) != 0) { fprintf(stderr, "Failed to write to temporary file: %s\n", - strerror(errno)); + zfs_strerror(errno)); nfs_abort_tmpfile(tmpf); return (SA_SYSTEM_ERR); } if (rename(tmpf->name, exports) == -1) { fprintf(stderr, "Unable to rename %s -> %s: %s\n", - tmpf->name, exports, strerror(errno)); + tmpf->name, exports, zfs_strerror(errno)); nfs_abort_tmpfile(tmpf); return (SA_SYSTEM_ERR); } @@ -213,7 +216,7 @@ nfs_process_exports(const char *exports, const char *mountpoint, if (fclose(oldfp) != 0) { fprintf(stderr, "Unable to close file %s: %s\n", - exports, strerror(errno)); + exports, zfs_strerror(errno)); error = error != SA_OK ? error : SA_SYSTEM_ERR; } } diff --git a/lib/libspl/os/freebsd/getmntany.c b/lib/libspl/os/freebsd/getmntany.c index fc875fcb133f..fc1c9de6df81 100644 --- a/lib/libspl/os/freebsd/getmntany.c +++ b/lib/libspl/os/freebsd/getmntany.c @@ -36,6 +36,7 @@ #include #include #include +#include int getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf) @@ -49,13 +50,13 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf) if (stat64(path, statbuf) != 0) { (void) fprintf(stderr, "cannot open '%s': %s\n", - path, strerror(errno)); + path, zfs_strerror(errno)); return (-1); } if (statfs(path, &sfs) != 0) { (void) fprintf(stderr, "%s: %s\n", path, - strerror(errno)); + zfs_strerror(errno)); return (-1); } statfs2mnttab(&sfs, (struct mnttab *)entry); diff --git a/lib/libspl/os/linux/getmntany.c b/lib/libspl/os/linux/getmntany.c index 7e3722cd373e..a46c4e931719 100644 --- a/lib/libspl/os/linux/getmntany.c +++ b/lib/libspl/os/linux/getmntany.c @@ -38,6 +38,7 @@ #include #include #include +#include #define BUFSIZE (MNT_LINE_MAX + 2) @@ -122,7 +123,7 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf) */ if (stat64(path, statbuf) != 0) { (void) fprintf(stderr, "cannot open '%s': %s\n", - path, strerror(errno)); + path, zfs_strerror(errno)); return (-1); } diff --git a/lib/libzfs/libzfs_crypto.c b/lib/libzfs/libzfs_crypto.c index 8f2a50d55e87..93dfa9cbc2c0 100644 --- a/lib/libzfs/libzfs_crypto.c +++ b/lib/libzfs/libzfs_crypto.c @@ -37,6 +37,7 @@ #include #endif #include +#include #include "libzfs_impl.h" #include "zfeature_common.h" @@ -493,7 +494,7 @@ get_key_material_file(libzfs_handle_t *hdl, const char *uri, ret = errno; errno = 0; zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "Failed to open key material file: %s"), strerror(ret)); + "Failed to open key material file: %s"), zfs_strerror(ret)); return (ret); } @@ -595,7 +596,7 @@ get_key_material_https(libzfs_handle_t *hdl, const char *uri, "%s/libzfs-XXXXXXXX.https", getenv("TMPDIR") ?: "/tmp") == -1) { ret = ENOMEM; zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "%s"), - strerror(ret)); + zfs_strerror(ret)); goto end; } @@ -604,7 +605,7 @@ get_key_material_https(libzfs_handle_t *hdl, const char *uri, ret = errno; zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "Couldn't create temporary file %s: %s"), - path, strerror(ret)); + path, zfs_strerror(ret)); free(path); goto end; } @@ -616,7 +617,7 @@ get_key_material_https(libzfs_handle_t *hdl, const char *uri, ret = errno; (void) close(kfd); zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "Couldn't reopen temporary file: %s"), strerror(ret)); + "Couldn't reopen temporary file: %s"), zfs_strerror(ret)); goto end; } diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 727efc5a91ad..aa5b1e4df189 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -5217,7 +5217,7 @@ zfs_get_fsacl(zfs_handle_t *zhp, nvlist_t **nvl) nvbuf = malloc(nvsz); if (nvbuf == NULL) { - err = (zfs_error(hdl, EZFS_NOMEM, strerror(errno))); + err = (zfs_error(hdl, EZFS_NOMEM, zfs_strerror(errno))); goto out; } diff --git a/lib/libzfs/libzfs_diff.c b/lib/libzfs/libzfs_diff.c index da2b26ef99ce..edf290c4d040 100644 --- a/lib/libzfs/libzfs_diff.c +++ b/lib/libzfs/libzfs_diff.c @@ -283,7 +283,7 @@ write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj) fobjerr = get_stats_for_obj(di, di->fromsnap, dobj, fobjname, MAXPATHLEN, &fsb); if (fobjerr && di->zerr != ENOTSUP && di->zerr != ENOENT) { - zfs_error_aux(di->zhp->zfs_hdl, "%s", strerror(di->zerr)); + zfs_error_aux(di->zhp->zfs_hdl, "%s", zfs_strerror(di->zerr)); zfs_error(di->zhp->zfs_hdl, di->zerr, di->errbuf); /* * Let's not print an error for the same object more than @@ -298,7 +298,7 @@ write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj) if (tobjerr && di->zerr != ENOTSUP && di->zerr != ENOENT) { if (!already_logged) { zfs_error_aux(di->zhp->zfs_hdl, - "%s", strerror(di->zerr)); + "%s", zfs_strerror(di->zerr)); zfs_error(di->zhp->zfs_hdl, di->zerr, di->errbuf); } } @@ -445,7 +445,7 @@ differ(void *arg) if ((ofp = fdopen(di->outputfd, "w")) == NULL) { di->zerr = errno; - strlcpy(di->errbuf, strerror(errno), sizeof (di->errbuf)); + strlcpy(di->errbuf, zfs_strerror(errno), sizeof (di->errbuf)); (void) close(di->datafd); return ((void *)-1); } @@ -762,7 +762,7 @@ zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap, } if (pipe2(pipefd, O_CLOEXEC)) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(errno)); teardown_differ_info(&di); return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED, errbuf)); } @@ -776,7 +776,7 @@ zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap, di.datafd = pipefd[0]; if (pthread_create(&tid, NULL, differ, &di)) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(errno)); (void) close(pipefd[0]); (void) close(pipefd[1]); teardown_differ_info(&di); @@ -802,14 +802,15 @@ zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap, zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN, "\n Not an earlier snapshot from the same fs")); } else if (errno != EPIPE || di.zerr == 0) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(errno)); } (void) close(pipefd[1]); (void) pthread_cancel(tid); (void) pthread_join(tid, NULL); teardown_differ_info(&di); if (di.zerr != 0 && di.zerr != EPIPE) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(di.zerr)); + zfs_error_aux(zhp->zfs_hdl, "%s", + zfs_strerror(di.zerr)); return (zfs_error(zhp->zfs_hdl, EZFS_DIFF, di.errbuf)); } else { return (zfs_error(zhp->zfs_hdl, EZFS_DIFFDATA, errbuf)); @@ -820,7 +821,7 @@ zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap, (void) pthread_join(tid, NULL); if (di.zerr != 0) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(di.zerr)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(di.zerr)); return (zfs_error(zhp->zfs_hdl, EZFS_DIFF, di.errbuf)); } teardown_differ_info(&di); diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index b38ad88096b2..ec6ebad2f180 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -74,6 +74,7 @@ #include #include +#include #include "libzfs_impl.h" #include @@ -466,7 +467,7 @@ zfs_mount_at(zfs_handle_t *zhp, const char *options, int flags, if (mkdirp(mountpoint, 0755) != 0) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "failed to create mountpoint: %s"), - strerror(errno)); + zfs_strerror(errno)); return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, dgettext(TEXT_DOMAIN, "cannot mount '%s'"), mountpoint)); @@ -524,7 +525,7 @@ zfs_mount_at(zfs_handle_t *zhp, const char *options, int flags, (u_longlong_t)zfs_prop_get_int(zhp, ZFS_PROP_VERSION), spa_version); } else { - zfs_error_aux(hdl, "%s", strerror(rc)); + zfs_error_aux(hdl, "%s", zfs_strerror(rc)); } return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, dgettext(TEXT_DOMAIN, "cannot mount '%s'"), diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index c6ee7e5660a5..0370112c022a 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -793,7 +793,7 @@ zfs_send_space(zfs_handle_t *zhp, const char *snapname, const char *from, case EFAULT: case EROFS: case EINVAL: - zfs_error_aux(hdl, "%s", strerror(error)); + zfs_error_aux(hdl, "%s", zfs_strerror(error)); return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); default: @@ -876,7 +876,7 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj, case EFAULT: case EROFS: case EINVAL: - zfs_error_aux(hdl, "%s", strerror(errno)); + zfs_error_aux(hdl, "%s", zfs_strerror(errno)); return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); default: @@ -1633,7 +1633,7 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, err = pthread_create(&ptid, NULL, send_progress_thread, &pa); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(errno)); return (zfs_error(zhp->zfs_hdl, EZFS_THREADCREATEFAILED, errbuf)); } @@ -1652,7 +1652,7 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, return (err); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(err)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(err)); return (zfs_error(zhp->zfs_hdl, EZFS_BADBACKUP, errbuf)); } @@ -1768,7 +1768,7 @@ find_redact_book(libzfs_handle_t *hdl, const char *path, "dataset to be sent no longer exists")); } else { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "unknown error: %s"), strerror(error)); + "unknown error: %s"), zfs_strerror(error)); } return (zfs_error(hdl, EZFS_BADPROP, errbuf)); } @@ -2005,7 +2005,7 @@ zfs_send_resume_impl_cb_impl(libzfs_handle_t *hdl, sendflags_t *flags, case ERANGE: case EFAULT: case EROFS: - zfs_error_aux(hdl, "%s", strerror(errno)); + zfs_error_aux(hdl, "%s", zfs_strerror(errno)); return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); default: @@ -2293,13 +2293,13 @@ send_prelim_records(zfs_handle_t *zhp, const char *from, int fd, err = dump_record(&drr, packbuf, buflen, &zc, fd); free(packbuf); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(err)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(err)); return (zfs_error(zhp->zfs_hdl, EZFS_BADBACKUP, errbuf)); } err = send_conclusion_record(fd, &zc); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(err)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(err)); return (zfs_error(zhp->zfs_hdl, EZFS_BADBACKUP, errbuf)); } @@ -2768,7 +2768,7 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd, err = pthread_create(&ptid, NULL, send_progress_thread, &pa); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", zfs_strerror(errno)); return (zfs_error(zhp->zfs_hdl, EZFS_THREADCREATEFAILED, errbuf)); } @@ -2826,7 +2826,7 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd, case EPIPE: case ERANGE: case EROFS: - zfs_error_aux(hdl, "%s", strerror(errno)); + zfs_error_aux(hdl, "%s", zfs_strerror(errno)); return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); default: diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index d36a7999b64a..1db79fb170e4 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -514,7 +514,7 @@ zfs_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...) zfs_verror(hdl, EZFS_NOT_USER_NAMESPACE, fmt, ap); break; default: - zfs_error_aux(hdl, "%s", strerror(error)); + zfs_error_aux(hdl, "%s", zfs_strerror(error)); zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap); break; } @@ -770,7 +770,7 @@ zpool_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...) zfs_verror(hdl, EZFS_ASHIFT_MISMATCH, fmt, ap); break; default: - zfs_error_aux(hdl, "%s", strerror(error)); + zfs_error_aux(hdl, "%s", zfs_strerror(error)); zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap); } @@ -1973,7 +1973,7 @@ zfs_version_print(void) char *kver = zfs_version_kernel(); if (kver == NULL) { fprintf(stderr, "zfs_version_kernel() failed: %s\n", - strerror(errno)); + zfs_strerror(errno)); return (-1); } diff --git a/lib/libzfs/os/freebsd/libzfs_compat.c b/lib/libzfs/os/freebsd/libzfs_compat.c index aef2abf62568..2abf7755b518 100644 --- a/lib/libzfs/os/freebsd/libzfs_compat.c +++ b/lib/libzfs/os/freebsd/libzfs_compat.c @@ -212,7 +212,7 @@ libzfs_error_init(int error) msglen -= len; } - (void) snprintf(msg, msglen, "%s", strerror(error)); + (void) snprintf(msg, msglen, "%s", zfs_strerror(error)); return (errbuf); } diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c index b49153c67f7b..77fa0ce38b2a 100644 --- a/lib/libzutil/zutil_import.c +++ b/lib/libzutil/zutil_import.c @@ -1291,7 +1291,7 @@ zpool_find_import_scan_dir(libpc_handle_t *hdl, pthread_mutex_t *lock, if (error == ENOENT) return (0); - zutil_error_aux(hdl, "%s", strerror(error)); + zutil_error_aux(hdl, "%s", zfs_strerror(error)); (void) zutil_error_fmt(hdl, LPC_BADPATH, dgettext(TEXT_DOMAIN, "cannot resolve path '%s'"), dir); return (error); @@ -1300,7 +1300,7 @@ zpool_find_import_scan_dir(libpc_handle_t *hdl, pthread_mutex_t *lock, dirp = opendir(path); if (dirp == NULL) { error = errno; - zutil_error_aux(hdl, "%s", strerror(error)); + zutil_error_aux(hdl, "%s", zfs_strerror(error)); (void) zutil_error_fmt(hdl, LPC_BADPATH, dgettext(TEXT_DOMAIN, "cannot open '%s'"), path); return (error); @@ -1362,7 +1362,7 @@ zpool_find_import_scan_path(libpc_handle_t *hdl, pthread_mutex_t *lock, goto out; } - zutil_error_aux(hdl, "%s", strerror(error)); + zutil_error_aux(hdl, "%s", zfs_strerror(error)); (void) zutil_error_fmt(hdl, LPC_BADPATH, dgettext(TEXT_DOMAIN, "cannot resolve path '%s'"), dir); goto out; @@ -1400,7 +1400,7 @@ zpool_find_import_scan(libpc_handle_t *hdl, pthread_mutex_t *lock, if (error == ENOENT) continue; - zutil_error_aux(hdl, "%s", strerror(error)); + zutil_error_aux(hdl, "%s", zfs_strerror(error)); (void) zutil_error_fmt(hdl, LPC_BADPATH, dgettext( TEXT_DOMAIN, "cannot resolve path '%s'"), dir[i]); goto error; @@ -1644,14 +1644,14 @@ zpool_find_import_cached(libpc_handle_t *hdl, importargs_t *iarg) verify(iarg->poolname == NULL || iarg->guid == 0); if ((fd = open(iarg->cachefile, O_RDONLY | O_CLOEXEC)) < 0) { - zutil_error_aux(hdl, "%s", strerror(errno)); + zutil_error_aux(hdl, "%s", zfs_strerror(errno)); (void) zutil_error(hdl, LPC_BADCACHE, dgettext(TEXT_DOMAIN, "failed to open cache file")); return (NULL); } if (fstat64(fd, &statbuf) != 0) { - zutil_error_aux(hdl, "%s", strerror(errno)); + zutil_error_aux(hdl, "%s", zfs_strerror(errno)); (void) close(fd); (void) zutil_error(hdl, LPC_BADCACHE, dgettext(TEXT_DOMAIN, "failed to get size of cache file")); From 63fbbe87129849eca11f66b8903e5c7478a0648e Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Sat, 12 Oct 2024 13:48:56 -0700 Subject: [PATCH 064/223] Fallback to strerror() when strerror_l() isn't available Some C libraries, such as uClibc, do not provide strerror_l() in which case we fallback to strerror(). Reviewed-by: Tino Reichardt Signed-off-by: Brian Behlendorf Closes #16636 Closes #16640 --- config/user.m4 | 2 +- include/libzutil.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/user.m4 b/config/user.m4 index badd920d2b8a..4e31745a2abc 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -33,7 +33,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV ZFS_AC_CONFIG_USER_ZFSEXEC - AC_CHECK_FUNCS([execvpe issetugid mlockall strlcat strlcpy gettid]) + AC_CHECK_FUNCS([execvpe issetugid mlockall strerror_l strlcat strlcpy gettid]) AC_SUBST(RM) ]) diff --git a/include/libzutil.h b/include/libzutil.h index d9a9a65753dd..3a527410fd73 100644 --- a/include/libzutil.h +++ b/include/libzutil.h @@ -274,7 +274,11 @@ _LIBZUTIL_H void update_vdev_config_dev_sysfs_path(nvlist_t *nv, * Thread-safe strerror() for use in ZFS libraries */ static inline char *zfs_strerror(int errnum) { +#ifdef HAVE_STRERROR_L return (strerror_l(errnum, uselocale(0))); +#else + return (strerror(errnum)); +#endif } #ifdef __cplusplus From 308d04ac37402830cc5e8fa7694cf51fe8b4fef8 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Thu, 17 Oct 2024 18:09:39 +0500 Subject: [PATCH 065/223] Fix inconsistent mount options for ZFS root While mounting ZFS root during boot on Linux distributions from initrd, mount from busybox is effectively used which executes mount system call directly. This skips the ZFS helper mount.zfs, which checks and enables the mount options as specified in dataset properties. As a result, datasets mounted during boot from initrd do not have correct mount options as specified in ZFS dataset properties. There has been an attempt to use mount.zfs in zfs initrd script, responsible for mounting the ZFS root filesystem (PR#13305). This was later reverted (PR#14908) after discovering that using mount.zfs breaks mounting of snapshots on root (/) and other child datasets of root have the same issue (Issue#9461). This happens because switching from busybox mount to mount.zfs correctly parses the mount options but also adds 'mntpoint=/root' to the mount options, which is then prepended to the snapshot mountpoint in '.zfs/snapshot'. '/root' is the directory on Debian with initramfs-tools where root filesystem is mounted before pivot_root. When Linux runtime is reached, trying to access the snapshots on root results in automounting the snapshot on '/root/.zfs/*', which fails. This commit attempts to fix the automounting of snapshots on root, while using mount.zfs in initrd script. Since the mountpoint of dataset is stored in vfs_mntpoint field, we can check if current mountpoint of dataset and vfs_mntpoint are same or not. If they are not same, reset the vfs_mntpoint field with current mountpoint. This fixes the mountpoints of root dataset and children in respective vfs_mntpoint fields when we try to access the snapshots of root dataset or its children. With correct mountpoint for root dataset and children stored in vfs_mntpoint, all snapshots of root dataset are mounted correctly and become accessible. This fix will come into play only if current process, that is trying to access the snapshots is not in chroot context. The Linux kernel API that is used to convert struct path into char format (d_path), returns the complete path for given struct path. It works in chroot environment as well and returns the correct path from original filesystem root. However d_path fails to return the complete path if any directory from original root filesystem is mounted using --bind flag or --rbind flag in chroot environment. In this case, if we try to access the snapshot from outside the chroot environment, d_path returns the path correctly, i.e. it returns the correct path to the directory that is mounted with --bind flag. However inside the chroot environment, it only returns the path inside chroot. For now, there is not a better way in my understanding that gives the complete path in char format and handles the case where directories from root filesystem are mounted with --bind or --rbind on another path which user will later chroot into. So this fix gets enabled if current process trying to access the snapshot is not in chroot context. With the snapshots issue fixed for root filesystem, using mount.zfs in ZFS initrd script, mounts the datasets with correct mount options. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Ameer Hamza Signed-off-by: Umer Saleem Closes #16646 --- contrib/initramfs/scripts/zfs | 5 +- include/os/linux/zfs/sys/zfs_vfsops_os.h | 1 + module/os/linux/zfs/zfs_ctldir.c | 109 +++++++++++++++++++++-- module/os/linux/zfs/zfs_vfsops.c | 6 +- 4 files changed, 111 insertions(+), 10 deletions(-) diff --git a/contrib/initramfs/scripts/zfs b/contrib/initramfs/scripts/zfs index 0a2bd2efda7a..c569b2528368 100644 --- a/contrib/initramfs/scripts/zfs +++ b/contrib/initramfs/scripts/zfs @@ -344,7 +344,7 @@ mount_fs() # Need the _original_ datasets mountpoint! mountpoint=$(get_fs_value "$fs" mountpoint) - ZFS_CMD="mount -o zfsutil -t zfs" + ZFS_CMD="mount.zfs -o zfsutil" if [ "$mountpoint" = "legacy" ] || [ "$mountpoint" = "none" ]; then # Can't use the mountpoint property. Might be one of our # clones. Check the 'org.zol:mountpoint' property set in @@ -359,9 +359,8 @@ mount_fs() # isn't the root fs. return 0 fi - # Don't use mount.zfs -o zfsutils for legacy mountpoint if [ "$mountpoint" = "legacy" ]; then - ZFS_CMD="mount -t zfs" + ZFS_CMD="mount.zfs" fi # Last hail-mary: Hope 'rootmnt' is set! mountpoint="" diff --git a/include/os/linux/zfs/sys/zfs_vfsops_os.h b/include/os/linux/zfs/sys/zfs_vfsops_os.h index b4d5db21f5e5..720a8a6327af 100644 --- a/include/os/linux/zfs/sys/zfs_vfsops_os.h +++ b/include/os/linux/zfs/sys/zfs_vfsops_os.h @@ -69,6 +69,7 @@ typedef struct vfs { boolean_t vfs_do_relatime; boolean_t vfs_nbmand; boolean_t vfs_do_nbmand; + kmutex_t vfs_mntpt_lock; } vfs_t; typedef struct zfs_mnt { diff --git a/module/os/linux/zfs/zfs_ctldir.c b/module/os/linux/zfs/zfs_ctldir.c index 54ed70d0394f..25ce66f5385a 100644 --- a/module/os/linux/zfs/zfs_ctldir.c +++ b/module/os/linux/zfs/zfs_ctldir.c @@ -769,9 +769,6 @@ zfsctl_snapshot_path_objset(zfsvfs_t *zfsvfs, uint64_t objsetid, uint64_t id, pos = 0; int error = 0; - if (zfsvfs->z_vfs->vfs_mntpoint == NULL) - return (SET_ERROR(ENOENT)); - cookie = spl_fstrans_mark(); snapname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); @@ -788,8 +785,14 @@ zfsctl_snapshot_path_objset(zfsvfs_t *zfsvfs, uint64_t objsetid, break; } - snprintf(full_path, path_len, "%s/.zfs/snapshot/%s", - zfsvfs->z_vfs->vfs_mntpoint, snapname); + mutex_enter(&zfsvfs->z_vfs->vfs_mntpt_lock); + if (zfsvfs->z_vfs->vfs_mntpoint != NULL) { + snprintf(full_path, path_len, "%s/.zfs/snapshot/%s", + zfsvfs->z_vfs->vfs_mntpoint, snapname); + } else + error = SET_ERROR(ENOENT); + mutex_exit(&zfsvfs->z_vfs->vfs_mntpt_lock); + out: kmem_free(snapname, ZFS_MAX_DATASET_NAME_LEN); spl_fstrans_unmark(cookie); @@ -1049,6 +1052,66 @@ exportfs_flush(void) (void) call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); } +/* + * Returns the path in char format for given struct path. Uses + * d_path exported by kernel to convert struct path to char + * format. Returns the correct path for mountpoints and chroot + * environments. + * + * If chroot environment has directories that are mounted with + * --bind or --rbind flag, d_path returns the complete path inside + * chroot environment but does not return the absolute path, i.e. + * the path to chroot environment is missing. + */ +static int +get_root_path(struct path *path, char *buff, int len) +{ + char *path_buffer, *path_ptr; + int error = 0; + + path_get(path); + path_buffer = kmem_zalloc(len, KM_SLEEP); + path_ptr = d_path(path, path_buffer, len); + if (IS_ERR(path_ptr)) + error = SET_ERROR(-PTR_ERR(path_ptr)); + else + strcpy(buff, path_ptr); + + kmem_free(path_buffer, len); + path_put(path); + return (error); +} + +/* + * Returns if the current process root is chrooted or not. Linux + * kernel exposes the task_struct for current process and init. + * Since init process root points to actual root filesystem when + * Linux runtime is reached, we can compare the current process + * root with init process root to determine if root of the current + * process is different from init, which can reliably determine if + * current process is in chroot context or not. + */ +static int +is_current_chrooted(void) +{ + struct task_struct *curr = current, *global = &init_task; + struct path cr_root, gl_root; + + task_lock(curr); + get_fs_root(curr->fs, &cr_root); + task_unlock(curr); + + task_lock(global); + get_fs_root(global->fs, &gl_root); + task_unlock(global); + + int chrooted = !path_equal(&cr_root, &gl_root); + path_put(&gl_root); + path_put(&cr_root); + + return (chrooted); +} + /* * Attempt to unmount a snapshot by making a call to user space. * There is no assurance that this can or will succeed, is just a @@ -1122,14 +1185,50 @@ zfsctl_snapshot_mount(struct path *path, int flags) if (error) goto error; + if (is_current_chrooted() == 0) { + /* + * Current process is not in chroot context + */ + + char *m = kmem_zalloc(MAXPATHLEN, KM_SLEEP); + struct path mnt_path; + mnt_path.mnt = path->mnt; + mnt_path.dentry = path->mnt->mnt_root; + + /* + * Get path to current mountpoint + */ + error = get_root_path(&mnt_path, m, MAXPATHLEN); + if (error != 0) { + kmem_free(m, MAXPATHLEN); + goto error; + } + mutex_enter(&zfsvfs->z_vfs->vfs_mntpt_lock); + if (zfsvfs->z_vfs->vfs_mntpoint != NULL) { + /* + * If current mnountpoint and vfs_mntpoint are not same, + * store current mountpoint in vfs_mntpoint. + */ + if (strcmp(zfsvfs->z_vfs->vfs_mntpoint, m) != 0) { + kmem_strfree(zfsvfs->z_vfs->vfs_mntpoint); + zfsvfs->z_vfs->vfs_mntpoint = kmem_strdup(m); + } + } else + zfsvfs->z_vfs->vfs_mntpoint = kmem_strdup(m); + mutex_exit(&zfsvfs->z_vfs->vfs_mntpt_lock); + kmem_free(m, MAXPATHLEN); + } + /* * Construct a mount point path from sb of the ctldir inode and dirent * name, instead of from d_path(), so that chroot'd process doesn't fail * on mount.zfs(8). */ + mutex_enter(&zfsvfs->z_vfs->vfs_mntpt_lock); snprintf(full_path, MAXPATHLEN, "%s/.zfs/snapshot/%s", zfsvfs->z_vfs->vfs_mntpoint ? zfsvfs->z_vfs->vfs_mntpoint : "", dname(dentry)); + mutex_exit(&zfsvfs->z_vfs->vfs_mntpt_lock); /* * Multiple concurrent automounts of a snapshot are never allowed. diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index 2015c20d7340..8e0a319fb422 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -113,7 +113,7 @@ zfsvfs_vfs_free(vfs_t *vfsp) if (vfsp != NULL) { if (vfsp->vfs_mntpoint != NULL) kmem_strfree(vfsp->vfs_mntpoint); - + mutex_destroy(&vfsp->vfs_mntpt_lock); kmem_free(vfsp, sizeof (vfs_t)); } } @@ -195,10 +195,11 @@ zfsvfs_parse_option(char *option, int token, substring_t *args, vfs_t *vfsp) vfsp->vfs_do_nbmand = B_TRUE; break; case TOKEN_MNTPOINT: + if (vfsp->vfs_mntpoint != NULL) + kmem_strfree(vfsp->vfs_mntpoint); vfsp->vfs_mntpoint = match_strdup(&args[0]); if (vfsp->vfs_mntpoint == NULL) return (SET_ERROR(ENOMEM)); - break; default: break; @@ -217,6 +218,7 @@ zfsvfs_parse_options(char *mntopts, vfs_t **vfsp) int error; tmp_vfsp = kmem_zalloc(sizeof (vfs_t), KM_SLEEP); + mutex_init(&tmp_vfsp->vfs_mntpt_lock, NULL, MUTEX_DEFAULT, NULL); if (mntopts != NULL) { substring_t args[MAX_OPT_ARGS]; From b32b35cea8806dbcbd66c949763ceb76f54cff00 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 21 Oct 2024 04:01:49 +1100 Subject: [PATCH 066/223] zdb: show bp in uberblock dump Just another useful nugget of info in times of strife. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16667 --- cmd/zdb/zdb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index da3cb983f4cc..9d85d7f4b6dd 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -4252,6 +4252,10 @@ dump_uberblock(uberblock_t *ub, const char *header, const char *footer) (void) printf("\ttimestamp = %llu UTC = %s", (u_longlong_t)ub->ub_timestamp, ctime(×tamp)); + char blkbuf[BP_SPRINTF_LEN]; + snprintf_blkptr(blkbuf, sizeof (blkbuf), &ub->ub_rootbp); + (void) printf("\tbp = %s\n", blkbuf); + (void) printf("\tmmp_magic = %016llx\n", (u_longlong_t)ub->ub_mmp_magic); if (MMP_VALID(ub)) { From 82ab837a0e581022409a113446af83558e7ef0b7 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 29 Oct 2024 19:49:54 +0100 Subject: [PATCH 067/223] Fix gcc unused value warning in FreeBSD simd.h The macros `simd_stat_init()` and `simd_stat_fini()` in FreeBSD's `simd.h` are defined as zero, but they are actually only used as statements. Replace the definitions with `do {} while (0)` instead, to avoid gcc `-Wunused-value` warnings. Reviewed-by: Tino Reichardt Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Toomas Soome Signed-off-by: Dimitry Andric Closes #16693 --- include/os/freebsd/spl/sys/simd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/os/freebsd/spl/sys/simd.h b/include/os/freebsd/spl/sys/simd.h index 6bc46755c4e3..d16e1db5e826 100644 --- a/include/os/freebsd/spl/sys/simd.h +++ b/include/os/freebsd/spl/sys/simd.h @@ -50,7 +50,7 @@ #define kfpu_fini() do {} while (0) #endif -#define simd_stat_init() 0 -#define simd_stat_fini() 0 +#define simd_stat_init() do {} while (0) +#define simd_stat_fini() do {} while (0) #endif From 73b3e8acef77cdb936fe201d6b896f4d501cca5e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 29 Oct 2024 20:05:02 +0100 Subject: [PATCH 068/223] Fix gcc uninitialized warning in FreeBSD zio_crypt.c In FreeBSD's `zio_do_crypt_data()`, ensure that two `struct uio` variables are cleared before copying data out of them. This avoids accessing garbage data, and fixes gcc `-Wuninitialized` warnings. Reviewed-by: Brian Behlendorf Reviewed-by: Toomas Soome Reviewed-by: Alexander Motin Signed-off-by: Dimitry Andric Closes #16688 --- module/os/freebsd/zfs/zio_crypt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/module/os/freebsd/zfs/zio_crypt.c b/module/os/freebsd/zfs/zio_crypt.c index b08916b317f8..ebf18aaa3403 100644 --- a/module/os/freebsd/zfs/zio_crypt.c +++ b/module/os/freebsd/zfs/zio_crypt.c @@ -1692,11 +1692,10 @@ zio_do_crypt_data(boolean_t encrypt, zio_crypt_key_t *key, freebsd_crypt_session_t *tmpl = NULL; uint8_t *authbuf = NULL; - + memset(&puio_s, 0, sizeof (puio_s)); + memset(&cuio_s, 0, sizeof (cuio_s)); zfs_uio_init(&puio, &puio_s); zfs_uio_init(&cuio, &cuio_s); - memset(GET_UIO_STRUCT(&puio), 0, sizeof (struct uio)); - memset(GET_UIO_STRUCT(&cuio), 0, sizeof (struct uio)); #ifdef FCRYPTO_DEBUG printf("%s(%s, %p, %p, %d, %p, %p, %u, %s, %p, %p, %p)\n", From 727506c943f517533ad886cdf8e2cf258cfad12a Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 29 Oct 2024 15:23:24 -0400 Subject: [PATCH 069/223] On the first vdev open ignore impossible ashift hints If on the first open device's logical ashift is bigger than set by pool's ashift property, ignore the last as unusable instead of creating vdev that will fail most of I/Os due to misalignment. Reviewed-by: Rob Norris Reviewed-by: Brian Behlendorf Reviewed-by: Ameer Hamza Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16690 --- module/zfs/vdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index f8055e69c916..82763c125caa 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -2178,10 +2178,11 @@ vdev_open(vdev_t *vd) vd->vdev_max_asize = max_asize; /* - * If the vdev_ashift was not overridden at creation time, + * If the vdev_ashift was not overridden at creation time + * (0) or the override value is impossible for the device, * then set it the logical ashift and optimize the ashift. */ - if (vd->vdev_ashift == 0) { + if (vd->vdev_ashift < vd->vdev_logical_ashift) { vd->vdev_ashift = vd->vdev_logical_ashift; if (vd->vdev_logical_ashift > ASHIFT_MAX) { From f237b8e2a4d220ff97783d72f8d5f05a0fe1287c Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 25 Oct 2024 16:14:37 +1100 Subject: [PATCH 070/223] vdev_disk: try harder to ensure IO alignment rules It seems out our notion of "properly" aligned IO was incomplete. In particular, dm-crypt does its own splitting, and assumes that a logical block will never cross an order-0 page boundary (ie, the physical page size, not compound size). This effectively means that it needs to be possible to split a BIO at any page or block size boundary and have it work correctly. This updates the alignment check function to enforce these rules (to the extent possible). Our response to misaligned data is to make some new allocation that is properly aligned, and copy the data into it. It turns out that linearising (via abd_borrow_buf()) is not enough, because we allocate eg 4K blocks from a general purpose slab, and so may receive (or already have) a 4K block that crosses pages. So instead, we allocate a new ABD, which is guaranteed to be aligned properly to block sizes, and then copy everything into it, and back out on the way back. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Tony Hutter Signed-off-by: Rob Norris Closes #16687 #16631 #15646 #15533 #14533 (cherry picked from commit 63bafe60ec741c269d29e26b192a8a5c4f6acf92) --- module/os/linux/zfs/vdev_disk.c | 120 ++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 52 deletions(-) diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index 67704093d71b..5c7b35cc5652 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -832,14 +832,11 @@ BIO_END_IO_PROTO(vbio_completion, bio, error) * to the ADB, with changes if appropriate. */ if (vbio->vbio_abd != NULL) { - void *buf = abd_to_buf(vbio->vbio_abd); + if (zio->io_type == ZIO_TYPE_READ) + abd_copy(zio->io_abd, vbio->vbio_abd, zio->io_size); + abd_free(vbio->vbio_abd); vbio->vbio_abd = NULL; - - if (zio->io_type == ZIO_TYPE_READ) - abd_return_buf_copy(zio->io_abd, buf, zio->io_size); - else - abd_return_buf(zio->io_abd, buf, zio->io_size); } /* Final cleanup */ @@ -859,34 +856,59 @@ BIO_END_IO_PROTO(vbio_completion, bio, error) * split the BIO, the two halves will still be properly aligned. */ typedef struct { - uint_t bmask; - uint_t npages; - uint_t end; -} vdev_disk_check_pages_t; + size_t blocksize; + int seen_first; + int seen_last; +} vdev_disk_check_alignment_t; static int -vdev_disk_check_pages_cb(struct page *page, size_t off, size_t len, void *priv) +vdev_disk_check_alignment_cb(struct page *page, size_t off, size_t len, + void *priv) { - vdev_disk_check_pages_t *s = priv; + (void) page; + vdev_disk_check_alignment_t *s = priv; /* - * If we didn't finish on a block size boundary last time, then there - * would be a gap if we tried to use this ABD as-is, so abort. + * The cardinal rule: a single on-disk block must never cross an + * physical (order-0) page boundary, as the kernel expects to be able + * to split at both LBS and page boundaries. + * + * This implies various alignment rules for the blocks in this + * (possibly compound) page, which we can check for. */ - if (s->end != 0) - return (1); /* - * Note if we're taking less than a full block, so we can check it - * above on the next call. + * If the previous page did not end on a page boundary, then we + * can't proceed without creating a hole. */ - s->end = (off+len) & s->bmask; + if (s->seen_last) + return (1); - /* All blocks after the first must start on a block size boundary. */ - if (s->npages != 0 && (off & s->bmask) != 0) + /* This page must contain only whole LBS-sized blocks. */ + if (!IS_P2ALIGNED(len, s->blocksize)) return (1); - s->npages++; + /* + * If this is not the first page in the ABD, then the data must start + * on a page-aligned boundary (so the kernel can split on page + * boundaries without having to deal with a hole). If it is, then + * it can start on LBS-alignment. + */ + if (s->seen_first) { + if (!IS_P2ALIGNED(off, PAGESIZE)) + return (1); + } else { + if (!IS_P2ALIGNED(off, s->blocksize)) + return (1); + s->seen_first = 1; + } + + /* + * If this data does not end on a page-aligned boundary, then this + * must be the last page in the ABD, for the same reason. + */ + s->seen_last = !IS_P2ALIGNED(off+len, PAGESIZE); + return (0); } @@ -895,15 +917,14 @@ vdev_disk_check_pages_cb(struct page *page, size_t off, size_t len, void *priv) * the number of pages, or 0 if it can't be submitted like this. */ static boolean_t -vdev_disk_check_pages(abd_t *abd, uint64_t size, struct block_device *bdev) +vdev_disk_check_alignment(abd_t *abd, uint64_t size, struct block_device *bdev) { - vdev_disk_check_pages_t s = { - .bmask = bdev_logical_block_size(bdev)-1, - .npages = 0, - .end = 0, + vdev_disk_check_alignment_t s = { + .blocksize = bdev_logical_block_size(bdev), }; - if (abd_iterate_page_func(abd, 0, size, vdev_disk_check_pages_cb, &s)) + if (abd_iterate_page_func(abd, 0, size, + vdev_disk_check_alignment_cb, &s)) return (B_FALSE); return (B_TRUE); @@ -937,37 +958,32 @@ vdev_disk_io_rw(zio_t *zio) /* * Check alignment of the incoming ABD. If any part of it would require - * submitting a page that is not aligned to the logical block size, - * then we take a copy into a linear buffer and submit that instead. - * This should be impossible on a 512b LBS, and fairly rare on 4K, - * usually requiring abnormally-small data blocks (eg gang blocks) - * mixed into the same ABD as larger ones (eg aggregated). + * submitting a page that is not aligned to both the logical block size + * and the page size, then we take a copy into a new memory region with + * correct alignment. This should be impossible on a 512b LBS. On + * larger blocks, this can happen at least when a small number of + * blocks (usually 1) are allocated from a shared slab, or when + * abnormally-small data regions (eg gang headers) are mixed into the + * same ABD as larger allocations (eg aggregations). */ abd_t *abd = zio->io_abd; - if (!vdev_disk_check_pages(abd, zio->io_size, bdev)) { - void *buf; - if (zio->io_type == ZIO_TYPE_READ) - buf = abd_borrow_buf(zio->io_abd, zio->io_size); - else - buf = abd_borrow_buf_copy(zio->io_abd, zio->io_size); + if (!vdev_disk_check_alignment(abd, zio->io_size, bdev)) { + /* Allocate a new memory region with guaranteed alignment */ + abd = abd_alloc_for_io(zio->io_size, + zio->io_abd->abd_flags & ABD_FLAG_META); - /* - * Wrap the copy in an abd_t, so we can use the same iterators - * to count and fill the vbio later. - */ - abd = abd_get_from_buf(buf, zio->io_size); + /* If we're writing copy our data into it */ + if (zio->io_type == ZIO_TYPE_WRITE) + abd_copy(abd, zio->io_abd, zio->io_size); /* - * False here would mean the borrowed copy has an invalid - * alignment too, which would mean we've somehow been passed a - * linear ABD with an interior page that has a non-zero offset - * or a size not a multiple of PAGE_SIZE. This is not possible. - * It would mean either zio_buf_alloc() or its underlying - * allocators have done something extremely strange, or our - * math in vdev_disk_check_pages() is wrong. In either case, + * False here would mean the new allocation has an invalid + * alignment too, which would mean that abd_alloc() is not + * guaranteeing this, or our logic in + * vdev_disk_check_alignment() is wrong. In either case, * something in seriously wrong and its not safe to continue. */ - VERIFY(vdev_disk_check_pages(abd, zio->io_size, bdev)); + VERIFY(vdev_disk_check_alignment(abd, zio->io_size, bdev)); } /* Allocate vbio, with a pointer to the borrowed ABD if necessary */ From d83cd5307d98505ea723c8d6cedcc93c0b99c313 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 2 Nov 2024 03:08:33 +1100 Subject: [PATCH 071/223] zdb: add extra -T flag to show histograms of BRT refcounts Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Closes #16692 (cherry picked from commit 673efbbf5d160aea9a58f9eaac6d781d0975659a) --- cmd/zdb/zdb.c | 29 ++++++++++++++++++++++++----- man/man8/zdb.8 | 4 +++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 9d85d7f4b6dd..52b8fe8ae66e 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -2195,14 +2195,21 @@ dump_brt(spa_t *spa) if (dump_opt['T'] < 3) return; + /* -TTT shows a per-vdev histograms; -TTTT shows all entries */ + boolean_t do_histo = dump_opt['T'] == 3; + char dva[64]; - printf("\n%-16s %-10s\n", "DVA", "REFCNT"); + + if (!do_histo) + printf("\n%-16s %-10s\n", "DVA", "REFCNT"); for (uint64_t vdevid = 0; vdevid < brt->brt_nvdevs; vdevid++) { brt_vdev_t *brtvd = &brt->brt_vdevs[vdevid]; if (brtvd == NULL || !brtvd->bv_initiated) continue; + uint64_t counts[64] = {}; + zap_cursor_t zc; zap_attribute_t za; for (zap_cursor_init(&zc, brt->brt_mos, brtvd->bv_mos_entries); @@ -2214,13 +2221,25 @@ dump_brt(spa_t *spa) (const uint64_t *)za.za_name, 1, za.za_integer_length, za.za_num_integers, &refcnt)); - uint64_t offset = *(const uint64_t *)za.za_name; + if (do_histo) + counts[highbit64(refcnt)]++; + else { + uint64_t offset = + *(const uint64_t *)za.za_name; - snprintf(dva, sizeof (dva), "%" PRIu64 ":%llx", vdevid, - (u_longlong_t)offset); - printf("%-16s %-10llu\n", dva, (u_longlong_t)refcnt); + snprintf(dva, sizeof (dva), "%" PRIu64 ":%llx", + vdevid, (u_longlong_t)offset); + printf("%-16s %-10llu\n", dva, + (u_longlong_t)refcnt); + } } zap_cursor_fini(&zc); + + if (do_histo) { + printf("\nBRT: vdev %" PRIu64 + ": DVAs with 2^n refcnts:\n", vdevid); + dump_histogram(counts, 64, 0); + } } } diff --git a/man/man8/zdb.8 b/man/man8/zdb.8 index d7f66d917ac7..78466f42a040 100644 --- a/man/man8/zdb.8 +++ b/man/man8/zdb.8 @@ -14,7 +14,7 @@ .\" Copyright (c) 2017 Lawrence Livermore National Security, LLC. .\" Copyright (c) 2017 Intel Corporation. .\" -.Dd November 18, 2023 +.Dd October 27, 2024 .Dt ZDB 8 .Os . @@ -409,6 +409,8 @@ blocks cloned, the space saving as a result of cloning, and the saving ratio. .It Fl TT Display the per-vdev BRT statistics, including total references. .It Fl TTT +Display histograms of per-vdev BRT refcounts. +.It Fl TTTT Dump the contents of the block reference tables. .It Fl u , -uberblock Display the current uberblock. From d3887c4c61b79bce7a6d91c9bb9bfdabf7737cc6 Mon Sep 17 00:00:00 2001 From: Uglymotha Date: Tue, 5 Nov 2024 01:44:38 +0100 Subject: [PATCH 072/223] Verify parent_dev before calling udev_device_get_sysattr_value Not all udev devices have parent devices. Calling udev_device_get_ functions yield an assertion error if called with a NULL pointer. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Sietse Co-authored-by: Sietse Closes #16705 Closes #16717 --- cmd/zed/zed_disk_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/zed/zed_disk_event.c b/cmd/zed/zed_disk_event.c index 32a8789d3001..4a2b7398e922 100644 --- a/cmd/zed/zed_disk_event.c +++ b/cmd/zed/zed_disk_event.c @@ -139,7 +139,8 @@ dev_event_nvlist(struct udev_device *dev) * is /dev/sda. */ struct udev_device *parent_dev = udev_device_get_parent(dev); - if ((value = udev_device_get_sysattr_value(parent_dev, "size")) + if (parent_dev != NULL && + (value = udev_device_get_sysattr_value(parent_dev, "size")) != NULL) { uint64_t numval = DEV_BSIZE; From 5dac614e7b598574affd7a3cdec7a213d3e897f0 Mon Sep 17 00:00:00 2001 From: Derek Schrock Date: Thu, 6 Jun 2024 20:37:26 -0400 Subject: [PATCH 073/223] contrib/bash_completion.d: squelch FreeBSD seq when first < last With seq x -1 z and x is less than z FreeBSD seq will print the error: $ seq 1 -1 2 seq: needs positive increment Hide this error. Alternatively $COMP_CWORD could be checked for < 2. Reviewed-by: Brian Behlendorf Signed-off-by: Derek Schrock Closes #16234 --- contrib/bash_completion.d/zfs.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/bash_completion.d/zfs.in b/contrib/bash_completion.d/zfs.in index c5cfd8e8efb2..dbeb10d8994b 100644 --- a/contrib/bash_completion.d/zfs.in +++ b/contrib/bash_completion.d/zfs.in @@ -155,7 +155,7 @@ __zfs_list_volumes() __zfs_argument_chosen() { local word property - for word in $(seq $((COMP_CWORD-1)) -1 2) + for word in $(seq $((COMP_CWORD-1)) -1 2 2>/dev/null) do local prev="${COMP_WORDS[$word]}" if [[ ${COMP_WORDS[$word-1]} != -[tos] ]] From 9a0ebe3a87459954b180952bd2953e2f99de5c28 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 9 Aug 2024 08:36:09 +1000 Subject: [PATCH 074/223] contrib: bash_completion.d: force zpool symlink recreation ln will fail if the target already exists, which causes make to bail out. Adding -f makes it more "compiler-like", overwriting the target instead. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Tino Reichardt Reviewed-by: Allan Jude Reviewed-by: Mateusz Piotrowski <0mp@FreeBSD.org> Signed-off-by: Rob Norris Closes #16423 --- contrib/bash_completion.d/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/bash_completion.d/Makefile.am b/contrib/bash_completion.d/Makefile.am index d3e6c0e79071..cc901b34de12 100644 --- a/contrib/bash_completion.d/Makefile.am +++ b/contrib/bash_completion.d/Makefile.am @@ -6,4 +6,4 @@ SHELLCHECKSCRIPTS += $(COMPLETION_FILES) $(call SHELLCHECK_OPTS,$(COMPLETION_FILES)): SHELLCHECK_SHELL = bash %D%/zpool: %D%/zfs - $(LN_S) zfs $@ + $(LN_S) -f zfs $@ From 4197af4df1468245cff12625235f7cfcd8a8aaad Mon Sep 17 00:00:00 2001 From: Brian Atkinson Date: Thu, 8 Aug 2024 18:39:25 -0400 Subject: [PATCH 075/223] Updating bash completion build file Commit 46ebd0a updated the build system to make symbolic link for zpool. However, this commit did not update the automake file to also add the symbolic link to the CLEANFILES variable. This is necessary so the link is removed when running make clean/distclean. Reviewed-by: Brian Behlendorf Reviewed-by: Tino Reichardt Signed-off-by: Brian Atkinson Closes #16422 --- contrib/bash_completion.d/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/bash_completion.d/Makefile.am b/contrib/bash_completion.d/Makefile.am index cc901b34de12..95d4ffa76e22 100644 --- a/contrib/bash_completion.d/Makefile.am +++ b/contrib/bash_completion.d/Makefile.am @@ -1,6 +1,7 @@ nodist_bashcompletion_DATA = %D%/zfs %D%/zpool COMPLETION_FILES = %D%/zfs -SUBSTFILES += $(COMPLETION_FILES) +SUBSTFILES += $(COMPLETION_FILES) +CLEANFILES += %D%/zpool SHELLCHECKSCRIPTS += $(COMPLETION_FILES) $(call SHELLCHECK_OPTS,$(COMPLETION_FILES)): SHELLCHECK_SHELL = bash From f4e66db40188743073559ea8c8e443dedf016edc Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 25 Oct 2024 17:28:20 +1100 Subject: [PATCH 076/223] vdev_disk: move abd return and free off the interrupt handler Freeing an ABD can take sleeping locks to update various stats. We aren't allowed to sleep on an interrupt handler. So, move the free off to the io_done callback. We should never have been freeing things in the interrupt handler, but we got away with it because we were usually freeing a linear ABD, which at most is returning two objects to a cache and never sleeping. Scatter ABDs can be used now, and those have more complex locking. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Tony Hutter Signed-off-by: Rob Norris Closes #16687 --- module/os/linux/zfs/vdev_disk.c | 40 ++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index 5c7b35cc5652..ec3538215cb4 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -828,21 +828,13 @@ BIO_END_IO_PROTO(vbio_completion, bio, error) bio_put(bio); /* - * If we copied the ABD before issuing it, clean up and return the copy - * to the ADB, with changes if appropriate. + * We're likely in an interrupt context so we can't do ABD/memory work + * here; instead we stash vbio on the zio and take care of it in the + * done callback. */ - if (vbio->vbio_abd != NULL) { - if (zio->io_type == ZIO_TYPE_READ) - abd_copy(zio->io_abd, vbio->vbio_abd, zio->io_size); + ASSERT3P(zio->io_bio, ==, NULL); + zio->io_bio = vbio; - abd_free(vbio->vbio_abd); - vbio->vbio_abd = NULL; - } - - /* Final cleanup */ - kmem_free(vbio, sizeof (vbio_t)); - - /* All done, submit for processing */ zio_delay_interrupt(zio); } @@ -1496,6 +1488,28 @@ vdev_disk_io_start(zio_t *zio) static void vdev_disk_io_done(zio_t *zio) { + /* If this was a read or write, we need to clean up the vbio */ + if (zio->io_bio != NULL) { + vbio_t *vbio = zio->io_bio; + zio->io_bio = NULL; + + /* + * If we copied the ABD before issuing it, clean up and return + * the copy to the ADB, with changes if appropriate. + */ + if (vbio->vbio_abd != NULL) { + if (zio->io_type == ZIO_TYPE_READ) + abd_copy(zio->io_abd, vbio->vbio_abd, + zio->io_size); + + abd_free(vbio->vbio_abd); + vbio->vbio_abd = NULL; + } + + /* Final cleanup */ + kmem_free(vbio, sizeof (vbio_t)); + } + /* * If the device returned EIO, we revalidate the media. If it is * determined the media has changed this triggers the asynchronous From b2bef90465fb78086ca6f488175171ca2683f75f Mon Sep 17 00:00:00 2001 From: Pavel Snajdr Date: Tue, 17 Sep 2024 22:38:02 +0200 Subject: [PATCH 077/223] Linux 6.10 compat: Fix tracepoints definitions __string field definition includes the source variable for a value of the string when the TP hits; in 6.10+ kernels, __assign_str() uses that to copy a value from src to the string, with older kernels, __assign_str still accepted src as a second parameter. Reviewed-by: Brian Behlendorf Signed-off-by: Pavel Snajdr Co-authored-by: Tony Hutter Closes #16475 Closes #16515 --- config/kernel-assign_str.m4 | 62 +++++++++++++++++++++++++ config/kernel-vfs-iov_iter.m4 | 49 +++++++++++++++++++ config/kernel.m4 | 1 + include/os/linux/spl/sys/types.h | 6 +++ include/os/linux/zfs/sys/trace_dbgmsg.h | 3 +- include/os/linux/zfs/sys/trace_dbuf.h | 29 +++++------- 6 files changed, 131 insertions(+), 19 deletions(-) create mode 100644 config/kernel-assign_str.m4 diff --git a/config/kernel-assign_str.m4 b/config/kernel-assign_str.m4 new file mode 100644 index 000000000000..cf4b00e7cbf2 --- /dev/null +++ b/config/kernel-assign_str.m4 @@ -0,0 +1,62 @@ +dnl # +dnl # 6.10 kernel, check number of args of __assign_str() for trace: +dnl +dnl # 6.10+: one arg +dnl # 6.9 and older: two args +dnl # +dnl # More specifically, this will test to see if __assign_str() takes one +dnl # arg. If __assign_str() takes two args, or is not defined, then +dnl # HAVE_1ARG_ASSIGN_STR will not be set. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_1ARG_ASSIGN_STR], [ + AC_MSG_CHECKING([whether __assign_str() has one arg]) + ZFS_LINUX_TRY_COMPILE_HEADER([ + #include + MODULE_LICENSE("$ZFS_META_LICENSE"); + + #define CREATE_TRACE_POINTS + #include "conftest.h" + ],[ + trace_zfs_autoconf_event_one("1"); + trace_zfs_autoconf_event_two("2"); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_1ARG_ASSIGN_STR, 1, + [__assign_str() has one arg]) + ],[ + AC_MSG_RESULT(no) + ],[ + #if !defined(_CONFTEST_H) || defined(TRACE_HEADER_MULTI_READ) + #define _CONFTEST_H + + #undef TRACE_SYSTEM + #define TRACE_SYSTEM zfs + #include + + DECLARE_EVENT_CLASS(zfs_autoconf_event_class, + TP_PROTO(char *string), + TP_ARGS(string), + TP_STRUCT__entry( + __string(str, string) + ), + TP_fast_assign( + __assign_str(str); + ), + TP_printk("str = %s", __get_str(str)) + ); + + #define DEFINE_AUTOCONF_EVENT(name) \ + DEFINE_EVENT(zfs_autoconf_event_class, name, \ + TP_PROTO(char * str), \ + TP_ARGS(str)) + DEFINE_AUTOCONF_EVENT(zfs_autoconf_event_one); + DEFINE_AUTOCONF_EVENT(zfs_autoconf_event_two); + + #endif /* _CONFTEST_H */ + + #undef TRACE_INCLUDE_PATH + #define TRACE_INCLUDE_PATH . + #define TRACE_INCLUDE_FILE conftest + #include + ]) +]) diff --git a/config/kernel-vfs-iov_iter.m4 b/config/kernel-vfs-iov_iter.m4 index ff560ff3eef0..e7ced0297014 100644 --- a/config/kernel-vfs-iov_iter.m4 +++ b/config/kernel-vfs-iov_iter.m4 @@ -85,6 +85,34 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [ bytes = copy_from_iter((void *)&buf, size, &iter); ]) + ZFS_LINUX_TEST_SRC([iov_iter_get_pages2], [ + #include + ], [ + struct iov_iter iter = { 0 }; + struct page **pages = NULL; + size_t maxsize = 4096; + unsigned maxpages = 1; + size_t start; + size_t ret __attribute__ ((unused)); + + ret = iov_iter_get_pages2(&iter, pages, maxsize, maxpages, + &start); + ]) + + ZFS_LINUX_TEST_SRC([iov_iter_get_pages], [ + #include + ], [ + struct iov_iter iter = { 0 }; + struct page **pages = NULL; + size_t maxsize = 4096; + unsigned maxpages = 1; + size_t start; + size_t ret __attribute__ ((unused)); + + ret = iov_iter_get_pages(&iter, pages, maxsize, maxpages, + &start); + ]) + ZFS_LINUX_TEST_SRC([iov_iter_type], [ #include #include @@ -184,6 +212,27 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [ enable_vfs_iov_iter="no" ]) + dnl # + dnl # Kernel 6.0 changed iov_iter_get_pages() to iov_iter_page_pages2(). + dnl # + AC_MSG_CHECKING([whether iov_iter_get_pages2() is available]) + ZFS_LINUX_TEST_RESULT([iov_iter_get_pages2], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IOV_ITER_GET_PAGES2, 1, + [iov_iter_get_pages2() is available]) + ], [ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([whether iov_iter_get_pages() is available]) + ZFS_LINUX_TEST_RESULT([iov_iter_get_pages], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IOV_ITER_GET_PAGES, 1, + [iov_iter_get_pages() is available]) + ], [ + AC_MSG_RESULT(no) + enable_vfs_iov_iter="no" + ]) + ]) + dnl # dnl # This checks for iov_iter_type() in linux/uio.h. It is not dnl # required, however, and the module will compiled without it diff --git a/config/kernel.m4 b/config/kernel.m4 index f0cd76fd7325..17d8694ceff1 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -326,6 +326,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SYNC_BDEV ZFS_AC_KERNEL_MM_PAGE_SIZE ZFS_AC_KERNEL_MM_PAGE_MAPPING + ZFS_AC_KERNEL_1ARG_ASSIGN_STR case "$host_cpu" in powerpc*) ZFS_AC_KERNEL_CPU_HAS_FEATURE diff --git a/include/os/linux/spl/sys/types.h b/include/os/linux/spl/sys/types.h index 94ba7b6ad323..d3aefb18449d 100644 --- a/include/os/linux/spl/sys/types.h +++ b/include/os/linux/spl/sys/types.h @@ -83,4 +83,10 @@ typedef struct user_namespace zidmap_t; extern zidmap_t *zfs_init_idmap; +#ifdef HAVE_1ARG_ASSIGN_STR +#define __assign_str_impl(a, b) __assign_str(a) +#else +#define __assign_str_impl(a, b) __assign_str(a, b) +#endif + #endif /* _SPL_TYPES_H */ diff --git a/include/os/linux/zfs/sys/trace_dbgmsg.h b/include/os/linux/zfs/sys/trace_dbgmsg.h index 19f533baaaaf..58081d64cf40 100644 --- a/include/os/linux/zfs/sys/trace_dbgmsg.h +++ b/include/os/linux/zfs/sys/trace_dbgmsg.h @@ -32,6 +32,7 @@ #define _TRACE_DBGMSG_H #include +#include /* * This file defines tracepoint events for use by the dbgmsg(), @@ -59,7 +60,7 @@ DECLARE_EVENT_CLASS(zfs_dprintf_class, __string(msg, msg) ), TP_fast_assign( - __assign_str(msg, msg); + __assign_str_impl(msg, msg); ), TP_printk("%s", __get_str(msg)) ); diff --git a/include/os/linux/zfs/sys/trace_dbuf.h b/include/os/linux/zfs/sys/trace_dbuf.h index 0e9cbdd725b4..b61807744d5c 100644 --- a/include/os/linux/zfs/sys/trace_dbuf.h +++ b/include/os/linux/zfs/sys/trace_dbuf.h @@ -45,9 +45,13 @@ * dmu_buf_impl_t *, ..., * zio_t *, ...); */ +#define DBUF_TP_STRUCT_ENTRY_OS_SPA \ + (db != NULL && \ + POINTER_IS_VALID(DB_DNODE(db)->dn_objset)) \ + ? spa_name(DB_DNODE(db)->dn_objset->os_spa) : "NULL" #define DBUF_TP_STRUCT_ENTRY \ - __dynamic_array(char, os_spa, TRACE_DBUF_MSG_MAX) \ + __string(os_spa, DBUF_TP_STRUCT_ENTRY_OS_SPA) \ __field(uint64_t, ds_object) \ __field(uint64_t, db_object) \ __field(uint64_t, db_level) \ @@ -55,18 +59,11 @@ __field(uint64_t, db_offset) \ __field(uint64_t, db_size) \ __field(uint64_t, db_state) \ - __field(int64_t, db_holds) \ - __dynamic_array(char, msg, TRACE_DBUF_MSG_MAX) + __field(int64_t, db_holds) #define DBUF_TP_FAST_ASSIGN \ if (db != NULL) { \ - if (POINTER_IS_VALID(DB_DNODE(db)->dn_objset)) { \ - __assign_str(os_spa, \ - spa_name(DB_DNODE(db)->dn_objset->os_spa)); \ - } else { \ - __assign_str(os_spa, "NULL"); \ - } \ - \ + __assign_str_impl(os_spa, DBUF_TP_STRUCT_ENTRY_OS_SPA); \ __entry->ds_object = db->db_objset->os_dsl_dataset ? \ db->db_objset->os_dsl_dataset->ds_object : 0; \ \ @@ -77,10 +74,8 @@ __entry->db_size = db->db.db_size; \ __entry->db_state = db->db_state; \ __entry->db_holds = zfs_refcount_count(&db->db_holds); \ - snprintf(__get_str(msg), TRACE_DBUF_MSG_MAX, \ - DBUF_TP_PRINTK_FMT, DBUF_TP_PRINTK_ARGS); \ } else { \ - __assign_str(os_spa, "NULL"); \ + __assign_str_impl(os_spa, DBUF_TP_STRUCT_ENTRY_OS_SPA); \ __entry->ds_object = 0; \ __entry->db_object = 0; \ __entry->db_level = 0; \ @@ -89,8 +84,6 @@ __entry->db_size = 0; \ __entry->db_state = 0; \ __entry->db_holds = 0; \ - snprintf(__get_str(msg), TRACE_DBUF_MSG_MAX, \ - "dbuf { NULL }"); \ } #define DBUF_TP_PRINTK_FMT \ @@ -109,7 +102,7 @@ DECLARE_EVENT_CLASS(zfs_dbuf_class, TP_ARGS(db, zio), TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY), TP_fast_assign(DBUF_TP_FAST_ASSIGN), - TP_printk("%s", __get_str(msg)) + TP_printk(DBUF_TP_PRINTK_FMT, DBUF_TP_PRINTK_ARGS) ); DECLARE_EVENT_CLASS(zfs_dbuf_state_class, @@ -117,7 +110,7 @@ DECLARE_EVENT_CLASS(zfs_dbuf_state_class, TP_ARGS(db, why), TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY), TP_fast_assign(DBUF_TP_FAST_ASSIGN), - TP_printk("%s", __get_str(msg)) + TP_printk(DBUF_TP_PRINTK_FMT, DBUF_TP_PRINTK_ARGS) ); /* END CSTYLED */ @@ -139,7 +132,7 @@ DECLARE_EVENT_CLASS(zfs_dbuf_evict_one_class, TP_ARGS(db, mls), TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY), TP_fast_assign(DBUF_TP_FAST_ASSIGN), - TP_printk("%s", __get_str(msg)) + TP_printk(DBUF_TP_PRINTK_FMT, DBUF_TP_PRINTK_ARGS) ); /* END CSTYLED */ From deddfdd2804c68bc0c9b4c112f855e202aa37d21 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 10:20:12 +1000 Subject: [PATCH 078/223] config: remove checks with unused defines All of these set a #define that doesn't appear anywhere in the tree. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/intlmacosx.m4 | 72 -------------- config/kernel-config-defined.m4 | 15 --- config/kernel-dentry-operations.m4 | 30 ------ config/kernel-inode-setattr.m4 | 22 ----- config/kernel-kstrtoul.m4 | 21 ---- config/kernel-make-request-fn.m4 | 42 ++------ config/kernel-mkdir.m4 | 9 -- config/kernel-rwsem.m4 | 60 ------------ config/kernel-shrink.m4 | 28 ------ config/kernel-vfs-iov_iter.m4 | 150 +---------------------------- config/kernel-vfs-iterate.m4 | 23 ----- config/kernel-xattr-handler.m4 | 28 ------ config/kernel-zlib.m4 | 26 ----- config/kernel.m4 | 6 -- 14 files changed, 13 insertions(+), 519 deletions(-) delete mode 100644 config/intlmacosx.m4 delete mode 100644 config/kernel-kstrtoul.m4 delete mode 100644 config/kernel-rwsem.m4 delete mode 100644 config/kernel-zlib.m4 diff --git a/config/intlmacosx.m4 b/config/intlmacosx.m4 deleted file mode 100644 index 30e6f50e0ac6..000000000000 --- a/config/intlmacosx.m4 +++ /dev/null @@ -1,72 +0,0 @@ -# intlmacosx.m4 serial 6 (gettext-0.20) -dnl Copyright (C) 2004-2014, 2016, 2019 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Checks for special options needed on Mac OS X. -dnl Defines INTL_MACOSX_LIBS. -AC_DEFUN([gt_INTL_MACOSX], -[ - dnl Check for API introduced in Mac OS X 10.4. - AC_CACHE_CHECK([for CFPreferencesCopyAppValue], - [gt_cv_func_CFPreferencesCopyAppValue], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[CFPreferencesCopyAppValue(NULL, NULL)]])], - [gt_cv_func_CFPreferencesCopyAppValue=yes], - [gt_cv_func_CFPreferencesCopyAppValue=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then - AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], - [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) - fi - dnl Check for API introduced in Mac OS X 10.5. - AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[CFLocaleCopyCurrent();]])], - [gt_cv_func_CFLocaleCopyCurrent=yes], - [gt_cv_func_CFLocaleCopyCurrent=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], - [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) - fi - AC_CACHE_CHECK([for CFLocaleCopyPreferredLanguages], [gt_cv_func_CFLocaleCopyPreferredLanguages], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[CFLocaleCopyPreferredLanguages();]])], - [gt_cv_func_CFLocaleCopyPreferredLanguages=yes], - [gt_cv_func_CFLocaleCopyPreferredLanguages=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then - AC_DEFINE([HAVE_CFLOCALECOPYPREFERREDLANGUAGES], [1], - [Define to 1 if you have the Mac OS X function CFLocaleCopyPreferredLanguages in the CoreFoundation framework.]) - fi - INTL_MACOSX_LIBS= - if test $gt_cv_func_CFPreferencesCopyAppValue = yes \ - || test $gt_cv_func_CFLocaleCopyCurrent = yes \ - || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then - INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" - fi - AC_SUBST([INTL_MACOSX_LIBS]) -]) diff --git a/config/kernel-config-defined.m4 b/config/kernel-config-defined.m4 index 54837d728341..83c40fa6cd8e 100644 --- a/config/kernel-config-defined.m4 +++ b/config/kernel-config-defined.m4 @@ -4,21 +4,6 @@ dnl # detected at configure time and cause a build failure. Otherwise dnl # modules may be successfully built that behave incorrectly. dnl # AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [ - AS_IF([test "x$cross_compiling" != xyes], [ - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ - #include "$LINUX/include/linux/license.h" - ], [ - return !license_is_gpl_compatible( - "$ZFS_META_LICENSE"); - ]) - ], [ - AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1], - [Define to 1 if GPL-only symbols can be used]) - ], [ - ]) - ]) - ZFS_AC_KERNEL_SRC_CONFIG_MODULES ZFS_AC_KERNEL_SRC_CONFIG_BLOCK ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC diff --git a/config/kernel-dentry-operations.m4 b/config/kernel-dentry-operations.m4 index 500f61e26aee..957ebc9f0581 100644 --- a/config/kernel-dentry-operations.m4 +++ b/config/kernel-dentry-operations.m4 @@ -119,34 +119,6 @@ AC_DEFUN([ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA], [ ]) ]) -dnl # -dnl # 2.6.30 API change -dnl # The 'struct dentry_operations' was constified in the dentry structure. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_CONST_DENTRY_OPERATIONS], [ - ZFS_LINUX_TEST_SRC([dentry_operations_const], [ - #include - - const struct dentry_operations test_d_op = { - .d_revalidate = NULL, - }; - ],[ - struct dentry d __attribute__ ((unused)); - d.d_op = &test_d_op; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_CONST_DENTRY_OPERATIONS], [ - AC_MSG_CHECKING([whether dentry uses const struct dentry_operations]) - ZFS_LINUX_TEST_RESULT([dentry_operations_const], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_CONST_DENTRY_OPERATIONS, 1, - [dentry uses const struct dentry_operations]) - ],[ - ZFS_LINUX_TEST_ERROR([const dentry_operations]) - ]) -]) - dnl # dnl # 2.6.38 API change dnl # Added sb->s_d_op default dentry_operations member @@ -175,7 +147,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY], [ ZFS_AC_KERNEL_SRC_D_PRUNE_ALIASES ZFS_AC_KERNEL_SRC_D_SET_D_OP ZFS_AC_KERNEL_SRC_D_REVALIDATE_NAMEIDATA - ZFS_AC_KERNEL_SRC_CONST_DENTRY_OPERATIONS ZFS_AC_KERNEL_SRC_S_D_OP ]) @@ -185,6 +156,5 @@ AC_DEFUN([ZFS_AC_KERNEL_DENTRY], [ ZFS_AC_KERNEL_D_PRUNE_ALIASES ZFS_AC_KERNEL_D_SET_D_OP ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA - ZFS_AC_KERNEL_CONST_DENTRY_OPERATIONS ZFS_AC_KERNEL_S_D_OP ]) diff --git a/config/kernel-inode-setattr.m4 b/config/kernel-inode-setattr.m4 index 69289e897be6..9a12acc95a3f 100644 --- a/config/kernel-inode-setattr.m4 +++ b/config/kernel-inode-setattr.m4 @@ -37,19 +37,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_SETATTR], [ .setattr = test_setattr, }; ],[]) - - ZFS_LINUX_TEST_SRC([inode_operations_setattr], [ - #include - - static int test_setattr( - struct dentry *de, struct iattr *ia) - { return 0; } - - static const struct inode_operations - iops __attribute__ ((unused)) = { - .setattr = test_setattr, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_INODE_SETATTR], [ @@ -73,15 +60,6 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_SETATTR], [ [iops->setattr() takes struct user_namespace*]) ],[ AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether iops->setattr() exists]) - ZFS_LINUX_TEST_RESULT([inode_operations_setattr], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_IOPS_SETATTR, 1, - [iops->setattr() exists]) - ],[ - AC_MSG_RESULT(no) - ]) ]) ]) ]) diff --git a/config/kernel-kstrtoul.m4 b/config/kernel-kstrtoul.m4 deleted file mode 100644 index 8e4b542978a9..000000000000 --- a/config/kernel-kstrtoul.m4 +++ /dev/null @@ -1,21 +0,0 @@ -dnl # -dnl # 2.6.39 API change -dnl # Added kstrtoul() -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_KSTRTOUL], [ - ZFS_LINUX_TEST_SRC([kstrtoul], [ - #include - ],[ - int ret __attribute__ ((unused)) = kstrtoul(NULL, 10, NULL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_KSTRTOUL], [ - AC_MSG_CHECKING([whether kstrtoul() exists]) - ZFS_LINUX_TEST_RESULT([kstrtoul], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KSTRTOUL, 1, [kstrtoul() exists]) - ],[ - ZFS_LINUX_TEST_ERROR([kstrtoul()]) - ]) -]) diff --git a/config/kernel-make-request-fn.m4 b/config/kernel-make-request-fn.m4 index 4c54bdd6d4a2..66d6a18cd976 100644 --- a/config/kernel-make-request-fn.m4 +++ b/config/kernel-make-request-fn.m4 @@ -2,14 +2,6 @@ dnl # dnl # Check for make_request_fn interface. dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN], [ - ZFS_LINUX_TEST_SRC([make_request_fn_void], [ - #include - static void make_request(struct request_queue *q, - struct bio *bio) { return; } - ],[ - blk_queue_make_request(NULL, &make_request); - ]) - ZFS_LINUX_TEST_SRC([make_request_fn_blk_qc_t], [ #include static blk_qc_t make_request(struct request_queue *q, @@ -197,36 +189,20 @@ AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [ AC_MSG_RESULT(no) dnl # - dnl # Linux 3.2 API Change - dnl # make_request_fn returns void. + dnl # Linux 4.4 API Change + dnl # make_request_fn returns blk_qc_t. dnl # AC_MSG_CHECKING( - [whether make_request_fn() returns void]) - ZFS_LINUX_TEST_RESULT([make_request_fn_void], [ + [whether make_request_fn() returns blk_qc_t]) + ZFS_LINUX_TEST_RESULT([make_request_fn_blk_qc_t], [ AC_MSG_RESULT(yes) - AC_DEFINE(MAKE_REQUEST_FN_RET, void, + AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t, [make_request_fn() return type]) - AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_VOID, 1, - [Noting that make_request_fn() returns void]) + AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1, + [Noting that make_request_fn() ] + [returns blk_qc_t]) ],[ - AC_MSG_RESULT(no) - - dnl # - dnl # Linux 4.4 API Change - dnl # make_request_fn returns blk_qc_t. - dnl # - AC_MSG_CHECKING( - [whether make_request_fn() returns blk_qc_t]) - ZFS_LINUX_TEST_RESULT([make_request_fn_blk_qc_t], [ - AC_MSG_RESULT(yes) - AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t, - [make_request_fn() return type]) - AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1, - [Noting that make_request_fn() ] - [returns blk_qc_t]) - ],[ - ZFS_LINUX_TEST_ERROR([make_request_fn]) - ]) + ZFS_LINUX_TEST_ERROR([make_request_fn]) ]) ]) ]) diff --git a/config/kernel-mkdir.m4 b/config/kernel-mkdir.m4 index 367f100094d3..bad79f3aacfc 100644 --- a/config/kernel-mkdir.m4 +++ b/config/kernel-mkdir.m4 @@ -80,15 +80,6 @@ AC_DEFUN([ZFS_AC_KERNEL_MKDIR], [ [iops->mkdir() takes struct user_namespace*]) ],[ AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether iops->mkdir() takes umode_t]) - ZFS_LINUX_TEST_RESULT([inode_operations_mkdir], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_MKDIR_UMODE_T, 1, - [iops->mkdir() takes umode_t]) - ],[ - ZFS_LINUX_TEST_ERROR([mkdir()]) - ]) ]) ]) ]) diff --git a/config/kernel-rwsem.m4 b/config/kernel-rwsem.m4 deleted file mode 100644 index d3a64a8efa19..000000000000 --- a/config/kernel-rwsem.m4 +++ /dev/null @@ -1,60 +0,0 @@ -dnl # -dnl # 3.16 API Change -dnl # -dnl # rwsem-spinlock "->activity" changed to "->count" -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_RWSEM_ACTIVITY], [ - ZFS_LINUX_TEST_SRC([rwsem_activity], [ - #include - ],[ - struct rw_semaphore dummy_semaphore __attribute__ ((unused)); - dummy_semaphore.activity = 0; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_RWSEM_ACTIVITY], [ - AC_MSG_CHECKING([whether struct rw_semaphore has member activity]) - ZFS_LINUX_TEST_RESULT([rwsem_activity], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1, - [struct rw_semaphore has member activity]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -dnl # -dnl # 4.8 API Change -dnl # -dnl # rwsem "->count" changed to atomic_long_t type -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_RWSEM_ATOMIC_LONG_COUNT], [ - ZFS_LINUX_TEST_SRC([rwsem_atomic_long_count], [ - #include - ],[ - DECLARE_RWSEM(dummy_semaphore); - (void) atomic_long_read(&dummy_semaphore.count); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_RWSEM_ATOMIC_LONG_COUNT], [ - AC_MSG_CHECKING( - [whether struct rw_semaphore has atomic_long_t member count]) - ZFS_LINUX_TEST_RESULT([rwsem_atomic_long_count], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1, - [struct rw_semaphore has atomic_long_t member count]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SRC_RWSEM], [ - ZFS_AC_KERNEL_SRC_RWSEM_ACTIVITY - ZFS_AC_KERNEL_SRC_RWSEM_ATOMIC_LONG_COUNT -]) - -AC_DEFUN([ZFS_AC_KERNEL_RWSEM], [ - ZFS_AC_KERNEL_RWSEM_ACTIVITY - ZFS_AC_KERNEL_RWSEM_ATOMIC_LONG_COUNT -]) diff --git a/config/kernel-shrink.m4 b/config/kernel-shrink.m4 index 6580b08d5ff2..4879a129af01 100644 --- a/config/kernel-shrink.m4 +++ b/config/kernel-shrink.m4 @@ -216,38 +216,11 @@ AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[ ]) ]) -dnl # -dnl # 2.6.39 API change, -dnl # Shrinker adjust to use common shrink_control structure. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [ - ZFS_LINUX_TEST_SRC([shrink_control_struct], [ - #include - ],[ - struct shrink_control sc __attribute__ ((unused)); - - sc.nr_to_scan = 0; - sc.gfp_mask = GFP_KERNEL; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [ - AC_MSG_CHECKING([whether struct shrink_control exists]) - ZFS_LINUX_TEST_RESULT([shrink_control_struct], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1, - [struct shrink_control exists]) - ],[ - ZFS_LINUX_TEST_ERROR([shrink_control]) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [ ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK - ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER ]) @@ -256,5 +229,4 @@ AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [ ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID ZFS_AC_KERNEL_SHRINKER_CALLBACK - ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT ]) diff --git a/config/kernel-vfs-iov_iter.m4 b/config/kernel-vfs-iov_iter.m4 index e7ced0297014..ed7961a9e9dd 100644 --- a/config/kernel-vfs-iov_iter.m4 +++ b/config/kernel-vfs-iov_iter.m4 @@ -2,44 +2,6 @@ dnl # dnl # Check for available iov_iter functionality. dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [ - ZFS_LINUX_TEST_SRC([iov_iter_types], [ - #include - #include - ],[ - int type __attribute__ ((unused)) = ITER_KVEC; - ]) - - ZFS_LINUX_TEST_SRC([iov_iter_advance], [ - #include - #include - ],[ - struct iov_iter iter = { 0 }; - size_t advance = 512; - - iov_iter_advance(&iter, advance); - ]) - - ZFS_LINUX_TEST_SRC([iov_iter_revert], [ - #include - #include - ],[ - struct iov_iter iter = { 0 }; - size_t revert = 512; - - iov_iter_revert(&iter, revert); - ]) - - ZFS_LINUX_TEST_SRC([iov_iter_fault_in_readable], [ - #include - #include - ],[ - struct iov_iter iter = { 0 }; - size_t size = 512; - int error __attribute__ ((unused)); - - error = iov_iter_fault_in_readable(&iter, size); - ]) - ZFS_LINUX_TEST_SRC([fault_in_iov_iter_readable], [ #include #include @@ -51,40 +13,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [ error = fault_in_iov_iter_readable(&iter, size); ]) - ZFS_LINUX_TEST_SRC([iov_iter_count], [ - #include - #include - ],[ - struct iov_iter iter = { 0 }; - size_t bytes __attribute__ ((unused)); - - bytes = iov_iter_count(&iter); - ]) - - ZFS_LINUX_TEST_SRC([copy_to_iter], [ - #include - #include - ],[ - struct iov_iter iter = { 0 }; - char buf[512] = { 0 }; - size_t size = 512; - size_t bytes __attribute__ ((unused)); - - bytes = copy_to_iter((const void *)&buf, size, &iter); - ]) - - ZFS_LINUX_TEST_SRC([copy_from_iter], [ - #include - #include - ],[ - struct iov_iter iter = { 0 }; - char buf[512] = { 0 }; - size_t size = 512; - size_t bytes __attribute__ ((unused)); - - bytes = copy_from_iter((void *)&buf, size, &iter); - ]) - ZFS_LINUX_TEST_SRC([iov_iter_get_pages2], [ #include ], [ @@ -133,83 +61,13 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [ AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [ enable_vfs_iov_iter="yes" - AC_MSG_CHECKING([whether iov_iter types are available]) - ZFS_LINUX_TEST_RESULT([iov_iter_types], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_IOV_ITER_TYPES, 1, - [iov_iter types are available]) - ],[ - AC_MSG_RESULT(no) - enable_vfs_iov_iter="no" - ]) - - AC_MSG_CHECKING([whether iov_iter_advance() is available]) - ZFS_LINUX_TEST_RESULT([iov_iter_advance], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_IOV_ITER_ADVANCE, 1, - [iov_iter_advance() is available]) - ],[ - AC_MSG_RESULT(no) - enable_vfs_iov_iter="no" - ]) - - AC_MSG_CHECKING([whether iov_iter_revert() is available]) - ZFS_LINUX_TEST_RESULT([iov_iter_revert], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_IOV_ITER_REVERT, 1, - [iov_iter_revert() is available]) - ],[ - AC_MSG_RESULT(no) - enable_vfs_iov_iter="no" - ]) - - AC_MSG_CHECKING([whether iov_iter_fault_in_readable() is available]) - ZFS_LINUX_TEST_RESULT([iov_iter_fault_in_readable], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_IOV_ITER_FAULT_IN_READABLE, 1, - [iov_iter_fault_in_readable() is available]) - ],[ - AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether fault_in_iov_iter_readable() is available]) - ZFS_LINUX_TEST_RESULT([fault_in_iov_iter_readable], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FAULT_IN_IOV_ITER_READABLE, 1, - [fault_in_iov_iter_readable() is available]) - ],[ - AC_MSG_RESULT(no) - enable_vfs_iov_iter="no" - ]) - ]) - - AC_MSG_CHECKING([whether iov_iter_count() is available]) - ZFS_LINUX_TEST_RESULT([iov_iter_count], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_IOV_ITER_COUNT, 1, - [iov_iter_count() is available]) - ],[ - AC_MSG_RESULT(no) - enable_vfs_iov_iter="no" - ]) - - AC_MSG_CHECKING([whether copy_to_iter() is available]) - ZFS_LINUX_TEST_RESULT([copy_to_iter], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_COPY_TO_ITER, 1, - [copy_to_iter() is available]) - ],[ - AC_MSG_RESULT(no) - enable_vfs_iov_iter="no" - ]) - - AC_MSG_CHECKING([whether copy_from_iter() is available]) - ZFS_LINUX_TEST_RESULT([copy_from_iter], [ + AC_MSG_CHECKING([whether fault_in_iov_iter_readable() is available]) + ZFS_LINUX_TEST_RESULT([fault_in_iov_iter_readable], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_COPY_FROM_ITER, 1, - [copy_from_iter() is available]) + AC_DEFINE(HAVE_FAULT_IN_IOV_ITER_READABLE, 1, + [fault_in_iov_iter_readable() is available]) ],[ AC_MSG_RESULT(no) - enable_vfs_iov_iter="no" ]) dnl # diff --git a/config/kernel-vfs-iterate.m4 b/config/kernel-vfs-iterate.m4 index 2e396daa1c0f..7e2a9f0cb3a4 100644 --- a/config/kernel-vfs-iterate.m4 +++ b/config/kernel-vfs-iterate.m4 @@ -24,17 +24,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_ITERATE], [ #error "RHEL 7.5, FMODE_KABI_ITERATE interface" #endif ],[]) - - ZFS_LINUX_TEST_SRC([file_operations_readdir], [ - #include - static int readdir(struct file *filp, void *entry, - filldir_t func) { return 0; } - - static const struct file_operations fops - __attribute__ ((unused)) = { - .readdir = readdir, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_VFS_ITERATE], [ @@ -66,18 +55,6 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_ITERATE], [ [fops->iterate() is available]) ],[ AC_MSG_RESULT(no) - - dnl # - dnl # readdir interface introduced - dnl # - AC_MSG_CHECKING([whether fops->readdir() is available]) - ZFS_LINUX_TEST_RESULT([file_operations_readdir], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_VFS_READDIR, 1, - [fops->readdir() is available]) - ],[ - ZFS_LINUX_TEST_ERROR([vfs_iterate]) - ]) ]) ]) ]) diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4 index 32f58c70a500..5d4eb567c48c 100644 --- a/config/kernel-xattr-handler.m4 +++ b/config/kernel-xattr-handler.m4 @@ -402,32 +402,6 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_LIST], [ ]) ]) -dnl # -dnl # 3.7 API change, -dnl # The posix_acl_{from,to}_xattr functions gained a new -dnl # parameter: user_ns -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_POSIX_ACL_FROM_XATTR_USERNS], [ - ZFS_LINUX_TEST_SRC([posix_acl_from_xattr_userns], [ - #include - #include - #include - ],[ - posix_acl_from_xattr(&init_user_ns, NULL, 0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_FROM_XATTR_USERNS], [ - AC_MSG_CHECKING([whether posix_acl_from_xattr() needs user_ns]) - ZFS_LINUX_TEST_RESULT([posix_acl_from_xattr_userns], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_POSIX_ACL_FROM_XATTR_USERNS, 1, - [posix_acl_from_xattr() needs user_ns]) - ],[ - ZFS_LINUX_TEST_ERROR([posix_acl_from_xattr()]) - ]) -]) - dnl # dnl # 4.9 API change, dnl # iops->{set,get,remove}xattr and generic_{set,get,remove}xattr are @@ -462,7 +436,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR], [ ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET ZFS_AC_KERNEL_SRC_XATTR_HANDLER_LIST - ZFS_AC_KERNEL_SRC_POSIX_ACL_FROM_XATTR_USERNS ZFS_AC_KERNEL_SRC_GENERIC_SETXATTR ]) @@ -472,6 +445,5 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR], [ ZFS_AC_KERNEL_XATTR_HANDLER_GET ZFS_AC_KERNEL_XATTR_HANDLER_SET ZFS_AC_KERNEL_XATTR_HANDLER_LIST - ZFS_AC_KERNEL_POSIX_ACL_FROM_XATTR_USERNS ZFS_AC_KERNEL_GENERIC_SETXATTR ]) diff --git a/config/kernel-zlib.m4 b/config/kernel-zlib.m4 deleted file mode 100644 index 752d388389cb..000000000000 --- a/config/kernel-zlib.m4 +++ /dev/null @@ -1,26 +0,0 @@ -dnl # -dnl # 2.6.39 API compat, -dnl -dnl # The function zlib_deflate_workspacesize() now take 2 arguments. -dnl # This was done to avoid always having to allocate the maximum size -dnl # workspace (268K). The caller can now specific the windowBits and -dnl # memLevel compression parameters to get a smaller workspace. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE], [ - ZFS_LINUX_TEST_SRC([2args_zlib_deflate_workspacesize], [ - #include - ],[ - return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE], [ - AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args]) - ZFS_LINUX_TEST_RESULT([2args_zlib_deflate_workspacesize], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1, - [zlib_deflate_workspacesize() wants 2 args]) - ],[ - ZFS_LINUX_TEST_ERROR([zlib_deflate_workspacesize()]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 17d8694ceff1..3164d631d0f5 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -45,8 +45,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_FALLOCATE ZFS_AC_KERNEL_SRC_FADVISE ZFS_AC_KERNEL_SRC_GENERIC_FADVISE - ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE - ZFS_AC_KERNEL_SRC_RWSEM ZFS_AC_KERNEL_SRC_SCHED ZFS_AC_KERNEL_SRC_USLEEP_RANGE ZFS_AC_KERNEL_SRC_KMEM_CACHE @@ -139,7 +137,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_KTIME ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES - ZFS_AC_KERNEL_SRC_KSTRTOUL ZFS_AC_KERNEL_SRC_PERCPU ZFS_AC_KERNEL_SRC_CPU_HOTPLUG ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR @@ -199,8 +196,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_FALLOCATE ZFS_AC_KERNEL_FADVISE ZFS_AC_KERNEL_GENERIC_FADVISE - ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE - ZFS_AC_KERNEL_RWSEM ZFS_AC_KERNEL_SCHED ZFS_AC_KERNEL_USLEEP_RANGE ZFS_AC_KERNEL_KMEM_CACHE @@ -293,7 +288,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_KTIME ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_TOTALHIGH_PAGES - ZFS_AC_KERNEL_KSTRTOUL ZFS_AC_KERNEL_PERCPU ZFS_AC_KERNEL_CPU_HOTPLUG ZFS_AC_KERNEL_GENERIC_FILLATTR From 05d6f621a987d249038d48c91de82344b0c21ee3 Mon Sep 17 00:00:00 2001 From: Daniel Perry Date: Thu, 9 May 2024 10:30:28 -0400 Subject: [PATCH 079/223] Replace usage of schedule_timeout with schedule_timeout_interruptible (#16150) This commit replaces current usages of schedule_timeout() with schedule_timeout_interruptible() in code paths that expect the running task to sleep for a short period of time. When schedule_timeout() is called without previously calling set_current_state(), the running task never sleeps because the task state remains in TASK_RUNNING. By calling schedule_timeout_interruptible() to set the task state to TASK_INTERRUPTIBLE before calling schedule_timeout() we achieve the intended/desired behavior of putting the task to sleep for the specified timeout. Reviewed-by: Brian Behlendorf Signed-off-by: Daniel Perry Closes #16150 --- module/os/linux/spl/spl-taskq.c | 2 +- module/os/linux/zfs/vdev_disk.c | 2 +- module/os/linux/zfs/zvol_os.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/module/os/linux/spl/spl-taskq.c b/module/os/linux/spl/spl-taskq.c index 0e44aa1fcd38..ba6a1e10ec31 100644 --- a/module/os/linux/spl/spl-taskq.c +++ b/module/os/linux/spl/spl-taskq.c @@ -158,7 +158,7 @@ task_alloc(taskq_t *tq, uint_t flags, unsigned long *irqflags) * throttling the task dispatch rate. */ spin_unlock_irqrestore(&tq->tq_lock, *irqflags); - schedule_timeout(HZ / 100); + schedule_timeout_interruptible(HZ / 100); spin_lock_irqsave_nested(&tq->tq_lock, *irqflags, tq->tq_lock_class); if (count < 100) { diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index ec3538215cb4..ace6327f8204 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -401,7 +401,7 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize, if (v->vdev_removed) break; - schedule_timeout(MSEC_TO_TICK(10)); + schedule_timeout_interruptible(MSEC_TO_TICK(10)); } else if (unlikely(BDH_PTR_ERR(bdh) == -ERESTARTSYS)) { timeout = MSEC2NSEC(zfs_vdev_open_timeout_ms * 10); continue; diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 928a222f1505..493f7f4bdc1c 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -800,7 +800,8 @@ zvol_open(struct block_device *bdev, fmode_t flag) if ((gethrtime() - start) > timeout) return (-SET_ERROR(ERESTARTSYS)); - schedule_timeout(MSEC_TO_TICK(10)); + schedule_timeout_interruptible( + MSEC_TO_TICK(10)); goto retry; #endif } else { From ca95fa3531d8aab7d7c08cb3850cb050494221eb Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 30 Jul 2024 14:40:47 -0400 Subject: [PATCH 080/223] Linux: Report reclaimable memory to kernel as such (#16385) Linux provides SLAB_RECLAIM_ACCOUNT and __GFP_RECLAIMABLE flags to mark memory allocations that can be freed via shinker calls. It should allow kernel to tune and group such allocations for lower memory fragmentation and better reclamation under pressure. This patch marks as reclaimable most of ARC memory, directly evictable via ZFS shrinker, plus also dnode/znode/sa memory, indirectly evictable via kernel's superblock shrinker. Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Reviewed-by: Tony Hutter Reviewed-by: Allan Jude --- include/os/freebsd/spl/sys/kmem.h | 1 + include/os/linux/spl/sys/kmem_cache.h | 5 ++--- include/sys/zfs_context.h | 1 + module/os/freebsd/zfs/abd_os.c | 2 +- module/os/freebsd/zfs/zfs_znode.c | 2 +- module/os/linux/spl/spl-kmem-cache.c | 8 ++++++++ module/os/linux/spl/spl-zlib.c | 2 +- module/os/linux/zfs/abd_os.c | 6 +++--- module/os/linux/zfs/zfs_znode.c | 3 ++- module/zfs/arc.c | 2 +- module/zfs/dnode.c | 2 +- module/zfs/lz4_zfs.c | 3 ++- module/zfs/sa.c | 2 +- module/zfs/zio.c | 4 ++++ 14 files changed, 29 insertions(+), 14 deletions(-) diff --git a/include/os/freebsd/spl/sys/kmem.h b/include/os/freebsd/spl/sys/kmem.h index c633799318d5..ae786f0e20ca 100644 --- a/include/os/freebsd/spl/sys/kmem.h +++ b/include/os/freebsd/spl/sys/kmem.h @@ -49,6 +49,7 @@ MALLOC_DECLARE(M_SOLARIS); #define KM_NOSLEEP M_NOWAIT #define KM_NORMALPRI 0 #define KMC_NODEBUG UMA_ZONE_NODUMP +#define KMC_RECLAIMABLE 0x0 typedef struct vmem vmem_t; diff --git a/include/os/linux/spl/sys/kmem_cache.h b/include/os/linux/spl/sys/kmem_cache.h index 905ff57a1434..2b4f120e6427 100644 --- a/include/os/linux/spl/sys/kmem_cache.h +++ b/include/os/linux/spl/sys/kmem_cache.h @@ -45,6 +45,7 @@ typedef enum kmc_bit { KMC_BIT_TOTAL = 18, /* Proc handler helper bit */ KMC_BIT_ALLOC = 19, /* Proc handler helper bit */ KMC_BIT_MAX = 20, /* Proc handler helper bit */ + KMC_BIT_RECLAIMABLE = 21, /* Can be freed by shrinker */ } kmc_bit_t; /* kmem move callback return values */ @@ -66,9 +67,7 @@ typedef enum kmem_cbrc { #define KMC_TOTAL (1 << KMC_BIT_TOTAL) #define KMC_ALLOC (1 << KMC_BIT_ALLOC) #define KMC_MAX (1 << KMC_BIT_MAX) - -#define KMC_REAP_CHUNK INT_MAX -#define KMC_DEFAULT_SEEKS 1 +#define KMC_RECLAIMABLE (1 << KMC_BIT_RECLAIMABLE) extern struct list_head spl_kmem_cache_list; extern struct rw_semaphore spl_kmem_cache_sem; diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 750ca612b962..0b35b73e4df2 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -414,6 +414,7 @@ void procfs_list_add(procfs_list_t *procfs_list, void *p); #define KM_NORMALPRI 0 /* not needed with UMEM_DEFAULT */ #define KMC_NODEBUG UMC_NODEBUG #define KMC_KVMEM 0x0 +#define KMC_RECLAIMABLE 0x0 #define kmem_alloc(_s, _f) umem_alloc(_s, _f) #define kmem_zalloc(_s, _f) umem_zalloc(_s, _f) #define kmem_free(_b, _s) umem_free(_b, _s) diff --git a/module/os/freebsd/zfs/abd_os.c b/module/os/freebsd/zfs/abd_os.c index 3b812271f98b..fb5c46ecf7c2 100644 --- a/module/os/freebsd/zfs/abd_os.c +++ b/module/os/freebsd/zfs/abd_os.c @@ -300,7 +300,7 @@ void abd_init(void) { abd_chunk_cache = kmem_cache_create("abd_chunk", PAGE_SIZE, 0, - NULL, NULL, NULL, NULL, 0, KMC_NODEBUG); + NULL, NULL, NULL, NULL, 0, KMC_NODEBUG | KMC_RECLAIMABLE); wmsum_init(&abd_sums.abdstat_struct_size, 0); wmsum_init(&abd_sums.abdstat_scatter_cnt, 0); diff --git a/module/os/freebsd/zfs/zfs_znode.c b/module/os/freebsd/zfs/zfs_znode.c index 0eea2a849416..afbea9798c33 100644 --- a/module/os/freebsd/zfs/zfs_znode.c +++ b/module/os/freebsd/zfs/zfs_znode.c @@ -236,7 +236,7 @@ zfs_znode_init(void) ASSERT3P(znode_cache, ==, NULL); znode_cache = kmem_cache_create("zfs_znode_cache", sizeof (znode_t), 0, zfs_znode_cache_constructor, - zfs_znode_cache_destructor, NULL, NULL, NULL, 0); + zfs_znode_cache_destructor, NULL, NULL, NULL, KMC_RECLAIMABLE); } static znode_t * diff --git a/module/os/linux/spl/spl-kmem-cache.c b/module/os/linux/spl/spl-kmem-cache.c index 737c2e063f71..16412bc9e6cf 100644 --- a/module/os/linux/spl/spl-kmem-cache.c +++ b/module/os/linux/spl/spl-kmem-cache.c @@ -144,6 +144,8 @@ kv_alloc(spl_kmem_cache_t *skc, int size, int flags) gfp_t lflags = kmem_flags_convert(flags); void *ptr; + if (skc->skc_flags & KMC_RECLAIMABLE) + lflags |= __GFP_RECLAIMABLE; ptr = spl_vmalloc(size, lflags | __GFP_HIGHMEM); /* Resulting allocated memory will be page aligned */ @@ -424,6 +426,8 @@ spl_emergency_alloc(spl_kmem_cache_t *skc, int flags, void **obj) if (!empty) return (-EEXIST); + if (skc->skc_flags & KMC_RECLAIMABLE) + lflags |= __GFP_RECLAIMABLE; ske = kmalloc(sizeof (*ske), lflags); if (ske == NULL) return (-ENOMEM); @@ -663,6 +667,7 @@ spl_magazine_destroy(spl_kmem_cache_t *skc) * KMC_KVMEM Force kvmem backed SPL cache * KMC_SLAB Force Linux slab backed cache * KMC_NODEBUG Disable debugging (unsupported) + * KMC_RECLAIMABLE Memory can be freed under pressure */ spl_kmem_cache_t * spl_kmem_cache_create(const char *name, size_t size, size_t align, @@ -780,6 +785,9 @@ spl_kmem_cache_create(const char *name, size_t size, size_t align, if (size > spl_kmem_cache_slab_limit) goto out; + if (skc->skc_flags & KMC_RECLAIMABLE) + slabflags |= SLAB_RECLAIM_ACCOUNT; + #if defined(SLAB_USERCOPY) /* * Required for PAX-enabled kernels if the slab is to be diff --git a/module/os/linux/spl/spl-zlib.c b/module/os/linux/spl/spl-zlib.c index 8c6282ee5d16..a7b6c14ee150 100644 --- a/module/os/linux/spl/spl-zlib.c +++ b/module/os/linux/spl/spl-zlib.c @@ -202,7 +202,7 @@ spl_zlib_init(void) zlib_workspace_cache = kmem_cache_create( "spl_zlib_workspace_cache", size, 0, NULL, NULL, NULL, NULL, NULL, - KMC_KVMEM); + KMC_KVMEM | KMC_RECLAIMABLE); if (!zlib_workspace_cache) return (-ENOMEM); diff --git a/module/os/linux/zfs/abd_os.c b/module/os/linux/zfs/abd_os.c index cee7410c8833..a388acfad7d6 100644 --- a/module/os/linux/zfs/abd_os.c +++ b/module/os/linux/zfs/abd_os.c @@ -281,7 +281,7 @@ abd_alloc_chunks(abd_t *abd, size_t size) struct sg_table table; struct scatterlist *sg; struct page *page, *tmp_page = NULL; - gfp_t gfp = __GFP_NOWARN | GFP_NOIO; + gfp_t gfp = __GFP_RECLAIMABLE | __GFP_NOWARN | GFP_NOIO; gfp_t gfp_comp = (gfp | __GFP_NORETRY | __GFP_COMP) & ~__GFP_RECLAIM; unsigned int max_order = MIN(zfs_abd_scatter_max_order, ABD_MAX_ORDER - 1); @@ -403,7 +403,7 @@ abd_alloc_chunks(abd_t *abd, size_t size) struct scatterlist *sg = NULL; struct sg_table table; struct page *page; - gfp_t gfp = __GFP_NOWARN | GFP_NOIO; + gfp_t gfp = __GFP_RECLAIMABLE | __GFP_NOWARN | GFP_NOIO; int nr_pages = abd_chunkcnt_for_bytes(size); int i = 0; @@ -762,7 +762,7 @@ abd_init(void) int i; abd_cache = kmem_cache_create("abd_t", sizeof (abd_t), - 0, NULL, NULL, NULL, NULL, NULL, 0); + 0, NULL, NULL, NULL, NULL, NULL, KMC_RECLAIMABLE); wmsum_init(&abd_sums.abdstat_struct_size, 0); wmsum_init(&abd_sums.abdstat_linear_cnt, 0); diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index b99df188c64b..265153e011e7 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -194,7 +194,8 @@ zfs_znode_init(void) ASSERT(znode_cache == NULL); znode_cache = kmem_cache_create("zfs_znode_cache", sizeof (znode_t), 0, zfs_znode_cache_constructor, - zfs_znode_cache_destructor, NULL, NULL, NULL, KMC_SLAB); + zfs_znode_cache_destructor, NULL, NULL, NULL, + KMC_SLAB | KMC_RECLAIMABLE); ASSERT(znode_hold_cache == NULL); znode_hold_cache = kmem_cache_create("zfs_znode_hold_cache", diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 370500ef096b..00f551710173 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -1258,7 +1258,7 @@ buf_init(void) } hdr_full_cache = kmem_cache_create("arc_buf_hdr_t_full", HDR_FULL_SIZE, - 0, hdr_full_cons, hdr_full_dest, NULL, NULL, NULL, 0); + 0, hdr_full_cons, hdr_full_dest, NULL, NULL, NULL, KMC_RECLAIMABLE); hdr_l2only_cache = kmem_cache_create("arc_buf_hdr_t_l2only", HDR_L2ONLY_SIZE, 0, hdr_l2only_cons, hdr_l2only_dest, NULL, NULL, NULL, 0); diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c index efb94bbe23ba..227a2c98705a 100644 --- a/module/zfs/dnode.c +++ b/module/zfs/dnode.c @@ -298,7 +298,7 @@ dnode_init(void) { ASSERT(dnode_cache == NULL); dnode_cache = kmem_cache_create("dnode_t", sizeof (dnode_t), - 0, dnode_cons, dnode_dest, NULL, NULL, NULL, 0); + 0, dnode_cons, dnode_dest, NULL, NULL, NULL, KMC_RECLAIMABLE); kmem_cache_set_move(dnode_cache, dnode_move); wmsum_init(&dnode_sums.dnode_hold_dbuf_hold, 0); diff --git a/module/zfs/lz4_zfs.c b/module/zfs/lz4_zfs.c index e28215cf3501..a3b9e7070373 100644 --- a/module/zfs/lz4_zfs.c +++ b/module/zfs/lz4_zfs.c @@ -867,7 +867,8 @@ void lz4_init(void) { lz4_cache = kmem_cache_create("lz4_cache", - sizeof (struct refTables), 0, NULL, NULL, NULL, NULL, NULL, 0); + sizeof (struct refTables), 0, NULL, NULL, NULL, NULL, NULL, + KMC_RECLAIMABLE); } void diff --git a/module/zfs/sa.c b/module/zfs/sa.c index bb4cf246ea07..3f0ba6c4cf98 100644 --- a/module/zfs/sa.c +++ b/module/zfs/sa.c @@ -235,7 +235,7 @@ sa_cache_init(void) { sa_cache = kmem_cache_create("sa_cache", sizeof (sa_handle_t), 0, sa_cache_constructor, - sa_cache_destructor, NULL, NULL, NULL, 0); + sa_cache_destructor, NULL, NULL, NULL, KMC_RECLAIMABLE); } void diff --git a/module/zfs/zio.c b/module/zfs/zio.c index 046e6d64c1a9..ce008c0bdb5c 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -172,6 +172,10 @@ zio_init(void) data_cflags = KMC_NODEBUG; cflags = (zio_exclude_metadata || size > zio_buf_debug_limit) ? KMC_NODEBUG : 0; + if (abd_size_alloc_linear(size)) { + cflags |= KMC_RECLAIMABLE; + data_cflags |= KMC_RECLAIMABLE; + } while (!ISP2(p2)) p2 &= p2 - 1; From e5e4957a54d8a1e0d3585dc90e366b3fe10023c1 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 24 May 2024 18:45:09 -0700 Subject: [PATCH 081/223] Allow block cloning to be interrupted by a signal. Even though block cloning is much faster than regular copying, it is not instantaneous - the file might be large and the recordsize small. It would be nice to be able to interrupt it with a signal (e.g., SIGINFO on FreeBSD to see the progress). Reviewed-by: Brian Behlendorf Signed-off-by: Pawel Jakub Dawidek Closes #16208 --- module/zfs/zfs_vnops.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 7020f88ecf93..c3a440c95be6 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -1418,6 +1418,11 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp, outoff += size; len -= size; done += size; + + if (issig(JUSTLOOKING) && issig(FORREAL)) { + error = SET_ERROR(EINTR); + break; + } } vmem_free(bps, sizeof (bps[0]) * maxblocks); From a6198f34bd33fd6f2464f07a90d22b0386f9f53d Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Wed, 29 May 2024 10:49:11 -0700 Subject: [PATCH 082/223] Simplify issig(). We always call it twice with JUSTLOOKING and then FORREAL. Reviewed-by: Brian Behlendorf Signed-off-by: Pawel Jakub Dawidek Closes #16225 --- include/os/freebsd/spl/sys/sig.h | 8 +------- include/os/linux/spl/sys/signal.h | 5 +---- include/sys/zfs_context.h | 3 +-- module/os/linux/spl/spl-thread.c | 16 +++------------- module/zfs/dmu_diff.c | 2 +- module/zfs/dmu_objset.c | 2 +- module/zfs/dmu_recv.c | 2 +- module/zfs/dmu_redact.c | 2 +- module/zfs/dmu_send.c | 2 +- module/zfs/zcp.c | 3 +-- module/zfs/zfs_ioctl.c | 2 +- module/zfs/zfs_vnops.c | 2 +- 12 files changed, 14 insertions(+), 35 deletions(-) diff --git a/include/os/freebsd/spl/sys/sig.h b/include/os/freebsd/spl/sys/sig.h index a4d440d38326..17fc65cbe3e2 100644 --- a/include/os/freebsd/spl/sys/sig.h +++ b/include/os/freebsd/spl/sys/sig.h @@ -39,20 +39,14 @@ #include #include -#define FORREAL 0 -#define JUSTLOOKING 1 - static __inline int -issig(int why) +issig(void) { struct thread *td = curthread; struct proc *p; int sig; - ASSERT(why == FORREAL || why == JUSTLOOKING); if (SIGPENDING(td)) { - if (why == JUSTLOOKING) - return (1); p = td->td_proc; PROC_LOCK(p); mtx_lock(&p->p_sigacts->ps_mtx); diff --git a/include/os/linux/spl/sys/signal.h b/include/os/linux/spl/sys/signal.h index 6b538c8966f2..cb4b33261647 100644 --- a/include/os/linux/spl/sys/signal.h +++ b/include/os/linux/spl/sys/signal.h @@ -30,9 +30,6 @@ #include #endif -#define FORREAL 0 /* Usual side-effects */ -#define JUSTLOOKING 1 /* Don't stop the process */ - -extern int issig(int why); +extern int issig(void); #endif /* SPL_SIGNAL_H */ diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 0b35b73e4df2..bd123435cdb1 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -249,8 +249,7 @@ extern struct proc p0; extern kthread_t *zk_thread_create(void (*func)(void *), void *arg, size_t stksize, int state); -#define issig(why) (FALSE) -#define ISSIG(thr, why) (FALSE) +#define issig() (FALSE) #define KPREEMPT_SYNC (-1) diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c index ee3eb4690c3a..dbb8eefa7ec4 100644 --- a/module/os/linux/spl/spl-thread.c +++ b/module/os/linux/spl/spl-thread.c @@ -152,26 +152,16 @@ spl_kthread_create(int (*func)(void *), void *data, const char namefmt[], ...) EXPORT_SYMBOL(spl_kthread_create); /* - * The "why" argument indicates the allowable side-effects of the call: - * - * FORREAL: Extract the next pending signal from p_sig into p_cursig; - * stop the process if a stop has been requested or if a traced signal - * is pending. - * - * JUSTLOOKING: Don't stop the process, just indicate whether or not - * a signal might be pending (FORREAL is needed to tell for sure). + * Extract the next pending signal from p_sig into p_cursig; stop the process + * if a stop has been requested or if a traced signal is pending. */ int -issig(int why) +issig(void) { - ASSERT(why == FORREAL || why == JUSTLOOKING); if (!signal_pending(current)) return (0); - if (why != FORREAL) - return (1); - struct task_struct *task = current; spl_kernel_siginfo_t __info; sigset_t set; diff --git a/module/zfs/dmu_diff.c b/module/zfs/dmu_diff.c index a2b1a27c88e9..0def0956beb8 100644 --- a/module/zfs/dmu_diff.c +++ b/module/zfs/dmu_diff.c @@ -116,7 +116,7 @@ diff_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, dmu_diffarg_t *da = arg; int err = 0; - if (issig(JUSTLOOKING) && issig(FORREAL)) + if (issig()) return (SET_ERROR(EINTR)); if (zb->zb_level == ZB_DNODE_LEVEL || diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index c9729fd8853f..5ea2fca9db1e 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -2365,7 +2365,7 @@ dmu_objset_space_upgrade(objset_t *os) if (err != 0) return (err); - if (issig(JUSTLOOKING) && issig(FORREAL)) + if (issig()) return (SET_ERROR(EINTR)); objerr = dmu_bonus_hold(os, obj, FTAG, &db); diff --git a/module/zfs/dmu_recv.c b/module/zfs/dmu_recv.c index 9f1c25f866f7..883ee192f07f 100644 --- a/module/zfs/dmu_recv.c +++ b/module/zfs/dmu_recv.c @@ -3386,7 +3386,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, offset_t *voffp) * stream, then we free drc->drc_rrd and exit. */ while (rwa->err == 0) { - if (issig(JUSTLOOKING) && issig(FORREAL)) { + if (issig()) { err = SET_ERROR(EINTR); break; } diff --git a/module/zfs/dmu_redact.c b/module/zfs/dmu_redact.c index 6bd35713ff18..9bfa3ec84508 100644 --- a/module/zfs/dmu_redact.c +++ b/module/zfs/dmu_redact.c @@ -912,7 +912,7 @@ perform_redaction(objset_t *os, redaction_list_t *rl, object = prev_obj; } while (err == 0 && object <= rec->end_object) { - if (issig(JUSTLOOKING) && issig(FORREAL)) { + if (issig()) { err = EINTR; break; } diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index 37c68528bf95..30d2ca5d6aa2 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -2552,7 +2552,7 @@ dmu_send_impl(struct dmu_send_params *dspp) while (err == 0 && !range->eos_marker) { err = do_dump(&dsc, range); range = get_next_range(&srt_arg->q, range); - if (issig(JUSTLOOKING) && issig(FORREAL)) + if (issig()) err = SET_ERROR(EINTR); } diff --git a/module/zfs/zcp.c b/module/zfs/zcp.c index 959404f665ab..7c279162a9d1 100644 --- a/module/zfs/zcp.c +++ b/module/zfs/zcp.c @@ -780,8 +780,7 @@ zcp_lua_counthook(lua_State *state, lua_Debug *ar) * Check if we were canceled while waiting for the * txg to sync or from our open context thread */ - if (ri->zri_canceled || - (!ri->zri_sync && issig(JUSTLOOKING) && issig(FORREAL))) { + if (ri->zri_canceled || (!ri->zri_sync && issig())) { ri->zri_canceled = B_TRUE; (void) lua_pushstring(state, "Channel program was canceled."); (void) lua_error(state); diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index b07837113293..8f28687bb36b 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -2336,7 +2336,7 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc) } while (error == 0) { - if (issig(JUSTLOOKING) && issig(FORREAL)) { + if (issig()) { error = SET_ERROR(EINTR); break; } diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index c3a440c95be6..a588fdd0cfbb 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -1419,7 +1419,7 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp, len -= size; done += size; - if (issig(JUSTLOOKING) && issig(FORREAL)) { + if (issig()) { error = SET_ERROR(EINTR); break; } From f6fce8e12a1b3323432a53c8d6413f6b1c669093 Mon Sep 17 00:00:00 2001 From: Jitendra Patidar Date: Tue, 27 Aug 2024 06:06:49 +0530 Subject: [PATCH 083/223] Fix issig() to check signal_pending after dequeue SIGSTOP/SIGTSTP When process got SIGSTOP/SIGTSTP, issig() dequeue them and return 0. But process could still have another signal pending after dequeue. So, after dequeue, check and return 1, if signal_pending. Reviewed-by: Brian Behlendorf Signed-off-by: Jitendra Patidar Closes #16464 --- module/os/linux/spl/spl-thread.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c index dbb8eefa7ec4..2af766ac2049 100644 --- a/module/os/linux/spl/spl-thread.c +++ b/module/os/linux/spl/spl-thread.c @@ -186,6 +186,13 @@ issig(void) schedule(); #endif + /* + * Dequeued SIGSTOP/SIGTSTP. + * Check if process has other singal pending. + */ + if (signal_pending(current)) + return (1); + return (0); } From f3a9746f2155105ba00b9b27fa8909cc37f4af05 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 18 Jul 2024 12:37:43 +1000 Subject: [PATCH 084/223] zvol_impl: document and tidy flags ZVOL_DUMPIFIED is a vestigial Solaris leftover, and not used anywhere. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris Closes #16364 --- include/sys/zvol_impl.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/include/sys/zvol_impl.h b/include/sys/zvol_impl.h index 3243917bcd3f..60b368919929 100644 --- a/include/sys/zvol_impl.h +++ b/include/sys/zvol_impl.h @@ -24,16 +24,9 @@ #include -#define ZVOL_RDONLY 0x1 -/* - * Whether the zvol has been written to (as opposed to ZVOL_RDONLY, which - * specifies whether or not the zvol _can_ be written to) - */ -#define ZVOL_WRITTEN_TO 0x2 - -#define ZVOL_DUMPIFIED 0x4 - -#define ZVOL_EXCL 0x8 +#define ZVOL_RDONLY (1<<0) /* zvol is readonly (writes rejected) */ +#define ZVOL_WRITTEN_TO (1<<1) /* zvol has been written to (needs flush) */ +#define ZVOL_EXCL (1<<2) /* zvol has O_EXCL client right now */ /* * The in-core state of each volume. From cf80a803d58fef02d5419cbbe5950fc6b50ae221 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 18 Jul 2024 13:24:05 +1000 Subject: [PATCH 085/223] zvol: ensure device minors are properly cleaned up Currently, if a minor is in use when we try to remove it, we'll skip it and never come back to it again. Since the zvol state is hung off the minor in the kernel, this can get us into weird situations if something tries to use it after the removal fails. It's even worse at pool export, as there's now a vestigial zvol state with no pool under it. It's weirder again if the pool is subsequently reimported, as the zvol code (reasonably) assumes the zvol state has been properly setup, when it's actually left over from the previous import of the pool. This commit attempts to tackle that by setting a flag on the zvol if its minor can't be removed, and then checking that flag when a request is made and rejecting it, thus stopping new work coming in. The flag also causes a condvar to be signaled when the last client finishes. For the case where a single minor is being removed (eg changing volmode), it will wait for this signal before proceeding. Meanwhile, when removing all minors, a background task is created for each minor that couldn't be removed on the spot, and those tasks then wake and clean up. Since any new tasks are queued on to the pool's spa_zvol_taskq, spa_export_common() will continue to wait at export until all minors are removed. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris Closes #14872 Closes #16364 --- include/sys/zvol_impl.h | 5 ++ module/os/freebsd/zfs/zvol_os.c | 10 ++- module/os/linux/zfs/zvol_os.c | 15 +++++ module/zfs/zvol.c | 116 +++++++++++++++++++++++++------- 4 files changed, 121 insertions(+), 25 deletions(-) diff --git a/include/sys/zvol_impl.h b/include/sys/zvol_impl.h index 60b368919929..07b9499e7ee6 100644 --- a/include/sys/zvol_impl.h +++ b/include/sys/zvol_impl.h @@ -18,6 +18,9 @@ * * CDDL HEADER END */ +/* + * Copyright (c) 2024, Klara, Inc. + */ #ifndef _SYS_ZVOL_IMPL_H #define _SYS_ZVOL_IMPL_H @@ -27,6 +30,7 @@ #define ZVOL_RDONLY (1<<0) /* zvol is readonly (writes rejected) */ #define ZVOL_WRITTEN_TO (1<<1) /* zvol has been written to (needs flush) */ #define ZVOL_EXCL (1<<2) /* zvol has O_EXCL client right now */ +#define ZVOL_REMOVING (1<<3) /* zvol waiting to remove minor */ /* * The in-core state of each volume. @@ -50,6 +54,7 @@ typedef struct zvol_state { kmutex_t zv_state_lock; /* protects zvol_state_t */ atomic_t zv_suspend_ref; /* refcount for suspend */ krwlock_t zv_suspend_lock; /* suspend lock */ + kcondvar_t zv_removing_cv; /* ready to remove minor */ struct zvol_state_os *zv_zso; /* private platform state */ } zvol_state_t; diff --git a/module/os/freebsd/zfs/zvol_os.c b/module/os/freebsd/zfs/zvol_os.c index 7c418f26fc14..12eb2b1e517e 100644 --- a/module/os/freebsd/zfs/zvol_os.c +++ b/module/os/freebsd/zfs/zvol_os.c @@ -30,6 +30,7 @@ * Copyright (c) 2012, 2017 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright (c) 2024, Klara, Inc. */ /* Portions Copyright 2011 Martin Matuska */ @@ -251,7 +252,7 @@ zvol_geom_open(struct g_provider *pp, int flag, int count) } mutex_enter(&zv->zv_state_lock); - if (zv->zv_zso->zso_dying) { + if (zv->zv_zso->zso_dying || zv->zv_flags & ZVOL_REMOVING) { rw_exit(&zvol_state_lock); err = SET_ERROR(ENXIO); goto out_zv_locked; @@ -683,6 +684,11 @@ zvol_geom_bio_strategy(struct bio *bp) rw_enter(&zv->zv_suspend_lock, ZVOL_RW_READER); + if (zv->zv_flags & ZVOL_REMOVING) { + error = SET_ERROR(ENXIO); + goto resume; + } + switch (bp->bio_cmd) { case BIO_READ: doread = B_TRUE; @@ -1374,6 +1380,7 @@ zvol_os_free(zvol_state_t *zv) } mutex_destroy(&zv->zv_state_lock); + cv_destroy(&zv->zv_removing_cv); dataset_kstats_destroy(&zv->zv_kstat); kmem_free(zv->zv_zso, sizeof (struct zvol_state_os)); kmem_free(zv, sizeof (zvol_state_t)); @@ -1431,6 +1438,7 @@ zvol_os_create_minor(const char *name) zv = kmem_zalloc(sizeof (*zv), KM_SLEEP); zv->zv_hash = hash; mutex_init(&zv->zv_state_lock, NULL, MUTEX_DEFAULT, NULL); + cv_init(&zv->zv_removing_cv, NULL, CV_DEFAULT, NULL); zv->zv_zso = kmem_zalloc(sizeof (struct zvol_state_os), KM_SLEEP); zv->zv_volmode = volmode; if (zv->zv_volmode == ZFS_VOLMODE_GEOM) { diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 493f7f4bdc1c..b5f5656b0ab0 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2012, 2020 by Delphix. All rights reserved. * Copyright (c) 2024, Rob Norris + * Copyright (c) 2024, Klara, Inc. */ #include @@ -527,6 +528,11 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq, uint64_t size = io_size(bio, rq); int rw = io_data_dir(bio, rq); + if (unlikely(zv->zv_flags & ZVOL_REMOVING)) { + END_IO(zv, bio, rq, -SET_ERROR(ENXIO)); + goto out; + } + if (zvol_request_sync) force_sync = 1; @@ -735,6 +741,13 @@ zvol_open(struct block_device *bdev, fmode_t flag) } mutex_enter(&zv->zv_state_lock); + + if (unlikely(zv->zv_flags & ZVOL_REMOVING)) { + mutex_exit(&zv->zv_state_lock); + rw_exit(&zvol_state_lock); + return (-SET_ERROR(ENXIO)); + } + /* * Make sure zvol is not suspended during first open * (hold zv_suspend_lock) and respect proper lock acquisition @@ -1368,6 +1381,7 @@ zvol_alloc(dev_t dev, const char *name, uint64_t volblocksize) list_link_init(&zv->zv_next); mutex_init(&zv->zv_state_lock, NULL, MUTEX_DEFAULT, NULL); + cv_init(&zv->zv_removing_cv, NULL, CV_DEFAULT, NULL); #ifdef HAVE_BLK_MQ zv->zv_zso->use_blk_mq = zvol_use_blk_mq; @@ -1488,6 +1502,7 @@ zvol_os_free(zvol_state_t *zv) ida_simple_remove(&zvol_ida, MINOR(zv->zv_zso->zvo_dev) >> ZVOL_MINOR_BITS); + cv_destroy(&zv->zv_removing_cv); mutex_destroy(&zv->zv_state_lock); dataset_kstats_destroy(&zv->zv_kstat); diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 89b523ddd903..ee493c875689 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -37,6 +37,7 @@ * Copyright 2014 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2016 Actifio, Inc. All rights reserved. * Copyright (c) 2012, 2019 by Delphix. All rights reserved. + * Copyright (c) 2024, Klara, Inc. */ /* @@ -868,6 +869,9 @@ zvol_resume(zvol_state_t *zv) */ atomic_dec(&zv->zv_suspend_ref); + if (zv->zv_flags & ZVOL_REMOVING) + cv_broadcast(&zv->zv_removing_cv); + return (SET_ERROR(error)); } @@ -903,6 +907,9 @@ zvol_last_close(zvol_state_t *zv) ASSERT(RW_READ_HELD(&zv->zv_suspend_lock)); ASSERT(MUTEX_HELD(&zv->zv_state_lock)); + if (zv->zv_flags & ZVOL_REMOVING) + cv_broadcast(&zv->zv_removing_cv); + zvol_shutdown_zv(zv); dmu_objset_disown(zv->zv_objset, 1, zv); @@ -1195,6 +1202,41 @@ zvol_create_minor(const char *name) * Remove minors for specified dataset including children and snapshots. */ +/* + * Remove the minor for a given zvol. This will do it all: + * - flag the zvol for removal, so new requests are rejected + * - wait until outstanding requests are completed + * - remove it from lists + * - free it + * It's also usable as a taskq task, and smells nice too. + */ +static void +zvol_remove_minor_task(void *arg) +{ + zvol_state_t *zv = (zvol_state_t *)arg; + + ASSERT(!RW_LOCK_HELD(&zvol_state_lock)); + ASSERT(!MUTEX_HELD(&zv->zv_state_lock)); + + mutex_enter(&zv->zv_state_lock); + while (zv->zv_open_count > 0 || atomic_read(&zv->zv_suspend_ref)) { + zv->zv_flags |= ZVOL_REMOVING; + cv_wait(&zv->zv_removing_cv, &zv->zv_state_lock); + } + mutex_exit(&zv->zv_state_lock); + + rw_enter(&zvol_state_lock, RW_WRITER); + mutex_enter(&zv->zv_state_lock); + + zvol_remove(zv); + zvol_os_clear_private(zv); + + mutex_exit(&zv->zv_state_lock); + rw_exit(&zvol_state_lock); + + zvol_os_free(zv); +} + static void zvol_free_task(void *arg) { @@ -1207,11 +1249,13 @@ zvol_remove_minors_impl(const char *name) zvol_state_t *zv, *zv_next; int namelen = ((name) ? strlen(name) : 0); taskqid_t t; - list_t free_list; + list_t delay_list, free_list; if (zvol_inhibit_dev) return; + list_create(&delay_list, sizeof (zvol_state_t), + offsetof(zvol_state_t, zv_next)); list_create(&free_list, sizeof (zvol_state_t), offsetof(zvol_state_t, zv_next)); @@ -1230,9 +1274,24 @@ zvol_remove_minors_impl(const char *name) * one is currently using this zv */ - /* If in use, leave alone */ + /* + * If in use, try to throw everyone off and try again + * later. + */ if (zv->zv_open_count > 0 || atomic_read(&zv->zv_suspend_ref)) { + zv->zv_flags |= ZVOL_REMOVING; + t = taskq_dispatch( + zv->zv_objset->os_spa->spa_zvol_taskq, + zvol_remove_minor_task, zv, TQ_SLEEP); + if (t == TASKQID_INVALID) { + /* + * Couldn't create the task, so we'll + * do it in place once the loop is + * finished. + */ + list_insert_head(&delay_list, zv); + } mutex_exit(&zv->zv_state_lock); continue; } @@ -1259,7 +1318,11 @@ zvol_remove_minors_impl(const char *name) } rw_exit(&zvol_state_lock); - /* Drop zvol_state_lock before calling zvol_free() */ + /* Wait for zvols that we couldn't create a remove task for */ + while ((zv = list_remove_head(&delay_list)) != NULL) + zvol_remove_minor_task(zv); + + /* Free any that we couldn't free in parallel earlier */ while ((zv = list_remove_head(&free_list)) != NULL) zvol_os_free(zv); } @@ -1279,33 +1342,38 @@ zvol_remove_minor_impl(const char *name) zv_next = list_next(&zvol_state_list, zv); mutex_enter(&zv->zv_state_lock); - if (strcmp(zv->zv_name, name) == 0) { - /* - * By holding zv_state_lock here, we guarantee that no - * one is currently using this zv - */ + if (strcmp(zv->zv_name, name) == 0) + /* Found, leave the the loop with zv_lock held */ + break; + mutex_exit(&zv->zv_state_lock); + } - /* If in use, leave alone */ - if (zv->zv_open_count > 0 || - atomic_read(&zv->zv_suspend_ref)) { - mutex_exit(&zv->zv_state_lock); - continue; - } - zvol_remove(zv); + if (zv == NULL) { + rw_exit(&zvol_state_lock); + return; + } - zvol_os_clear_private(zv); - mutex_exit(&zv->zv_state_lock); - break; - } else { - mutex_exit(&zv->zv_state_lock); - } + ASSERT(MUTEX_HELD(&zv->zv_state_lock)); + + if (zv->zv_open_count > 0 || atomic_read(&zv->zv_suspend_ref)) { + /* + * In use, so try to throw everyone off, then wait + * until finished. + */ + zv->zv_flags |= ZVOL_REMOVING; + mutex_exit(&zv->zv_state_lock); + rw_exit(&zvol_state_lock); + zvol_remove_minor_task(zv); + return; } - /* Drop zvol_state_lock before calling zvol_free() */ + zvol_remove(zv); + zvol_os_clear_private(zv); + + mutex_exit(&zv->zv_state_lock); rw_exit(&zvol_state_lock); - if (zv != NULL) - zvol_os_free(zv); + zvol_os_free(zv); } /* From 4f0a8eb7c1634107d6c161dff25ade1c2086d314 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 16 Jul 2024 18:27:29 -0600 Subject: [PATCH 086/223] Use kmap_local_page instead of kmap_atomic (#16329) Changed zfs_k(un)map_atomic to zfs_k(un)map_local Signed-off-by: Jason Lee Reviewed-by: Alexander Motin Reviewed-by: Brian Atkinson --- config/kernel-kmap-local-page.m4 | 23 +++++++++++++++++++++ config/kernel.m4 | 2 ++ include/os/linux/kernel/linux/kmap_compat.h | 10 +++++++-- module/os/linux/zfs/abd_os.c | 8 +++---- module/os/linux/zfs/zfs_uio.c | 8 +++---- 5 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 config/kernel-kmap-local-page.m4 diff --git a/config/kernel-kmap-local-page.m4 b/config/kernel-kmap-local-page.m4 new file mode 100644 index 000000000000..1990914d493d --- /dev/null +++ b/config/kernel-kmap-local-page.m4 @@ -0,0 +1,23 @@ +dnl # +dnl # 5.11 API change +dnl # kmap_atomic() was deprecated in favor of kmap_local_page() +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_KMAP_LOCAL_PAGE], [ + ZFS_LINUX_TEST_SRC([kmap_local_page], [ + #include + ],[ + struct page page; + kmap_local_page(&page); + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_KMAP_LOCAL_PAGE], [ + AC_MSG_CHECKING([whether kmap_local_page exists]) + ZFS_LINUX_TEST_RESULT([kmap_local_page], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_KMAP_LOCAL_PAGE, 1, + [kernel has kmap_local_page]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 3164d631d0f5..cd93925b3ee1 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -123,6 +123,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VFS_DEDUPE_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_FILE_OPERATIONS_EXTEND ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS + ZFS_AC_KERNEL_SRC_KMAP_LOCAL_PAGE ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT @@ -274,6 +275,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VFS_DEDUPE_FILE_RANGE ZFS_AC_KERNEL_VFS_FILE_OPERATIONS_EXTEND ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS + ZFS_AC_KERNEL_KMAP_LOCAL_PAGE ZFS_AC_KERNEL_FOLLOW_DOWN_ONE ZFS_AC_KERNEL_MAKE_REQUEST_FN ZFS_AC_KERNEL_GENERIC_IO_ACCT diff --git a/include/os/linux/kernel/linux/kmap_compat.h b/include/os/linux/kernel/linux/kmap_compat.h index 7f9c00af802b..fb59c5f0267c 100644 --- a/include/os/linux/kernel/linux/kmap_compat.h +++ b/include/os/linux/kernel/linux/kmap_compat.h @@ -29,9 +29,15 @@ #include #include +#ifdef HAVE_KMAP_LOCAL_PAGE +/* 5.11 API change */ +#define zfs_kmap_local(page) kmap_local_page(page) +#define zfs_kunmap_local(addr) kunmap_local(addr) +#else /* 2.6.37 API change */ -#define zfs_kmap_atomic(page) kmap_atomic(page) -#define zfs_kunmap_atomic(addr) kunmap_atomic(addr) +#define zfs_kmap_local(page) kmap_atomic(page) +#define zfs_kunmap_local(addr) kunmap_atomic(addr) +#endif /* 5.0 API change - no more 'type' argument for access_ok() */ #ifdef HAVE_ACCESS_OK_TYPE diff --git a/module/os/linux/zfs/abd_os.c b/module/os/linux/zfs/abd_os.c index a388acfad7d6..f7af20c619a4 100644 --- a/module/os/linux/zfs/abd_os.c +++ b/module/os/linux/zfs/abd_os.c @@ -526,8 +526,8 @@ abd_alloc_zero_scatter(void) #define PAGE_SHIFT (highbit64(PAGESIZE)-1) #endif -#define zfs_kmap_atomic(chunk) ((void *)chunk) -#define zfs_kunmap_atomic(addr) do { (void)(addr); } while (0) +#define zfs_kmap_local(chunk) ((void *)chunk) +#define zfs_kunmap_local(addr) do { (void)(addr); } while (0) #define local_irq_save(flags) do { (void)(flags); } while (0) #define local_irq_restore(flags) do { (void)(flags); } while (0) #define nth_page(pg, i) \ @@ -980,7 +980,7 @@ abd_iter_map(struct abd_iter *aiter) aiter->iter_mapsize = MIN(aiter->iter_sg->length - offset, aiter->iter_abd->abd_size - aiter->iter_pos); - paddr = zfs_kmap_atomic(sg_page(aiter->iter_sg)); + paddr = zfs_kmap_local(sg_page(aiter->iter_sg)); } aiter->iter_mapaddr = (char *)paddr + offset; @@ -999,7 +999,7 @@ abd_iter_unmap(struct abd_iter *aiter) if (!abd_is_linear(aiter->iter_abd)) { /* LINTED E_FUNC_SET_NOT_USED */ - zfs_kunmap_atomic(aiter->iter_mapaddr - aiter->iter_offset); + zfs_kunmap_local(aiter->iter_mapaddr - aiter->iter_offset); } ASSERT3P(aiter->iter_mapaddr, !=, NULL); diff --git a/module/os/linux/zfs/zfs_uio.c b/module/os/linux/zfs/zfs_uio.c index c2ed67c438c6..a99a1ba88256 100644 --- a/module/os/linux/zfs/zfs_uio.c +++ b/module/os/linux/zfs/zfs_uio.c @@ -136,7 +136,7 @@ zfs_uiomove_bvec_impl(void *p, size_t n, zfs_uio_rw_t rw, zfs_uio_t *uio) void *paddr; cnt = MIN(bv->bv_len - skip, n); - paddr = zfs_kmap_atomic(bv->bv_page); + paddr = zfs_kmap_local(bv->bv_page); if (rw == UIO_READ) { /* Copy from buffer 'p' to the bvec data */ memcpy(paddr + bv->bv_offset + skip, p, cnt); @@ -144,7 +144,7 @@ zfs_uiomove_bvec_impl(void *p, size_t n, zfs_uio_rw_t rw, zfs_uio_t *uio) /* Copy from bvec data to buffer 'p' */ memcpy(p, paddr + bv->bv_offset + skip, cnt); } - zfs_kunmap_atomic(paddr); + zfs_kunmap_local(paddr); skip += cnt; if (skip == bv->bv_len) { @@ -168,7 +168,7 @@ zfs_copy_bvec(void *p, size_t skip, size_t cnt, zfs_uio_rw_t rw, { void *paddr; - paddr = zfs_kmap_atomic(bv->bv_page); + paddr = zfs_kmap_local(bv->bv_page); if (rw == UIO_READ) { /* Copy from buffer 'p' to the bvec data */ memcpy(paddr + bv->bv_offset + skip, p, cnt); @@ -176,7 +176,7 @@ zfs_copy_bvec(void *p, size_t skip, size_t cnt, zfs_uio_rw_t rw, /* Copy from bvec data to buffer 'p' */ memcpy(p, paddr + bv->bv_offset + skip, cnt); } - zfs_kunmap_atomic(paddr); + zfs_kunmap_local(paddr); } /* From 8a33624ec6284c560709d3b99ed9a8bde138d75a Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 12:39:20 +1000 Subject: [PATCH 087/223] config: remove HAVE_1ARG_BIO_END_IO_T Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bio.m4 | 28 ------------------- include/os/linux/kernel/linux/blkdev_compat.h | 11 -------- module/os/linux/zfs/vdev_disk.c | 24 +--------------- 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index b22c1a3de7e1..9dddf0d3de68 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -237,32 +237,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [ ]) ]) -dnl # -dnl # 4.3 API change -dnl # Error argument dropped from bio_endio in favor of newly introduced -dnl # bio->bi_error. This also replaces bio->bi_flags value BIO_UPTODATE. -dnl # Introduced by torvalds/linux@4246a0b63bd8f56a1469b12eafeb875b1041a451 -dnl # ("block: add a bi_error field to struct bio"). -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS], [ - ZFS_LINUX_TEST_SRC([bio_end_io_t_args], [ - #include - static void wanted_end_io(struct bio *bio) { return; } - bio_end_io_t *end_io __attribute__ ((unused)) = wanted_end_io; - ], []) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_END_IO_T_ARGS], [ - AC_MSG_CHECKING([whether bio_end_io_t wants 1 arg]) - ZFS_LINUX_TEST_RESULT([bio_end_io_t_args], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_1ARG_BIO_END_IO_T, 1, - [bio_end_io_t wants 1 arg]) - ], [ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 4.13 API change dnl # The bio->bi_error field was replaced with bio->bi_status which is an @@ -513,7 +487,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_REQ ZFS_AC_KERNEL_SRC_BIO_OPS ZFS_AC_KERNEL_SRC_BIO_SET_DEV - ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS ZFS_AC_KERNEL_SRC_BIO_BI_STATUS ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO @@ -539,7 +512,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BIO_SET_OP_ATTRS ZFS_AC_KERNEL_BIO_SET_DEV - ZFS_AC_KERNEL_BIO_END_IO_T_ARGS ZFS_AC_KERNEL_BIO_BI_STATUS ZFS_AC_KERNEL_BIO_BVEC_ITER ZFS_AC_KERNEL_BIO_SUBMIT_BIO diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 6154c4a86331..311353c123a0 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -249,12 +249,6 @@ errno_to_bi_status(int error) } #endif /* HAVE_BIO_BI_STATUS */ -/* - * 4.3 API change - * The bio_endio() prototype changed slightly. These are helper - * macro's to ensure the prototype and invocation are handled. - */ -#ifdef HAVE_1ARG_BIO_END_IO_T #ifdef HAVE_BIO_BI_STATUS #define BIO_END_IO_ERROR(bio) bi_status_to_errno(bio->bi_status) #define BIO_END_IO_PROTO(fn, x, z) static void fn(struct bio *x) @@ -279,11 +273,6 @@ bio_set_bi_error(struct bio *bio, int error) } #endif /* HAVE_BIO_BI_STATUS */ -#else -#define BIO_END_IO_PROTO(fn, x, z) static void fn(struct bio *x, int z) -#define BIO_END_IO(bio, error) bio_endio(bio, error); -#endif /* HAVE_1ARG_BIO_END_IO_T */ - /* * 5.15 MACRO, * GD_DEAD diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index ace6327f8204..5536057e62de 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -810,15 +810,7 @@ BIO_END_IO_PROTO(vbio_completion, bio, error) ASSERT(zio); /* Capture and log any errors */ -#ifdef HAVE_1ARG_BIO_END_IO_T zio->io_error = BIO_END_IO_ERROR(bio); -#else - zio->io_error = 0; - if (error) - zio->io_error = -(error); - else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) - zio->io_error = EIO; -#endif ASSERT3U(zio->io_error, >=, 0); if (zio->io_error) @@ -1078,14 +1070,7 @@ BIO_END_IO_PROTO(vdev_classic_physio_completion, bio, error) dio_request_t *dr = bio->bi_private; if (dr->dr_error == 0) { -#ifdef HAVE_1ARG_BIO_END_IO_T dr->dr_error = BIO_END_IO_ERROR(bio); -#else - if (error) - dr->dr_error = -(error); - else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) - dr->dr_error = EIO; -#endif } /* Drop reference acquired by vdev_classic_physio */ @@ -1227,11 +1212,7 @@ vdev_classic_physio(zio_t *zio) BIO_END_IO_PROTO(vdev_disk_io_flush_completion, bio, error) { zio_t *zio = bio->bi_private; -#ifdef HAVE_1ARG_BIO_END_IO_T zio->io_error = BIO_END_IO_ERROR(bio); -#else - zio->io_error = -error; -#endif if (zio->io_error && (zio->io_error == EOPNOTSUPP)) zio->io_vd->vdev_nowritecache = B_TRUE; @@ -1269,11 +1250,8 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio) BIO_END_IO_PROTO(vdev_disk_discard_end_io, bio, error) { zio_t *zio = bio->bi_private; -#ifdef HAVE_1ARG_BIO_END_IO_T zio->io_error = BIO_END_IO_ERROR(bio); -#else - zio->io_error = -error; -#endif + bio_put(bio); if (zio->io_error) vdev_disk_error(zio); From 2c3e42b252f01bde9650dc690811401933189a56 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 12:52:05 +1000 Subject: [PATCH 088/223] config: remove HAVE_BIO_BVEC_ITER Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bio.m4 | 26 ------------------- include/os/linux/kernel/linux/blkdev_compat.h | 10 ------- 2 files changed, 36 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index 9dddf0d3de68..c53bb0d09c74 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -262,30 +262,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_STATUS], [ ]) ]) -dnl # -dnl # 3.14 API change, -dnl # Immutable biovecs. A number of fields of struct bio are moved to -dnl # struct bvec_iter. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER], [ - ZFS_LINUX_TEST_SRC([bio_bvec_iter], [ - #include - ],[ - struct bio bio; - bio.bi_iter.bi_sector = 0; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_BVEC_ITER], [ - AC_MSG_CHECKING([whether bio has bi_iter]) - ZFS_LINUX_TEST_RESULT([bio_bvec_iter], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BIO_BVEC_ITER, 1, [bio has bi_iter]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 4.8 API change dnl # The rw argument has been removed from submit_bio/submit_bio_wait. @@ -488,7 +464,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_BIO_OPS ZFS_AC_KERNEL_SRC_BIO_SET_DEV ZFS_AC_KERNEL_SRC_BIO_BI_STATUS - ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_SRC_BLKG_TRYGET @@ -513,7 +488,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BIO_SET_DEV ZFS_AC_KERNEL_BIO_BI_STATUS - ZFS_AC_KERNEL_BIO_BVEC_ITER ZFS_AC_KERNEL_BIO_SUBMIT_BIO ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_BLKG_TRYGET diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 311353c123a0..891ff4403622 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -116,7 +116,6 @@ blk_queue_set_read_ahead(struct request_queue *q, unsigned long ra_pages) #endif } -#ifdef HAVE_BIO_BVEC_ITER #define BIO_BI_SECTOR(bio) (bio)->bi_iter.bi_sector #define BIO_BI_SIZE(bio) (bio)->bi_iter.bi_size #define BIO_BI_IDX(bio) (bio)->bi_iter.bi_idx @@ -124,15 +123,6 @@ blk_queue_set_read_ahead(struct request_queue *q, unsigned long ra_pages) #define bio_for_each_segment4(bv, bvp, b, i) \ bio_for_each_segment((bv), (b), (i)) typedef struct bvec_iter bvec_iterator_t; -#else -#define BIO_BI_SECTOR(bio) (bio)->bi_sector -#define BIO_BI_SIZE(bio) (bio)->bi_size -#define BIO_BI_IDX(bio) (bio)->bi_idx -#define BIO_BI_SKIP(bio) (0) -#define bio_for_each_segment4(bv, bvp, b, i) \ - bio_for_each_segment((bvp), (b), (i)) -typedef int bvec_iterator_t; -#endif static inline void bio_set_flags_failfast(struct block_device *bdev, int *flags, bool dev, From 5e42628c459be60cca79398f0ece491e880dde7b Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 12:55:00 +1000 Subject: [PATCH 089/223] config: remove HAVE_CLEAR_INODE and HAVE_EVICT_INODE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-clear-inode.m4 | 39 ---------------------- config/kernel-evict-inode.m4 | 24 ------------- config/kernel.m4 | 4 --- include/os/linux/kernel/linux/vfs_compat.h | 10 ------ 4 files changed, 77 deletions(-) delete mode 100644 config/kernel-clear-inode.m4 delete mode 100644 config/kernel-evict-inode.m4 diff --git a/config/kernel-clear-inode.m4 b/config/kernel-clear-inode.m4 deleted file mode 100644 index 3f454d7ec0d3..000000000000 --- a/config/kernel-clear-inode.m4 +++ /dev/null @@ -1,39 +0,0 @@ -dnl # -dnl # 3.5.0 API change -dnl # torvalds/linux@dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430 and -dnl # torvalds/linux@7994e6f7254354e03028a11f98a27bd67dace9f1 reworked -dnl # where inode_sync_wait() is called. -dnl # -dnl # Prior to these changes it would occur in end_writeback() but due -dnl # to various issues (described in the above commits) it has been -dnl # moved to evict(). This changes the ordering is which sync occurs -dnl # but otherwise doesn't impact the zpl implementation. -dnl # -dnl # The major impact here is the renaming of end_writeback() to -dnl # clear_inode(). However, care must be taken when detecting this -dnl # API change because as recently as 2.6.35 there was a clear_inode() -dnl # function. However, it was made obsolete by the evict_inode() API -dnl # change at the same time. -dnl # -dnl # Therefore, to ensure we have the correct API we only allow the -dnl # clear_inode() compatibility code to be defined iff the evict_inode() -dnl # functionality is also detected. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_CLEAR_INODE], [ - ZFS_LINUX_TEST_SRC([clear_inode], [ - #include - ], [ - clear_inode(NULL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_CLEAR_INODE], [ - AC_MSG_CHECKING([whether clear_inode() is available]) - ZFS_LINUX_TEST_RESULT_SYMBOL([clear_inode], - [clear_inode], [fs/inode.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_CLEAR_INODE, 1, [clear_inode() is available]) - ], [ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel-evict-inode.m4 b/config/kernel-evict-inode.m4 deleted file mode 100644 index 87082c9a2839..000000000000 --- a/config/kernel-evict-inode.m4 +++ /dev/null @@ -1,24 +0,0 @@ -dnl # -dnl # 2.6.36 API change -dnl # The sops->delete_inode() and sops->clear_inode() callbacks have -dnl # replaced by a single sops->evict_inode() callback. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_EVICT_INODE], [ - ZFS_LINUX_TEST_SRC([evict_inode], [ - #include - static void evict_inode (struct inode * t) { return; } - static struct super_operations sops __attribute__ ((unused)) = { - .evict_inode = evict_inode, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_EVICT_INODE], [ - AC_MSG_CHECKING([whether sops->evict_inode() exists]) - ZFS_LINUX_TEST_RESULT([evict_inode], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_EVICT_INODE, 1, [sops->evict_inode() exists]) - ],[ - ZFS_LINUX_TEST_ERROR([evict_inode]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index cd93925b3ee1..e64f3bd69d9d 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -79,7 +79,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_FILE_DENTRY ZFS_AC_KERNEL_SRC_FSYNC ZFS_AC_KERNEL_SRC_AIO_FSYNC - ZFS_AC_KERNEL_SRC_EVICT_INODE ZFS_AC_KERNEL_SRC_DIRTY_INODE ZFS_AC_KERNEL_SRC_SHRINKER ZFS_AC_KERNEL_SRC_MKDIR @@ -92,7 +91,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_AUTOMOUNT ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE ZFS_AC_KERNEL_SRC_COMMIT_METADATA - ZFS_AC_KERNEL_SRC_CLEAR_INODE ZFS_AC_KERNEL_SRC_SETATTR_PREPARE ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED ZFS_AC_KERNEL_SRC_DENTRY @@ -231,7 +229,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_FILE_DENTRY ZFS_AC_KERNEL_FSYNC ZFS_AC_KERNEL_AIO_FSYNC - ZFS_AC_KERNEL_EVICT_INODE ZFS_AC_KERNEL_DIRTY_INODE ZFS_AC_KERNEL_SHRINKER ZFS_AC_KERNEL_MKDIR @@ -244,7 +241,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_AUTOMOUNT ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE ZFS_AC_KERNEL_COMMIT_METADATA - ZFS_AC_KERNEL_CLEAR_INODE ZFS_AC_KERNEL_SETATTR_PREPARE ZFS_AC_KERNEL_INSERT_INODE_LOCKED ZFS_AC_KERNEL_DENTRY diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index aea8bd5ed22c..6ab760169294 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -136,16 +136,6 @@ zpl_bdi_destroy(struct super_block *sb) #define SB_NOATIME MS_NOATIME #endif -/* - * 3.5 API change, - * The clear_inode() function replaces end_writeback() and introduces an - * ordering change regarding when the inode_sync_wait() occurs. See the - * configure check in config/kernel-clear-inode.m4 for full details. - */ -#if defined(HAVE_EVICT_INODE) && !defined(HAVE_CLEAR_INODE) -#define clear_inode(ip) end_writeback(ip) -#endif /* HAVE_EVICT_INODE && !HAVE_CLEAR_INODE */ - #if defined(SEEK_HOLE) && defined(SEEK_DATA) && !defined(HAVE_LSEEK_EXECUTE) static inline loff_t lseek_execute( From 80bd3e3459792244821199d9b2190198935b1866 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 12:56:04 +1000 Subject: [PATCH 090/223] config: remove HAVE_DENTRY_D_U_ALIASES Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-dentry-alias.m4 | 30 ------------------- config/kernel.m4 | 2 -- include/os/linux/kernel/linux/dcache_compat.h | 2 -- 3 files changed, 34 deletions(-) delete mode 100644 config/kernel-dentry-alias.m4 diff --git a/config/kernel-dentry-alias.m4 b/config/kernel-dentry-alias.m4 deleted file mode 100644 index f0ddb8d010b0..000000000000 --- a/config/kernel-dentry-alias.m4 +++ /dev/null @@ -1,30 +0,0 @@ -dnl # -dnl # 3.18 API change -dnl # Dentry aliases are in d_u struct dentry member -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY_ALIAS_D_U], [ - ZFS_LINUX_TEST_SRC([dentry_alias_d_u], [ - #include - #include - #include - ], [ - struct inode *inode __attribute__ ((unused)) = NULL; - struct dentry *dentry __attribute__ ((unused)) = NULL; - hlist_for_each_entry(dentry, &inode->i_dentry, - d_u.d_alias) { - d_drop(dentry); - } - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_DENTRY_ALIAS_D_U], [ - AC_MSG_CHECKING([whether dentry aliases are in d_u member]) - ZFS_LINUX_TEST_RESULT([dentry_alias_d_u], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_DENTRY_D_U_ALIASES, 1, - [dentry aliases are in d_u member]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - diff --git a/config/kernel.m4 b/config/kernel.m4 index e64f3bd69d9d..f9dab8fbe423 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -94,7 +94,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SETATTR_PREPARE ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED ZFS_AC_KERNEL_SRC_DENTRY - ZFS_AC_KERNEL_SRC_DENTRY_ALIAS_D_U ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE ZFS_AC_KERNEL_SRC_SECURITY_INODE ZFS_AC_KERNEL_SRC_FST_MOUNT @@ -244,7 +243,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SETATTR_PREPARE ZFS_AC_KERNEL_INSERT_INODE_LOCKED ZFS_AC_KERNEL_DENTRY - ZFS_AC_KERNEL_DENTRY_ALIAS_D_U ZFS_AC_KERNEL_TRUNCATE_SETSIZE ZFS_AC_KERNEL_SECURITY_INODE ZFS_AC_KERNEL_FST_MOUNT diff --git a/include/os/linux/kernel/linux/dcache_compat.h b/include/os/linux/kernel/linux/dcache_compat.h index ab1711b99f3f..4d92e4dbde57 100644 --- a/include/os/linux/kernel/linux/dcache_compat.h +++ b/include/os/linux/kernel/linux/dcache_compat.h @@ -35,9 +35,7 @@ #define d_make_root(inode) d_alloc_root(inode) #endif /* HAVE_D_MAKE_ROOT */ -#ifdef HAVE_DENTRY_D_U_ALIASES #define d_alias d_u.d_alias -#endif /* * Starting from Linux 5.13, flush_dcache_page() becomes an inline function From a0548295797fe68538bd2086934e344b2b2a33ab Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 12:57:21 +1000 Subject: [PATCH 091/223] config: remove HAVE_DIRTY_INODE_WITH_FLAGS Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-dirty-inode.m4 | 29 ----------------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_super.c | 12 ------------ 3 files changed, 43 deletions(-) delete mode 100644 config/kernel-dirty-inode.m4 diff --git a/config/kernel-dirty-inode.m4 b/config/kernel-dirty-inode.m4 deleted file mode 100644 index 2ef8658748ca..000000000000 --- a/config/kernel-dirty-inode.m4 +++ /dev/null @@ -1,29 +0,0 @@ -dnl # -dnl # 3.0 API change -dnl # The sops->dirty_inode() callbacks were updated to take a flags -dnl # argument. This allows the greater control over whether the -dnl # filesystem needs to push out a transaction or not. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_DIRTY_INODE], [ - ZFS_LINUX_TEST_SRC([dirty_inode_with_flags], [ - #include - - static void dirty_inode(struct inode *a, int b) { return; } - - static const struct super_operations - sops __attribute__ ((unused)) = { - .dirty_inode = dirty_inode, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_DIRTY_INODE], [ - AC_MSG_CHECKING([whether sops->dirty_inode() wants flags]) - ZFS_LINUX_TEST_RESULT([dirty_inode_with_flags], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_DIRTY_INODE_WITH_FLAGS, 1, - [sops->dirty_inode() wants flags]) - ],[ - AC_MSG_RESULT([no]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index f9dab8fbe423..8b711e972aa2 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -79,7 +79,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_FILE_DENTRY ZFS_AC_KERNEL_SRC_FSYNC ZFS_AC_KERNEL_SRC_AIO_FSYNC - ZFS_AC_KERNEL_SRC_DIRTY_INODE ZFS_AC_KERNEL_SRC_SHRINKER ZFS_AC_KERNEL_SRC_MKDIR ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS @@ -228,7 +227,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_FILE_DENTRY ZFS_AC_KERNEL_FSYNC ZFS_AC_KERNEL_AIO_FSYNC - ZFS_AC_KERNEL_DIRTY_INODE ZFS_AC_KERNEL_SHRINKER ZFS_AC_KERNEL_MKDIR ZFS_AC_KERNEL_LOOKUP_FLAGS diff --git a/module/os/linux/zfs/zpl_super.c b/module/os/linux/zfs/zpl_super.c index d98d32c1f9fb..66014eb87486 100644 --- a/module/os/linux/zfs/zpl_super.c +++ b/module/os/linux/zfs/zpl_super.c @@ -54,7 +54,6 @@ zpl_inode_destroy(struct inode *ip) * inode has changed. We use it to ensure the znode system attributes * are always strictly update to date with respect to the inode. */ -#ifdef HAVE_DIRTY_INODE_WITH_FLAGS static void zpl_dirty_inode(struct inode *ip, int flags) { @@ -64,17 +63,6 @@ zpl_dirty_inode(struct inode *ip, int flags) zfs_dirty_inode(ip, flags); spl_fstrans_unmark(cookie); } -#else -static void -zpl_dirty_inode(struct inode *ip) -{ - fstrans_cookie_t cookie; - - cookie = spl_fstrans_mark(); - zfs_dirty_inode(ip, 0); - spl_fstrans_unmark(cookie); -} -#endif /* HAVE_DIRTY_INODE_WITH_FLAGS */ /* * When ->drop_inode() is called its return value indicates if the From 6e57494626f76d57d7b1a3af5e79265c125328c6 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:02:48 +1000 Subject: [PATCH 092/223] config: remove HAVE_D_MAKE_ROOT Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-dentry-operations.m4 | 25 ------------------- include/os/linux/kernel/linux/dcache_compat.h | 4 --- 2 files changed, 29 deletions(-) diff --git a/config/kernel-dentry-operations.m4 b/config/kernel-dentry-operations.m4 index 957ebc9f0581..a364211677cb 100644 --- a/config/kernel-dentry-operations.m4 +++ b/config/kernel-dentry-operations.m4 @@ -1,26 +1,3 @@ -dnl # -dnl # 3.4.0 API change -dnl # Added d_make_root() to replace previous d_alloc_root() function. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_D_MAKE_ROOT], [ - ZFS_LINUX_TEST_SRC([d_make_root], [ - #include - ], [ - d_make_root(NULL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_D_MAKE_ROOT], [ - AC_MSG_CHECKING([whether d_make_root() is available]) - ZFS_LINUX_TEST_RESULT_SYMBOL([d_make_root], - [d_make_root], [fs/dcache.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_D_MAKE_ROOT, 1, [d_make_root() is available]) - ], [ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.28 API change dnl # Added d_obtain_alias() helper function. @@ -142,7 +119,6 @@ AC_DEFUN([ZFS_AC_KERNEL_S_D_OP], [ ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY], [ - ZFS_AC_KERNEL_SRC_D_MAKE_ROOT ZFS_AC_KERNEL_SRC_D_OBTAIN_ALIAS ZFS_AC_KERNEL_SRC_D_PRUNE_ALIASES ZFS_AC_KERNEL_SRC_D_SET_D_OP @@ -151,7 +127,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY], [ ]) AC_DEFUN([ZFS_AC_KERNEL_DENTRY], [ - ZFS_AC_KERNEL_D_MAKE_ROOT ZFS_AC_KERNEL_D_OBTAIN_ALIAS ZFS_AC_KERNEL_D_PRUNE_ALIASES ZFS_AC_KERNEL_D_SET_D_OP diff --git a/include/os/linux/kernel/linux/dcache_compat.h b/include/os/linux/kernel/linux/dcache_compat.h index 4d92e4dbde57..de533a5fd28b 100644 --- a/include/os/linux/kernel/linux/dcache_compat.h +++ b/include/os/linux/kernel/linux/dcache_compat.h @@ -31,10 +31,6 @@ #define dname(dentry) ((char *)((dentry)->d_name.name)) #define dlen(dentry) ((int)((dentry)->d_name.len)) -#ifndef HAVE_D_MAKE_ROOT -#define d_make_root(inode) d_alloc_root(inode) -#endif /* HAVE_D_MAKE_ROOT */ - #define d_alias d_u.d_alias /* From 984a836986c84b38a2ee5631234777bf8089553a Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:07:13 +1000 Subject: [PATCH 093/223] config: remove HAVE_D_PRUNE_ALIASES Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-dentry-operations.m4 | 27 --------------------------- module/os/linux/zfs/zfs_vfsops.c | 5 +---- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/config/kernel-dentry-operations.m4 b/config/kernel-dentry-operations.m4 index a364211677cb..87f5c92fb59b 100644 --- a/config/kernel-dentry-operations.m4 +++ b/config/kernel-dentry-operations.m4 @@ -20,31 +20,6 @@ AC_DEFUN([ZFS_AC_KERNEL_D_OBTAIN_ALIAS], [ ]) ]) -dnl # -dnl # 2.6.12 API change -dnl # d_prune_aliases() helper function available. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_D_PRUNE_ALIASES], [ - ZFS_LINUX_TEST_SRC([d_prune_aliases], [ - #include - ], [ - struct inode *ip = NULL; - d_prune_aliases(ip); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_D_PRUNE_ALIASES], [ - AC_MSG_CHECKING([whether d_prune_aliases() is available]) - ZFS_LINUX_TEST_RESULT_SYMBOL([d_prune_aliases], - [d_prune_aliases], [fs/dcache.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_D_PRUNE_ALIASES, 1, - [d_prune_aliases() is available]) - ], [ - ZFS_LINUX_TEST_ERROR([d_prune_aliases()]) - ]) -]) - dnl # dnl # 2.6.38 API change dnl # Added d_set_d_op() helper function. @@ -120,7 +95,6 @@ AC_DEFUN([ZFS_AC_KERNEL_S_D_OP], [ AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY], [ ZFS_AC_KERNEL_SRC_D_OBTAIN_ALIAS - ZFS_AC_KERNEL_SRC_D_PRUNE_ALIASES ZFS_AC_KERNEL_SRC_D_SET_D_OP ZFS_AC_KERNEL_SRC_D_REVALIDATE_NAMEIDATA ZFS_AC_KERNEL_SRC_S_D_OP @@ -128,7 +102,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY], [ AC_DEFUN([ZFS_AC_KERNEL_DENTRY], [ ZFS_AC_KERNEL_D_OBTAIN_ALIAS - ZFS_AC_KERNEL_D_PRUNE_ALIASES ZFS_AC_KERNEL_D_SET_D_OP ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA ZFS_AC_KERNEL_S_D_OP diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index 8e0a319fb422..617d7d74a36d 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -1283,14 +1283,11 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects) *objects = (*shrinker->scan_objects)(shrinker, &sc); #elif defined(HAVE_SINGLE_SHRINKER_CALLBACK) *objects = (*shrinker->shrink)(shrinker, &sc); -#elif defined(HAVE_D_PRUNE_ALIASES) #define D_PRUNE_ALIASES_IS_DEFAULT *objects = zfs_prune_aliases(zfsvfs, nr_to_scan); -#else -#error "No available dentry and inode cache pruning mechanism." #endif -#if defined(HAVE_D_PRUNE_ALIASES) && !defined(D_PRUNE_ALIASES_IS_DEFAULT) +#ifndef D_PRUNE_ALIASES_IS_DEFAULT #undef D_PRUNE_ALIASES_IS_DEFAULT /* * Fall back to zfs_prune_aliases if the kernel's per-superblock From bfc7e03ec65d5c676caaa400c55435150b0e3860 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:12:07 +1000 Subject: [PATCH 094/223] config: remove HAVE_ENCODE_FH_WITH_INODE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-encode-fh-inode.m4 | 27 --------------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_export.c | 7 ------- 3 files changed, 36 deletions(-) delete mode 100644 config/kernel-encode-fh-inode.m4 diff --git a/config/kernel-encode-fh-inode.m4 b/config/kernel-encode-fh-inode.m4 deleted file mode 100644 index b3ec040b5e95..000000000000 --- a/config/kernel-encode-fh-inode.m4 +++ /dev/null @@ -1,27 +0,0 @@ -dnl # -dnl # 3.5.0 API change -dnl # torvalds/linux@b0b0382bb4904965a9e9fca77ad87514dfda0d1c changed the -dnl # ->encode_fh() callback to pass the child inode and its parents inode -dnl # rather than a dentry and a boolean saying whether we want the parent. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE], [ - ZFS_LINUX_TEST_SRC([export_operations_encode_fh], [ - #include - static int encode_fh(struct inode *inode, __u32 *fh, int *max_len, - struct inode *parent) { return 0; } - static struct export_operations eops __attribute__ ((unused))={ - .encode_fh = encode_fh, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE], [ - AC_MSG_CHECKING([whether eops->encode_fh() wants inode]) - ZFS_LINUX_TEST_RESULT([export_operations_encode_fh], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_ENCODE_FH_WITH_INODE, 1, - [eops->encode_fh() wants child and parent inodes]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 8b711e972aa2..283102340ae4 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -88,7 +88,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_PUT_LINK ZFS_AC_KERNEL_SRC_TMPFILE ZFS_AC_KERNEL_SRC_AUTOMOUNT - ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE ZFS_AC_KERNEL_SRC_COMMIT_METADATA ZFS_AC_KERNEL_SRC_SETATTR_PREPARE ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED @@ -236,7 +235,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_PUT_LINK ZFS_AC_KERNEL_TMPFILE ZFS_AC_KERNEL_AUTOMOUNT - ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE ZFS_AC_KERNEL_COMMIT_METADATA ZFS_AC_KERNEL_SETATTR_PREPARE ZFS_AC_KERNEL_INSERT_INODE_LOCKED diff --git a/module/os/linux/zfs/zpl_export.c b/module/os/linux/zfs/zpl_export.c index aa80b72e2d7a..b6b9e2754055 100644 --- a/module/os/linux/zfs/zpl_export.c +++ b/module/os/linux/zfs/zpl_export.c @@ -31,15 +31,8 @@ static int -#ifdef HAVE_ENCODE_FH_WITH_INODE zpl_encode_fh(struct inode *ip, __u32 *fh, int *max_len, struct inode *parent) { -#else -zpl_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len, int connectable) -{ - /* CSTYLED */ - struct inode *ip = dentry->d_inode; -#endif /* HAVE_ENCODE_FH_WITH_INODE */ fstrans_cookie_t cookie; ushort_t empty_fid = 0; fid_t *fid; From ccb59e31e483756e3c872fa1598dc897aed2b156 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:21:36 +1000 Subject: [PATCH 095/223] config: remove HAVE_FALLOC_FL_ZERO_RANGE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-fallocate.m4 | 44 ---------------------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_file.c | 5 +--- 3 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 config/kernel-fallocate.m4 diff --git a/config/kernel-fallocate.m4 b/config/kernel-fallocate.m4 deleted file mode 100644 index 95186dada453..000000000000 --- a/config/kernel-fallocate.m4 +++ /dev/null @@ -1,44 +0,0 @@ -dnl # -dnl # Linux 2.6.38 - 3.x API -dnl # The fallocate callback was moved from the inode_operations -dnl # structure to the file_operations structure. -dnl # -dnl # -dnl # Linux 3.15+ -dnl # fallocate learned a new flag, FALLOC_FL_ZERO_RANGE -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_FALLOCATE], [ - ZFS_LINUX_TEST_SRC([file_fallocate], [ - #include - - static long test_fallocate(struct file *file, int mode, - loff_t offset, loff_t len) { return 0; } - - static const struct file_operations - fops __attribute__ ((unused)) = { - .fallocate = test_fallocate, - }; - ], []) - ZFS_LINUX_TEST_SRC([falloc_fl_zero_range], [ - #include - ],[ - int flags __attribute__ ((unused)); - flags = FALLOC_FL_ZERO_RANGE; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_FALLOCATE], [ - AC_MSG_CHECKING([whether fops->fallocate() exists]) - ZFS_LINUX_TEST_RESULT([file_fallocate], [ - AC_MSG_RESULT(yes) - AC_MSG_CHECKING([whether FALLOC_FL_ZERO_RANGE exists]) - ZFS_LINUX_TEST_RESULT([falloc_fl_zero_range], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FALLOC_FL_ZERO_RANGE, 1, [FALLOC_FL_ZERO_RANGE is defined]) - ],[ - AC_MSG_RESULT(no) - ]) - ],[ - ZFS_LINUX_TEST_ERROR([file_fallocate]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 283102340ae4..136319ff34ee 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -42,7 +42,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE ZFS_AC_KERNEL_SRC_PDE_DATA - ZFS_AC_KERNEL_SRC_FALLOCATE ZFS_AC_KERNEL_SRC_FADVISE ZFS_AC_KERNEL_SRC_GENERIC_FADVISE ZFS_AC_KERNEL_SRC_SCHED @@ -189,7 +188,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_GLOBAL_PAGE_STATE ZFS_AC_KERNEL_OBJTOOL ZFS_AC_KERNEL_PDE_DATA - ZFS_AC_KERNEL_FALLOCATE ZFS_AC_KERNEL_FADVISE ZFS_AC_KERNEL_GENERIC_FADVISE ZFS_AC_KERNEL_SCHED diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 9dec52215c7c..8fc5cba3ce56 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -833,10 +833,7 @@ zpl_fallocate_common(struct inode *ip, int mode, loff_t offset, loff_t len) fstrans_cookie_t cookie; int error = 0; - int test_mode = FALLOC_FL_PUNCH_HOLE; -#ifdef HAVE_FALLOC_FL_ZERO_RANGE - test_mode |= FALLOC_FL_ZERO_RANGE; -#endif + int test_mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_ZERO_RANGE; if ((mode & ~(FALLOC_FL_KEEP_SIZE | test_mode)) != 0) return (-EOPNOTSUPP); From 3aa4629e1d059a7f9135dc8850806eff7b95c99a Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:22:38 +1000 Subject: [PATCH 096/223] config: remove HAVE_FILE_DENTRY Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-file-dentry.m4 | 24 ---------------------- config/kernel.m4 | 2 -- include/os/linux/kernel/linux/vfs_compat.h | 12 ----------- 3 files changed, 38 deletions(-) delete mode 100644 config/kernel-file-dentry.m4 diff --git a/config/kernel-file-dentry.m4 b/config/kernel-file-dentry.m4 deleted file mode 100644 index 9cb5869c3821..000000000000 --- a/config/kernel-file-dentry.m4 +++ /dev/null @@ -1,24 +0,0 @@ -dnl # -dnl # 4.1 API change -dnl # struct access file->f_path.dentry was replaced by accessor function -dnl # since fix torvalds/linux@4bacc9c9234c ("overlayfs: Make f_path always -dnl # point to the overlay and f_inode to the underlay"). -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_FILE_DENTRY], [ - ZFS_LINUX_TEST_SRC([file_dentry], [ - #include - ],[ - struct file *f = NULL; - file_dentry(f); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_FILE_DENTRY], [ - AC_MSG_CHECKING([whether file_dentry() is available]) - ZFS_LINUX_TEST_RESULT([file_dentry], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILE_DENTRY, 1, [file_dentry() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 136319ff34ee..03d6314e9793 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -75,7 +75,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION ZFS_AC_KERNEL_SRC_SHOW_OPTIONS ZFS_AC_KERNEL_SRC_FILE_INODE - ZFS_AC_KERNEL_SRC_FILE_DENTRY ZFS_AC_KERNEL_SRC_FSYNC ZFS_AC_KERNEL_SRC_AIO_FSYNC ZFS_AC_KERNEL_SRC_SHRINKER @@ -221,7 +220,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_INODE_SET_IVERSION ZFS_AC_KERNEL_SHOW_OPTIONS ZFS_AC_KERNEL_FILE_INODE - ZFS_AC_KERNEL_FILE_DENTRY ZFS_AC_KERNEL_FSYNC ZFS_AC_KERNEL_AIO_FSYNC ZFS_AC_KERNEL_SHRINKER diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 6ab760169294..eb4ce8880f0f 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -272,18 +272,6 @@ static inline struct inode *file_inode(const struct file *f) } #endif /* HAVE_FILE_INODE */ -/* - * 4.1 API change - * struct access file->f_path.dentry was replaced by accessor function - * file_dentry(f) - */ -#ifndef HAVE_FILE_DENTRY -static inline struct dentry *file_dentry(const struct file *f) -{ - return (f->f_path.dentry); -} -#endif /* HAVE_FILE_DENTRY */ - static inline uid_t zfs_uid_read_impl(struct inode *ip) { return (from_kuid(kcred->user_ns, ip->i_uid)); From 928342104f94bba6e358a9fa593e6d5c2e8067b1 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:23:19 +1000 Subject: [PATCH 097/223] config: remove HAVE_FILE_INODE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-file-inode.m4 | 23 ---------------------- config/kernel.m4 | 2 -- include/os/linux/kernel/linux/vfs_compat.h | 12 ----------- 3 files changed, 37 deletions(-) delete mode 100644 config/kernel-file-inode.m4 diff --git a/config/kernel-file-inode.m4 b/config/kernel-file-inode.m4 deleted file mode 100644 index 00a3621657ad..000000000000 --- a/config/kernel-file-inode.m4 +++ /dev/null @@ -1,23 +0,0 @@ -dnl # -dnl # 3.19 API change -dnl # struct access f->f_dentry->d_inode was replaced by accessor function -dnl # file_inode(f) -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_FILE_INODE], [ - ZFS_LINUX_TEST_SRC([file_inode], [ - #include - ],[ - struct file *f = NULL; - file_inode(f); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_FILE_INODE], [ - AC_MSG_CHECKING([whether file_inode() is available]) - ZFS_LINUX_TEST_RESULT([file_inode], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILE_INODE, 1, [file_inode() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 03d6314e9793..3681ebae9a46 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -74,7 +74,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION ZFS_AC_KERNEL_SRC_SHOW_OPTIONS - ZFS_AC_KERNEL_SRC_FILE_INODE ZFS_AC_KERNEL_SRC_FSYNC ZFS_AC_KERNEL_SRC_AIO_FSYNC ZFS_AC_KERNEL_SRC_SHRINKER @@ -219,7 +218,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_INODE_SET_FLAGS ZFS_AC_KERNEL_INODE_SET_IVERSION ZFS_AC_KERNEL_SHOW_OPTIONS - ZFS_AC_KERNEL_FILE_INODE ZFS_AC_KERNEL_FSYNC ZFS_AC_KERNEL_AIO_FSYNC ZFS_AC_KERNEL_SHRINKER diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index eb4ce8880f0f..5e7874c5b19b 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -260,18 +260,6 @@ zpl_forget_cached_acl(struct inode *ip, int type) #endif /* CONFIG_FS_POSIX_ACL */ -/* - * 3.19 API change - * struct access f->f_dentry->d_inode was replaced by accessor function - * file_inode(f) - */ -#ifndef HAVE_FILE_INODE -static inline struct inode *file_inode(const struct file *f) -{ - return (f->f_dentry->d_inode); -} -#endif /* HAVE_FILE_INODE */ - static inline uid_t zfs_uid_read_impl(struct inode *ip) { return (from_kuid(kcred->user_ns, ip->i_uid)); From b6223a572e11ff00ebb4a64e726f5d5bd04a0f99 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:27:16 +1000 Subject: [PATCH 098/223] config: remove HAVE_FSYNC_RANGE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-fsync.m4 | 53 ------------------------------ config/kernel.m4 | 2 -- module/os/linux/zfs/zfs_vnops_os.c | 3 +- module/os/linux/zfs/zpl_file.c | 45 ------------------------- 4 files changed, 1 insertion(+), 102 deletions(-) delete mode 100644 config/kernel-fsync.m4 diff --git a/config/kernel-fsync.m4 b/config/kernel-fsync.m4 deleted file mode 100644 index c155f8af81a8..000000000000 --- a/config/kernel-fsync.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl # -dnl # Check file_operations->fsync interface. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_FSYNC], [ - ZFS_LINUX_TEST_SRC([fsync_without_dentry], [ - #include - - static int test_fsync(struct file *f, int x) { return 0; } - - static const struct file_operations - fops __attribute__ ((unused)) = { - .fsync = test_fsync, - }; - ],[]) - - ZFS_LINUX_TEST_SRC([fsync_range], [ - #include - - static int test_fsync(struct file *f, loff_t a, loff_t b, int c) - { return 0; } - - static const struct file_operations - fops __attribute__ ((unused)) = { - .fsync = test_fsync, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_FSYNC], [ - dnl # - dnl # Linux 2.6.35 - Linux 3.0 API - dnl # - AC_MSG_CHECKING([whether fops->fsync() wants no dentry]) - ZFS_LINUX_TEST_RESULT([fsync_without_dentry], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_FSYNC_WITHOUT_DENTRY, 1, - [fops->fsync() without dentry]) - ],[ - AC_MSG_RESULT([no]) - - dnl # - dnl # Linux 3.1 - 3.x API - dnl # - AC_MSG_CHECKING([whether fops->fsync() wants range]) - ZFS_LINUX_TEST_RESULT([fsync_range], [ - AC_MSG_RESULT([range]) - AC_DEFINE(HAVE_FSYNC_RANGE, 1, - [fops->fsync() with range]) - ],[ - ZFS_LINUX_TEST_ERROR([fops->fsync]) - ]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 3681ebae9a46..84cc572d6160 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -74,7 +74,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION ZFS_AC_KERNEL_SRC_SHOW_OPTIONS - ZFS_AC_KERNEL_SRC_FSYNC ZFS_AC_KERNEL_SRC_AIO_FSYNC ZFS_AC_KERNEL_SRC_SHRINKER ZFS_AC_KERNEL_SRC_MKDIR @@ -218,7 +217,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_INODE_SET_FLAGS ZFS_AC_KERNEL_INODE_SET_IVERSION ZFS_AC_KERNEL_SHOW_OPTIONS - ZFS_AC_KERNEL_FSYNC ZFS_AC_KERNEL_AIO_FSYNC ZFS_AC_KERNEL_SHRINKER ZFS_AC_KERNEL_MKDIR diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c index fb871ed8cef6..bbe9f2818428 100644 --- a/module/os/linux/zfs/zfs_vnops_os.c +++ b/module/os/linux/zfs/zfs_vnops_os.c @@ -3748,8 +3748,7 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc, /* * Speed up any non-sync page writebacks since * they may take several seconds to complete. - * Refer to the comment in zpl_fsync() (when - * HAVE_FSYNC_RANGE is defined) for details. + * Refer to the comment in zpl_fsync() for details. */ if (atomic_load_32(&zp->z_async_writes_cnt) > 0) { zil_commit(zfsvfs->z_log, zp->z_id); diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 8fc5cba3ce56..67a2857d7c8a 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -124,47 +124,6 @@ zpl_readdir(struct file *filp, void *dirent, filldir_t filldir) } #endif /* !HAVE_VFS_ITERATE && !HAVE_VFS_ITERATE_SHARED */ -#if defined(HAVE_FSYNC_WITHOUT_DENTRY) -/* - * Linux 2.6.35 - 3.0 API, - * As of 2.6.35 the dentry argument to the fops->fsync() hook was deemed - * redundant. The dentry is still accessible via filp->f_path.dentry, - * and we are guaranteed that filp will never be NULL. - */ -static int -zpl_fsync(struct file *filp, int datasync) -{ - struct inode *inode = filp->f_mapping->host; - cred_t *cr = CRED(); - int error; - fstrans_cookie_t cookie; - - crhold(cr); - cookie = spl_fstrans_mark(); - error = -zfs_fsync(ITOZ(inode), datasync, cr); - spl_fstrans_unmark(cookie); - crfree(cr); - ASSERT3S(error, <=, 0); - - return (error); -} - -#ifdef HAVE_FILE_AIO_FSYNC -static int -zpl_aio_fsync(struct kiocb *kiocb, int datasync) -{ - return (zpl_fsync(kiocb->ki_filp, datasync)); -} -#endif - -#elif defined(HAVE_FSYNC_RANGE) -/* - * Linux 3.1 API, - * As of 3.1 the responsibility to call filemap_write_and_wait_range() has - * been pushed down in to the .fsync() vfs hook. Additionally, the i_mutex - * lock is no longer held by the caller, for zfs we don't require the lock - * to be held so we don't acquire it. - */ static int zpl_fsync(struct file *filp, loff_t start, loff_t end, int datasync) { @@ -237,10 +196,6 @@ zpl_aio_fsync(struct kiocb *kiocb, int datasync) } #endif -#else -#error "Unsupported fops->fsync() implementation" -#endif - static inline int zfs_io_flags(struct kiocb *kiocb) { From 3c370f09fa3a4b84226345b0531c87ed4ade1b2d Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:28:29 +1000 Subject: [PATCH 099/223] config: remove HAVE_GENERIC_WRITE_CHECKS_KIOCB Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-rw-iterate.m4 | 24 ------------------------ config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_file.c | 12 ------------ 3 files changed, 38 deletions(-) diff --git a/config/kernel-vfs-rw-iterate.m4 b/config/kernel-vfs-rw-iterate.m4 index cb20ed03099a..7c568e94fbec 100644 --- a/config/kernel-vfs-rw-iterate.m4 +++ b/config/kernel-vfs-rw-iterate.m4 @@ -54,27 +54,3 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_RW_ITERATE], [ AC_MSG_RESULT(no) ]) ]) - -dnl # -dnl # Linux 4.1.x API -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_GENERIC_WRITE_CHECKS], [ - ZFS_LINUX_TEST_SRC([generic_write_checks], [ - #include - ],[ - struct kiocb *iocb = NULL; - struct iov_iter *iov = NULL; - generic_write_checks(iocb, iov); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_VFS_GENERIC_WRITE_CHECKS], [ - AC_MSG_CHECKING([whether generic_write_checks() takes kiocb]) - ZFS_LINUX_TEST_RESULT([generic_write_checks], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GENERIC_WRITE_CHECKS_KIOCB, 1, - [generic_write_checks() takes kiocb]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 84cc572d6160..2a5b96f242de 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -104,7 +104,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VFS_READPAGES ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE - ZFS_AC_KERNEL_SRC_VFS_GENERIC_WRITE_CHECKS ZFS_AC_KERNEL_SRC_VFS_IOV_ITER ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE @@ -247,7 +246,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VFS_READPAGES ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_VFS_RW_ITERATE - ZFS_AC_KERNEL_VFS_GENERIC_WRITE_CHECKS ZFS_AC_KERNEL_VFS_IOV_ITER ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 67a2857d7c8a..d0eaa6289f26 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -298,23 +298,11 @@ static inline ssize_t zpl_generic_write_checks(struct kiocb *kiocb, struct iov_iter *from, size_t *countp) { -#ifdef HAVE_GENERIC_WRITE_CHECKS_KIOCB ssize_t ret = generic_write_checks(kiocb, from); if (ret <= 0) return (ret); *countp = ret; -#else - struct file *file = kiocb->ki_filp; - struct address_space *mapping = file->f_mapping; - struct inode *ip = mapping->host; - int isblk = S_ISBLK(ip->i_mode); - - *countp = iov_iter_count(from); - ssize_t ret = generic_write_checks(file, &kiocb->ki_pos, countp, isblk); - if (ret) - return (ret); -#endif return (0); } From 22131b9a6e01c57eafdbb7f6aa1ca6aa17f14109 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:29:51 +1000 Subject: [PATCH 100/223] config: remove HAVE_INODE_SET_FLAGS Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-inode-set-flags.m4 | 22 ---------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zfs_znode.c | 12 ------------ 3 files changed, 36 deletions(-) delete mode 100644 config/kernel-inode-set-flags.m4 diff --git a/config/kernel-inode-set-flags.m4 b/config/kernel-inode-set-flags.m4 deleted file mode 100644 index 133f666a9517..000000000000 --- a/config/kernel-inode-set-flags.m4 +++ /dev/null @@ -1,22 +0,0 @@ -dnl # -dnl # 3.15 API change -dnl # inode_set_flags introduced to set i_flags -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS], [ - ZFS_LINUX_TEST_SRC([inode_set_flags], [ - #include - ],[ - struct inode inode; - inode_set_flags(&inode, S_IMMUTABLE, S_IMMUTABLE); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_INODE_SET_FLAGS], [ - AC_MSG_CHECKING([whether inode_set_flags() exists]) - ZFS_LINUX_TEST_RESULT([inode_set_flags], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_INODE_SET_FLAGS, 1, [inode_set_flags() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 2a5b96f242de..61014f6cd745 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -71,7 +71,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_ACL ZFS_AC_KERNEL_SRC_INODE_SETATTR ZFS_AC_KERNEL_SRC_INODE_GETATTR - ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION ZFS_AC_KERNEL_SRC_SHOW_OPTIONS ZFS_AC_KERNEL_SRC_AIO_FSYNC @@ -213,7 +212,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_ACL ZFS_AC_KERNEL_INODE_SETATTR ZFS_AC_KERNEL_INODE_GETATTR - ZFS_AC_KERNEL_INODE_SET_FLAGS ZFS_AC_KERNEL_INODE_SET_IVERSION ZFS_AC_KERNEL_SHOW_OPTIONS ZFS_AC_KERNEL_AIO_FSYNC diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index 265153e011e7..24aee0b88d44 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -476,7 +476,6 @@ zfs_set_inode_flags(znode_t *zp, struct inode *ip) * Linux and Solaris have different sets of file attributes, so we * restrict this conversion to the intersection of the two. */ -#ifdef HAVE_INODE_SET_FLAGS unsigned int flags = 0; if (zp->z_pflags & ZFS_IMMUTABLE) flags |= S_IMMUTABLE; @@ -484,17 +483,6 @@ zfs_set_inode_flags(znode_t *zp, struct inode *ip) flags |= S_APPEND; inode_set_flags(ip, flags, S_IMMUTABLE|S_APPEND); -#else - if (zp->z_pflags & ZFS_IMMUTABLE) - ip->i_flags |= S_IMMUTABLE; - else - ip->i_flags &= ~S_IMMUTABLE; - - if (zp->z_pflags & ZFS_APPENDONLY) - ip->i_flags |= S_APPEND; - else - ip->i_flags &= ~S_APPEND; -#endif } /* From 8bc4c13fac3990653d2146a7cf35b7f2da72e020 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:31:43 +1000 Subject: [PATCH 101/223] config: remove HAVE_IO_SCHEDULE_TIMEOUT Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-sched.m4 | 27 ------------------- module/os/linux/spl/spl-condvar.c | 44 +------------------------------ 2 files changed, 1 insertion(+), 70 deletions(-) diff --git a/config/kernel-sched.m4 b/config/kernel-sched.m4 index 17e49fbdf472..91c1e91faa94 100644 --- a/config/kernel-sched.m4 +++ b/config/kernel-sched.m4 @@ -44,39 +44,12 @@ AC_DEFUN([ZFS_AC_KERNEL_SCHED_SIGNAL_HEADER], [ ]) ]) -dnl # -dnl # 3.19 API change -dnl # The io_schedule_timeout() function is present in all 2.6.32 kernels -dnl # but it was not exported until Linux 3.19. The RHEL 7.x kernels which -dnl # are based on a 3.10 kernel do export this symbol. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_IO_SCHEDULE_TIMEOUT], [ - ZFS_LINUX_TEST_SRC([io_schedule_timeout], [ - #include - ], [ - (void) io_schedule_timeout(1); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_IO_SCHEDULE_TIMEOUT], [ - AC_MSG_CHECKING([whether io_schedule_timeout() is available]) - ZFS_LINUX_TEST_RESULT_SYMBOL([io_schedule_timeout], - [io_schedule_timeout], [], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_IO_SCHEDULE_TIMEOUT, 1, [yes]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_SRC_SCHED], [ ZFS_AC_KERNEL_SRC_SCHED_RT_HEADER ZFS_AC_KERNEL_SRC_SCHED_SIGNAL_HEADER - ZFS_AC_KERNEL_SRC_IO_SCHEDULE_TIMEOUT ]) AC_DEFUN([ZFS_AC_KERNEL_SCHED], [ ZFS_AC_KERNEL_SCHED_RT_HEADER ZFS_AC_KERNEL_SCHED_SIGNAL_HEADER - ZFS_AC_KERNEL_IO_SCHEDULE_TIMEOUT ]) diff --git a/module/os/linux/spl/spl-condvar.c b/module/os/linux/spl/spl-condvar.c index 5898789ad53d..c44cc018b6e5 100644 --- a/module/os/linux/spl/spl-condvar.c +++ b/module/os/linux/spl/spl-condvar.c @@ -209,48 +209,6 @@ __cv_wait_idle(kcondvar_t *cvp, kmutex_t *mp) } EXPORT_SYMBOL(__cv_wait_idle); -#if defined(HAVE_IO_SCHEDULE_TIMEOUT) -#define spl_io_schedule_timeout(t) io_schedule_timeout(t) -#else - -struct spl_task_timer { - struct timer_list timer; - struct task_struct *task; -}; - -static void -__cv_wakeup(spl_timer_list_t t) -{ - struct timer_list *tmr = (struct timer_list *)t; - struct spl_task_timer *task_timer = from_timer(task_timer, tmr, timer); - - wake_up_process(task_timer->task); -} - -static long -spl_io_schedule_timeout(long time_left) -{ - long expire_time = jiffies + time_left; - struct spl_task_timer task_timer; - struct timer_list *timer = &task_timer.timer; - - task_timer.task = current; - - timer_setup(timer, __cv_wakeup, 0); - - timer->expires = expire_time; - add_timer(timer); - - io_schedule(); - - del_timer_sync(timer); - - time_left = expire_time - jiffies; - - return (time_left < 0 ? 0 : time_left); -} -#endif - /* * 'expire_time' argument is an absolute wall clock time in jiffies. * Return value is time left (expire_time - now) or -1 if timeout occurred. @@ -290,7 +248,7 @@ __cv_timedwait_common(kcondvar_t *cvp, kmutex_t *mp, clock_t expire_time, */ mutex_exit(mp); if (io) - time_left = spl_io_schedule_timeout(time_left); + time_left = io_schedule_timeout(time_left); else time_left = schedule_timeout(time_left); From e6b916d69bfa764382abab82a72701705af12307 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:54:24 +1000 Subject: [PATCH 102/223] config: remove HAVE_KERNEL_STRSCPY Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-strlcpy.m4 | 25 +------------------------ config/kernel.m4 | 2 -- include/os/linux/spl/sys/string.h | 7 ------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/config/kernel-strlcpy.m4 b/config/kernel-strlcpy.m4 index c31cf52d78b0..d50b0035e9d9 100644 --- a/config/kernel-strlcpy.m4 +++ b/config/kernel-strlcpy.m4 @@ -1,6 +1,5 @@ dnl # -dnl # 6.8.x replaced strlcpy with strscpy. Check for both so we can provide -dnl # appropriate fallbacks. +dnl # 6.8 removed strlcpy. dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_STRLCPY], [ ZFS_LINUX_TEST_SRC([kernel_has_strlcpy], [ @@ -13,17 +12,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_STRLCPY], [ ]) ]) -AC_DEFUN([ZFS_AC_KERNEL_SRC_STRSCPY], [ - ZFS_LINUX_TEST_SRC([kernel_has_strscpy], [ - #include - ], [ - const char *src = "goodbye"; - char dst[32]; - ssize_t len; - len = strscpy(dst, src, sizeof (dst)); - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_STRLCPY], [ AC_MSG_CHECKING([whether strlcpy() exists]) ZFS_LINUX_TEST_RESULT([kernel_has_strlcpy], [ @@ -34,14 +22,3 @@ AC_DEFUN([ZFS_AC_KERNEL_STRLCPY], [ AC_MSG_RESULT([no]) ]) ]) - -AC_DEFUN([ZFS_AC_KERNEL_STRSCPY], [ - AC_MSG_CHECKING([whether strscpy() exists]) - ZFS_LINUX_TEST_RESULT([kernel_has_strscpy], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_KERNEL_STRSCPY, 1, - [strscpy() exists]) - ], [ - AC_MSG_RESULT([no]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 61014f6cd745..52db9449b7b0 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -139,7 +139,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_SRC_STRLCPY - ZFS_AC_KERNEL_SRC_STRSCPY ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT ZFS_AC_KERNEL_SRC_ADD_DISK ZFS_AC_KERNEL_SRC_KTHREAD @@ -280,7 +279,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SET_SPECIAL_STATE ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_STRLCPY - ZFS_AC_KERNEL_STRSCPY ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT ZFS_AC_KERNEL_ADD_DISK ZFS_AC_KERNEL_KTHREAD diff --git a/include/os/linux/spl/sys/string.h b/include/os/linux/spl/sys/string.h index f44bf23eb326..20bde1f0898a 100644 --- a/include/os/linux/spl/sys/string.h +++ b/include/os/linux/spl/sys/string.h @@ -25,10 +25,7 @@ #include -/* Fallbacks for kernel missing strlcpy */ #ifndef HAVE_KERNEL_STRLCPY - -#if defined(HAVE_KERNEL_STRSCPY) /* * strscpy is strlcpy, but returns an error on truncation. strlcpy is defined * to return strlen(src), so detect error and override it. @@ -41,10 +38,6 @@ strlcpy(char *dest, const char *src, size_t size) return ((size_t)ret); return (strlen(src)); } -#else -#error "no strlcpy fallback available" -#endif - #endif /* HAVE_KERNEL_STRLCPY */ #endif /* _SPL_STRING_H */ From e19f530dbe28b78b42321665c6d2f8c1e8d6ef86 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:56:01 +1000 Subject: [PATCH 103/223] config: remove HAVE_KERNEL_TIMER_LIST_FLAGS Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-timer.m4 | 16 ---------------- include/os/linux/spl/sys/timer.h | 2 -- 2 files changed, 18 deletions(-) diff --git a/config/kernel-timer.m4 b/config/kernel-timer.m4 index c710e804be0b..94c2c443f195 100644 --- a/config/kernel-timer.m4 +++ b/config/kernel-timer.m4 @@ -36,13 +36,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_TIMER_SETUP], [ struct timer_list tl; tl.function = task_expire; ]) - - ZFS_LINUX_TEST_SRC([timer_list_flags], [ - #include - ],[ - struct timer_list tl; - tl.flags = 2; - ]) ]) AC_DEFUN([ZFS_AC_KERNEL_TIMER_SETUP], [ @@ -63,13 +56,4 @@ AC_DEFUN([ZFS_AC_KERNEL_TIMER_SETUP], [ ],[ AC_MSG_RESULT(no) ]) - - AC_MSG_CHECKING([whether struct timer_list has flags]) - ZFS_LINUX_TEST_RESULT([timer_list_flags], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KERNEL_TIMER_LIST_FLAGS, 1, - [struct timer_list has a flags member]) - ],[ - AC_MSG_RESULT(no) - ]) ]) diff --git a/include/os/linux/spl/sys/timer.h b/include/os/linux/spl/sys/timer.h index 02c3c7893477..bcc58dbd8ea2 100644 --- a/include/os/linux/spl/sys/timer.h +++ b/include/os/linux/spl/sys/timer.h @@ -73,9 +73,7 @@ typedef unsigned long spl_timer_list_t; static inline void timer_setup(struct timer_list *timer, void (*func)(spl_timer_list_t), u32 fl) { -#ifdef HAVE_KERNEL_TIMER_LIST_FLAGS (timer)->flags = fl; -#endif init_timer(timer); setup_timer(timer, func, (spl_timer_list_t)(timer)); } From b2802da49e4096403bf77d4f549f6f9982b6036e Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 13:57:19 +1000 Subject: [PATCH 104/223] config: remove HAVE_LINUX_BLK_CGROUP_HEADER Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bio.m4 | 27 --------------------------- module/os/linux/zfs/vdev_disk.c | 2 -- 2 files changed, 29 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index c53bb0d09c74..a00a2b48d325 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -399,31 +399,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID], [ ]) ]) -dnl # -dnl # Linux 5.16 API -dnl # -dnl # The Linux 5.16 API moved struct blkcg_gq into linux/blk-cgroup.h, which -dnl # has been around since 2015. This test looks for the presence of that -dnl # header, so that it can be conditionally included where it exists, but -dnl # still be backward compatible with kernels that pre-date its introduction. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_CGROUP_HEADER], [ - ZFS_LINUX_TEST_SRC([blk_cgroup_header], [ - #include - ], []) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BLK_CGROUP_HEADER], [ - AC_MSG_CHECKING([whether linux/blk-cgroup.h exists]) - ZFS_LINUX_TEST_RESULT([blk_cgroup_header],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_LINUX_BLK_CGROUP_HEADER, 1, - [linux/blk-cgroup.h exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # Linux 5.18 API dnl # @@ -470,7 +445,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO - ZFS_AC_KERNEL_SRC_BLK_CGROUP_HEADER ZFS_AC_KERNEL_SRC_BIO_ALLOC_4ARG ]) @@ -493,6 +467,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BLKG_TRYGET ZFS_AC_KERNEL_BIO_BDEV_DISK ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID - ZFS_AC_KERNEL_BLK_CGROUP_HEADER ZFS_AC_KERNEL_BIO_ALLOC_4ARG ]) diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index 5536057e62de..613855081e6d 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -38,9 +38,7 @@ #include #include #include -#ifdef HAVE_LINUX_BLK_CGROUP_HEADER #include -#endif /* * Linux 6.8.x uses a bdev_handle as an instance/refcount for an underlying From 339b126bac642bc7c5a91e951a376009b102c2c8 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 14:01:15 +1000 Subject: [PATCH 105/223] config: remove HAVE_PERCPU_COUNTER_INIT_WITH_GFP Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-percpu.m4 | 29 ------------ include/os/linux/Makefile.am | 1 - include/os/linux/kernel/linux/percpu_compat.h | 44 ------------------- include/os/linux/spl/sys/wmsum.h | 5 --- module/os/linux/spl/spl-kmem-cache.c | 4 +- module/os/linux/spl/spl-vmem.c | 1 - module/os/linux/spl/spl-zlib.c | 1 - 7 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 include/os/linux/kernel/linux/percpu_compat.h diff --git a/config/kernel-percpu.m4 b/config/kernel-percpu.m4 index 5125dd5c5bb8..f42b27bd5267 100644 --- a/config/kernel-percpu.m4 +++ b/config/kernel-percpu.m4 @@ -1,30 +1,3 @@ -dnl # -dnl # 3.18 API change, -dnl # The function percpu_counter_init now must be passed a GFP mask. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_INIT], [ - ZFS_LINUX_TEST_SRC([percpu_counter_init_with_gfp], [ - #include - #include - ],[ - struct percpu_counter counter; - int error; - - error = percpu_counter_init(&counter, 0, GFP_KERNEL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_PERCPU_COUNTER_INIT], [ - AC_MSG_CHECKING([whether percpu_counter_init() wants gfp_t]) - ZFS_LINUX_TEST_RESULT([percpu_counter_init_with_gfp], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_WITH_GFP, 1, - [percpu_counter_init() wants gfp_t]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 4.13 API change, dnl # __percpu_counter_add() was renamed to percpu_counter_add_batch(). @@ -75,13 +48,11 @@ AC_DEFUN([ZFS_AC_KERNEL_PERCPU_REF_COUNT_IN_DATA], [ ]) ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_PERCPU], [ - ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_INIT ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_ADD_BATCH ZFS_AC_KERNEL_SRC_PERCPU_REF_COUNT_IN_DATA ]) AC_DEFUN([ZFS_AC_KERNEL_PERCPU], [ - ZFS_AC_KERNEL_PERCPU_COUNTER_INIT ZFS_AC_KERNEL_PERCPU_COUNTER_ADD_BATCH ZFS_AC_KERNEL_PERCPU_REF_COUNT_IN_DATA ]) diff --git a/include/os/linux/Makefile.am b/include/os/linux/Makefile.am index 332569efe361..28f4e62efbd6 100644 --- a/include/os/linux/Makefile.am +++ b/include/os/linux/Makefile.am @@ -8,7 +8,6 @@ kernel_linux_HEADERS = \ %D%/kernel/linux/mm_compat.h \ %D%/kernel/linux/mod_compat.h \ %D%/kernel/linux/page_compat.h \ - %D%/kernel/linux/percpu_compat.h \ %D%/kernel/linux/simd.h \ %D%/kernel/linux/simd_aarch64.h \ %D%/kernel/linux/simd_arm.h \ diff --git a/include/os/linux/kernel/linux/percpu_compat.h b/include/os/linux/kernel/linux/percpu_compat.h deleted file mode 100644 index bf3a5a01c27e..000000000000 --- a/include/os/linux/kernel/linux/percpu_compat.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or https://opensource.org/licenses/CDDL-1.0. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright (c) 2020 by Delphix. All rights reserved. - */ - -#ifndef _ZFS_PERCPU_H -#define _ZFS_PERCPU_H - -#include - -/* - * 3.18 API change, - * percpu_counter_init() now must be passed a gfp mask which will be - * used for the dynamic allocation of the actual counter. - */ -#ifdef HAVE_PERCPU_COUNTER_INIT_WITH_GFP -#define percpu_counter_init_common(counter, n, gfp) \ - percpu_counter_init(counter, n, gfp) -#else -#define percpu_counter_init_common(counter, n, gfp) \ - percpu_counter_init(counter, n) -#endif - -#endif /* _ZFS_PERCPU_H */ diff --git a/include/os/linux/spl/sys/wmsum.h b/include/os/linux/spl/sys/wmsum.h index 0871bd69504c..8fdc3f4b1663 100644 --- a/include/os/linux/spl/sys/wmsum.h +++ b/include/os/linux/spl/sys/wmsum.h @@ -36,12 +36,7 @@ typedef struct percpu_counter wmsum_t; static inline void wmsum_init(wmsum_t *ws, uint64_t value) { - -#ifdef HAVE_PERCPU_COUNTER_INIT_WITH_GFP percpu_counter_init(ws, value, GFP_KERNEL); -#else - percpu_counter_init(ws, value); -#endif } static inline void diff --git a/module/os/linux/spl/spl-kmem-cache.c b/module/os/linux/spl/spl-kmem-cache.c index 16412bc9e6cf..96b61daf49f5 100644 --- a/module/os/linux/spl/spl-kmem-cache.c +++ b/module/os/linux/spl/spl-kmem-cache.c @@ -23,7 +23,6 @@ #define SPL_KMEM_CACHE_IMPLEMENTING -#include #include #include #include @@ -728,8 +727,7 @@ spl_kmem_cache_create(const char *name, size_t size, size_t align, skc->skc_obj_emergency = 0; skc->skc_obj_emergency_max = 0; - rc = percpu_counter_init_common(&skc->skc_linux_alloc, 0, - GFP_KERNEL); + rc = percpu_counter_init(&skc->skc_linux_alloc, 0, GFP_KERNEL); if (rc != 0) { kfree(skc); return (NULL); diff --git a/module/os/linux/spl/spl-vmem.c b/module/os/linux/spl/spl-vmem.c index cab3e9549cfe..7e2402477705 100644 --- a/module/os/linux/spl/spl-vmem.c +++ b/module/os/linux/spl/spl-vmem.c @@ -21,7 +21,6 @@ * with the SPL. If not, see . */ -#include #include #include #include diff --git a/module/os/linux/spl/spl-zlib.c b/module/os/linux/spl/spl-zlib.c index a7b6c14ee150..68078ac32bc5 100644 --- a/module/os/linux/spl/spl-zlib.c +++ b/module/os/linux/spl/spl-zlib.c @@ -53,7 +53,6 @@ */ -#include #include #include #include From 937a01124a3186ad04177f35b3f0c5a2adfd2ff7 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 3 Aug 2024 14:04:08 +1000 Subject: [PATCH 106/223] config: remove HAVE___POSIX_ACL_CHMOD Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-acl.m4 | 45 ---------------------- include/os/linux/kernel/linux/vfs_compat.h | 16 -------- 2 files changed, 61 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index 3ae5dc6b6dbc..cb28fb2ebcd6 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -64,49 +64,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE], [ ]) ]) -dnl # -dnl # 3.1 API change, -dnl # posix_acl_chmod() was added as the preferred interface. -dnl # -dnl # 3.14 API change, -dnl # posix_acl_chmod() was changed to __posix_acl_chmod() -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_POSIX_ACL_CHMOD], [ - ZFS_LINUX_TEST_SRC([posix_acl_chmod], [ - #include - #include - ],[ - posix_acl_chmod(NULL, 0, 0) - ]) - - ZFS_LINUX_TEST_SRC([__posix_acl_chmod], [ - #include - #include - ],[ - __posix_acl_chmod(NULL, 0, 0) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_CHMOD], [ - AC_MSG_CHECKING([whether __posix_acl_chmod exists]) - ZFS_LINUX_TEST_RESULT([__posix_acl_chmod], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE___POSIX_ACL_CHMOD, 1, - [__posix_acl_chmod() exists]) - ],[ - AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether posix_acl_chmod exists]) - ZFS_LINUX_TEST_RESULT([posix_acl_chmod], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_POSIX_ACL_CHMOD, 1, - [posix_acl_chmod() exists]) - ],[ - ZFS_LINUX_TEST_ERROR([posix_acl_chmod()]) - ]) - ]) -]) - dnl # dnl # 3.1 API change, dnl # posix_acl_equiv_mode now wants an umode_t instead of a mode_t @@ -373,7 +330,6 @@ AC_DEFUN([ZFS_AC_KERNEL_ACL_HAS_REFCOUNT], [ AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ ZFS_AC_KERNEL_SRC_POSIX_ACL_RELEASE ZFS_AC_KERNEL_SRC_SET_CACHED_ACL_USABLE - ZFS_AC_KERNEL_SRC_POSIX_ACL_CHMOD ZFS_AC_KERNEL_SRC_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T ZFS_AC_KERNEL_SRC_POSIX_ACL_VALID_WITH_NS ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL @@ -385,7 +341,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ AC_DEFUN([ZFS_AC_KERNEL_ACL], [ ZFS_AC_KERNEL_POSIX_ACL_RELEASE ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE - ZFS_AC_KERNEL_POSIX_ACL_CHMOD ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 5e7874c5b19b..9f7bce4242da 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -231,22 +231,6 @@ zpl_forget_cached_acl(struct inode *ip, int type) } #endif /* HAVE_SET_CACHED_ACL_USABLE */ -/* - * 3.1 API change, - * posix_acl_chmod() was added as the preferred interface. - * - * 3.14 API change, - * posix_acl_chmod() was changed to __posix_acl_chmod() - */ -#ifndef HAVE___POSIX_ACL_CHMOD -#ifdef HAVE_POSIX_ACL_CHMOD -#define __posix_acl_chmod(acl, gfp, mode) posix_acl_chmod(acl, gfp, mode) -#define __posix_acl_create(acl, gfp, mode) posix_acl_create(acl, gfp, mode) -#else -#error "Unsupported kernel" -#endif /* HAVE_POSIX_ACL_CHMOD */ -#endif /* HAVE___POSIX_ACL_CHMOD */ - /* * 4.8 API change, * posix_acl_valid() now must be passed a namespace, the namespace from From 88c358cce181da5d738c86e90d2626a495324fae Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 09:42:35 +1000 Subject: [PATCH 107/223] config: remove HAVE_POSIX_ACL_RELEASE and HAVE_POSIX_ACL_RELEASE_GPL_ONLY Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-acl.m4 | 38 ---------------------- include/os/linux/kernel/linux/vfs_compat.h | 4 --- module/os/linux/zfs/zpl_xattr.c | 5 ++- 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index cb28fb2ebcd6..dedbb844baf6 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -1,39 +1,3 @@ -dnl # -dnl # Check if posix_acl_release can be used from a ZFS_META_LICENSED -dnl # module. The is_owner_or_cap macro was replaced by -dnl # inode_owner_or_capable -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_POSIX_ACL_RELEASE], [ - ZFS_LINUX_TEST_SRC([posix_acl_release], [ - #include - #include - #include - ], [ - struct posix_acl *tmp = posix_acl_alloc(1, 0); - posix_acl_release(tmp); - ], [], [ZFS_META_LICENSE]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_RELEASE], [ - AC_MSG_CHECKING([whether posix_acl_release() is available]) - ZFS_LINUX_TEST_RESULT([posix_acl_release], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_POSIX_ACL_RELEASE, 1, - [posix_acl_release() is available]) - - AC_MSG_CHECKING([whether posix_acl_release() is GPL-only]) - ZFS_LINUX_TEST_RESULT([posix_acl_release_license], [ - AC_MSG_RESULT(no) - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_POSIX_ACL_RELEASE_GPL_ONLY, 1, - [posix_acl_release() is GPL-only]) - ]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 3.14 API change, dnl # set_cached_acl() and forget_cached_acl() changed from inline to @@ -328,7 +292,6 @@ AC_DEFUN([ZFS_AC_KERNEL_ACL_HAS_REFCOUNT], [ ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ - ZFS_AC_KERNEL_SRC_POSIX_ACL_RELEASE ZFS_AC_KERNEL_SRC_SET_CACHED_ACL_USABLE ZFS_AC_KERNEL_SRC_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T ZFS_AC_KERNEL_SRC_POSIX_ACL_VALID_WITH_NS @@ -339,7 +302,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ ]) AC_DEFUN([ZFS_AC_KERNEL_ACL], [ - ZFS_AC_KERNEL_POSIX_ACL_RELEASE ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 9f7bce4242da..4a5dc957c687 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -174,9 +174,6 @@ lseek_execute( #include -#if defined(HAVE_POSIX_ACL_RELEASE) && !defined(HAVE_POSIX_ACL_RELEASE_GPL_ONLY) -#define zpl_posix_acl_release(arg) posix_acl_release(arg) -#else void zpl_posix_acl_release_impl(struct posix_acl *); static inline void @@ -192,7 +189,6 @@ zpl_posix_acl_release(struct posix_acl *acl) zpl_posix_acl_release_impl(acl); #endif } -#endif /* HAVE_POSIX_ACL_RELEASE */ #ifdef HAVE_SET_CACHED_ACL_USABLE #define zpl_set_cached_acl(ip, ty, n) set_cached_acl(ip, ty, n) diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index 4e4f5210f85d..689de19fbe18 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1532,9 +1532,8 @@ zpl_xattr_permission(xattr_filldir_t *xf, const char *name, int name_len) return (perm); } -#if defined(CONFIG_FS_POSIX_ACL) && \ - (!defined(HAVE_POSIX_ACL_RELEASE) || \ - defined(HAVE_POSIX_ACL_RELEASE_GPL_ONLY)) +#ifdef CONFIG_FS_POSIX_ACL + struct acl_rel_struct { struct acl_rel_struct *next; struct posix_acl *acl; From e954f086e0c96c3e8df74576ee03ca1aee323b88 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 09:47:34 +1000 Subject: [PATCH 108/223] config: remove HAVE_SET_ACL Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-acl.m4 | 15 ++------------- include/os/linux/zfs/sys/zpl.h | 5 +++-- module/os/linux/zfs/zpl_inode.c | 6 ------ module/os/linux/zfs/zpl_xattr.c | 2 -- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index dedbb844baf6..54c9401dfcb4 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -147,9 +147,6 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL], [ ]) ]) -dnl # -dnl # 3.14 API change, -dnl # Check if inode_operations contains the function set_acl dnl # dnl # 5.12 API change, dnl # set_acl() added a user_namespace* parameter first @@ -211,30 +208,22 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL], [ ]) AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [ - AC_MSG_CHECKING([whether iops->set_acl() exists]) + AC_MSG_CHECKING([whether iops->set_acl() with 4 args exists]) ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_userns], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists]) AC_DEFINE(HAVE_SET_ACL_USERNS, 1, [iops->set_acl() takes 4 args]) ],[ ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_mnt_idmap_dentry], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists]) AC_DEFINE(HAVE_SET_ACL_IDMAP_DENTRY, 1, [iops->set_acl() takes 4 args, arg1 is struct mnt_idmap *]) ],[ ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_userns_dentry], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists]) AC_DEFINE(HAVE_SET_ACL_USERNS_DENTRY_ARG2, 1, [iops->set_acl() takes 4 args, arg2 is struct dentry *]) ],[ - ZFS_LINUX_TEST_RESULT([inode_operations_set_acl], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists, takes 3 args]) - ],[ - ZFS_LINUX_REQUIRE_API([i_op->set_acl()], [3.14]) - ]) + AC_MSG_RESULT(no) ]) ]) ]) diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index 91a4751fffb0..e93901b3efd5 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -70,8 +70,9 @@ extern struct file_system_type zpl_fs_type; extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size); extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip, const struct qstr *qstr); + #if defined(CONFIG_FS_POSIX_ACL) -#if defined(HAVE_SET_ACL) + #if defined(HAVE_SET_ACL_IDMAP_DENTRY) extern int zpl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, struct posix_acl *acl, int type); @@ -84,7 +85,7 @@ extern int zpl_set_acl(struct user_namespace *userns, struct dentry *dentry, #else extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type); #endif /* HAVE_SET_ACL_USERNS */ -#endif /* HAVE_SET_ACL */ + #if defined(HAVE_GET_ACL_RCU) || defined(HAVE_GET_INODE_ACL) extern struct posix_acl *zpl_get_acl(struct inode *ip, int type, bool rcu); #elif defined(HAVE_GET_ACL) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index ad1753f7a071..059f74786625 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -807,9 +807,7 @@ const struct inode_operations zpl_inode_operations = { #endif .listxattr = zpl_xattr_list, #if defined(CONFIG_FS_POSIX_ACL) -#if defined(HAVE_SET_ACL) .set_acl = zpl_set_acl, -#endif /* HAVE_SET_ACL */ #if defined(HAVE_GET_INODE_ACL) .get_inode_acl = zpl_get_acl, #else @@ -853,9 +851,7 @@ const struct inode_operations zpl_dir_inode_operations = { #endif .listxattr = zpl_xattr_list, #if defined(CONFIG_FS_POSIX_ACL) -#if defined(HAVE_SET_ACL) .set_acl = zpl_set_acl, -#endif /* HAVE_SET_ACL */ #if defined(HAVE_GET_INODE_ACL) .get_inode_acl = zpl_get_acl, #else @@ -900,9 +896,7 @@ const struct inode_operations zpl_special_inode_operations = { #endif .listxattr = zpl_xattr_list, #if defined(CONFIG_FS_POSIX_ACL) -#if defined(HAVE_SET_ACL) .set_acl = zpl_set_acl, -#endif /* HAVE_SET_ACL */ #if defined(HAVE_GET_INODE_ACL) .get_inode_acl = zpl_get_acl, #else diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index 689de19fbe18..a1a7396c0833 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1057,7 +1057,6 @@ zpl_set_acl_impl(struct inode *ip, struct posix_acl *acl, int type) return (error); } -#ifdef HAVE_SET_ACL int #ifdef HAVE_SET_ACL_USERNS zpl_set_acl(struct user_namespace *userns, struct inode *ip, @@ -1080,7 +1079,6 @@ zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type) return (zpl_set_acl_impl(ip, acl, type)); #endif /* HAVE_SET_ACL_USERNS_DENTRY_ARG2 */ } -#endif /* HAVE_SET_ACL */ static struct posix_acl * zpl_get_acl_impl(struct inode *ip, int type) From 02daa0984627942f4a9b2f9cdddef8db16cfb6f1 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 09:50:00 +1000 Subject: [PATCH 109/223] config: remove HAVE_SET_CACHED_ACL_USABLE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-acl.m4 | 32 ------------------- include/os/linux/kernel/linux/vfs_compat.h | 37 ---------------------- module/os/linux/zfs/zpl_xattr.c | 6 ++-- 3 files changed, 3 insertions(+), 72 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index 54c9401dfcb4..b1da74173eda 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -1,33 +1,3 @@ -dnl # -dnl # 3.14 API change, -dnl # set_cached_acl() and forget_cached_acl() changed from inline to -dnl # EXPORT_SYMBOL. In the former case, they may not be usable because of -dnl # posix_acl_release. In the latter case, we can always use them. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_SET_CACHED_ACL_USABLE], [ - ZFS_LINUX_TEST_SRC([set_cached_acl], [ - #include - #include - #include - ], [ - struct inode *ip = NULL; - struct posix_acl *acl = posix_acl_alloc(1, 0); - set_cached_acl(ip, ACL_TYPE_ACCESS, acl); - forget_cached_acl(ip, ACL_TYPE_ACCESS); - ], [], [ZFS_META_LICENSE]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE], [ - AC_MSG_CHECKING([whether set_cached_acl() is usable]) - ZFS_LINUX_TEST_RESULT([set_cached_acl_license], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SET_CACHED_ACL_USABLE, 1, - [set_cached_acl() is usable]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 3.1 API change, dnl # posix_acl_equiv_mode now wants an umode_t instead of a mode_t @@ -281,7 +251,6 @@ AC_DEFUN([ZFS_AC_KERNEL_ACL_HAS_REFCOUNT], [ ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ - ZFS_AC_KERNEL_SRC_SET_CACHED_ACL_USABLE ZFS_AC_KERNEL_SRC_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T ZFS_AC_KERNEL_SRC_POSIX_ACL_VALID_WITH_NS ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL @@ -291,7 +260,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ ]) AC_DEFUN([ZFS_AC_KERNEL_ACL], [ - ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 4a5dc957c687..1aa8ef1fd2d9 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -190,43 +190,6 @@ zpl_posix_acl_release(struct posix_acl *acl) #endif } -#ifdef HAVE_SET_CACHED_ACL_USABLE -#define zpl_set_cached_acl(ip, ty, n) set_cached_acl(ip, ty, n) -#define zpl_forget_cached_acl(ip, ty) forget_cached_acl(ip, ty) -#else -static inline void -zpl_set_cached_acl(struct inode *ip, int type, struct posix_acl *newer) -{ - struct posix_acl *older = NULL; - - spin_lock(&ip->i_lock); - - if ((newer != ACL_NOT_CACHED) && (newer != NULL)) - posix_acl_dup(newer); - - switch (type) { - case ACL_TYPE_ACCESS: - older = ip->i_acl; - rcu_assign_pointer(ip->i_acl, newer); - break; - case ACL_TYPE_DEFAULT: - older = ip->i_default_acl; - rcu_assign_pointer(ip->i_default_acl, newer); - break; - } - - spin_unlock(&ip->i_lock); - - zpl_posix_acl_release(older); -} - -static inline void -zpl_forget_cached_acl(struct inode *ip, int type) -{ - zpl_set_cached_acl(ip, type, (struct posix_acl *)ACL_NOT_CACHED); -} -#endif /* HAVE_SET_CACHED_ACL_USABLE */ - /* * 4.8 API change, * posix_acl_valid() now must be passed a namespace, the namespace from diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index a1a7396c0833..9c0559333eb6 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1049,9 +1049,9 @@ zpl_set_acl_impl(struct inode *ip, struct posix_acl *acl, int type) if (!error) { if (acl) - zpl_set_cached_acl(ip, type, acl); + set_cached_acl(ip, type, acl); else - zpl_forget_cached_acl(ip, type); + forget_cached_acl(ip, type); } return (error); @@ -1129,7 +1129,7 @@ zpl_get_acl_impl(struct inode *ip, int type) /* As of Linux 4.7, the kernel get_acl will set this for us */ #ifndef HAVE_KERNEL_GET_ACL_HANDLE_CACHE if (!IS_ERR(acl)) - zpl_set_cached_acl(ip, type, acl); + set_cached_acl(ip, type, acl); #endif return (acl); From 5f73630e9cbea5efa23d16809f06e0d08523b241 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 10:11:03 +1000 Subject: [PATCH 110/223] config: remove HAVE_SPLIT_SHRINKER_CALLBACK and HAVE_SINGLE_SHRINKER_CALLBACK Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-shrink.m4 | 110 +++++------------------------ module/os/linux/spl/spl-shrinker.c | 46 ++---------- module/os/linux/zfs/zfs_vfsops.c | 79 +-------------------- 3 files changed, 24 insertions(+), 211 deletions(-) diff --git a/config/kernel-shrink.m4 b/config/kernel-shrink.m4 index 4879a129af01..30ea1c2698ef 100644 --- a/config/kernel-shrink.m4 +++ b/config/kernel-shrink.m4 @@ -83,6 +83,11 @@ AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [ ]) ]) +dnl # +dnl # 6.0 API change +dnl # register_shrinker() becomes a var-arg function that takes +dnl # a printf-style format string as args > 0 +dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG], [ ZFS_LINUX_TEST_SRC([register_shrinker_vararg], [ #include @@ -98,30 +103,14 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG], [ ]) ]) -AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [ - ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [ - #include - static int shrinker_cb(struct shrinker *shrink, - struct shrink_control *sc) { return 0; } - ],[ - struct shrinker cache_shrinker = { - .shrink = shrinker_cb, - .seeks = DEFAULT_SEEKS, - }; - register_shrinker(&cache_shrinker); - ]) - - ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [ - #include - static unsigned long shrinker_cb(struct shrinker *shrink, - struct shrink_control *sc) { return 0; } +AC_DEFUN([ZFS_AC_KERNEL_REGISTER_SHRINKER_VARARG],[ + AC_MSG_CHECKING([whether new var-arg register_shrinker() exists]) + ZFS_LINUX_TEST_RESULT([register_shrinker_vararg], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_REGISTER_SHRINKER_VARARG, 1, + [register_shrinker is vararg]) ],[ - struct shrinker cache_shrinker = { - .count_objects = shrinker_cb, - .scan_objects = shrinker_cb, - .seeks = DEFAULT_SEEKS, - }; - register_shrinker(&cache_shrinker); + AC_MSG_RESULT(no) ]) ]) @@ -144,75 +133,12 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER], [ ]) ]) -AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[ - dnl # - dnl # 6.0 API change - dnl # register_shrinker() becomes a var-arg function that takes - dnl # a printf-style format string as args > 0 - dnl # - AC_MSG_CHECKING([whether new var-arg register_shrinker() exists]) - ZFS_LINUX_TEST_RESULT([register_shrinker_vararg], [ +AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_REGISTER], [ + ZFS_LINUX_TEST_RESULT([shrinker_register], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_REGISTER_SHRINKER_VARARG, 1, - [register_shrinker is vararg]) - - dnl # We assume that the split shrinker callback exists if the - dnl # vararg register_shrinker() exists, because the latter is - dnl # a much more recent addition, and the macro test for the - dnl # var-arg version only works if the callback is split - AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1, - [cs->count_objects exists]) - ],[ + AC_DEFINE(HAVE_SHRINKER_REGISTER, 1, [shrinker_register exists]) + ], [ AC_MSG_RESULT(no) - dnl # - dnl # 3.0 - 3.11 API change - dnl # cs->shrink(struct shrinker *, struct shrink_control *sc) - dnl # - AC_MSG_CHECKING([whether new 2-argument shrinker exists]) - ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1, - [new shrinker callback wants 2 args]) - ],[ - AC_MSG_RESULT(no) - - dnl # - dnl # 3.12 API change, - dnl # cs->shrink() is logically split in to - dnl # cs->count_objects() and cs->scan_objects() - dnl # - AC_MSG_CHECKING( - [whether cs->count_objects callback exists]) - ZFS_LINUX_TEST_RESULT( - [shrinker_cb_shrink_control_split],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1, - [cs->count_objects exists]) - ],[ - AC_MSG_RESULT(no) - - AC_MSG_CHECKING( - [whether shrinker_register exists]) - ZFS_LINUX_TEST_RESULT([shrinker_register], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SHRINKER_REGISTER, 1, - [shrinker_register exists]) - - dnl # We assume that the split shrinker - dnl # callback exists if - dnl # shrinker_register() exists, - dnl # because the latter is a much more - dnl # recent addition, and the macro - dnl # test for shrinker_register() only - dnl # works if the callback is split - AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, - 1, [cs->count_objects exists]) - ],[ - AC_MSG_RESULT(no) - ZFS_LINUX_TEST_ERROR([shrinker]) - ]) - ]) - ]) ]) ]) @@ -220,7 +146,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [ ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID - ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER ]) @@ -228,5 +153,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [ AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [ ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID - ZFS_AC_KERNEL_SHRINKER_CALLBACK + ZFS_AC_KERNEL_REGISTER_SHRINKER_VARARG + ZFS_AC_KERNEL_SHRINKER_REGISTER ]) diff --git a/module/os/linux/spl/spl-shrinker.c b/module/os/linux/spl/spl-shrinker.c index d5c8da471cbb..ff1c196d09f6 100644 --- a/module/os/linux/spl/spl-shrinker.c +++ b/module/os/linux/spl/spl-shrinker.c @@ -26,25 +26,6 @@ #include #include -#ifdef HAVE_SINGLE_SHRINKER_CALLBACK -/* 3.0-3.11: single shrink() callback, which we wrap to carry both functions */ -struct spl_shrinker_wrap { - struct shrinker shrinker; - spl_shrinker_cb countfunc; - spl_shrinker_cb scanfunc; -}; - -static int -spl_shrinker_single_cb(struct shrinker *shrinker, struct shrink_control *sc) -{ - struct spl_shrinker_wrap *sw = (struct spl_shrinker_wrap *)shrinker; - - if (sc->nr_to_scan != 0) - (void) sw->scanfunc(&sw->shrinker, sc); - return (sw->countfunc(&sw->shrinker, sc)); -} -#endif - struct shrinker * spl_register_shrinker(const char *name, spl_shrinker_cb countfunc, spl_shrinker_cb scanfunc, int seek_cost) @@ -52,34 +33,20 @@ spl_register_shrinker(const char *name, spl_shrinker_cb countfunc, struct shrinker *shrinker; /* allocate shrinker */ -#if defined(HAVE_SHRINKER_REGISTER) +#ifdef HAVE_SHRINKER_REGISTER /* 6.7: kernel will allocate the shrinker for us */ shrinker = shrinker_alloc(0, name); -#elif defined(HAVE_SPLIT_SHRINKER_CALLBACK) - /* 3.12-6.6: we allocate the shrinker */ - shrinker = kmem_zalloc(sizeof (struct shrinker), KM_SLEEP); -#elif defined(HAVE_SINGLE_SHRINKER_CALLBACK) - /* 3.0-3.11: allocate a wrapper */ - struct spl_shrinker_wrap *sw = - kmem_zalloc(sizeof (struct spl_shrinker_wrap), KM_SLEEP); - shrinker = &sw->shrinker; #else - /* 2.x-2.6.22, or a newer shrinker API has been introduced. */ -#error "Unknown shrinker API" + /* 4.4-6.6: we allocate the shrinker */ + shrinker = kmem_zalloc(sizeof (struct shrinker), KM_SLEEP); #endif if (shrinker == NULL) return (NULL); /* set callbacks */ -#ifdef HAVE_SINGLE_SHRINKER_CALLBACK - sw->countfunc = countfunc; - sw->scanfunc = scanfunc; - shrinker->shrink = spl_shrinker_single_cb; -#else shrinker->count_objects = countfunc; shrinker->scan_objects = scanfunc; -#endif /* set params */ shrinker->seeks = seek_cost; @@ -102,14 +69,9 @@ spl_unregister_shrinker(struct shrinker *shrinker) { #if defined(HAVE_SHRINKER_REGISTER) shrinker_free(shrinker); -#elif defined(HAVE_SPLIT_SHRINKER_CALLBACK) +#else unregister_shrinker(shrinker); kmem_free(shrinker, sizeof (struct shrinker)); -#elif defined(HAVE_SINGLE_SHRINKER_CALLBACK) - unregister_shrinker(shrinker); - kmem_free(shrinker, sizeof (struct spl_shrinker_wrap)); -#else -#error "Unknown shrinker API" #endif } EXPORT_SYMBOL(spl_unregister_shrinker); diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index 617d7d74a36d..9f9722bf67ab 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -1179,64 +1179,6 @@ zfs_root(zfsvfs_t *zfsvfs, struct inode **ipp) return (error); } -/* - * Linux kernels older than 3.1 do not support a per-filesystem shrinker. - * To accommodate this we must improvise and manually walk the list of znodes - * attempting to prune dentries in order to be able to drop the inodes. - * - * To avoid scanning the same znodes multiple times they are always rotated - * to the end of the z_all_znodes list. New znodes are inserted at the - * end of the list so we're always scanning the oldest znodes first. - */ -static int -zfs_prune_aliases(zfsvfs_t *zfsvfs, unsigned long nr_to_scan) -{ - znode_t **zp_array, *zp; - int max_array = MIN(nr_to_scan, PAGE_SIZE * 8 / sizeof (znode_t *)); - int objects = 0; - int i = 0, j = 0; - - zp_array = vmem_zalloc(max_array * sizeof (znode_t *), KM_SLEEP); - - mutex_enter(&zfsvfs->z_znodes_lock); - while ((zp = list_head(&zfsvfs->z_all_znodes)) != NULL) { - - if ((i++ > nr_to_scan) || (j >= max_array)) - break; - - ASSERT(list_link_active(&zp->z_link_node)); - list_remove(&zfsvfs->z_all_znodes, zp); - list_insert_tail(&zfsvfs->z_all_znodes, zp); - - /* Skip active znodes and .zfs entries */ - if (MUTEX_HELD(&zp->z_lock) || zp->z_is_ctldir) - continue; - - if (igrab(ZTOI(zp)) == NULL) - continue; - - zp_array[j] = zp; - j++; - } - mutex_exit(&zfsvfs->z_znodes_lock); - - for (i = 0; i < j; i++) { - zp = zp_array[i]; - - ASSERT3P(zp, !=, NULL); - d_prune_aliases(ZTOI(zp)); - - if (atomic_read(&ZTOI(zp)->i_count) == 1) - objects++; - - zrele(zp); - } - - vmem_free(zp_array, max_array * sizeof (znode_t *)); - - return (objects); -} - /* * The ARC has requested that the filesystem drop entries from the dentry * and inode caches. This can occur when the ARC needs to free meta data @@ -1262,8 +1204,7 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects) if ((error = zfs_enter(zfsvfs, FTAG)) != 0) return (error); -#if defined(HAVE_SPLIT_SHRINKER_CALLBACK) && \ - defined(SHRINK_CONTROL_HAS_NID) && \ +#if defined(SHRINK_CONTROL_HAS_NID) && \ defined(SHRINKER_NUMA_AWARE) if (shrinker->flags & SHRINKER_NUMA_AWARE) { *objects = 0; @@ -1278,24 +1219,8 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects) } else { *objects = (*shrinker->scan_objects)(shrinker, &sc); } - -#elif defined(HAVE_SPLIT_SHRINKER_CALLBACK) +#else *objects = (*shrinker->scan_objects)(shrinker, &sc); -#elif defined(HAVE_SINGLE_SHRINKER_CALLBACK) - *objects = (*shrinker->shrink)(shrinker, &sc); -#define D_PRUNE_ALIASES_IS_DEFAULT - *objects = zfs_prune_aliases(zfsvfs, nr_to_scan); -#endif - -#ifndef D_PRUNE_ALIASES_IS_DEFAULT -#undef D_PRUNE_ALIASES_IS_DEFAULT - /* - * Fall back to zfs_prune_aliases if the kernel's per-superblock - * shrinker couldn't free anything, possibly due to the inodes being - * allocated in a different memcg. - */ - if (*objects == 0) - *objects = zfs_prune_aliases(zfsvfs, nr_to_scan); #endif zfs_exit(zfsvfs, FTAG); From a184db86a55f5364496dffc1252231b550dcd3dd Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 10:26:48 +1000 Subject: [PATCH 111/223] config: remove HAVE_USER_NS_COMMON_INUM Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-user-ns-inum.m4 | 23 ----------------------- config/kernel.m4 | 2 -- module/os/linux/spl/spl-zone.c | 20 ++++++++------------ 3 files changed, 8 insertions(+), 37 deletions(-) delete mode 100644 config/kernel-user-ns-inum.m4 diff --git a/config/kernel-user-ns-inum.m4 b/config/kernel-user-ns-inum.m4 deleted file mode 100644 index 2207a4aa6921..000000000000 --- a/config/kernel-user-ns-inum.m4 +++ /dev/null @@ -1,23 +0,0 @@ -dnl # -dnl # 3.18 API change -dnl # struct user_namespace inum moved from .proc_inum to .ns.inum. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_USER_NS_COMMON_INUM], [ - ZFS_LINUX_TEST_SRC([user_ns_common_inum], [ - #include - ], [ - struct user_namespace uns; - uns.ns.inum = 0; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_USER_NS_COMMON_INUM], [ - AC_MSG_CHECKING([whether user_namespace->ns.inum exists]) - ZFS_LINUX_TEST_RESULT([user_ns_common_inum], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_USER_NS_COMMON_INUM, 1, - [user_namespace->ns.inum exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 52db9449b7b0..c7fa69beee41 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -144,7 +144,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_KTHREAD ZFS_AC_KERNEL_SRC_ZERO_PAGE ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC - ZFS_AC_KERNEL_SRC_USER_NS_COMMON_INUM ZFS_AC_KERNEL_SRC_IDMAP_MNT_API ZFS_AC_KERNEL_SRC_IDMAP_NO_USERNS ZFS_AC_KERNEL_SRC_IATTR_VFSID @@ -284,7 +283,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_KTHREAD ZFS_AC_KERNEL_ZERO_PAGE ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC - ZFS_AC_KERNEL_USER_NS_COMMON_INUM ZFS_AC_KERNEL_IDMAP_MNT_API ZFS_AC_KERNEL_IDMAP_NO_USERNS ZFS_AC_KERNEL_IATTR_VFSID diff --git a/module/os/linux/spl/spl-zone.c b/module/os/linux/spl/spl-zone.c index d0d0cca154a7..58b5e0dc44b7 100644 --- a/module/os/linux/spl/spl-zone.c +++ b/module/os/linux/spl/spl-zone.c @@ -54,7 +54,7 @@ typedef struct zone_dataset { char zd_dsname[]; /* name of the member dataset */ } zone_dataset_t; -#if defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM) +#ifdef CONFIG_USER_NS /* * Returns: * - 0 on success @@ -95,18 +95,14 @@ user_ns_get(int fd, struct user_namespace **userns) return (error); } -#endif /* defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM) */ +#endif /* CONFIG_USER_NS */ static unsigned int user_ns_zoneid(struct user_namespace *user_ns) { unsigned int r; -#if defined(HAVE_USER_NS_COMMON_INUM) r = user_ns->ns.inum; -#else - r = user_ns->proc_inum; -#endif return (r); } @@ -123,7 +119,7 @@ zone_datasets_lookup(unsigned int nsinum) return (NULL); } -#if defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM) +#ifdef CONFIG_USER_NS static struct zone_dataset * zone_dataset_lookup(zone_datasets_t *zds, const char *dataset, size_t dsnamelen) { @@ -148,7 +144,7 @@ zone_dataset_cred_check(cred_t *cred) return (0); } -#endif /* defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM) */ +#endif /* CONFIG_USER_NS */ static int zone_dataset_name_check(const char *dataset, size_t *dsnamelen) @@ -168,7 +164,7 @@ zone_dataset_name_check(const char *dataset, size_t *dsnamelen) int zone_dataset_attach(cred_t *cred, const char *dataset, int userns_fd) { -#if defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM) +#ifdef CONFIG_USER_NS struct user_namespace *userns; zone_datasets_t *zds; zone_dataset_t *zd; @@ -213,14 +209,14 @@ zone_dataset_attach(cred_t *cred, const char *dataset, int userns_fd) return (0); #else return (ENXIO); -#endif /* defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM) */ +#endif /* CONFIG_USER_NS */ } EXPORT_SYMBOL(zone_dataset_attach); int zone_dataset_detach(cred_t *cred, const char *dataset, int userns_fd) { -#if defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM) +#ifdef CONFIG_USER_NS struct user_namespace *userns; zone_datasets_t *zds; zone_dataset_t *zd; @@ -262,7 +258,7 @@ zone_dataset_detach(cred_t *cred, const char *dataset, int userns_fd) return (0); #else return (ENXIO); -#endif /* defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM) */ +#endif /* CONFIG_USER_NS */ } EXPORT_SYMBOL(zone_dataset_detach); From a9a6d78a9b8dec10bb5fe82245325481ef371963 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 10:28:38 +1000 Subject: [PATCH 112/223] config: remove HAVE_VFS_RW_ITERATE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-new-sync-rw.m4 | 29 ++++++ config/kernel-vfs-rw-iterate.m4 | 56 ----------- config/kernel.m4 | 4 +- module/os/linux/zfs/zpl_file.c | 161 ++++--------------------------- 4 files changed, 51 insertions(+), 199 deletions(-) create mode 100644 config/kernel-vfs-new-sync-rw.m4 delete mode 100644 config/kernel-vfs-rw-iterate.m4 diff --git a/config/kernel-vfs-new-sync-rw.m4 b/config/kernel-vfs-new-sync-rw.m4 new file mode 100644 index 000000000000..c7332f373216 --- /dev/null +++ b/config/kernel-vfs-new-sync-rw.m4 @@ -0,0 +1,29 @@ +dnl # +dnl # Linux 4.1 API +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_NEW_SYNC_RW], [ + ZFS_LINUX_TEST_SRC([new_sync_rw], [ + #include + ],[ + ssize_t ret __attribute__ ((unused)); + struct file *filp = NULL; + char __user *rbuf = NULL; + const char __user *wbuf = NULL; + size_t len = 0; + loff_t ppos; + + ret = new_sync_read(filp, rbuf, len, &ppos); + ret = new_sync_write(filp, wbuf, len, &ppos); + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_VFS_NEW_SYNC_RW], [ + AC_MSG_CHECKING([whether new_sync_read/write() are available]) + ZFS_LINUX_TEST_RESULT([new_sync_rw], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NEW_SYNC_READ, 1, + [new_sync_read()/new_sync_write() are available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-vfs-rw-iterate.m4 b/config/kernel-vfs-rw-iterate.m4 deleted file mode 100644 index 7c568e94fbec..000000000000 --- a/config/kernel-vfs-rw-iterate.m4 +++ /dev/null @@ -1,56 +0,0 @@ -dnl # -dnl # Linux 3.16 API -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE], [ - ZFS_LINUX_TEST_SRC([file_operations_rw], [ - #include - - static ssize_t test_read(struct kiocb *kiocb, struct iov_iter *to) - { return 0; } - static ssize_t test_write(struct kiocb *kiocb, struct iov_iter *from) - { return 0; } - - static const struct file_operations - fops __attribute__ ((unused)) = { - .read_iter = test_read, - .write_iter = test_write, - }; - ],[]) - - ZFS_LINUX_TEST_SRC([new_sync_rw], [ - #include - ],[ - ssize_t ret __attribute__ ((unused)); - struct file *filp = NULL; - char __user *rbuf = NULL; - const char __user *wbuf = NULL; - size_t len = 0; - loff_t ppos; - - ret = new_sync_read(filp, rbuf, len, &ppos); - ret = new_sync_write(filp, wbuf, len, &ppos); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_VFS_RW_ITERATE], [ - AC_MSG_CHECKING([whether fops->read/write_iter() are available]) - ZFS_LINUX_TEST_RESULT([file_operations_rw], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_VFS_RW_ITERATE, 1, - [fops->read/write_iter() are available]) - - dnl # - dnl # Linux 4.1 API - dnl # - AC_MSG_CHECKING([whether new_sync_read/write() are available]) - ZFS_LINUX_TEST_RESULT([new_sync_rw], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_NEW_SYNC_READ, 1, - [new_sync_read()/new_sync_write() are available]) - ],[ - AC_MSG_RESULT(no) - ]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index c7fa69beee41..b5de5ab46ea7 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -102,7 +102,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO ZFS_AC_KERNEL_SRC_VFS_READPAGES ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS - ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE + ZFS_AC_KERNEL_SRC_VFS_NEW_SYNC_RW ZFS_AC_KERNEL_SRC_VFS_IOV_ITER ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE @@ -241,7 +241,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VFS_DIRECT_IO ZFS_AC_KERNEL_VFS_READPAGES ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS - ZFS_AC_KERNEL_VFS_RW_ITERATE + ZFS_AC_KERNEL_VFS_NEW_SYNC_RW ZFS_AC_KERNEL_VFS_IOV_ITER ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index d0eaa6289f26..0c9e6f94e186 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -240,8 +240,6 @@ zpl_file_accessed(struct file *filp) } } -#if defined(HAVE_VFS_RW_ITERATE) - /* * When HAVE_VFS_IOV_ITER is defined the iov_iter structure supports * iovecs, kvevs, bvecs and pipes, plus all the required interfaces to @@ -277,14 +275,14 @@ zpl_iter_read(struct kiocb *kiocb, struct iov_iter *to) crhold(cr); cookie = spl_fstrans_mark(); - int error = -zfs_read(ITOZ(filp->f_mapping->host), &uio, + ssize_t ret = -zfs_read(ITOZ(filp->f_mapping->host), &uio, filp->f_flags | zfs_io_flags(kiocb), cr); spl_fstrans_unmark(cookie); crfree(cr); - if (error < 0) - return (error); + if (ret < 0) + return (ret); ssize_t read = count - uio.uio_resid; kiocb->ki_pos += read; @@ -327,169 +325,56 @@ zpl_iter_write(struct kiocb *kiocb, struct iov_iter *from) crhold(cr); cookie = spl_fstrans_mark(); - int error = -zfs_write(ITOZ(ip), &uio, + ret = -zfs_write(ITOZ(ip), &uio, filp->f_flags | zfs_io_flags(kiocb), cr); spl_fstrans_unmark(cookie); crfree(cr); - if (error < 0) - return (error); - - ssize_t wrote = count - uio.uio_resid; - kiocb->ki_pos += wrote; - - return (wrote); -} - -#else /* !HAVE_VFS_RW_ITERATE */ - -static ssize_t -zpl_aio_read(struct kiocb *kiocb, const struct iovec *iov, - unsigned long nr_segs, loff_t pos) -{ - cred_t *cr = CRED(); - fstrans_cookie_t cookie; - struct file *filp = kiocb->ki_filp; - size_t count; - ssize_t ret; - - ret = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE); - if (ret) + if (ret < 0) return (ret); - zfs_uio_t uio; - zfs_uio_iovec_init(&uio, iov, nr_segs, kiocb->ki_pos, UIO_USERSPACE, - count, 0); - - crhold(cr); - cookie = spl_fstrans_mark(); - - int error = -zfs_read(ITOZ(filp->f_mapping->host), &uio, - filp->f_flags | zfs_io_flags(kiocb), cr); - - spl_fstrans_unmark(cookie); - crfree(cr); - - if (error < 0) - return (error); - - ssize_t read = count - uio.uio_resid; - kiocb->ki_pos += read; - - zpl_file_accessed(filp); - - return (read); -} - -static ssize_t -zpl_aio_write(struct kiocb *kiocb, const struct iovec *iov, - unsigned long nr_segs, loff_t pos) -{ - cred_t *cr = CRED(); - fstrans_cookie_t cookie; - struct file *filp = kiocb->ki_filp; - struct inode *ip = filp->f_mapping->host; - size_t count; - ssize_t ret; - - ret = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ); - if (ret) - return (ret); - - ret = generic_write_checks(filp, &pos, &count, S_ISBLK(ip->i_mode)); - if (ret) - return (ret); - - kiocb->ki_pos = pos; - - zfs_uio_t uio; - zfs_uio_iovec_init(&uio, iov, nr_segs, kiocb->ki_pos, UIO_USERSPACE, - count, 0); - - crhold(cr); - cookie = spl_fstrans_mark(); - - int error = -zfs_write(ITOZ(ip), &uio, - filp->f_flags | zfs_io_flags(kiocb), cr); - - spl_fstrans_unmark(cookie); - crfree(cr); - - if (error < 0) - return (error); - ssize_t wrote = count - uio.uio_resid; kiocb->ki_pos += wrote; return (wrote); } -#endif /* HAVE_VFS_RW_ITERATE */ -#if defined(HAVE_VFS_RW_ITERATE) static ssize_t -zpl_direct_IO_impl(int rw, struct kiocb *kiocb, struct iov_iter *iter) +zpl_direct_IO_impl(void) { - if (rw == WRITE) - return (zpl_iter_write(kiocb, iter)); - else - return (zpl_iter_read(kiocb, iter)); + /* + * All O_DIRECT requests should be handled by + * zpl_{iter/aio}_{write/read}(). There is no way kernel generic code + * should call the direct_IO address_space_operations function. We set + * this code path to be fatal if it is executed. + */ + PANIC(0); + return (0); } + #if defined(HAVE_VFS_DIRECT_IO_ITER) static ssize_t zpl_direct_IO(struct kiocb *kiocb, struct iov_iter *iter) { - return (zpl_direct_IO_impl(iov_iter_rw(iter), kiocb, iter)); + return (zpl_direct_IO_impl()); } #elif defined(HAVE_VFS_DIRECT_IO_ITER_OFFSET) static ssize_t zpl_direct_IO(struct kiocb *kiocb, struct iov_iter *iter, loff_t pos) { - ASSERT3S(pos, ==, kiocb->ki_pos); - return (zpl_direct_IO_impl(iov_iter_rw(iter), kiocb, iter)); + return (zpl_direct_IO_impl()); } #elif defined(HAVE_VFS_DIRECT_IO_ITER_RW_OFFSET) static ssize_t zpl_direct_IO(int rw, struct kiocb *kiocb, struct iov_iter *iter, loff_t pos) { - ASSERT3S(pos, ==, kiocb->ki_pos); - return (zpl_direct_IO_impl(rw, kiocb, iter)); + return (zpl_direct_IO_impl()); } #else -#error "Unknown direct IO interface" +#error "Unknown Direct I/O interface" #endif -#else /* HAVE_VFS_RW_ITERATE */ - -#if defined(HAVE_VFS_DIRECT_IO_IOVEC) -static ssize_t -zpl_direct_IO(int rw, struct kiocb *kiocb, const struct iovec *iov, - loff_t pos, unsigned long nr_segs) -{ - if (rw == WRITE) - return (zpl_aio_write(kiocb, iov, nr_segs, pos)); - else - return (zpl_aio_read(kiocb, iov, nr_segs, pos)); -} -#elif defined(HAVE_VFS_DIRECT_IO_ITER_RW_OFFSET) -static ssize_t -zpl_direct_IO(int rw, struct kiocb *kiocb, struct iov_iter *iter, loff_t pos) -{ - const struct iovec *iovp = iov_iter_iovec(iter); - unsigned long nr_segs = iter->nr_segs; - - ASSERT3S(pos, ==, kiocb->ki_pos); - if (rw == WRITE) - return (zpl_aio_write(kiocb, iovp, nr_segs, pos)); - else - return (zpl_aio_read(kiocb, iovp, nr_segs, pos)); -} -#else -#error "Unknown direct IO interface" -#endif - -#endif /* HAVE_VFS_RW_ITERATE */ - static loff_t zpl_llseek(struct file *filp, loff_t offset, int whence) { @@ -570,6 +455,7 @@ zpl_mmap(struct file *filp, struct vm_area_struct *vma) error = -zfs_map(ip, vma->vm_pgoff, (caddr_t *)vma->vm_start, (size_t)(vma->vm_end - vma->vm_start), vma->vm_flags); spl_fstrans_unmark(cookie); + if (error) return (error); @@ -1255,7 +1141,6 @@ const struct file_operations zpl_file_operations = { .open = zpl_open, .release = zpl_release, .llseek = zpl_llseek, -#ifdef HAVE_VFS_RW_ITERATE #ifdef HAVE_NEW_SYNC_READ .read = new_sync_read, .write = new_sync_write, @@ -1269,12 +1154,6 @@ const struct file_operations zpl_file_operations = { .splice_read = generic_file_splice_read, #endif .splice_write = iter_file_splice_write, -#endif -#else - .read = do_sync_read, - .write = do_sync_write, - .aio_read = zpl_aio_read, - .aio_write = zpl_aio_write, #endif .mmap = zpl_mmap, .fsync = zpl_fsync, From eb6e61bc9af81779fdaa28941ce48fbf6ec61d2f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 10:34:18 +1000 Subject: [PATCH 113/223] config: remove SHRINK_CONTROL_HAS_NID Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-shrink.m4 | 28 ---------------------------- module/os/linux/zfs/zfs_vfsops.c | 3 +-- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/config/kernel-shrink.m4 b/config/kernel-shrink.m4 index 30ea1c2698ef..77300e1589e1 100644 --- a/config/kernel-shrink.m4 +++ b/config/kernel-shrink.m4 @@ -57,32 +57,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK], [ ]) ]) -dnl # -dnl # 3.12 API change -dnl # The nid member was added to struct shrink_control to support -dnl # NUMA-aware shrinkers. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [ - ZFS_LINUX_TEST_SRC([shrink_control_nid], [ - #include - ],[ - struct shrink_control sc __attribute__ ((unused)); - unsigned long scnidsize __attribute__ ((unused)) = - sizeof(sc.nid); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [ - AC_MSG_CHECKING([whether shrink_control has nid]) - ZFS_LINUX_TEST_RESULT([shrink_control_nid], [ - AC_MSG_RESULT(yes) - AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1, - [struct shrink_control has nid]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 6.0 API change dnl # register_shrinker() becomes a var-arg function that takes @@ -145,14 +119,12 @@ AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_REGISTER], [ AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [ ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR - ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER ]) AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [ ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK - ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID ZFS_AC_KERNEL_REGISTER_SHRINKER_VARARG ZFS_AC_KERNEL_SHRINKER_REGISTER ]) diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index 9f9722bf67ab..97e65a04ad7e 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -1204,8 +1204,7 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects) if ((error = zfs_enter(zfsvfs, FTAG)) != 0) return (error); -#if defined(SHRINK_CONTROL_HAS_NID) && \ - defined(SHRINKER_NUMA_AWARE) +#ifdef SHRINKER_NUMA_AWARE if (shrinker->flags & SHRINKER_NUMA_AWARE) { *objects = 0; for_each_online_node(sc.nid) { From 251c5fa39ba1c7fb2870b8151eeeb7f25ec274a6 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 13:16:42 +1000 Subject: [PATCH 114/223] config: remove HAVE_3ARGS_BDI_SETUP_AND_REGISTER Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bdi.m4 | 27 +-------------------- include/os/linux/kernel/linux/vfs_compat.h | 28 ---------------------- 2 files changed, 1 insertion(+), 54 deletions(-) diff --git a/config/kernel-bdi.m4 b/config/kernel-bdi.m4 index 9758863a9cbf..95f1291dde8c 100644 --- a/config/kernel-bdi.m4 +++ b/config/kernel-bdi.m4 @@ -23,16 +23,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BDI], [ int error __attribute__((unused)) = bdi_setup_and_register(&bdi, name); ]) - - ZFS_LINUX_TEST_SRC([bdi_setup_and_register_3args], [ - #include - struct backing_dev_info bdi; - ], [ - char *name = "bdi"; - unsigned int cap = BDI_CAP_MAP_COPY; - int error __attribute__((unused)) = - bdi_setup_and_register(&bdi, name, cap); - ]) ]) AC_DEFUN([ZFS_AC_KERNEL_BDI], [ @@ -60,22 +50,7 @@ AC_DEFUN([ZFS_AC_KERNEL_BDI], [ [bdi_setup_and_register() wants 2 args]) ], [ AC_MSG_RESULT(no) - - dnl # - dnl # 2.6.34 - 3.19, bdi_setup_and_register() - dnl # takes 3 arguments. - dnl # - AC_MSG_CHECKING( - [whether bdi_setup_and_register() wants 3 args]) - ZFS_LINUX_TEST_RESULT_SYMBOL( - [bdi_setup_and_register_3args], - [bdi_setup_and_register], [mm/backing-dev.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_3ARGS_BDI_SETUP_AND_REGISTER, 1, - [bdi_setup_and_register() wants 3 args]) - ], [ - ZFS_LINUX_TEST_ERROR([bdi_setup]) - ]) + ZFS_LINUX_TEST_ERROR([bdi_setup]) ]) ]) ]) diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 1aa8ef1fd2d9..f600ff80d823 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -33,7 +33,6 @@ #include /* - * 2.6.34 - 3.19, bdi_setup_and_register() takes 3 arguments. * 4.0 - 4.11, bdi_setup_and_register() takes 2 arguments. * 4.12 - x.y, super_setup_bdi_name() new interface. */ @@ -77,33 +76,6 @@ zpl_bdi_destroy(struct super_block *sb) kmem_free(bdi, sizeof (struct backing_dev_info)); sb->s_bdi = NULL; } -#elif defined(HAVE_3ARGS_BDI_SETUP_AND_REGISTER) -static inline int -zpl_bdi_setup(struct super_block *sb, char *name) -{ - struct backing_dev_info *bdi; - int error; - - bdi = kmem_zalloc(sizeof (struct backing_dev_info), KM_SLEEP); - error = bdi_setup_and_register(bdi, name, BDI_CAP_MAP_COPY); - if (error) { - kmem_free(sb->s_bdi, sizeof (struct backing_dev_info)); - return (error); - } - - sb->s_bdi = bdi; - - return (0); -} -static inline void -zpl_bdi_destroy(struct super_block *sb) -{ - struct backing_dev_info *bdi = sb->s_bdi; - - bdi_destroy(bdi); - kmem_free(bdi, sizeof (struct backing_dev_info)); - sb->s_bdi = NULL; -} #else #error "Unsupported kernel" #endif From f71866c35f7cd41eb34522c71cce9c62acf23ac4 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 13:18:20 +1000 Subject: [PATCH 115/223] config: remove HAVE_3ARGS_VFS_GETATTR Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-getattr.m4 | 27 --------------------------- module/os/linux/spl/spl-generic.c | 2 -- module/os/linux/zfs/zfs_file_os.c | 2 -- 3 files changed, 31 deletions(-) diff --git a/config/kernel-vfs-getattr.m4 b/config/kernel-vfs-getattr.m4 index eb07853cc4b9..1923d4ce8e82 100644 --- a/config/kernel-vfs-getattr.m4 +++ b/config/kernel-vfs-getattr.m4 @@ -48,39 +48,12 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_GETATTR_2ARGS], [ ]) ]) -dnl # -dnl # <3.9 API -dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k) -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_GETATTR_3ARGS], [ - ZFS_LINUX_TEST_SRC([vfs_getattr_3args], [ - #include - ],[ - vfs_getattr((struct vfsmount *)NULL, - (struct dentry *)NULL, - (struct kstat *)NULL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_VFS_GETATTR_3ARGS], [ - AC_MSG_CHECKING([whether vfs_getattr() wants 3 args]) - ZFS_LINUX_TEST_RESULT([vfs_getattr_3args], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1, - [vfs_getattr wants 3 args]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_GETATTR], [ ZFS_AC_KERNEL_SRC_VFS_GETATTR_4ARGS ZFS_AC_KERNEL_SRC_VFS_GETATTR_2ARGS - ZFS_AC_KERNEL_SRC_VFS_GETATTR_3ARGS ]) AC_DEFUN([ZFS_AC_KERNEL_VFS_GETATTR], [ ZFS_AC_KERNEL_VFS_GETATTR_4ARGS ZFS_AC_KERNEL_VFS_GETATTR_2ARGS - ZFS_AC_KERNEL_VFS_GETATTR_3ARGS ]) diff --git a/module/os/linux/spl/spl-generic.c b/module/os/linux/spl/spl-generic.c index 986db1518456..a40b4216c4cd 100644 --- a/module/os/linux/spl/spl-generic.c +++ b/module/os/linux/spl/spl-generic.c @@ -656,8 +656,6 @@ spl_getattr(struct file *filp, struct kstat *stat) AT_STATX_SYNC_AS_STAT); #elif defined(HAVE_2ARGS_VFS_GETATTR) rc = vfs_getattr(&filp->f_path, stat); -#elif defined(HAVE_3ARGS_VFS_GETATTR) - rc = vfs_getattr(filp->f_path.mnt, filp->f_dentry, stat); #else #error "No available vfs_getattr()" #endif diff --git a/module/os/linux/zfs/zfs_file_os.c b/module/os/linux/zfs/zfs_file_os.c index bc753614be27..32e71bf374a5 100644 --- a/module/os/linux/zfs/zfs_file_os.c +++ b/module/os/linux/zfs/zfs_file_os.c @@ -279,8 +279,6 @@ zfs_file_getattr(zfs_file_t *filp, zfs_file_attr_t *zfattr) AT_STATX_SYNC_AS_STAT); #elif defined(HAVE_2ARGS_VFS_GETATTR) rc = vfs_getattr(&filp->f_path, &stat); -#elif defined(HAVE_3ARGS_VFS_GETATTR) - rc = vfs_getattr(filp->f_path.mnt, filp->f_dentry, &stat); #else #error "No available vfs_getattr()" #endif From 81d780a0c4ea06a04c8024ae74356a1772a7eb2f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 13:31:02 +1000 Subject: [PATCH 116/223] config: remove HAVE_D_REVALIDATE_NAMEIDATA Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-dentry-operations.m4 | 31 ------------------------------ config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_ctldir.c | 4 ---- 3 files changed, 37 deletions(-) diff --git a/config/kernel-dentry-operations.m4 b/config/kernel-dentry-operations.m4 index 87f5c92fb59b..0166ab888d3c 100644 --- a/config/kernel-dentry-operations.m4 +++ b/config/kernel-dentry-operations.m4 @@ -42,35 +42,6 @@ AC_DEFUN([ZFS_AC_KERNEL_D_SET_D_OP], [ ]) ]) -dnl # -dnl # 3.6 API change -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_D_REVALIDATE_NAMEIDATA], [ - ZFS_LINUX_TEST_SRC([dentry_operations_revalidate], [ - #include - #include - - static int revalidate (struct dentry *dentry, - struct nameidata *nidata) { return 0; } - - static const struct dentry_operations - dops __attribute__ ((unused)) = { - .d_revalidate = revalidate, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA], [ - AC_MSG_CHECKING([whether dops->d_revalidate() takes struct nameidata]) - ZFS_LINUX_TEST_RESULT([dentry_operations_revalidate], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_D_REVALIDATE_NAMEIDATA, 1, - [dops->d_revalidate() operation takes nameidata]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.38 API change dnl # Added sb->s_d_op default dentry_operations member @@ -96,13 +67,11 @@ AC_DEFUN([ZFS_AC_KERNEL_S_D_OP], [ AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY], [ ZFS_AC_KERNEL_SRC_D_OBTAIN_ALIAS ZFS_AC_KERNEL_SRC_D_SET_D_OP - ZFS_AC_KERNEL_SRC_D_REVALIDATE_NAMEIDATA ZFS_AC_KERNEL_SRC_S_D_OP ]) AC_DEFUN([ZFS_AC_KERNEL_DENTRY], [ ZFS_AC_KERNEL_D_OBTAIN_ALIAS ZFS_AC_KERNEL_D_SET_D_OP - ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA ZFS_AC_KERNEL_S_D_OP ]) diff --git a/config/kernel.m4 b/config/kernel.m4 index b5de5ab46ea7..11d6f41035a5 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -86,7 +86,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_COMMIT_METADATA ZFS_AC_KERNEL_SRC_SETATTR_PREPARE ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED - ZFS_AC_KERNEL_SRC_DENTRY ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE ZFS_AC_KERNEL_SRC_SECURITY_INODE ZFS_AC_KERNEL_SRC_FST_MOUNT @@ -225,7 +224,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_COMMIT_METADATA ZFS_AC_KERNEL_SETATTR_PREPARE ZFS_AC_KERNEL_INSERT_INODE_LOCKED - ZFS_AC_KERNEL_DENTRY ZFS_AC_KERNEL_TRUNCATE_SETSIZE ZFS_AC_KERNEL_SECURITY_INODE ZFS_AC_KERNEL_FST_MOUNT diff --git a/module/os/linux/zfs/zpl_ctldir.c b/module/os/linux/zfs/zpl_ctldir.c index 8ee7fcecc7b7..eb8788074283 100644 --- a/module/os/linux/zfs/zpl_ctldir.c +++ b/module/os/linux/zfs/zpl_ctldir.c @@ -207,11 +207,7 @@ zpl_snapdir_automount(struct path *path) * the snapshot being immediately unmounted. */ static int -#ifdef HAVE_D_REVALIDATE_NAMEIDATA -zpl_snapdir_revalidate(struct dentry *dentry, struct nameidata *i) -#else zpl_snapdir_revalidate(struct dentry *dentry, unsigned int flags) -#endif { return (!!dentry->d_inode); } From 6d2553ae5d8e50d173d3583f99a4022166c34d83 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 13:48:12 +1000 Subject: [PATCH 117/223] config: remove HAVE_FOLLOW_LINK_NAMEIDATA Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-get-link.m4 | 25 +------------------------ module/os/linux/zfs/zpl_inode.c | 17 +---------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/config/kernel-get-link.m4 b/config/kernel-get-link.m4 index 1f8f5b0c8b72..31c7ac623d43 100644 --- a/config/kernel-get-link.m4 +++ b/config/kernel-get-link.m4 @@ -32,16 +32,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GET_LINK], [ .follow_link = follow_link, }; ],[]) - - ZFS_LINUX_TEST_SRC([inode_operations_follow_link_nameidata], [ - #include - static void *follow_link(struct dentry *de, struct - nameidata *nd) { return (void *)NULL; } - static struct inode_operations - iops __attribute__ ((unused)) = { - .follow_link = follow_link, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_GET_LINK], [ @@ -84,20 +74,7 @@ AC_DEFUN([ZFS_AC_KERNEL_GET_LINK], [ [iops->follow_link() cookie]) ],[ AC_MSG_RESULT(no) - - dnl # - dnl # 2.6.32 API - dnl # - AC_MSG_CHECKING( - [whether iops->follow_link() passes nameidata]) - ZFS_LINUX_TEST_RESULT( - [inode_operations_follow_link_nameidata],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FOLLOW_LINK_NAMEIDATA, 1, - [iops->follow_link() nameidata]) - ],[ - ZFS_LINUX_TEST_ERROR([get_link]) - ]) + ZFS_LINUX_TEST_ERROR([get_link]) ]) ]) ]) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index 059f74786625..1b7d06217fcb 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -748,21 +748,6 @@ zpl_follow_link(struct dentry *dentry, void **cookie) return (*cookie = link); } -#elif defined(HAVE_FOLLOW_LINK_NAMEIDATA) -static void * -zpl_follow_link(struct dentry *dentry, struct nameidata *nd) -{ - char *link = NULL; - int error; - - error = zpl_get_link_common(dentry, dentry->d_inode, &link); - if (error) - nd_set_link(nd, ERR_PTR(error)); - else - nd_set_link(nd, link); - - return (NULL); -} #endif static int @@ -870,7 +855,7 @@ const struct inode_operations zpl_symlink_inode_operations = { #endif #if defined(HAVE_GET_LINK_DELAYED) || defined(HAVE_GET_LINK_COOKIE) .get_link = zpl_get_link, -#elif defined(HAVE_FOLLOW_LINK_COOKIE) || defined(HAVE_FOLLOW_LINK_NAMEIDATA) +#elif defined(HAVE_FOLLOW_LINK_COOKIE) .follow_link = zpl_follow_link, #endif #if defined(HAVE_PUT_LINK_COOKIE) || defined(HAVE_PUT_LINK_NAMEIDATA) From ef2aed16d79e6a936713e0e14783427061e722a8 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 13:51:12 +1000 Subject: [PATCH 118/223] config: remove HAVE_LSEEK_EXECUTE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-lseek-execute.m4 | 27 ---------------------- config/kernel.m4 | 2 -- include/os/linux/kernel/linux/vfs_compat.h | 4 ++-- 3 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 config/kernel-lseek-execute.m4 diff --git a/config/kernel-lseek-execute.m4 b/config/kernel-lseek-execute.m4 deleted file mode 100644 index 652f611f8da4..000000000000 --- a/config/kernel-lseek-execute.m4 +++ /dev/null @@ -1,27 +0,0 @@ -dnl # -dnl # 3.11 API change -dnl # lseek_execute helper exported -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE], [ - ZFS_LINUX_TEST_SRC([lseek_execute], [ - #include - ], [ - struct file *fp __attribute__ ((unused)) = NULL; - struct inode *ip __attribute__ ((unused)) = NULL; - loff_t offset __attribute__ ((unused)) = 0; - loff_t maxsize __attribute__ ((unused)) = 0; - - lseek_execute(fp, ip, offset, maxsize); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_LSEEK_EXECUTE], [ - AC_MSG_CHECKING([whether lseek_execute() is available]) - ZFS_LINUX_TEST_RESULT_SYMBOL([lseek_execute], - [lseek_exclusive], [fs/read_write.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_LSEEK_EXECUTE, 1, [lseek_execute() is available]) - ], [ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 11d6f41035a5..b2f1cdc5a3a7 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -92,7 +92,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_BDI ZFS_AC_KERNEL_SRC_SET_NLINK ZFS_AC_KERNEL_SRC_SGET - ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO ZFS_AC_KERNEL_SRC_VFS_GETATTR @@ -230,7 +229,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_BDI ZFS_AC_KERNEL_SET_NLINK ZFS_AC_KERNEL_SGET - ZFS_AC_KERNEL_LSEEK_EXECUTE ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO ZFS_AC_KERNEL_VFS_READ_FOLIO ZFS_AC_KERNEL_VFS_GETATTR diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index f600ff80d823..3a7a190e574d 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -108,7 +108,7 @@ zpl_bdi_destroy(struct super_block *sb) #define SB_NOATIME MS_NOATIME #endif -#if defined(SEEK_HOLE) && defined(SEEK_DATA) && !defined(HAVE_LSEEK_EXECUTE) +#if defined(SEEK_HOLE) && defined(SEEK_DATA) static inline loff_t lseek_execute( struct file *filp, @@ -131,7 +131,7 @@ lseek_execute( return (offset); } -#endif /* SEEK_HOLE && SEEK_DATA && !HAVE_LSEEK_EXECUTE */ +#endif /* SEEK_HOLE && SEEK_DATA */ #if defined(CONFIG_FS_POSIX_ACL) /* From 92eeeba665e01d794720f8de5eac96fa980a22c4 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 13:58:24 +1000 Subject: [PATCH 119/223] config: remove HAVE_PUT_LINK_NAMEIDATA Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-put-link.m4 | 24 +----------------------- module/os/linux/zfs/zpl_inode.c | 11 +---------- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/config/kernel-put-link.m4 b/config/kernel-put-link.m4 index 8ab318cbff8c..901024718949 100644 --- a/config/kernel-put-link.m4 +++ b/config/kernel-put-link.m4 @@ -11,16 +11,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_PUT_LINK], [ .put_link = put_link, }; ],[]) - - ZFS_LINUX_TEST_SRC([put_link_nameidata], [ - #include - static void put_link(struct dentry *de, struct - nameidata *nd, void *ptr) { return; } - static struct inode_operations - iops __attribute__ ((unused)) = { - .put_link = put_link, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_PUT_LINK], [ @@ -43,19 +33,7 @@ AC_DEFUN([ZFS_AC_KERNEL_PUT_LINK], [ [iops->put_link() cookie]) ],[ AC_MSG_RESULT(no) - - dnl # - dnl # 2.6.32 API - dnl # - AC_MSG_CHECKING( - [whether iops->put_link() passes nameidata]) - ZFS_LINUX_TEST_RESULT([put_link_nameidata], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PUT_LINK_NAMEIDATA, 1, - [iops->put_link() nameidata]) - ],[ - ZFS_LINUX_TEST_ERROR([put_link]) - ]) + ZFS_LINUX_TEST_ERROR([put_link]) ]) ]) ]) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index 1b7d06217fcb..dfaaa6f1e636 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -653,15 +653,6 @@ zpl_put_link(struct inode *unused, void *cookie) { kmem_free(cookie, MAXPATHLEN); } -#elif defined(HAVE_PUT_LINK_NAMEIDATA) -static void -zpl_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr) -{ - const char *link = nd_get_link(nd); - - if (!IS_ERR(link)) - kmem_free(link, MAXPATHLEN); -} #elif defined(HAVE_PUT_LINK_DELAYED) static void zpl_put_link(void *ptr) @@ -858,7 +849,7 @@ const struct inode_operations zpl_symlink_inode_operations = { #elif defined(HAVE_FOLLOW_LINK_COOKIE) .follow_link = zpl_follow_link, #endif -#if defined(HAVE_PUT_LINK_COOKIE) || defined(HAVE_PUT_LINK_NAMEIDATA) +#if defined(HAVE_PUT_LINK_COOKIE) .put_link = zpl_put_link, #endif .setattr = zpl_setattr, From 8ae3b6b675c9634b1b4f1a89ab1c0defa6e73792 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 14:34:02 +1000 Subject: [PATCH 120/223] config: remove HAVE_VFS_DIRECT_IO_ITER_RW_OFFSET Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-direct_IO.m4 | 54 +--------------------------------- module/os/linux/zfs/zpl_file.c | 6 ---- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/config/kernel-vfs-direct_IO.m4 b/config/kernel-vfs-direct_IO.m4 index 7b7b91f979f9..8271c3db594c 100644 --- a/config/kernel-vfs-direct_IO.m4 +++ b/config/kernel-vfs-direct_IO.m4 @@ -25,31 +25,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO], [ .direct_IO = test_direct_IO, }; ],[]) - - ZFS_LINUX_TEST_SRC([direct_io_iter_rw_offset], [ - #include - - static ssize_t test_direct_IO(int rw, struct kiocb *kiocb, - struct iov_iter *iter, loff_t offset) { return 0; } - - static const struct address_space_operations - aops __attribute__ ((unused)) = { - .direct_IO = test_direct_IO, - }; - ],[]) - - ZFS_LINUX_TEST_SRC([direct_io_iovec], [ - #include - - static ssize_t test_direct_IO(int rw, struct kiocb *kiocb, - const struct iovec *iov, loff_t offset, - unsigned long nr_segs) { return 0; } - - static const struct address_space_operations - aops __attribute__ ((unused)) = { - .direct_IO = test_direct_IO, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_VFS_DIRECT_IO], [ @@ -76,34 +51,7 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_DIRECT_IO], [ ],[ AC_MSG_RESULT([no]) - - dnl # - dnl # Linux 3.16.x API change - dnl # - AC_MSG_CHECKING( - [whether aops->direct_IO() uses rw and offset]) - ZFS_LINUX_TEST_RESULT([direct_io_iter_rw_offset], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_VFS_DIRECT_IO_ITER_RW_OFFSET, 1, - [aops->direct_IO() uses iov_iter with ] - [rw and offset]) - ],[ - AC_MSG_RESULT([no]) - - dnl # - dnl # Ancient Linux API (predates git) - dnl # - AC_MSG_CHECKING( - [whether aops->direct_IO() uses iovec]) - ZFS_LINUX_TEST_RESULT([direct_io_iovec], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_VFS_DIRECT_IO_IOVEC, 1, - [aops->direct_IO() uses iovec]) - ],[ - ZFS_LINUX_TEST_ERROR([direct IO]) - AC_MSG_RESULT([no]) - ]) - ]) + ZFS_LINUX_TEST_ERROR([Direct I/O]) ]) ]) ]) diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 0c9e6f94e186..7eb73f2d5718 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -365,12 +365,6 @@ zpl_direct_IO(struct kiocb *kiocb, struct iov_iter *iter, loff_t pos) { return (zpl_direct_IO_impl()); } -#elif defined(HAVE_VFS_DIRECT_IO_ITER_RW_OFFSET) -static ssize_t -zpl_direct_IO(int rw, struct kiocb *kiocb, struct iov_iter *iter, loff_t pos) -{ - return (zpl_direct_IO_impl()); -} #else #error "Unknown Direct I/O interface" #endif From 4af7a697c2fafb7ca3f1dc597549018235360487 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 4 Aug 2024 14:36:28 +1000 Subject: [PATCH 121/223] config: remove HAVE_WAIT_ON_BIT_ACTION Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-wait.m4 | 31 ---------------------------- include/os/linux/spl/sys/wait.h | 16 -------------- module/os/linux/spl/spl-kmem-cache.c | 2 +- 3 files changed, 1 insertion(+), 48 deletions(-) diff --git a/config/kernel-wait.m4 b/config/kernel-wait.m4 index 0414242bf6d4..dbc6b423dc37 100644 --- a/config/kernel-wait.m4 +++ b/config/kernel-wait.m4 @@ -21,35 +21,6 @@ AC_DEFUN([ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T], [ ]) ]) -dnl # -dnl # 3.17 API change, -dnl # wait_on_bit() no longer requires an action argument. The former -dnl # "wait_on_bit" interface required an 'action' function to be provided -dnl # which does the actual waiting. There were over 20 such functions in the -dnl # kernel, many of them identical, though most cases can be satisfied by one -dnl # of just two functions: one which uses io_schedule() and one which just -dnl # uses schedule(). This API change was made to consolidate all of those -dnl # redundant wait functions. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_WAIT_ON_BIT], [ - ZFS_LINUX_TEST_SRC([wait_on_bit], [ - #include - ],[ - int (*action)(void *) = NULL; - wait_on_bit(NULL, 0, action, 0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_WAIT_ON_BIT], [ - AC_MSG_CHECKING([whether wait_on_bit() takes an action]) - ZFS_LINUX_TEST_RESULT([wait_on_bit], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 4.13 API change dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head @@ -89,11 +60,9 @@ AC_DEFUN([ZFS_AC_KERNEL_WAIT_QUEUE_HEAD_ENTRY], [ ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_WAIT], [ - ZFS_AC_KERNEL_SRC_WAIT_ON_BIT ZFS_AC_KERNEL_SRC_WAIT_QUEUE_HEAD_ENTRY ]) AC_DEFUN([ZFS_AC_KERNEL_WAIT], [ - ZFS_AC_KERNEL_WAIT_ON_BIT ZFS_AC_KERNEL_WAIT_QUEUE_HEAD_ENTRY ]) diff --git a/include/os/linux/spl/sys/wait.h b/include/os/linux/spl/sys/wait.h index 65cd83e5ef12..da30ccdf672e 100644 --- a/include/os/linux/spl/sys/wait.h +++ b/include/os/linux/spl/sys/wait.h @@ -27,22 +27,6 @@ #include #include -#ifndef HAVE_WAIT_ON_BIT_ACTION -#define spl_wait_on_bit(word, bit, mode) wait_on_bit(word, bit, mode) -#else - -static inline int -spl_bit_wait(void *word) -{ - schedule(); - return (0); -} - -#define spl_wait_on_bit(word, bit, mode) \ - wait_on_bit(word, bit, spl_bit_wait, mode) - -#endif /* HAVE_WAIT_ON_BIT_ACTION */ - #ifdef HAVE_WAIT_QUEUE_ENTRY_T typedef wait_queue_head_t spl_wait_queue_head_t; typedef wait_queue_entry_t spl_wait_queue_entry_t; diff --git a/module/os/linux/spl/spl-kmem-cache.c b/module/os/linux/spl/spl-kmem-cache.c index 96b61daf49f5..7596f97b4984 100644 --- a/module/os/linux/spl/spl-kmem-cache.c +++ b/module/os/linux/spl/spl-kmem-cache.c @@ -1022,7 +1022,7 @@ spl_cache_grow(spl_kmem_cache_t *skc, int flags, void **obj) * then return so the local magazine can be rechecked for new objects. */ if (test_bit(KMC_BIT_REAPING, &skc->skc_flags)) { - rc = spl_wait_on_bit(&skc->skc_flags, KMC_BIT_REAPING, + rc = wait_on_bit(&skc->skc_flags, KMC_BIT_REAPING, TASK_UNINTERRUPTIBLE); return (rc ? rc : -EAGAIN); } From 41bacb42f98c94fc62fa4bd64eaa974e78025e1f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 5 Aug 2024 19:47:27 +1000 Subject: [PATCH 122/223] config: remove HAVE_XATTR_(GET|SET|LIST)_DENTRY Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-xattr-handler.m4 | 102 ++----------------- include/os/linux/kernel/linux/xattr_compat.h | 42 -------- module/os/linux/zfs/zpl_xattr.c | 5 - 3 files changed, 10 insertions(+), 139 deletions(-) diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4 index 5d4eb567c48c..6a07e9ee58b3 100644 --- a/config/kernel-xattr-handler.m4 +++ b/config/kernel-xattr-handler.m4 @@ -89,18 +89,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET], [ }; ],[]) - ZFS_LINUX_TEST_SRC([xattr_handler_get_dentry], [ - #include - - static int get(struct dentry *dentry, const char *name, - void *buffer, size_t size, int handler_flags) - { return 0; } - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .get = get, - }; - ],[]) - ZFS_LINUX_TEST_SRC([xattr_handler_get_dentry_inode_flags], [ #include @@ -142,34 +130,19 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [ [xattr_handler->get() wants xattr_handler]) ],[ dnl # - dnl # 2.6.33 API change, - dnl # The xattr_handler->get() callback was changed - dnl # to take a dentry instead of an inode, and a - dnl # handler_flags argument was added. + dnl # Android API change, + dnl # The xattr_handler->get() callback was + dnl # changed to take dentry, inode and flags. dnl # AC_MSG_RESULT(no) AC_MSG_CHECKING( - [whether xattr_handler->get() wants dentry]) - ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry], [ + [whether xattr_handler->get() wants dentry and inode and flags]) + ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_GET_DENTRY, 1, - [xattr_handler->get() wants dentry]) + AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1, + [xattr_handler->get() wants dentry and inode and flags]) ],[ - dnl # - dnl # Android API change, - dnl # The xattr_handler->get() callback was - dnl # changed to take dentry, inode and flags. - dnl # - AC_MSG_RESULT(no) - AC_MSG_CHECKING( - [whether xattr_handler->get() wants dentry and inode and flags]) - ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1, - [xattr_handler->get() wants dentry and inode and flags]) - ],[ - ZFS_LINUX_TEST_ERROR([xattr get()]) - ]) + ZFS_LINUX_TEST_ERROR([xattr get()]) ]) ]) ]) @@ -235,18 +208,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET], [ .set = set, }; ],[]) - - ZFS_LINUX_TEST_SRC([xattr_handler_set_dentry], [ - #include - - static int set(struct dentry *dentry, const char *name, - const void *buffer, size_t size, int flags, - int handler_flags) { return 0; } - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .set = set, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [ @@ -296,22 +257,7 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [ AC_DEFINE(HAVE_XATTR_SET_HANDLER, 1, [xattr_handler->set() wants xattr_handler]) ],[ - dnl # - dnl # 2.6.33 API change, - dnl # The xattr_handler->set() callback was changed - dnl # to take a dentry instead of an inode, and a - dnl # handler_flags argument was added. - dnl # - AC_MSG_RESULT(no) - AC_MSG_CHECKING( - [whether xattr_handler->set() wants dentry]) - ZFS_LINUX_TEST_RESULT([xattr_handler_set_dentry], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_SET_DENTRY, 1, - [xattr_handler->set() wants dentry]) - ],[ - ZFS_LINUX_TEST_ERROR([xattr set()]) - ]) + ZFS_LINUX_TEST_ERROR([xattr set()]) ]) ]) ]) @@ -343,19 +289,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_LIST], [ .list = list, }; ],[]) - - ZFS_LINUX_TEST_SRC([xattr_handler_list_dentry], [ - #include - - static size_t list(struct dentry *dentry, - char *list, size_t list_size, - const char *name, size_t name_len, - int handler_flags) { return 0; } - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .list = list, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_LIST], [ @@ -382,22 +315,7 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_LIST], [ AC_DEFINE(HAVE_XATTR_LIST_HANDLER, 1, [xattr_handler->list() wants xattr_handler]) ],[ - dnl # - dnl # 2.6.33 API change, - dnl # The xattr_handler->list() callback was changed - dnl # to take a dentry instead of an inode, and a - dnl # handler_flags argument was added. - dnl # - AC_MSG_RESULT(no) - AC_MSG_CHECKING( - [whether xattr_handler->list() wants dentry]) - ZFS_LINUX_TEST_RESULT([xattr_handler_list_dentry], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_LIST_DENTRY, 1, - [xattr_handler->list() wants dentry]) - ],[ - ZFS_LINUX_TEST_ERROR([xattr list()]) - ]) + ZFS_LINUX_TEST_ERROR([xattr list()]) ]) ]) ]) diff --git a/include/os/linux/kernel/linux/xattr_compat.h b/include/os/linux/kernel/linux/xattr_compat.h index bcc7289ad857..b3761a422d39 100644 --- a/include/os/linux/kernel/linux/xattr_compat.h +++ b/include/os/linux/kernel/linux/xattr_compat.h @@ -47,21 +47,6 @@ fn(struct dentry *dentry) \ { \ return (!!__ ## fn(dentry->d_inode, NULL, 0, NULL, 0)); \ } -/* - * 4.4 API change, - */ -#elif defined(HAVE_XATTR_LIST_DENTRY) -#define ZPL_XATTR_LIST_WRAPPER(fn) \ -static size_t \ -fn(struct dentry *dentry, char *list, size_t list_size, \ - const char *name, size_t name_len, int type) \ -{ \ - return (__ ## fn(dentry->d_inode, \ - list, list_size, name, name_len)); \ -} -/* - * 2.6.33 API change, - */ #elif defined(HAVE_XATTR_LIST_HANDLER) #define ZPL_XATTR_LIST_WRAPPER(fn) \ static size_t \ @@ -102,19 +87,6 @@ fn(const struct xattr_handler *handler, struct dentry *dentry, \ { \ return (__ ## fn(dentry->d_inode, name, buffer, size)); \ } -/* - * 2.6.33 API change, - * The xattr_handler->get() callback was changed to take a dentry - * instead of an inode, and a handler_flags argument was added. - */ -#elif defined(HAVE_XATTR_GET_DENTRY) -#define ZPL_XATTR_GET_WRAPPER(fn) \ -static int \ -fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \ - int unused_handler_flags) \ -{ \ - return (__ ## fn(dentry->d_inode, name, buffer, size)); \ -} /* * Android API change, * The xattr_handler->get() callback was changed to take a dentry and inode @@ -192,20 +164,6 @@ fn(const struct xattr_handler *handler, struct dentry *dentry, \ return (__ ## fn(kcred->user_ns, dentry->d_inode, name, \ buffer, size, flags)); \ } -/* - * 2.6.33 API change, - * The xattr_handler->set() callback was changed to take a dentry - * instead of an inode, and a handler_flags argument was added. - */ -#elif defined(HAVE_XATTR_SET_DENTRY) -#define ZPL_XATTR_SET_WRAPPER(fn) \ -static int \ -fn(struct dentry *dentry, const char *name, const void *buffer, \ - size_t size, int flags, int unused_handler_flags) \ -{ \ - return (__ ## fn(kcred->user_ns, dentry->d_inode, name, \ - buffer, size, flags)); \ -} #else #error "Unsupported kernel" #endif diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index 9c0559333eb6..beca5b6557cd 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1425,7 +1425,6 @@ static xattr_handler_t zpl_xattr_acl_access_handler = { .get = zpl_xattr_acl_get_access, .set = zpl_xattr_acl_set_access, #if defined(HAVE_XATTR_LIST_SIMPLE) || \ - defined(HAVE_XATTR_LIST_DENTRY) || \ defined(HAVE_XATTR_LIST_HANDLER) .flags = ACL_TYPE_ACCESS, #endif @@ -1447,7 +1446,6 @@ static xattr_handler_t zpl_xattr_acl_default_handler = { .get = zpl_xattr_acl_get_default, .set = zpl_xattr_acl_set_default, #if defined(HAVE_XATTR_LIST_SIMPLE) || \ - defined(HAVE_XATTR_LIST_DENTRY) || \ defined(HAVE_XATTR_LIST_HANDLER) .flags = ACL_TYPE_DEFAULT, #endif @@ -1518,9 +1516,6 @@ zpl_xattr_permission(xattr_filldir_t *xf, const char *name, int name_len) #if defined(HAVE_XATTR_LIST_SIMPLE) if (!handler->list(d)) return (XAPERM_DENY); -#elif defined(HAVE_XATTR_LIST_DENTRY) - if (!handler->list(d, NULL, 0, name, name_len, 0)) - return (XAPERM_DENY); #elif defined(HAVE_XATTR_LIST_HANDLER) if (!handler->list(handler, d, NULL, 0, name, name_len)) return (XAPERM_DENY); From d29ed3630e5d17901e164ad105b1aaaa685b8e34 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 5 Aug 2024 19:48:47 +1000 Subject: [PATCH 123/223] config: remove HAVE_NEW_SYNC_READ Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-new-sync-rw.m4 | 29 ----------------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_file.c | 4 ---- 3 files changed, 35 deletions(-) delete mode 100644 config/kernel-vfs-new-sync-rw.m4 diff --git a/config/kernel-vfs-new-sync-rw.m4 b/config/kernel-vfs-new-sync-rw.m4 deleted file mode 100644 index c7332f373216..000000000000 --- a/config/kernel-vfs-new-sync-rw.m4 +++ /dev/null @@ -1,29 +0,0 @@ -dnl # -dnl # Linux 4.1 API -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_NEW_SYNC_RW], [ - ZFS_LINUX_TEST_SRC([new_sync_rw], [ - #include - ],[ - ssize_t ret __attribute__ ((unused)); - struct file *filp = NULL; - char __user *rbuf = NULL; - const char __user *wbuf = NULL; - size_t len = 0; - loff_t ppos; - - ret = new_sync_read(filp, rbuf, len, &ppos); - ret = new_sync_write(filp, wbuf, len, &ppos); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_VFS_NEW_SYNC_RW], [ - AC_MSG_CHECKING([whether new_sync_read/write() are available]) - ZFS_LINUX_TEST_RESULT([new_sync_rw], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_NEW_SYNC_READ, 1, - [new_sync_read()/new_sync_write() are available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index b2f1cdc5a3a7..bf473af9c960 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -100,7 +100,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO ZFS_AC_KERNEL_SRC_VFS_READPAGES ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS - ZFS_AC_KERNEL_SRC_VFS_NEW_SYNC_RW ZFS_AC_KERNEL_SRC_VFS_IOV_ITER ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE @@ -237,7 +236,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VFS_DIRECT_IO ZFS_AC_KERNEL_VFS_READPAGES ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS - ZFS_AC_KERNEL_VFS_NEW_SYNC_RW ZFS_AC_KERNEL_VFS_IOV_ITER ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 7eb73f2d5718..97259ba5f0ad 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -1135,10 +1135,6 @@ const struct file_operations zpl_file_operations = { .open = zpl_open, .release = zpl_release, .llseek = zpl_llseek, -#ifdef HAVE_NEW_SYNC_READ - .read = new_sync_read, - .write = new_sync_write, -#endif .read_iter = zpl_iter_read, .write_iter = zpl_iter_write, #ifdef HAVE_VFS_IOV_ITER From 49f449c8656e0bef577b41291cda3bd186c5d33d Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 5 Aug 2024 19:53:26 +1000 Subject: [PATCH 124/223] config: remove HAVE_VFS_FILE_OPERATIONS_EXTEND Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-extended-file_range.m4 | 50 ------------------------ config/kernel.m4 | 2 - include/os/linux/zfs/sys/zpl.h | 4 -- module/os/linux/zfs/zfs_vfsops.c | 6 --- module/os/linux/zfs/zfs_znode.c | 8 ---- module/os/linux/zfs/zpl_file.c | 10 ----- module/os/linux/zfs/zpl_file_range.c | 10 ++--- 7 files changed, 4 insertions(+), 86 deletions(-) delete mode 100644 config/kernel-vfs-extended-file_range.m4 diff --git a/config/kernel-vfs-extended-file_range.m4 b/config/kernel-vfs-extended-file_range.m4 deleted file mode 100644 index a2622313129e..000000000000 --- a/config/kernel-vfs-extended-file_range.m4 +++ /dev/null @@ -1,50 +0,0 @@ -dnl # -dnl # EL7 have backported copy_file_range and clone_file_range and -dnl # added them to an "extended" file_operations struct. -dnl # -dnl # We're testing for both functions in one here, because they will only -dnl # ever appear together and we don't want to match a similar method in -dnl # some future vendor kernel. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_FILE_OPERATIONS_EXTEND], [ - ZFS_LINUX_TEST_SRC([vfs_file_operations_extend], [ - #include - - static ssize_t test_copy_file_range(struct file *src_file, - loff_t src_off, struct file *dst_file, loff_t dst_off, - size_t len, unsigned int flags) { - (void) src_file; (void) src_off; - (void) dst_file; (void) dst_off; - (void) len; (void) flags; - return (0); - } - - static int test_clone_file_range(struct file *src_file, - loff_t src_off, struct file *dst_file, loff_t dst_off, - u64 len) { - (void) src_file; (void) src_off; - (void) dst_file; (void) dst_off; - (void) len; - return (0); - } - - static const struct file_operations_extend - fops __attribute__ ((unused)) = { - .kabi_fops = {}, - .copy_file_range = test_copy_file_range, - .clone_file_range = test_clone_file_range, - }; - ],[]) -]) -AC_DEFUN([ZFS_AC_KERNEL_VFS_FILE_OPERATIONS_EXTEND], [ - AC_MSG_CHECKING([whether file_operations_extend takes \ -.copy_file_range() and .clone_file_range()]) - ZFS_LINUX_TEST_RESULT([vfs_file_operations_extend], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_VFS_FILE_OPERATIONS_EXTEND, 1, - [file_operations_extend takes .copy_file_range() - and .clone_file_range()]) - ],[ - AC_MSG_RESULT([no]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index bf473af9c960..6abaa934a3ba 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -107,7 +107,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VFS_REMAP_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_CLONE_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_DEDUPE_FILE_RANGE - ZFS_AC_KERNEL_SRC_VFS_FILE_OPERATIONS_EXTEND ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS ZFS_AC_KERNEL_SRC_KMAP_LOCAL_PAGE ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE @@ -243,7 +242,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VFS_REMAP_FILE_RANGE ZFS_AC_KERNEL_VFS_CLONE_FILE_RANGE ZFS_AC_KERNEL_VFS_DEDUPE_FILE_RANGE - ZFS_AC_KERNEL_VFS_FILE_OPERATIONS_EXTEND ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS ZFS_AC_KERNEL_KMAP_LOCAL_PAGE ZFS_AC_KERNEL_FOLLOW_DOWN_ONE diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index e93901b3efd5..5d0691f5aa2e 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -52,11 +52,7 @@ extern const struct inode_operations zpl_special_inode_operations; /* zpl_file.c */ extern const struct address_space_operations zpl_address_space_operations; -#ifdef HAVE_VFS_FILE_OPERATIONS_EXTEND -extern const struct file_operations_extend zpl_file_operations; -#else extern const struct file_operations zpl_file_operations; -#endif extern const struct file_operations zpl_dir_file_operations; /* zpl_super.c */ diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index 97e65a04ad7e..92c97d2584cf 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -2020,9 +2020,6 @@ zfs_init(void) zfs_znode_init(); dmu_objset_register_type(DMU_OST_ZFS, zpl_get_file_info); register_filesystem(&zpl_fs_type); -#ifdef HAVE_VFS_FILE_OPERATIONS_EXTEND - register_fo_extend(&zpl_file_operations); -#endif } void @@ -2033,9 +2030,6 @@ zfs_fini(void) */ taskq_wait(system_delay_taskq); taskq_wait(system_taskq); -#ifdef HAVE_VFS_FILE_OPERATIONS_EXTEND - unregister_fo_extend(&zpl_file_operations); -#endif unregister_filesystem(&zpl_fs_type); zfs_znode_fini(); zfsctl_fini(); diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index 24aee0b88d44..bc01faed1102 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -415,11 +415,7 @@ zfs_inode_set_ops(zfsvfs_t *zfsvfs, struct inode *ip) switch (ip->i_mode & S_IFMT) { case S_IFREG: ip->i_op = &zpl_inode_operations; -#ifdef HAVE_VFS_FILE_OPERATIONS_EXTEND - ip->i_fop = &zpl_file_operations.kabi_fops; -#else ip->i_fop = &zpl_file_operations; -#endif ip->i_mapping->a_ops = &zpl_address_space_operations; break; @@ -459,11 +455,7 @@ zfs_inode_set_ops(zfsvfs_t *zfsvfs, struct inode *ip) /* Assume the inode is a file and attempt to continue */ ip->i_mode = S_IFREG | 0644; ip->i_op = &zpl_inode_operations; -#ifdef HAVE_VFS_FILE_OPERATIONS_EXTEND - ip->i_fop = &zpl_file_operations.kabi_fops; -#else ip->i_fop = &zpl_file_operations; -#endif ip->i_mapping->a_ops = &zpl_address_space_operations; break; } diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 97259ba5f0ad..aaccdef55667 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -1126,12 +1126,7 @@ const struct address_space_operations zpl_address_space_operations = { #endif }; -#ifdef HAVE_VFS_FILE_OPERATIONS_EXTEND -const struct file_operations_extend zpl_file_operations = { - .kabi_fops = { -#else const struct file_operations zpl_file_operations = { -#endif .open = zpl_open, .release = zpl_release, .llseek = zpl_llseek, @@ -1170,11 +1165,6 @@ const struct file_operations zpl_file_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = zpl_compat_ioctl, #endif -#ifdef HAVE_VFS_FILE_OPERATIONS_EXTEND - }, /* kabi_fops */ - .copy_file_range = zpl_copy_file_range, - .clone_file_range = zpl_clone_file_range, -#endif }; const struct file_operations zpl_dir_file_operations = { diff --git a/module/os/linux/zfs/zpl_file_range.c b/module/os/linux/zfs/zpl_file_range.c index 64728fdb1187..58f3c200aa84 100644 --- a/module/os/linux/zfs/zpl_file_range.c +++ b/module/os/linux/zfs/zpl_file_range.c @@ -83,8 +83,7 @@ zpl_clone_file_range_impl(struct file *src_file, loff_t src_off, return ((ssize_t)len_o); } -#if defined(HAVE_VFS_COPY_FILE_RANGE) || \ - defined(HAVE_VFS_FILE_OPERATIONS_EXTEND) +#if defined(HAVE_VFS_COPY_FILE_RANGE) /* * Entry point for copy_file_range(). Copy len bytes from src_off in src_file * to dst_off in dst_file. We are permitted to do this however we like, so we @@ -134,7 +133,7 @@ zpl_copy_file_range(struct file *src_file, loff_t src_off, return (ret); } -#endif /* HAVE_VFS_COPY_FILE_RANGE || HAVE_VFS_FILE_OPERATIONS_EXTEND */ +#endif /* HAVE_VFS_COPY_FILE_RANGE */ #ifdef HAVE_VFS_REMAP_FILE_RANGE /* @@ -179,8 +178,7 @@ zpl_remap_file_range(struct file *src_file, loff_t src_off, } #endif /* HAVE_VFS_REMAP_FILE_RANGE */ -#if defined(HAVE_VFS_CLONE_FILE_RANGE) || \ - defined(HAVE_VFS_FILE_OPERATIONS_EXTEND) +#if defined(HAVE_VFS_CLONE_FILE_RANGE) /* * Entry point for FICLONE and FICLONERANGE, before Linux 4.20. */ @@ -201,7 +199,7 @@ zpl_clone_file_range(struct file *src_file, loff_t src_off, return (ret); } -#endif /* HAVE_VFS_CLONE_FILE_RANGE || HAVE_VFS_FILE_OPERATIONS_EXTEND */ +#endif /* HAVE_VFS_CLONE_FILE_RANGE */ #ifdef HAVE_VFS_DEDUPE_FILE_RANGE /* From f5a1abcafa5d1c4ebf095b1807c140fbb05325bc Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 5 Aug 2024 19:56:01 +1000 Subject: [PATCH 125/223] config: remove HAVE_RENAME2_OPERATIONS_WRAPPER Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-rename.m4 | 27 --------------------------- include/os/linux/zfs/sys/zpl.h | 4 ---- module/os/linux/zfs/zfs_znode.c | 5 ----- module/os/linux/zfs/zpl_inode.c | 9 --------- 4 files changed, 45 deletions(-) diff --git a/config/kernel-rename.m4 b/config/kernel-rename.m4 index ce881502d1b1..cbb27082b247 100644 --- a/config/kernel-rename.m4 +++ b/config/kernel-rename.m4 @@ -36,24 +36,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_RENAME], [ }; ],[]) - dnl # - dnl # EL7 compatibility - dnl # - dnl # EL7 has backported renameat2 support, but it's done by defining a - dnl # separate iops wrapper structure that takes the .renameat2 function. - dnl # - ZFS_LINUX_TEST_SRC([dir_inode_operations_wrapper_rename2], [ - #include - static int rename2_fn(struct inode *sip, struct dentry *sdp, - struct inode *tip, struct dentry *tdp, - unsigned int flags) { return 0; } - - static const struct inode_operations_wrapper - iops __attribute__ ((unused)) = { - .rename2 = rename2_fn, - }; - ],[]) - dnl # dnl # 5.12 API change, dnl # @@ -117,15 +99,6 @@ AC_DEFUN([ZFS_AC_KERNEL_RENAME], [ [iops->rename() wants flags]) ],[ AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether struct inode_operations_wrapper takes .rename2()]) - ZFS_LINUX_TEST_RESULT([dir_inode_operations_wrapper_rename2], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_RENAME2_OPERATIONS_WRAPPER, 1, - [struct inode_operations_wrapper takes .rename2()]) - ],[ - AC_MSG_RESULT(no) - ]) ]) ]) ]) diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index 5d0691f5aa2e..38d8f086d3be 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -42,11 +42,7 @@ extern void zpl_vap_init(vattr_t *vap, struct inode *dir, umode_t mode, cred_t *cr, zidmap_t *mnt_ns); extern const struct inode_operations zpl_inode_operations; -#ifdef HAVE_RENAME2_OPERATIONS_WRAPPER -extern const struct inode_operations_wrapper zpl_dir_inode_operations; -#else extern const struct inode_operations zpl_dir_inode_operations; -#endif extern const struct inode_operations zpl_symlink_inode_operations; extern const struct inode_operations zpl_special_inode_operations; diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index bc01faed1102..7f031d16fb47 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -420,12 +420,7 @@ zfs_inode_set_ops(zfsvfs_t *zfsvfs, struct inode *ip) break; case S_IFDIR: -#ifdef HAVE_RENAME2_OPERATIONS_WRAPPER - ip->i_flags |= S_IOPS_WRAPPER; - ip->i_op = &zpl_dir_inode_operations.ops; -#else ip->i_op = &zpl_dir_inode_operations; -#endif ip->i_fop = &zpl_dir_file_operations; ITOZ(ip)->z_zn_prefetch = B_TRUE; break; diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index dfaaa6f1e636..863e439f4f80 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -792,12 +792,7 @@ const struct inode_operations zpl_inode_operations = { #endif /* CONFIG_FS_POSIX_ACL */ }; -#ifdef HAVE_RENAME2_OPERATIONS_WRAPPER -const struct inode_operations_wrapper zpl_dir_inode_operations = { - .ops = { -#else const struct inode_operations zpl_dir_inode_operations = { -#endif .create = zpl_create, .lookup = zpl_lookup, .link = zpl_link, @@ -834,10 +829,6 @@ const struct inode_operations zpl_dir_inode_operations = { .get_acl = zpl_get_acl, #endif /* HAVE_GET_INODE_ACL */ #endif /* CONFIG_FS_POSIX_ACL */ -#ifdef HAVE_RENAME2_OPERATIONS_WRAPPER - }, - .rename2 = zpl_rename2, -#endif }; const struct inode_operations zpl_symlink_inode_operations = { From a0abd7c5ff981473ea526a0dcf4cdcb66882223f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 5 Aug 2024 22:19:15 +1000 Subject: [PATCH 126/223] config: remove HAVE_GET_LINK_COOKIE As far as I can tell, this never made it to a real release. It was introduced in 6b2553918d8b and removed a couple of weeks later in fceef393a538. This was all part of the development of what would become 4.5. So I assume this was OpenZFS chasing upstream development at the time. fceef393a538 viro 2015-12-30 switch ->get_link() to delayed_call, kill ->put_link() cd3417c8fc95 viro 2015-12-29 kill free_page_put_link() 0d0def49d05a viro 2015-12-08 teach nfs_get_link() to work in RCU mode 1a384eaac265 viro 2015-12-08 teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode 6a6c99049635 viro 2015-12-08 teach shmem_get_link() to work in RCU mode d3883d4f9344 viro 2015-12-08 teach page_get_link() to work in RCU mode 6b2553918d8b viro 2015-12-08 replace ->follow_link() with new method that could stay in RCU mode Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-get-link.m4 | 42 ++++++++------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/config/kernel-get-link.m4 b/config/kernel-get-link.m4 index 31c7ac623d43..87ad948e315d 100644 --- a/config/kernel-get-link.m4 +++ b/config/kernel-get-link.m4 @@ -13,16 +13,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GET_LINK], [ }; ],[]) - ZFS_LINUX_TEST_SRC([inode_operations_get_link_cookie], [ - #include - static const char *get_link(struct dentry *de, struct - inode *ip, void **cookie) { return "symlink"; } - static struct inode_operations - iops __attribute__ ((unused)) = { - .get_link = get_link, - }; - ],[]) - ZFS_LINUX_TEST_SRC([inode_operations_follow_link], [ #include static const char *follow_link(struct dentry *de, @@ -48,34 +38,18 @@ AC_DEFUN([ZFS_AC_KERNEL_GET_LINK], [ AC_MSG_RESULT(no) dnl # - dnl # 4.5 API change - dnl # The follow_link() interface has been replaced by - dnl # get_link() which behaves the same as before except: - dnl # - An inode is passed as a separate argument - dnl # - When called in RCU mode a NULL dentry is passed. + dnl # 4.2 API change + dnl # This kernel retired the nameidata structure. dnl # - AC_MSG_CHECKING([whether iops->get_link() passes cookie]) - ZFS_LINUX_TEST_RESULT([inode_operations_get_link_cookie], [ + AC_MSG_CHECKING( + [whether iops->follow_link() passes cookie]) + ZFS_LINUX_TEST_RESULT([inode_operations_follow_link], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GET_LINK_COOKIE, 1, - [iops->get_link() cookie]) + AC_DEFINE(HAVE_FOLLOW_LINK_COOKIE, 1, + [iops->follow_link() cookie]) ],[ AC_MSG_RESULT(no) - - dnl # - dnl # 4.2 API change - dnl # This kernel retired the nameidata structure. - dnl # - AC_MSG_CHECKING( - [whether iops->follow_link() passes cookie]) - ZFS_LINUX_TEST_RESULT([inode_operations_follow_link], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FOLLOW_LINK_COOKIE, 1, - [iops->follow_link() cookie]) - ],[ - AC_MSG_RESULT(no) - ZFS_LINUX_TEST_ERROR([get_link]) - ]) + ZFS_LINUX_TEST_ERROR([get_link]) ]) ]) ]) From 91b48a42e0e03ba37e7a799d7409007811ac6850 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 15:45:56 +1000 Subject: [PATCH 127/223] config: remove HAVE_1ARG_SUBMIT_BIO Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bio.m4 | 26 -------------------------- module/os/linux/zfs/vdev_disk.c | 12 +----------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index a00a2b48d325..1b88f33ee496 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -262,30 +262,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_STATUS], [ ]) ]) -dnl # -dnl # 4.8 API change -dnl # The rw argument has been removed from submit_bio/submit_bio_wait. -dnl # Callers are now expected to set bio->bi_rw instead of passing it in. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO], [ - ZFS_LINUX_TEST_SRC([submit_bio], [ - #include - ],[ - struct bio *bio = NULL; - (void) submit_bio(bio); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_SUBMIT_BIO], [ - AC_MSG_CHECKING([whether submit_bio() wants 1 arg]) - ZFS_LINUX_TEST_RESULT([submit_bio], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_1ARG_SUBMIT_BIO, 1, [submit_bio() wants 1 arg]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.34 API change dnl # current->bio_list @@ -439,7 +415,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_BIO_OPS ZFS_AC_KERNEL_SRC_BIO_SET_DEV ZFS_AC_KERNEL_SRC_BIO_BI_STATUS - ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_SRC_BLKG_TRYGET ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK @@ -462,7 +437,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BIO_SET_DEV ZFS_AC_KERNEL_BIO_BI_STATUS - ZFS_AC_KERNEL_BIO_SUBMIT_BIO ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_BLKG_TRYGET ZFS_AC_KERNEL_BIO_BDEV_DISK diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index 613855081e6d..690667210cab 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -476,16 +476,6 @@ vdev_disk_close(vdev_t *v) v->vdev_tsd = NULL; } -static inline void -vdev_submit_bio_impl(struct bio *bio) -{ -#ifdef HAVE_1ARG_SUBMIT_BIO - (void) submit_bio(bio); -#else - (void) submit_bio(bio_data_dir(bio), bio); -#endif -} - /* * preempt_schedule_notrace is GPL-only which breaks the ZFS build, so * replace it with preempt_schedule under the following condition: @@ -606,7 +596,7 @@ vdev_submit_bio(struct bio *bio) { struct bio_list *bio_list = current->bio_list; current->bio_list = NULL; - vdev_submit_bio_impl(bio); + (void) submit_bio(bio); current->bio_list = bio_list; } From ea8a9768e71d9cbace1a40156ed185e0c73ec0ea Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 16:05:21 +1000 Subject: [PATCH 128/223] config: remove HAVE_BIO_BI_OPF Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bio.m4 | 18 -------------- include/os/linux/kernel/linux/blkdev_compat.h | 24 ++----------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index 1b88f33ee496..8d2af88d2e1f 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -102,13 +102,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_OPS], [ int op __attribute__ ((unused)) = REQ_OP_FLUSH; ]) - ZFS_LINUX_TEST_SRC([bio_bi_opf], [ - #include - ],[ - struct bio bio __attribute__ ((unused)); - bio.bi_opf = 0; - ]) - ZFS_LINUX_TEST_SRC([bio_set_op_attrs], [ #include ],[ @@ -148,16 +141,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH], [ ]) ]) -AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_OPF], [ - AC_MSG_CHECKING([whether bio->bi_opf is defined]) - ZFS_LINUX_TEST_RESULT([bio_bi_opf], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BIO_BI_OPF, 1, [bio->bi_opf is defined]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_OP_ATTRS], [ AC_MSG_CHECKING([whether bio_set_op_attrs is available]) ZFS_LINUX_TEST_RESULT([bio_set_op_attrs], [ @@ -432,7 +415,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BIO_REQ_OP_DISCARD ZFS_AC_KERNEL_BIO_REQ_OP_SECURE_ERASE ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH - ZFS_AC_KERNEL_BIO_BI_OPF ZFS_AC_KERNEL_BIO_SET_OP_ATTRS ZFS_AC_KERNEL_BIO_SET_DEV diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 891ff4403622..c9a4d0d34f8f 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -399,11 +399,7 @@ vdev_lookup_bdev(const char *path, dev_t *dev) static inline void bio_set_op_attrs(struct bio *bio, unsigned rw, unsigned flags) { -#if defined(HAVE_BIO_BI_OPF) bio->bi_opf = rw | flags; -#else - bio->bi_rw |= rw | flags; -#endif /* HAVE_BIO_BI_OPF */ } #endif @@ -446,9 +442,6 @@ bio_set_flush(struct bio *bio) * 4.8-rc0 - 4.8-rc1, * REQ_PREFLUSH * - * 2.6.36 - 4.7 API, - * REQ_FLUSH - * * in all cases but may have a performance impact for some kernels. It * has the advantage of minimizing kernel specific changes in the zvol code. * @@ -456,14 +449,10 @@ bio_set_flush(struct bio *bio) static inline boolean_t bio_is_flush(struct bio *bio) { -#if defined(HAVE_REQ_OP_FLUSH) && defined(HAVE_BIO_BI_OPF) +#if defined(HAVE_REQ_OP_FLUSH) return ((bio_op(bio) == REQ_OP_FLUSH) || (bio->bi_opf & REQ_PREFLUSH)); -#elif defined(HAVE_REQ_PREFLUSH) && defined(HAVE_BIO_BI_OPF) +#elif defined(HAVE_REQ_PREFLUSH) return (bio->bi_opf & REQ_PREFLUSH); -#elif defined(HAVE_REQ_PREFLUSH) && !defined(HAVE_BIO_BI_OPF) - return (bio->bi_rw & REQ_PREFLUSH); -#elif defined(HAVE_REQ_FLUSH) - return (bio->bi_rw & REQ_FLUSH); #else #error "Unsupported kernel" #endif @@ -472,20 +461,11 @@ bio_is_flush(struct bio *bio) /* * 4.8 API, * REQ_FUA flag moved to bio->bi_opf - * - * 2.6.x - 4.7 API, - * REQ_FUA */ static inline boolean_t bio_is_fua(struct bio *bio) { -#if defined(HAVE_BIO_BI_OPF) return (bio->bi_opf & REQ_FUA); -#elif defined(REQ_FUA) - return (bio->bi_rw & REQ_FUA); -#else -#error "Allowing the build will cause fua requests to be ignored." -#endif } /* From f32d5cf3c29ce2d9b611e17e689374d4f5040538 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 16:23:25 +1000 Subject: [PATCH 129/223] config: remove HAVE_BLK_QUEUE_WRITE_CACHE/HAVE_BLK_QUEUE_FLUSH Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-blk-queue.m4 | 73 ------------------- include/os/linux/kernel/linux/blkdev_compat.h | 24 ------ 2 files changed, 97 deletions(-) diff --git a/config/kernel-blk-queue.m4 b/config/kernel-blk-queue.m4 index a064140f337a..f5fb8f664752 100644 --- a/config/kernel-blk-queue.m4 +++ b/config/kernel-blk-queue.m4 @@ -269,77 +269,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR], [ ]) ]) -dnl # -dnl # 2.6.36 API change, -dnl # Added blk_queue_flush() interface, while the previous interface -dnl # was available to all the new one is GPL-only. Thus in addition to -dnl # detecting if this function is available we determine if it is -dnl # GPL-only. If the GPL-only interface is there we implement our own -dnl # compatibility function, otherwise we use the function. The hope -dnl # is that long term this function will be opened up. -dnl # -dnl # 4.7 API change, -dnl # Replace blk_queue_flush with blk_queue_write_cache -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH], [ - ZFS_LINUX_TEST_SRC([blk_queue_flush], [ - #include - ], [ - struct request_queue *q __attribute__ ((unused)) = NULL; - (void) blk_queue_flush(q, REQ_FLUSH); - ], [], [ZFS_META_LICENSE]) - - ZFS_LINUX_TEST_SRC([blk_queue_write_cache], [ - #include - #include - ], [ - struct request_queue *q __attribute__ ((unused)) = NULL; - blk_queue_write_cache(q, true, true); - ], [], [ZFS_META_LICENSE]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLUSH], [ - AC_MSG_CHECKING([whether blk_queue_flush() is available]) - ZFS_LINUX_TEST_RESULT([blk_queue_flush], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_QUEUE_FLUSH, 1, - [blk_queue_flush() is available]) - - AC_MSG_CHECKING([whether blk_queue_flush() is GPL-only]) - ZFS_LINUX_TEST_RESULT([blk_queue_flush_license], [ - AC_MSG_RESULT(no) - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY, 1, - [blk_queue_flush() is GPL-only]) - ]) - ],[ - AC_MSG_RESULT(no) - ]) - - dnl # - dnl # 4.7 API change - dnl # Replace blk_queue_flush with blk_queue_write_cache - dnl # - AC_MSG_CHECKING([whether blk_queue_write_cache() exists]) - ZFS_LINUX_TEST_RESULT([blk_queue_write_cache], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_QUEUE_WRITE_CACHE, 1, - [blk_queue_write_cache() exists]) - - AC_MSG_CHECKING([whether blk_queue_write_cache() is GPL-only]) - ZFS_LINUX_TEST_RESULT([blk_queue_write_cache_license], [ - AC_MSG_RESULT(no) - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_QUEUE_WRITE_CACHE_GPL_ONLY, 1, - [blk_queue_write_cache() is GPL-only]) - ]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.34 API change dnl # blk_queue_max_hw_sectors() replaces blk_queue_max_sectors(). @@ -439,7 +368,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [ ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR - ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS ZFS_AC_KERNEL_SRC_BLK_MQ @@ -454,7 +382,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [ ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR - ZFS_AC_KERNEL_BLK_QUEUE_FLUSH ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS ZFS_AC_KERNEL_BLK_MQ diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index c9a4d0d34f8f..5518f1f434af 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -61,24 +61,12 @@ blk_queue_flag_clear(unsigned int flag, struct request_queue *q) * Setting the flush flags directly is no longer possible; flush flags are set * on the queue_limits structure and passed to blk_disk_alloc(). In this case * we remove this function entirely. - * - * 4.7 API, - * The blk_queue_write_cache() interface has replaced blk_queue_flush() - * interface. However, the new interface is GPL-only thus we implement - * our own trivial wrapper when the GPL-only version is detected. - * - * 2.6.36 - 4.6 API, - * The blk_queue_flush() interface has replaced blk_queue_ordered() - * interface. However, while the old interface was available to all the - * new one is GPL-only. Thus if the GPL-only version is detected we - * implement our own trivial helper. */ #if !defined(HAVE_BLK_ALLOC_DISK_2ARG) || \ !defined(HAVE_BLKDEV_QUEUE_LIMITS_FEATURES) static inline void blk_queue_set_write_cache(struct request_queue *q, bool on) { -#if defined(HAVE_BLK_QUEUE_WRITE_CACHE_GPL_ONLY) if (on) { blk_queue_flag_set(QUEUE_FLAG_WC, q); blk_queue_flag_set(QUEUE_FLAG_FUA, q); @@ -86,18 +74,6 @@ blk_queue_set_write_cache(struct request_queue *q, bool on) blk_queue_flag_clear(QUEUE_FLAG_WC, q); blk_queue_flag_clear(QUEUE_FLAG_FUA, q); } -#elif defined(HAVE_BLK_QUEUE_WRITE_CACHE) - blk_queue_write_cache(q, on, on); -#elif defined(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY) - if (on) - q->flush_flags |= REQ_FLUSH | REQ_FUA; - else - q->flush_flags &= ~(REQ_FLUSH | REQ_FUA); -#elif defined(HAVE_BLK_QUEUE_FLUSH) - blk_queue_flush(q, on ? (REQ_FLUSH | REQ_FUA) : 0); -#else -#error "Unsupported kernel" -#endif } #endif /* !HAVE_BLK_ALLOC_DISK_2ARG || !HAVE_BLKDEV_QUEUE_LIMITS_FEATURES */ From 7bdea98d4f3143129d323d70c82cb69855060f69 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 16:25:17 +1000 Subject: [PATCH 130/223] config: remove HAVE_CPU_HOTPLUG Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-hotplug.m4 | 26 -------------------------- config/kernel.m4 | 2 -- module/os/linux/spl/spl-taskq.c | 20 ++------------------ 3 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 config/kernel-hotplug.m4 diff --git a/config/kernel-hotplug.m4 b/config/kernel-hotplug.m4 deleted file mode 100644 index e796a6d2e8e8..000000000000 --- a/config/kernel-hotplug.m4 +++ /dev/null @@ -1,26 +0,0 @@ -dnl # -dnl # 4.6 API change -dnl # Added CPU hotplug APIs -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_CPU_HOTPLUG], [ - ZFS_LINUX_TEST_SRC([cpu_hotplug], [ - #include - ],[ - enum cpuhp_state state = CPUHP_ONLINE; - int (*fp)(unsigned int, struct hlist_node *) = NULL; - cpuhp_state_add_instance_nocalls(0, (struct hlist_node *)NULL); - cpuhp_state_remove_instance_nocalls(0, (struct hlist_node *)NULL); - cpuhp_setup_state_multi(state, "", fp, fp); - cpuhp_remove_multi_state(0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_CPU_HOTPLUG], [ - AC_MSG_CHECKING([whether CPU hotplug APIs exist]) - ZFS_LINUX_TEST_RESULT([cpu_hotplug], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_CPU_HOTPLUG, 1, [yes]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 6abaa934a3ba..ae3ca7a60473 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -124,7 +124,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES ZFS_AC_KERNEL_SRC_PERCPU - ZFS_AC_KERNEL_SRC_CPU_HOTPLUG ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR ZFS_AC_KERNEL_SRC_MKNOD ZFS_AC_KERNEL_SRC_SYMLINK @@ -259,7 +258,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_TOTALHIGH_PAGES ZFS_AC_KERNEL_PERCPU - ZFS_AC_KERNEL_CPU_HOTPLUG ZFS_AC_KERNEL_GENERIC_FILLATTR ZFS_AC_KERNEL_MKNOD ZFS_AC_KERNEL_SYMLINK diff --git a/module/os/linux/spl/spl-taskq.c b/module/os/linux/spl/spl-taskq.c index ba6a1e10ec31..1c35cf3e43d4 100644 --- a/module/os/linux/spl/spl-taskq.c +++ b/module/os/linux/spl/spl-taskq.c @@ -28,9 +28,7 @@ #include #include #include -#ifdef HAVE_CPU_HOTPLUG #include -#endif static int spl_taskq_thread_bind = 0; module_param(spl_taskq_thread_bind, int, 0644); @@ -74,10 +72,8 @@ EXPORT_SYMBOL(system_delay_taskq); static taskq_t *dynamic_taskq; static taskq_thread_t *taskq_thread_create(taskq_t *); -#ifdef HAVE_CPU_HOTPLUG /* Multi-callback id for cpu hotplugging. */ static int spl_taskq_cpuhp_state; -#endif /* List of all taskqs */ LIST_HEAD(tq_list); @@ -1068,7 +1064,7 @@ taskq_create(const char *name, int threads_arg, pri_t pri, return (NULL); tq->tq_hp_support = B_FALSE; -#ifdef HAVE_CPU_HOTPLUG + if (flags & TASKQ_THREADS_CPU_PCT) { tq->tq_hp_support = B_TRUE; if (cpuhp_state_add_instance_nocalls(spl_taskq_cpuhp_state, @@ -1077,7 +1073,6 @@ taskq_create(const char *name, int threads_arg, pri_t pri, return (NULL); } } -#endif spin_lock_init(&tq->tq_lock); INIT_LIST_HEAD(&tq->tq_thread_list); @@ -1162,12 +1157,11 @@ taskq_destroy(taskq_t *tq) tq->tq_flags &= ~TASKQ_ACTIVE; spin_unlock_irqrestore(&tq->tq_lock, flags); -#ifdef HAVE_CPU_HOTPLUG if (tq->tq_hp_support) { VERIFY0(cpuhp_state_remove_instance_nocalls( spl_taskq_cpuhp_state, &tq->tq_hp_cb_node)); } -#endif + /* * When TASKQ_ACTIVE is clear new tasks may not be added nor may * new worker threads be spawned for dynamic taskq. @@ -1291,7 +1285,6 @@ module_param_call(spl_taskq_kick, param_set_taskq_kick, param_get_uint, MODULE_PARM_DESC(spl_taskq_kick, "Write nonzero to kick stuck taskqs to spawn more threads"); -#ifdef HAVE_CPU_HOTPLUG /* * This callback will be called exactly once for each core that comes online, * for each dynamic taskq. We attempt to expand taskqs that have @@ -1369,7 +1362,6 @@ spl_taskq_prepare_down(unsigned int cpu, struct hlist_node *node) spin_unlock_irqrestore(&tq->tq_lock, flags); return (0); } -#endif int spl_taskq_init(void) @@ -1377,10 +1369,8 @@ spl_taskq_init(void) init_rwsem(&tq_list_sem); tsd_create(&taskq_tsd, NULL); -#ifdef HAVE_CPU_HOTPLUG spl_taskq_cpuhp_state = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "fs/spl_taskq:online", spl_taskq_expand, spl_taskq_prepare_down); -#endif system_taskq = taskq_create("spl_system_taskq", MAX(boot_ncpus, 64), maxclsyspri, boot_ncpus, INT_MAX, TASKQ_PREPOPULATE|TASKQ_DYNAMIC); @@ -1390,9 +1380,7 @@ spl_taskq_init(void) system_delay_taskq = taskq_create("spl_delay_taskq", MAX(boot_ncpus, 4), maxclsyspri, boot_ncpus, INT_MAX, TASKQ_PREPOPULATE|TASKQ_DYNAMIC); if (system_delay_taskq == NULL) { -#ifdef HAVE_CPU_HOTPLUG cpuhp_remove_multi_state(spl_taskq_cpuhp_state); -#endif taskq_destroy(system_taskq); return (-ENOMEM); } @@ -1400,9 +1388,7 @@ spl_taskq_init(void) dynamic_taskq = taskq_create("spl_dynamic_taskq", 1, maxclsyspri, boot_ncpus, INT_MAX, TASKQ_PREPOPULATE); if (dynamic_taskq == NULL) { -#ifdef HAVE_CPU_HOTPLUG cpuhp_remove_multi_state(spl_taskq_cpuhp_state); -#endif taskq_destroy(system_taskq); taskq_destroy(system_delay_taskq); return (-ENOMEM); @@ -1432,8 +1418,6 @@ spl_taskq_fini(void) tsd_destroy(&taskq_tsd); -#ifdef HAVE_CPU_HOTPLUG cpuhp_remove_multi_state(spl_taskq_cpuhp_state); spl_taskq_cpuhp_state = 0; -#endif } From 5d537c76601025e9fa8ac1d168aeaaefcd2ea479 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 16:50:01 +1000 Subject: [PATCH 131/223] config: remove HAVE_CURRENT_TIME Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-current-time.m4 | 26 ---------------------- config/kernel.m4 | 2 -- include/os/linux/kernel/linux/vfs_compat.h | 12 ---------- 3 files changed, 40 deletions(-) delete mode 100644 config/kernel-current-time.m4 diff --git a/config/kernel-current-time.m4 b/config/kernel-current-time.m4 deleted file mode 100644 index ab7d9c5cedba..000000000000 --- a/config/kernel-current-time.m4 +++ /dev/null @@ -1,26 +0,0 @@ -dnl # -dnl # 4.9, current_time() added -dnl # 4.18, return type changed from timespec to timespec64 -dnl # -dnl # Note that we don't care about the return type in this check. If we have -dnl # to implement a fallback, we'll know we're <4.9, which was timespec. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_CURRENT_TIME], [ - ZFS_LINUX_TEST_SRC([current_time], [ - #include - ], [ - struct inode ip __attribute__ ((unused)); - (void) current_time(&ip); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_CURRENT_TIME], [ - AC_MSG_CHECKING([whether current_time() exists]) - ZFS_LINUX_TEST_RESULT_SYMBOL([current_time], - [current_time], [fs/inode.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_CURRENT_TIME, 1, [current_time() exists]) - ], [ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index ae3ca7a60473..179f4ff4d188 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -117,7 +117,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_KUIDGID_T ZFS_AC_KERNEL_SRC_KUID_HELPERS ZFS_AC_KERNEL_SRC_RENAME - ZFS_AC_KERNEL_SRC_CURRENT_TIME ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL ZFS_AC_KERNEL_SRC_KTIME @@ -251,7 +250,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_KUIDGID_T ZFS_AC_KERNEL_KUID_HELPERS ZFS_AC_KERNEL_RENAME - ZFS_AC_KERNEL_CURRENT_TIME ZFS_AC_KERNEL_USERNS_CAPABILITIES ZFS_AC_KERNEL_IN_COMPAT_SYSCALL ZFS_AC_KERNEL_KTIME diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 3a7a190e574d..e55c216acf09 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -291,18 +291,6 @@ func(struct mnt_idmap *user_ns, const struct path *path, \ #error #endif -/* - * 4.9 API change - * Preferred interface to get the current FS time. - */ -#if !defined(HAVE_CURRENT_TIME) -static inline struct timespec -current_time(struct inode *ip) -{ - return (timespec_trunc(current_kernel_time(), ip->i_sb->s_time_gran)); -} -#endif - /* * 4.16 API change * Added iversion interface for managing inode version field. From c9c1262b672687c2bc03e9eeab5091fc79e1001b Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 16:54:44 +1000 Subject: [PATCH 132/223] config: remove HAVE_GROUP_INFO_GID Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-group-info.m4 | 22 ---------------------- config/kernel.m4 | 2 -- module/os/linux/spl/spl-cred.c | 21 ++------------------- 3 files changed, 2 insertions(+), 43 deletions(-) delete mode 100644 config/kernel-group-info.m4 diff --git a/config/kernel-group-info.m4 b/config/kernel-group-info.m4 deleted file mode 100644 index 6941d62da017..000000000000 --- a/config/kernel-group-info.m4 +++ /dev/null @@ -1,22 +0,0 @@ -dnl # -dnl # 4.9 API change -dnl # group_info changed from 2d array via >blocks to 1d array via ->gid -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_GROUP_INFO_GID], [ - ZFS_LINUX_TEST_SRC([group_info_gid], [ - #include - ],[ - struct group_info gi __attribute__ ((unused)) = {}; - gi.gid[0] = KGIDT_INIT(0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_GROUP_INFO_GID], [ - AC_MSG_CHECKING([whether group_info->gid exists]) - ZFS_LINUX_TEST_RESULT([group_info_gid], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 179f4ff4d188..dfbd82c81b0c 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -52,7 +52,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_WAIT ZFS_AC_KERNEL_SRC_INODE_TIMES ZFS_AC_KERNEL_SRC_INODE_LOCK - ZFS_AC_KERNEL_SRC_GROUP_INFO_GID ZFS_AC_KERNEL_SRC_RW ZFS_AC_KERNEL_SRC_TIMER_SETUP ZFS_AC_KERNEL_SRC_SUPER_USER_NS @@ -185,7 +184,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_WAIT ZFS_AC_KERNEL_INODE_TIMES ZFS_AC_KERNEL_INODE_LOCK - ZFS_AC_KERNEL_GROUP_INFO_GID ZFS_AC_KERNEL_RW ZFS_AC_KERNEL_TIMER_SETUP ZFS_AC_KERNEL_SUPER_USER_NS diff --git a/module/os/linux/spl/spl-cred.c b/module/os/linux/spl/spl-cred.c index d407fc66b2de..7254df6bf294 100644 --- a/module/os/linux/spl/spl-cred.c +++ b/module/os/linux/spl/spl-cred.c @@ -74,26 +74,13 @@ crgetngroups(const cred_t *cr) gi = cr->group_info; rc = gi->ngroups; -#ifndef HAVE_GROUP_INFO_GID - /* - * For Linux <= 4.8, - * crgetgroups will only returns gi->blocks[0], which contains only - * the first NGROUPS_PER_BLOCK groups. - */ - if (rc > NGROUPS_PER_BLOCK) { - WARN_ON_ONCE(1); - rc = NGROUPS_PER_BLOCK; - } -#endif + return (rc); } /* * Return an array of supplemental gids. The returned address is safe * to use as long as the caller has taken a reference with crhold(). - * - * Linux 4.9 API change, group_info changed from 2d array via ->blocks to 1d - * array via ->gid. */ gid_t * crgetgroups(const cred_t *cr) @@ -102,12 +89,8 @@ crgetgroups(const cred_t *cr) gid_t *gids = NULL; gi = cr->group_info; -#ifdef HAVE_GROUP_INFO_GID gids = KGIDP_TO_SGIDP(gi->gid); -#else - if (gi->nblocks > 0) - gids = KGIDP_TO_SGIDP(gi->blocks[0]); -#endif + return (gids); } From 28f75aea2fba73c75b75217742db115baec2bf55 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 16:55:55 +1000 Subject: [PATCH 133/223] config: remove HAVE_IN_COMPAT_SYSCALL Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-in-compat-syscall.m4 | 24 ---------------------- config/kernel.m4 | 2 -- include/os/linux/kernel/linux/vfs_compat.h | 4 ---- 3 files changed, 30 deletions(-) delete mode 100644 config/kernel-in-compat-syscall.m4 diff --git a/config/kernel-in-compat-syscall.m4 b/config/kernel-in-compat-syscall.m4 deleted file mode 100644 index baaac8c4fda2..000000000000 --- a/config/kernel-in-compat-syscall.m4 +++ /dev/null @@ -1,24 +0,0 @@ -dnl # -dnl # 4.5 API change -dnl # Added in_compat_syscall() which can be overridden on a per- -dnl # architecture basis. Prior to this is_compat_task() was the -dnl # provided interface. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL], [ - ZFS_LINUX_TEST_SRC([in_compat_syscall], [ - #include - ],[ - in_compat_syscall(); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_IN_COMPAT_SYSCALL], [ - AC_MSG_CHECKING([whether in_compat_syscall() is available]) - ZFS_LINUX_TEST_RESULT([in_compat_syscall], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_IN_COMPAT_SYSCALL, 1, - [in_compat_syscall() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index dfbd82c81b0c..ed6007a19470 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -117,7 +117,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_KUID_HELPERS ZFS_AC_KERNEL_SRC_RENAME ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES - ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL ZFS_AC_KERNEL_SRC_KTIME ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES @@ -249,7 +248,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_KUID_HELPERS ZFS_AC_KERNEL_RENAME ZFS_AC_KERNEL_USERNS_CAPABILITIES - ZFS_AC_KERNEL_IN_COMPAT_SYSCALL ZFS_AC_KERNEL_KTIME ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_TOTALHIGH_PAGES diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index e55c216acf09..aa8f4cc97b2d 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -312,11 +312,7 @@ static inline int zpl_is_32bit_api(void) { #ifdef CONFIG_COMPAT -#ifdef HAVE_IN_COMPAT_SYSCALL return (in_compat_syscall()); -#else - return (is_compat_task()); -#endif #else return (BITS_PER_LONG == 32); #endif From 9629606882aa7de4f728f842f43b34c5763a81d8 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 16:57:45 +1000 Subject: [PATCH 134/223] config: remove HAVE_INODE_LOCK_SHARED Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-inode-lock.m4 | 24 ------------------------ config/kernel.m4 | 2 -- include/os/linux/spl/sys/file.h | 11 ----------- 3 files changed, 37 deletions(-) delete mode 100644 config/kernel-inode-lock.m4 diff --git a/config/kernel-inode-lock.m4 b/config/kernel-inode-lock.m4 deleted file mode 100644 index 5eb04af78771..000000000000 --- a/config/kernel-inode-lock.m4 +++ /dev/null @@ -1,24 +0,0 @@ -dnl # -dnl # 4.7 API change -dnl # i_mutex is changed to i_rwsem. Instead of directly using -dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared() -dnl # We test inode_lock_shared because inode_lock is introduced earlier. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_LOCK], [ - ZFS_LINUX_TEST_SRC([inode_lock], [ - #include - ],[ - struct inode *inode = NULL; - inode_lock_shared(inode); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_INODE_LOCK], [ - AC_MSG_CHECKING([whether inode_lock_shared() exists]) - ZFS_LINUX_TEST_RESULT([inode_lock], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index ed6007a19470..319baf8ed196 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -51,7 +51,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_SRC_WAIT ZFS_AC_KERNEL_SRC_INODE_TIMES - ZFS_AC_KERNEL_SRC_INODE_LOCK ZFS_AC_KERNEL_SRC_RW ZFS_AC_KERNEL_SRC_TIMER_SETUP ZFS_AC_KERNEL_SRC_SUPER_USER_NS @@ -182,7 +181,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_WAIT ZFS_AC_KERNEL_INODE_TIMES - ZFS_AC_KERNEL_INODE_LOCK ZFS_AC_KERNEL_RW ZFS_AC_KERNEL_TIMER_SETUP ZFS_AC_KERNEL_SUPER_USER_NS diff --git a/include/os/linux/spl/sys/file.h b/include/os/linux/spl/sys/file.h index e0bbd6d98cba..38d19d8c68b0 100644 --- a/include/os/linux/spl/sys/file.h +++ b/include/os/linux/spl/sys/file.h @@ -28,7 +28,6 @@ #define FKIOCTL 0x80000000 #define ED_CASE_CONFLICT 0x10 -#ifdef HAVE_INODE_LOCK_SHARED #define spl_inode_lock(ip) inode_lock(ip) #define spl_inode_unlock(ip) inode_unlock(ip) #define spl_inode_lock_shared(ip) inode_lock_shared(ip) @@ -37,15 +36,5 @@ #define spl_inode_trylock_shared(ip) inode_trylock_shared(ip) #define spl_inode_is_locked(ip) inode_is_locked(ip) #define spl_inode_lock_nested(ip, s) inode_lock_nested(ip, s) -#else -#define spl_inode_lock(ip) mutex_lock(&(ip)->i_mutex) -#define spl_inode_unlock(ip) mutex_unlock(&(ip)->i_mutex) -#define spl_inode_lock_shared(ip) mutex_lock(&(ip)->i_mutex) -#define spl_inode_unlock_shared(ip) mutex_unlock(&(ip)->i_mutex) -#define spl_inode_trylock(ip) mutex_trylock(&(ip)->i_mutex) -#define spl_inode_trylock_shared(ip) mutex_trylock(&(ip)->i_mutex) -#define spl_inode_is_locked(ip) mutex_is_locked(&(ip)->i_mutex) -#define spl_inode_lock_nested(ip, s) mutex_lock_nested(&(ip)->i_mutex, s) -#endif #endif /* SPL_FILE_H */ From a40444197b52e503c3ad46b3c9b7184ccc484b4e Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 17:00:43 +1000 Subject: [PATCH 135/223] config: remove HAVE_KERNEL_GET_ACL_HANDLE_CACHE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-acl.m4 | 28 ---------------------------- module/os/linux/zfs/zpl_xattr.c | 17 ----------------- 2 files changed, 45 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index b1da74173eda..e53b546affce 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -199,32 +199,6 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [ ]) ]) -dnl # -dnl # 4.7 API change, -dnl # The kernel get_acl will now check cache before calling i_op->get_acl and -dnl # do set_cached_acl after that, so i_op->get_acl don't need to do that -dnl # anymore. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_GET_ACL_HANDLE_CACHE], [ - ZFS_LINUX_TEST_SRC([get_acl_handle_cache], [ - #include - ],[ - void *sentinel __attribute__ ((unused)) = - uncached_acl_sentinel(NULL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE], [ - AC_MSG_CHECKING([whether uncached_acl_sentinel() exists]) - ZFS_LINUX_TEST_RESULT([get_acl_handle_cache], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KERNEL_GET_ACL_HANDLE_CACHE, 1, - [uncached_acl_sentinel() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 4.16 kernel: check if struct posix_acl acl.a_refcount is a refcount_t. dnl # It's an atomic_t on older kernels. @@ -255,7 +229,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ ZFS_AC_KERNEL_SRC_POSIX_ACL_VALID_WITH_NS ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL - ZFS_AC_KERNEL_SRC_GET_ACL_HANDLE_CACHE ZFS_AC_KERNEL_SRC_ACL_HAS_REFCOUNT ]) @@ -264,6 +237,5 @@ AC_DEFUN([ZFS_AC_KERNEL_ACL], [ ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL - ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE ZFS_AC_KERNEL_ACL_HAS_REFCOUNT ]) diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index beca5b6557cd..f272054e0c42 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1087,17 +1087,6 @@ zpl_get_acl_impl(struct inode *ip, int type) void *value = NULL; char *name; - /* - * As of Linux 3.14, the kernel get_acl will check this for us. - * Also as of Linux 4.7, comparing against ACL_NOT_CACHED is wrong - * as the kernel get_acl will set it to temporary sentinel value. - */ -#ifndef HAVE_KERNEL_GET_ACL_HANDLE_CACHE - acl = get_cached_acl(ip, type); - if (acl != ACL_NOT_CACHED) - return (acl); -#endif - switch (type) { case ACL_TYPE_ACCESS: name = XATTR_NAME_POSIX_ACL_ACCESS; @@ -1126,12 +1115,6 @@ zpl_get_acl_impl(struct inode *ip, int type) if (size > 0) kmem_free(value, size); - /* As of Linux 4.7, the kernel get_acl will set this for us */ -#ifndef HAVE_KERNEL_GET_ACL_HANDLE_CACHE - if (!IS_ERR(acl)) - set_cached_acl(ip, type, acl); -#endif - return (acl); } From 903c3bbc99a7b91f2bc5845e71eda44a4f2ebe9e Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 17:15:40 +1000 Subject: [PATCH 136/223] config: remove HAVE_POSIX_ACL_VALID_WITH_NS Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-acl.m4 | 30 ---------------------- include/os/linux/kernel/linux/vfs_compat.h | 12 --------- module/os/linux/zfs/zpl_xattr.c | 4 +-- 3 files changed, 2 insertions(+), 44 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index e53b546affce..0903818582c9 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -21,34 +21,6 @@ AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T], [ ]) ]) -dnl # -dnl # 4.8 API change, -dnl # The function posix_acl_valid now must be passed a namespace. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_POSIX_ACL_VALID_WITH_NS], [ - ZFS_LINUX_TEST_SRC([posix_acl_valid_with_ns], [ - #include - #include - ],[ - struct user_namespace *user_ns = NULL; - const struct posix_acl *acl = NULL; - int error; - - error = posix_acl_valid(user_ns, acl); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS], [ - AC_MSG_CHECKING([whether posix_acl_valid() wants user namespace]) - ZFS_LINUX_TEST_RESULT([posix_acl_valid_with_ns], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_POSIX_ACL_VALID_WITH_NS, 1, - [posix_acl_valid() wants user namespace]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 3.1 API change, dnl # Check if inode_operations contains the function get_acl @@ -226,7 +198,6 @@ AC_DEFUN([ZFS_AC_KERNEL_ACL_HAS_REFCOUNT], [ AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ ZFS_AC_KERNEL_SRC_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T - ZFS_AC_KERNEL_SRC_POSIX_ACL_VALID_WITH_NS ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL ZFS_AC_KERNEL_SRC_ACL_HAS_REFCOUNT @@ -234,7 +205,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ AC_DEFUN([ZFS_AC_KERNEL_ACL], [ ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T - ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL ZFS_AC_KERNEL_ACL_HAS_REFCOUNT diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index aa8f4cc97b2d..affd6caa0254 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -161,18 +161,6 @@ zpl_posix_acl_release(struct posix_acl *acl) zpl_posix_acl_release_impl(acl); #endif } - -/* - * 4.8 API change, - * posix_acl_valid() now must be passed a namespace, the namespace from - * from super block associated with the given inode is used for this purpose. - */ -#ifdef HAVE_POSIX_ACL_VALID_WITH_NS -#define zpl_posix_acl_valid(ip, acl) posix_acl_valid(ip->i_sb->s_user_ns, acl) -#else -#define zpl_posix_acl_valid(ip, acl) posix_acl_valid(acl) -#endif - #endif /* CONFIG_FS_POSIX_ACL */ static inline uid_t zfs_uid_read_impl(struct inode *ip) diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index f272054e0c42..dc0113d38b7b 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1329,7 +1329,7 @@ __zpl_xattr_acl_set_access(zidmap_t *mnt_ns, if (IS_ERR(acl)) return (PTR_ERR(acl)); else if (acl) { - error = zpl_posix_acl_valid(ip, acl); + error = posix_acl_valid(ip->i_sb->s_user_ns, acl); if (error) { zpl_posix_acl_release(acl); return (error); @@ -1375,7 +1375,7 @@ __zpl_xattr_acl_set_default(zidmap_t *mnt_ns, if (IS_ERR(acl)) return (PTR_ERR(acl)); else if (acl) { - error = zpl_posix_acl_valid(ip, acl); + error = posix_acl_valid(ip->i_sb->s_user_ns, acl); if (error) { zpl_posix_acl_release(acl); return (error); From 63ce63d46bc804830588c1e7a7d504209fd8d92d Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 16:52:28 +1000 Subject: [PATCH 137/223] config: remove HAVE_(GET|PUT)_LINK_DELAYED Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-get-link.m4 | 55 --------------------------------- config/kernel-put-link.m4 | 39 ----------------------- config/kernel.m4 | 4 --- module/os/linux/zfs/zpl_inode.c | 46 --------------------------- 4 files changed, 144 deletions(-) delete mode 100644 config/kernel-get-link.m4 delete mode 100644 config/kernel-put-link.m4 diff --git a/config/kernel-get-link.m4 b/config/kernel-get-link.m4 deleted file mode 100644 index 87ad948e315d..000000000000 --- a/config/kernel-get-link.m4 +++ /dev/null @@ -1,55 +0,0 @@ -dnl # -dnl # Supported get_link() interfaces checked newest to oldest. -dnl # Note this interface used to be named follow_link. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_GET_LINK], [ - ZFS_LINUX_TEST_SRC([inode_operations_get_link], [ - #include - static const char *get_link(struct dentry *de, struct inode *ip, - struct delayed_call *done) { return "symlink"; } - static struct inode_operations - iops __attribute__ ((unused)) = { - .get_link = get_link, - }; - ],[]) - - ZFS_LINUX_TEST_SRC([inode_operations_follow_link], [ - #include - static const char *follow_link(struct dentry *de, - void **cookie) { return "symlink"; } - static struct inode_operations - iops __attribute__ ((unused)) = { - .follow_link = follow_link, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_GET_LINK], [ - dnl # - dnl # 4.5 API change - dnl # The get_link interface has added a delayed done call and - dnl # used it to retire the put_link() interface. - dnl # - AC_MSG_CHECKING([whether iops->get_link() passes delayed]) - ZFS_LINUX_TEST_RESULT([inode_operations_get_link], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GET_LINK_DELAYED, 1, [iops->get_link() delayed]) - ],[ - AC_MSG_RESULT(no) - - dnl # - dnl # 4.2 API change - dnl # This kernel retired the nameidata structure. - dnl # - AC_MSG_CHECKING( - [whether iops->follow_link() passes cookie]) - ZFS_LINUX_TEST_RESULT([inode_operations_follow_link], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FOLLOW_LINK_COOKIE, 1, - [iops->follow_link() cookie]) - ],[ - AC_MSG_RESULT(no) - ZFS_LINUX_TEST_ERROR([get_link]) - ]) - ]) -]) diff --git a/config/kernel-put-link.m4 b/config/kernel-put-link.m4 deleted file mode 100644 index 901024718949..000000000000 --- a/config/kernel-put-link.m4 +++ /dev/null @@ -1,39 +0,0 @@ -dnl # -dnl # Supported symlink APIs -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_PUT_LINK], [ - ZFS_LINUX_TEST_SRC([put_link_cookie], [ - #include - static void put_link(struct inode *ip, void *cookie) - { return; } - static struct inode_operations - iops __attribute__ ((unused)) = { - .put_link = put_link, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_PUT_LINK], [ - dnl # - dnl # 4.5 API change - dnl # get_link() uses delayed done, there is no put_link() interface. - dnl # This check initially uses the inode_operations_get_link result - dnl # - ZFS_LINUX_TEST_RESULT([inode_operations_get_link], [ - AC_DEFINE(HAVE_PUT_LINK_DELAYED, 1, [iops->put_link() delayed]) - ],[ - dnl # - dnl # 4.2 API change - dnl # This kernel retired the nameidata structure. - dnl # - AC_MSG_CHECKING([whether iops->put_link() passes cookie]) - ZFS_LINUX_TEST_RESULT([put_link_cookie], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PUT_LINK_COOKIE, 1, - [iops->put_link() cookie]) - ],[ - AC_MSG_RESULT(no) - ZFS_LINUX_TEST_ERROR([put_link]) - ]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 319baf8ed196..2cf5c75624af 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -77,8 +77,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS ZFS_AC_KERNEL_SRC_CREATE ZFS_AC_KERNEL_SRC_PERMISSION - ZFS_AC_KERNEL_SRC_GET_LINK - ZFS_AC_KERNEL_SRC_PUT_LINK ZFS_AC_KERNEL_SRC_TMPFILE ZFS_AC_KERNEL_SRC_AUTOMOUNT ZFS_AC_KERNEL_SRC_COMMIT_METADATA @@ -207,8 +205,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_LOOKUP_FLAGS ZFS_AC_KERNEL_CREATE ZFS_AC_KERNEL_PERMISSION - ZFS_AC_KERNEL_GET_LINK - ZFS_AC_KERNEL_PUT_LINK ZFS_AC_KERNEL_TMPFILE ZFS_AC_KERNEL_AUTOMOUNT ZFS_AC_KERNEL_COMMIT_METADATA diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index 863e439f4f80..9d9c49d187af 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -647,19 +647,11 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name) return (error); } -#if defined(HAVE_PUT_LINK_COOKIE) -static void -zpl_put_link(struct inode *unused, void *cookie) -{ - kmem_free(cookie, MAXPATHLEN); -} -#elif defined(HAVE_PUT_LINK_DELAYED) static void zpl_put_link(void *ptr) { kmem_free(ptr, MAXPATHLEN); } -#endif static int zpl_get_link_common(struct dentry *dentry, struct inode *ip, char **link) @@ -691,7 +683,6 @@ zpl_get_link_common(struct dentry *dentry, struct inode *ip, char **link) return (error); } -#if defined(HAVE_GET_LINK_DELAYED) static const char * zpl_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *done) @@ -710,36 +701,6 @@ zpl_get_link(struct dentry *dentry, struct inode *inode, return (link); } -#elif defined(HAVE_GET_LINK_COOKIE) -static const char * -zpl_get_link(struct dentry *dentry, struct inode *inode, void **cookie) -{ - char *link = NULL; - int error; - - if (!dentry) - return (ERR_PTR(-ECHILD)); - - error = zpl_get_link_common(dentry, inode, &link); - if (error) - return (ERR_PTR(error)); - - return (*cookie = link); -} -#elif defined(HAVE_FOLLOW_LINK_COOKIE) -static const char * -zpl_follow_link(struct dentry *dentry, void **cookie) -{ - char *link = NULL; - int error; - - error = zpl_get_link_common(dentry, dentry->d_inode, &link); - if (error) - return (ERR_PTR(error)); - - return (*cookie = link); -} -#endif static int zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) @@ -835,14 +796,7 @@ const struct inode_operations zpl_symlink_inode_operations = { #ifdef HAVE_GENERIC_READLINK .readlink = generic_readlink, #endif -#if defined(HAVE_GET_LINK_DELAYED) || defined(HAVE_GET_LINK_COOKIE) .get_link = zpl_get_link, -#elif defined(HAVE_FOLLOW_LINK_COOKIE) - .follow_link = zpl_follow_link, -#endif -#if defined(HAVE_PUT_LINK_COOKIE) - .put_link = zpl_put_link, -#endif .setattr = zpl_setattr, .getattr = zpl_getattr, #ifdef HAVE_GENERIC_SETXATTR From 917ecc7b2c10ac60788396a5e80b56b5ed6eea21 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 17:31:53 +1000 Subject: [PATCH 138/223] config: remove HAVE_REQ_OP_* and HAVE_REQ_* Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bio.m4 | 137 ------------------ include/os/linux/kernel/linux/blkdev_compat.h | 51 +------ 2 files changed, 1 insertion(+), 187 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index 8d2af88d2e1f..6d3a020ede13 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -1,81 +1,3 @@ -dnl # -dnl # 2.6.36 API change, -dnl # REQ_FAILFAST_{DEV|TRANSPORT|DRIVER} -dnl # REQ_DISCARD -dnl # REQ_FLUSH -dnl # -dnl # 4.8 - 4.9 API, -dnl # REQ_FLUSH was renamed to REQ_PREFLUSH -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_REQ], [ - ZFS_LINUX_TEST_SRC([req_failfast_mask], [ - #include - ],[ - int flags __attribute__ ((unused)); - flags = REQ_FAILFAST_MASK; - ]) - - ZFS_LINUX_TEST_SRC([req_discard], [ - #include - ],[ - int flags __attribute__ ((unused)); - flags = REQ_DISCARD; - ]) - - ZFS_LINUX_TEST_SRC([req_flush], [ - #include - ],[ - int flags __attribute__ ((unused)); - flags = REQ_FLUSH; - ]) - - ZFS_LINUX_TEST_SRC([req_preflush], [ - #include - ],[ - int flags __attribute__ ((unused)); - flags = REQ_PREFLUSH; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_FAILFAST_MASK], [ - AC_MSG_CHECKING([whether REQ_FAILFAST_MASK is defined]) - ZFS_LINUX_TEST_RESULT([req_failfast_mask], [ - AC_MSG_RESULT(yes) - ],[ - ZFS_LINUX_TEST_ERROR([REQ_FAILFAST_MASK]) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_DISCARD], [ - AC_MSG_CHECKING([whether REQ_DISCARD is defined]) - ZFS_LINUX_TEST_RESULT([req_discard], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_REQ_DISCARD, 1, [REQ_DISCARD is defined]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_FLUSH], [ - AC_MSG_CHECKING([whether REQ_FLUSH is defined]) - ZFS_LINUX_TEST_RESULT([req_flush], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_REQ_FLUSH, 1, [REQ_FLUSH is defined]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_PREFLUSH], [ - AC_MSG_CHECKING([whether REQ_PREFLUSH is defined]) - ZFS_LINUX_TEST_RESULT([req_preflush], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_REQ_PREFLUSH, 1, [REQ_PREFLUSH is defined]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # Linux 4.8 API, dnl # @@ -84,24 +6,6 @@ dnl # checking the bio->bi_rw flags. The following checks are used to dnl # detect if a specific operation is supported. dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_OPS], [ - ZFS_LINUX_TEST_SRC([req_op_discard], [ - #include - ],[ - int op __attribute__ ((unused)) = REQ_OP_DISCARD; - ]) - - ZFS_LINUX_TEST_SRC([req_op_secure_erase], [ - #include - ],[ - int op __attribute__ ((unused)) = REQ_OP_SECURE_ERASE; - ]) - - ZFS_LINUX_TEST_SRC([req_op_flush], [ - #include - ],[ - int op __attribute__ ((unused)) = REQ_OP_FLUSH; - ]) - ZFS_LINUX_TEST_SRC([bio_set_op_attrs], [ #include ],[ @@ -110,37 +14,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_OPS], [ ]) ]) -AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_DISCARD], [ - AC_MSG_CHECKING([whether REQ_OP_DISCARD is defined]) - ZFS_LINUX_TEST_RESULT([req_op_discard], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_REQ_OP_DISCARD, 1, [REQ_OP_DISCARD is defined]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_SECURE_ERASE], [ - AC_MSG_CHECKING([whether REQ_OP_SECURE_ERASE is defined]) - ZFS_LINUX_TEST_RESULT([req_op_secure_erase], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_REQ_OP_SECURE_ERASE, 1, - [REQ_OP_SECURE_ERASE is defined]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH], [ - AC_MSG_CHECKING([whether REQ_OP_FLUSH is defined]) - ZFS_LINUX_TEST_RESULT([req_op_flush], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_REQ_OP_FLUSH, 1, [REQ_OP_FLUSH is defined]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_OP_ATTRS], [ AC_MSG_CHECKING([whether bio_set_op_attrs is available]) ZFS_LINUX_TEST_RESULT([bio_set_op_attrs], [ @@ -394,7 +267,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_ALLOC_4ARG], [ ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ - ZFS_AC_KERNEL_SRC_REQ ZFS_AC_KERNEL_SRC_BIO_OPS ZFS_AC_KERNEL_SRC_BIO_SET_DEV ZFS_AC_KERNEL_SRC_BIO_BI_STATUS @@ -407,16 +279,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ]) AC_DEFUN([ZFS_AC_KERNEL_BIO], [ - ZFS_AC_KERNEL_BIO_REQ_FAILFAST_MASK - ZFS_AC_KERNEL_BIO_REQ_DISCARD - ZFS_AC_KERNEL_BIO_REQ_FLUSH - ZFS_AC_KERNEL_BIO_REQ_PREFLUSH - - ZFS_AC_KERNEL_BIO_REQ_OP_DISCARD - ZFS_AC_KERNEL_BIO_REQ_OP_SECURE_ERASE - ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH ZFS_AC_KERNEL_BIO_SET_OP_ATTRS - ZFS_AC_KERNEL_BIO_SET_DEV ZFS_AC_KERNEL_BIO_BI_STATUS ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 5518f1f434af..87154003bf34 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -382,42 +382,17 @@ bio_set_op_attrs(struct bio *bio, unsigned rw, unsigned flags) /* * bio_set_flush - Set the appropriate flags in a bio to guarantee * data are on non-volatile media on completion. - * - * 2.6.37 - 4.8 API, - * Introduce WRITE_FLUSH, WRITE_FUA, and WRITE_FLUSH_FUA flags as a - * replacement for WRITE_BARRIER to allow expressing richer semantics - * to the block layer. It's up to the block layer to implement the - * semantics correctly. Use the WRITE_FLUSH_FUA flag combination. - * - * 4.8 - 4.9 API, - * REQ_FLUSH was renamed to REQ_PREFLUSH. For consistency with previous - * OpenZFS releases, prefer the WRITE_FLUSH_FUA flag set if it's available. - * - * 4.10 API, - * The read/write flags and their modifiers, including WRITE_FLUSH, - * WRITE_FUA and WRITE_FLUSH_FUA were removed from fs.h in - * torvalds/linux@70fd7614 and replaced by direct flag modification - * of the REQ_ flags in bio->bi_opf. Use REQ_PREFLUSH. */ static inline void bio_set_flush(struct bio *bio) { -#if defined(HAVE_REQ_PREFLUSH) /* >= 4.10 */ bio_set_op_attrs(bio, 0, REQ_PREFLUSH | REQ_OP_WRITE); -#elif defined(WRITE_FLUSH_FUA) /* >= 2.6.37 and <= 4.9 */ - bio_set_op_attrs(bio, 0, WRITE_FLUSH_FUA); -#else -#error "Allowing the build will cause bio_set_flush requests to be ignored." -#endif } /* * 4.8 API, * REQ_OP_FLUSH * - * 4.8-rc0 - 4.8-rc1, - * REQ_PREFLUSH - * * in all cases but may have a performance impact for some kernels. It * has the advantage of minimizing kernel specific changes in the zvol code. * @@ -425,13 +400,7 @@ bio_set_flush(struct bio *bio) static inline boolean_t bio_is_flush(struct bio *bio) { -#if defined(HAVE_REQ_OP_FLUSH) - return ((bio_op(bio) == REQ_OP_FLUSH) || (bio->bi_opf & REQ_PREFLUSH)); -#elif defined(HAVE_REQ_PREFLUSH) - return (bio->bi_opf & REQ_PREFLUSH); -#else -#error "Unsupported kernel" -#endif + return (bio_op(bio) == REQ_OP_FLUSH); } /* @@ -448,41 +417,23 @@ bio_is_fua(struct bio *bio) * 4.8 API, * REQ_OP_DISCARD * - * 2.6.36 - 4.7 API, - * REQ_DISCARD - * * In all cases the normal I/O path is used for discards. The only * difference is how the kernel tags individual I/Os as discards. */ static inline boolean_t bio_is_discard(struct bio *bio) { -#if defined(HAVE_REQ_OP_DISCARD) return (bio_op(bio) == REQ_OP_DISCARD); -#elif defined(HAVE_REQ_DISCARD) - return (bio->bi_rw & REQ_DISCARD); -#else -#error "Unsupported kernel" -#endif } /* * 4.8 API, * REQ_OP_SECURE_ERASE - * - * 2.6.36 - 4.7 API, - * REQ_SECURE */ static inline boolean_t bio_is_secure_erase(struct bio *bio) { -#if defined(HAVE_REQ_OP_SECURE_ERASE) return (bio_op(bio) == REQ_OP_SECURE_ERASE); -#elif defined(REQ_SECURE) - return (bio->bi_rw & REQ_SECURE); -#else - return (0); -#endif } /* From 0d53034f91583841645207ae45af0b001a12622b Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 17:33:16 +1000 Subject: [PATCH 139/223] config: remove HAVE_SUPER_USER_NS Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-super-userns.m4 | 25 ------------------------- config/kernel.m4 | 2 -- include/os/linux/spl/sys/cred.h | 4 ---- 3 files changed, 31 deletions(-) delete mode 100644 config/kernel-super-userns.m4 diff --git a/config/kernel-super-userns.m4 b/config/kernel-super-userns.m4 deleted file mode 100644 index 1ad35f2d19ba..000000000000 --- a/config/kernel-super-userns.m4 +++ /dev/null @@ -1,25 +0,0 @@ -dnl # -dnl # 4.8 API change -dnl # struct user_namespace was added to struct super_block as -dnl # super->s_user_ns member -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_USER_NS], [ - ZFS_LINUX_TEST_SRC([super_user_ns], [ - #include - #include - ], [ - struct super_block super; - super.s_user_ns = (struct user_namespace *)NULL; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SUPER_USER_NS], [ - AC_MSG_CHECKING([whether super_block->s_user_ns exists]) - ZFS_LINUX_TEST_RESULT([super_user_ns], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SUPER_USER_NS, 1, - [super_block->s_user_ns exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 2cf5c75624af..9358916c7584 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -53,7 +53,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_INODE_TIMES ZFS_AC_KERNEL_SRC_RW ZFS_AC_KERNEL_SRC_TIMER_SETUP - ZFS_AC_KERNEL_SRC_SUPER_USER_NS ZFS_AC_KERNEL_SRC_PROC_OPERATIONS ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS ZFS_AC_KERNEL_SRC_BIO @@ -181,7 +180,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_INODE_TIMES ZFS_AC_KERNEL_RW ZFS_AC_KERNEL_TIMER_SETUP - ZFS_AC_KERNEL_SUPER_USER_NS ZFS_AC_KERNEL_PROC_OPERATIONS ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS ZFS_AC_KERNEL_BIO diff --git a/include/os/linux/spl/sys/cred.h b/include/os/linux/spl/sys/cred.h index c19c3c0719ff..1c5120c24371 100644 --- a/include/os/linux/spl/sys/cred.h +++ b/include/os/linux/spl/sys/cred.h @@ -63,11 +63,7 @@ zfs_is_init_userns(struct user_namespace *user_ns) static inline struct user_namespace *zfs_i_user_ns(struct inode *inode) { -#ifdef HAVE_SUPER_USER_NS return (inode->i_sb->s_user_ns); -#else - return (kcred->user_ns); -#endif } static inline boolean_t zfs_no_idmapping(struct user_namespace *mnt_userns, From b5a21883bf3a376b99795bf6f60e48b9af65aacf Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 17:35:47 +1000 Subject: [PATCH 140/223] config: remove HAVE_VFS_COPY_FILE_RANGE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-file_range.m4 | 30 ---------------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_file.c | 2 -- module/os/linux/zfs/zpl_file_range.c | 2 -- 4 files changed, 36 deletions(-) diff --git a/config/kernel-vfs-file_range.m4 b/config/kernel-vfs-file_range.m4 index 8a5cbe2eeeed..936f7b4eba4c 100644 --- a/config/kernel-vfs-file_range.m4 +++ b/config/kernel-vfs-file_range.m4 @@ -19,36 +19,6 @@ dnl # dnl # 6.8: generic_copy_file_range() removed, replaced by dnl # splice_copy_file_range() dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE], [ - ZFS_LINUX_TEST_SRC([vfs_copy_file_range], [ - #include - - static ssize_t test_copy_file_range(struct file *src_file, - loff_t src_off, struct file *dst_file, loff_t dst_off, - size_t len, unsigned int flags) { - (void) src_file; (void) src_off; - (void) dst_file; (void) dst_off; - (void) len; (void) flags; - return (0); - } - - static const struct file_operations - fops __attribute__ ((unused)) = { - .copy_file_range = test_copy_file_range, - }; - ],[]) -]) -AC_DEFUN([ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE], [ - AC_MSG_CHECKING([whether fops->copy_file_range() is available]) - ZFS_LINUX_TEST_RESULT([vfs_copy_file_range], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_VFS_COPY_FILE_RANGE, 1, - [fops->copy_file_range() is available]) - ],[ - AC_MSG_RESULT([no]) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE], [ ZFS_LINUX_TEST_SRC([generic_copy_file_range], [ #include diff --git a/config/kernel.m4 b/config/kernel.m4 index 9358916c7584..46b83bfcc842 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -96,7 +96,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VFS_READPAGES ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_SRC_VFS_IOV_ITER - ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_SPLICE_COPY_FILE_RANGE ZFS_AC_KERNEL_SRC_VFS_REMAP_FILE_RANGE @@ -223,7 +222,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VFS_READPAGES ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_VFS_IOV_ITER - ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE ZFS_AC_KERNEL_VFS_SPLICE_COPY_FILE_RANGE ZFS_AC_KERNEL_VFS_REMAP_FILE_RANGE diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index aaccdef55667..e45a5064b9a6 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -1146,9 +1146,7 @@ const struct file_operations zpl_file_operations = { .aio_fsync = zpl_aio_fsync, #endif .fallocate = zpl_fallocate, -#ifdef HAVE_VFS_COPY_FILE_RANGE .copy_file_range = zpl_copy_file_range, -#endif #ifdef HAVE_VFS_CLONE_FILE_RANGE .clone_file_range = zpl_clone_file_range, #endif diff --git a/module/os/linux/zfs/zpl_file_range.c b/module/os/linux/zfs/zpl_file_range.c index 58f3c200aa84..d63797568ed2 100644 --- a/module/os/linux/zfs/zpl_file_range.c +++ b/module/os/linux/zfs/zpl_file_range.c @@ -83,7 +83,6 @@ zpl_clone_file_range_impl(struct file *src_file, loff_t src_off, return ((ssize_t)len_o); } -#if defined(HAVE_VFS_COPY_FILE_RANGE) /* * Entry point for copy_file_range(). Copy len bytes from src_off in src_file * to dst_off in dst_file. We are permitted to do this however we like, so we @@ -133,7 +132,6 @@ zpl_copy_file_range(struct file *src_file, loff_t src_off, return (ret); } -#endif /* HAVE_VFS_COPY_FILE_RANGE */ #ifdef HAVE_VFS_REMAP_FILE_RANGE /* From 5a615294fff32829a4c94e4f5ffecc398f54a92e Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 17:52:19 +1000 Subject: [PATCH 141/223] config: remove HAVE_VFS_ITERATE/HAVE_VFS_ITERATE_SHARED Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-iterate.m4 | 60 ------------------ config/kernel.m4 | 2 - include/os/linux/zfs/sys/zfs_vnops_os.h | 2 +- include/os/linux/zfs/sys/zpl.h | 67 -------------------- module/os/linux/zfs/zfs_vnops_os.c | 4 +- module/os/linux/zfs/zpl_ctldir.c | 82 +++---------------------- module/os/linux/zfs/zpl_file.c | 23 +------ 7 files changed, 13 insertions(+), 227 deletions(-) delete mode 100644 config/kernel-vfs-iterate.m4 diff --git a/config/kernel-vfs-iterate.m4 b/config/kernel-vfs-iterate.m4 deleted file mode 100644 index 7e2a9f0cb3a4..000000000000 --- a/config/kernel-vfs-iterate.m4 +++ /dev/null @@ -1,60 +0,0 @@ -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_ITERATE], [ - ZFS_LINUX_TEST_SRC([file_operations_iterate_shared], [ - #include - static int iterate(struct file *filp, struct dir_context * context) - { return 0; } - - static const struct file_operations fops - __attribute__ ((unused)) = { - .iterate_shared = iterate, - }; - ],[]) - - ZFS_LINUX_TEST_SRC([file_operations_iterate], [ - #include - static int iterate(struct file *filp, - struct dir_context *context) { return 0; } - - static const struct file_operations fops - __attribute__ ((unused)) = { - .iterate = iterate, - }; - - #if defined(FMODE_KABI_ITERATE) - #error "RHEL 7.5, FMODE_KABI_ITERATE interface" - #endif - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_VFS_ITERATE], [ - dnl # - dnl # 4.7 API change - dnl # - AC_MSG_CHECKING([whether fops->iterate_shared() is available]) - ZFS_LINUX_TEST_RESULT([file_operations_iterate_shared], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_VFS_ITERATE_SHARED, 1, - [fops->iterate_shared() is available]) - ],[ - AC_MSG_RESULT(no) - - dnl # - dnl # 3.11 API change - dnl # - dnl # RHEL 7.5 compatibility; the fops.iterate() method was - dnl # added to the file_operations structure but in order to - dnl # maintain KABI compatibility all callers must set - dnl # FMODE_KABI_ITERATE which is checked in iterate_dir(). - dnl # When detected ignore this interface and fallback to - dnl # to using fops.readdir() to retain KABI compatibility. - dnl # - AC_MSG_CHECKING([whether fops->iterate() is available]) - ZFS_LINUX_TEST_RESULT([file_operations_iterate], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_VFS_ITERATE, 1, - [fops->iterate() is available]) - ],[ - AC_MSG_RESULT(no) - ]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 46b83bfcc842..20893f58d3af 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -91,7 +91,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO ZFS_AC_KERNEL_SRC_VFS_GETATTR ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS - ZFS_AC_KERNEL_SRC_VFS_ITERATE ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO ZFS_AC_KERNEL_SRC_VFS_READPAGES ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS @@ -217,7 +216,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VFS_READ_FOLIO ZFS_AC_KERNEL_VFS_GETATTR ZFS_AC_KERNEL_VFS_FSYNC_2ARGS - ZFS_AC_KERNEL_VFS_ITERATE ZFS_AC_KERNEL_VFS_DIRECT_IO ZFS_AC_KERNEL_VFS_READPAGES ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS diff --git a/include/os/linux/zfs/sys/zfs_vnops_os.h b/include/os/linux/zfs/sys/zfs_vnops_os.h index 830c76e5743a..f34eb153f546 100644 --- a/include/os/linux/zfs/sys/zfs_vnops_os.h +++ b/include/os/linux/zfs/sys/zfs_vnops_os.h @@ -55,7 +55,7 @@ extern int zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap, znode_t **zpp, cred_t *cr, int flags, vsecattr_t *vsecp, zidmap_t *mnt_ns); extern int zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd, cred_t *cr, int flags); -extern int zfs_readdir(struct inode *ip, zpl_dir_context_t *ctx, cred_t *cr); +extern int zfs_readdir(struct inode *ip, struct dir_context *ctx, cred_t *cr); #ifdef HAVE_GENERIC_FILLATTR_IDMAP_REQMASK extern int zfs_getattr_fast(zidmap_t *, u32 request_mask, struct inode *ip, struct kstat *sp); diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index 38d8f086d3be..8ac459ead8a7 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -111,73 +111,6 @@ extern const struct inode_operations zpl_ops_snapdir; extern const struct file_operations zpl_fops_shares; extern const struct inode_operations zpl_ops_shares; -#if defined(HAVE_VFS_ITERATE) || defined(HAVE_VFS_ITERATE_SHARED) - -#define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \ - .actor = _actor, \ - .pos = _pos, \ -} - -typedef struct dir_context zpl_dir_context_t; - -#define zpl_dir_emit dir_emit -#define zpl_dir_emit_dot dir_emit_dot -#define zpl_dir_emit_dotdot dir_emit_dotdot -#define zpl_dir_emit_dots dir_emit_dots - -#else - -typedef struct zpl_dir_context { - void *dirent; - const filldir_t actor; - loff_t pos; -} zpl_dir_context_t; - -#define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \ - .dirent = _dirent, \ - .actor = _actor, \ - .pos = _pos, \ -} - -static inline bool -zpl_dir_emit(zpl_dir_context_t *ctx, const char *name, int namelen, - uint64_t ino, unsigned type) -{ - return (!ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type)); -} - -static inline bool -zpl_dir_emit_dot(struct file *file, zpl_dir_context_t *ctx) -{ - return (ctx->actor(ctx->dirent, ".", 1, ctx->pos, - file_inode(file)->i_ino, DT_DIR) == 0); -} - -static inline bool -zpl_dir_emit_dotdot(struct file *file, zpl_dir_context_t *ctx) -{ - return (ctx->actor(ctx->dirent, "..", 2, ctx->pos, - parent_ino(file_dentry(file)), DT_DIR) == 0); -} - -static inline bool -zpl_dir_emit_dots(struct file *file, zpl_dir_context_t *ctx) -{ - if (ctx->pos == 0) { - if (!zpl_dir_emit_dot(file, ctx)) - return (false); - ctx->pos = 1; - } - if (ctx->pos == 1) { - if (!zpl_dir_emit_dotdot(file, ctx)) - return (false); - ctx->pos = 2; - } - return (true); -} -#endif /* HAVE_VFS_ITERATE */ - - /* zpl_file_range.c */ /* handlers for file_operations of the same name */ diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c index bbe9f2818428..581e2e531771 100644 --- a/module/os/linux/zfs/zfs_vnops_os.c +++ b/module/os/linux/zfs/zfs_vnops_os.c @@ -1500,7 +1500,7 @@ zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd, cred_t *cr, * we use the offset 2 for the '.zfs' directory. */ int -zfs_readdir(struct inode *ip, zpl_dir_context_t *ctx, cred_t *cr) +zfs_readdir(struct inode *ip, struct dir_context *ctx, cred_t *cr) { (void) cr; znode_t *zp = ITOZ(ip); @@ -1606,7 +1606,7 @@ zfs_readdir(struct inode *ip, zpl_dir_context_t *ctx, cred_t *cr) type = ZFS_DIRENT_TYPE(zap.za_first_integer); } - done = !zpl_dir_emit(ctx, zap.za_name, strlen(zap.za_name), + done = !dir_emit(ctx, zap.za_name, strlen(zap.za_name), objnum, type); if (done) break; diff --git a/module/os/linux/zfs/zpl_ctldir.c b/module/os/linux/zfs/zpl_ctldir.c index eb8788074283..56a30be5110c 100644 --- a/module/os/linux/zfs/zpl_ctldir.c +++ b/module/os/linux/zfs/zpl_ctldir.c @@ -52,7 +52,7 @@ zpl_common_open(struct inode *ip, struct file *filp) * Get root directory contents. */ static int -zpl_root_iterate(struct file *filp, zpl_dir_context_t *ctx) +zpl_root_iterate(struct file *filp, struct dir_context *ctx) { zfsvfs_t *zfsvfs = ITOZSB(file_inode(filp)); int error = 0; @@ -60,11 +60,11 @@ zpl_root_iterate(struct file *filp, zpl_dir_context_t *ctx) if ((error = zpl_enter(zfsvfs, FTAG)) != 0) return (error); - if (!zpl_dir_emit_dots(filp, ctx)) + if (!dir_emit_dots(filp, ctx)) goto out; if (ctx->pos == 2) { - if (!zpl_dir_emit(ctx, ZFS_SNAPDIR_NAME, + if (!dir_emit(ctx, ZFS_SNAPDIR_NAME, strlen(ZFS_SNAPDIR_NAME), ZFSCTL_INO_SNAPDIR, DT_DIR)) goto out; @@ -72,7 +72,7 @@ zpl_root_iterate(struct file *filp, zpl_dir_context_t *ctx) } if (ctx->pos == 3) { - if (!zpl_dir_emit(ctx, ZFS_SHAREDIR_NAME, + if (!dir_emit(ctx, ZFS_SHAREDIR_NAME, strlen(ZFS_SHAREDIR_NAME), ZFSCTL_INO_SHARES, DT_DIR)) goto out; @@ -84,21 +84,6 @@ zpl_root_iterate(struct file *filp, zpl_dir_context_t *ctx) return (error); } -#if !defined(HAVE_VFS_ITERATE) && !defined(HAVE_VFS_ITERATE_SHARED) -static int -zpl_root_readdir(struct file *filp, void *dirent, filldir_t filldir) -{ - zpl_dir_context_t ctx = - ZPL_DIR_CONTEXT_INIT(dirent, filldir, filp->f_pos); - int error; - - error = zpl_root_iterate(filp, &ctx); - filp->f_pos = ctx.pos; - - return (error); -} -#endif /* !HAVE_VFS_ITERATE && !HAVE_VFS_ITERATE_SHARED */ - /* * Get root directory attributes. */ @@ -167,13 +152,7 @@ const struct file_operations zpl_fops_root = { .open = zpl_common_open, .llseek = generic_file_llseek, .read = generic_read_dir, -#ifdef HAVE_VFS_ITERATE_SHARED .iterate_shared = zpl_root_iterate, -#elif defined(HAVE_VFS_ITERATE) - .iterate = zpl_root_iterate, -#else - .readdir = zpl_root_readdir, -#endif }; const struct inode_operations zpl_ops_root = { @@ -254,7 +233,7 @@ zpl_snapdir_lookup(struct inode *dip, struct dentry *dentry, } static int -zpl_snapdir_iterate(struct file *filp, zpl_dir_context_t *ctx) +zpl_snapdir_iterate(struct file *filp, struct dir_context *ctx) { zfsvfs_t *zfsvfs = ITOZSB(file_inode(filp)); fstrans_cookie_t cookie; @@ -267,7 +246,7 @@ zpl_snapdir_iterate(struct file *filp, zpl_dir_context_t *ctx) return (error); cookie = spl_fstrans_mark(); - if (!zpl_dir_emit_dots(filp, ctx)) + if (!dir_emit_dots(filp, ctx)) goto out; /* Start the position at 0 if it already emitted . and .. */ @@ -280,7 +259,7 @@ zpl_snapdir_iterate(struct file *filp, zpl_dir_context_t *ctx) if (error) goto out; - if (!zpl_dir_emit(ctx, snapname, strlen(snapname), + if (!dir_emit(ctx, snapname, strlen(snapname), ZFSCTL_INO_SHARES - id, DT_DIR)) goto out; @@ -296,21 +275,6 @@ zpl_snapdir_iterate(struct file *filp, zpl_dir_context_t *ctx) return (error); } -#if !defined(HAVE_VFS_ITERATE) && !defined(HAVE_VFS_ITERATE_SHARED) -static int -zpl_snapdir_readdir(struct file *filp, void *dirent, filldir_t filldir) -{ - zpl_dir_context_t ctx = - ZPL_DIR_CONTEXT_INIT(dirent, filldir, filp->f_pos); - int error; - - error = zpl_snapdir_iterate(filp, &ctx); - filp->f_pos = ctx.pos; - - return (error); -} -#endif /* !HAVE_VFS_ITERATE && !HAVE_VFS_ITERATE_SHARED */ - static int #ifdef HAVE_IOPS_RENAME_USERNS zpl_snapdir_rename2(struct user_namespace *user_ns, struct inode *sdip, @@ -474,13 +438,7 @@ const struct file_operations zpl_fops_snapdir = { .open = zpl_common_open, .llseek = generic_file_llseek, .read = generic_read_dir, -#ifdef HAVE_VFS_ITERATE_SHARED .iterate_shared = zpl_snapdir_iterate, -#elif defined(HAVE_VFS_ITERATE) - .iterate = zpl_snapdir_iterate, -#else - .readdir = zpl_snapdir_readdir, -#endif }; @@ -531,7 +489,7 @@ zpl_shares_lookup(struct inode *dip, struct dentry *dentry, } static int -zpl_shares_iterate(struct file *filp, zpl_dir_context_t *ctx) +zpl_shares_iterate(struct file *filp, struct dir_context *ctx) { fstrans_cookie_t cookie; cred_t *cr = CRED(); @@ -544,7 +502,7 @@ zpl_shares_iterate(struct file *filp, zpl_dir_context_t *ctx) cookie = spl_fstrans_mark(); if (zfsvfs->z_shares_dir == 0) { - zpl_dir_emit_dots(filp, ctx); + dir_emit_dots(filp, ctx); goto out; } @@ -565,21 +523,6 @@ zpl_shares_iterate(struct file *filp, zpl_dir_context_t *ctx) return (error); } -#if !defined(HAVE_VFS_ITERATE) && !defined(HAVE_VFS_ITERATE_SHARED) -static int -zpl_shares_readdir(struct file *filp, void *dirent, filldir_t filldir) -{ - zpl_dir_context_t ctx = - ZPL_DIR_CONTEXT_INIT(dirent, filldir, filp->f_pos); - int error; - - error = zpl_shares_iterate(filp, &ctx); - filp->f_pos = ctx.pos; - - return (error); -} -#endif /* !HAVE_VFS_ITERATE && !HAVE_VFS_ITERATE_SHARED */ - static int #ifdef HAVE_USERNS_IOPS_GETATTR zpl_shares_getattr_impl(struct user_namespace *user_ns, @@ -650,14 +593,7 @@ const struct file_operations zpl_fops_shares = { .open = zpl_common_open, .llseek = generic_file_llseek, .read = generic_read_dir, -#ifdef HAVE_VFS_ITERATE_SHARED .iterate_shared = zpl_shares_iterate, -#elif defined(HAVE_VFS_ITERATE) - .iterate = zpl_shares_iterate, -#else - .readdir = zpl_shares_readdir, -#endif - }; /* diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index e45a5064b9a6..e854834fc10c 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -93,7 +93,7 @@ zpl_release(struct inode *ip, struct file *filp) } static int -zpl_iterate(struct file *filp, zpl_dir_context_t *ctx) +zpl_iterate(struct file *filp, struct dir_context *ctx) { cred_t *cr = CRED(); int error; @@ -109,21 +109,6 @@ zpl_iterate(struct file *filp, zpl_dir_context_t *ctx) return (error); } -#if !defined(HAVE_VFS_ITERATE) && !defined(HAVE_VFS_ITERATE_SHARED) -static int -zpl_readdir(struct file *filp, void *dirent, filldir_t filldir) -{ - zpl_dir_context_t ctx = - ZPL_DIR_CONTEXT_INIT(dirent, filldir, filp->f_pos); - int error; - - error = zpl_iterate(filp, &ctx); - filp->f_pos = ctx.pos; - - return (error); -} -#endif /* !HAVE_VFS_ITERATE && !HAVE_VFS_ITERATE_SHARED */ - static int zpl_fsync(struct file *filp, loff_t start, loff_t end, int datasync) { @@ -1168,13 +1153,7 @@ const struct file_operations zpl_file_operations = { const struct file_operations zpl_dir_file_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, -#if defined(HAVE_VFS_ITERATE_SHARED) .iterate_shared = zpl_iterate, -#elif defined(HAVE_VFS_ITERATE) - .iterate = zpl_iterate, -#else - .readdir = zpl_readdir, -#endif .fsync = zpl_fsync, .unlocked_ioctl = zpl_ioctl, #ifdef CONFIG_COMPAT From 783fa01cc6891f8c98ab952fc634eb00305bc268 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 18:11:21 +1000 Subject: [PATCH 142/223] config: remove HAVE_XATTR_HANDLER_NAME Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-xattr-handler.m4 | 30 ------------------- module/os/linux/zfs/zpl_xattr.c | 52 ++------------------------------- 2 files changed, 2 insertions(+), 80 deletions(-) diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4 index 6a07e9ee58b3..d85f6e5b2f38 100644 --- a/config/kernel-xattr-handler.m4 +++ b/config/kernel-xattr-handler.m4 @@ -33,34 +33,6 @@ AC_DEFUN([ZFS_AC_KERNEL_CONST_XATTR_HANDLER], [ ]) ]) -dnl # -dnl # 4.5 API change, -dnl # struct xattr_handler added new member "name". -dnl # xattr_handler which matches to whole name rather than prefix should use -dnl # "name" instead of "prefix", e.g. "system.posix_acl_access" -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_NAME], [ - ZFS_LINUX_TEST_SRC([xattr_handler_name], [ - #include - - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .name = XATTR_NAME_POSIX_ACL_ACCESS, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_NAME], [ - AC_MSG_CHECKING([whether xattr_handler has name]) - ZFS_LINUX_TEST_RESULT([xattr_handler_name], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_HANDLER_NAME, 1, - [xattr_handler has name]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # Supported xattr handler get() interfaces checked newest to oldest. dnl # @@ -350,7 +322,6 @@ AC_DEFUN([ZFS_AC_KERNEL_GENERIC_SETXATTR], [ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR], [ ZFS_AC_KERNEL_SRC_CONST_XATTR_HANDLER - ZFS_AC_KERNEL_SRC_XATTR_HANDLER_NAME ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET ZFS_AC_KERNEL_SRC_XATTR_HANDLER_LIST @@ -359,7 +330,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR], [ AC_DEFUN([ZFS_AC_KERNEL_XATTR], [ ZFS_AC_KERNEL_CONST_XATTR_HANDLER - ZFS_AC_KERNEL_XATTR_HANDLER_NAME ZFS_AC_KERNEL_XATTR_HANDLER_GET ZFS_AC_KERNEL_XATTR_HANDLER_SET ZFS_AC_KERNEL_XATTR_HANDLER_LIST diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index dc0113d38b7b..bd313d36ac29 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -712,10 +712,6 @@ __zpl_xattr_user_get(struct inode *ip, const char *name, { int error; /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") == 0) - return (-EINVAL); -#endif if (ZFS_XA_NS_PREFIX_FORBIDDEN(name)) return (-EINVAL); if (!(ITOZSB(ip)->z_flags & ZSB_XATTR)) @@ -745,10 +741,6 @@ __zpl_xattr_user_set(zidmap_t *user_ns, (void) user_ns; int error = 0; /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") == 0) - return (-EINVAL); -#endif if (ZFS_XA_NS_PREFIX_FORBIDDEN(name)) return (-EINVAL); if (!(ITOZSB(ip)->z_flags & ZSB_XATTR)) @@ -835,10 +827,6 @@ __zpl_xattr_trusted_get(struct inode *ip, const char *name, if (!capable(CAP_SYS_ADMIN)) return (-EACCES); /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") == 0) - return (-EINVAL); -#endif xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name); error = zpl_xattr_get(ip, xattr_name, value, size); kmem_strfree(xattr_name); @@ -859,10 +847,6 @@ __zpl_xattr_trusted_set(zidmap_t *user_ns, if (!capable(CAP_SYS_ADMIN)) return (-EACCES); /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") == 0) - return (-EINVAL); -#endif xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name); error = zpl_xattr_set(ip, xattr_name, value, size, flags); kmem_strfree(xattr_name); @@ -905,10 +889,6 @@ __zpl_xattr_security_get(struct inode *ip, const char *name, char *xattr_name; int error; /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") == 0) - return (-EINVAL); -#endif xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name); error = zpl_xattr_get(ip, xattr_name, value, size); kmem_strfree(xattr_name); @@ -926,10 +906,6 @@ __zpl_xattr_security_set(zidmap_t *user_ns, char *xattr_name; int error; /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") == 0) - return (-EINVAL); -#endif xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name); error = zpl_xattr_set(ip, xattr_name, value, size, flags); kmem_strfree(xattr_name); @@ -1251,10 +1227,6 @@ __zpl_xattr_acl_get_access(struct inode *ip, const char *name, int type = ACL_TYPE_ACCESS; int error; /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") != 0) - return (-EINVAL); -#endif if (ITOZSB(ip)->z_acl_type != ZFS_ACLTYPE_POSIX) return (-EOPNOTSUPP); @@ -1279,10 +1251,6 @@ __zpl_xattr_acl_get_default(struct inode *ip, const char *name, int type = ACL_TYPE_DEFAULT; int error; /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") != 0) - return (-EINVAL); -#endif if (ITOZSB(ip)->z_acl_type != ZFS_ACLTYPE_POSIX) return (-EOPNOTSUPP); @@ -1308,10 +1276,6 @@ __zpl_xattr_acl_set_access(zidmap_t *mnt_ns, int type = ACL_TYPE_ACCESS; int error = 0; /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") != 0) - return (-EINVAL); -#endif if (ITOZSB(ip)->z_acl_type != ZFS_ACLTYPE_POSIX) return (-EOPNOTSUPP); @@ -1354,10 +1318,6 @@ __zpl_xattr_acl_set_default(zidmap_t *mnt_ns, int type = ACL_TYPE_DEFAULT; int error = 0; /* xattr_resolve_name will do this for us if this is defined */ -#ifndef HAVE_XATTR_HANDLER_NAME - if (strcmp(name, "") != 0) - return (-EINVAL); -#endif if (ITOZSB(ip)->z_acl_type != ZFS_ACLTYPE_POSIX) return (-EOPNOTSUPP); @@ -1399,11 +1359,7 @@ ZPL_XATTR_SET_WRAPPER(zpl_xattr_acl_set_default); * whole name and reject anything that has .name only as prefix. */ static xattr_handler_t zpl_xattr_acl_access_handler = { -#ifdef HAVE_XATTR_HANDLER_NAME .name = XATTR_NAME_POSIX_ACL_ACCESS, -#else - .prefix = XATTR_NAME_POSIX_ACL_ACCESS, -#endif .list = zpl_xattr_acl_list_access, .get = zpl_xattr_acl_get_access, .set = zpl_xattr_acl_set_access, @@ -1416,15 +1372,11 @@ static xattr_handler_t zpl_xattr_acl_access_handler = { /* * ACL default xattr namespace handlers. * - * Use .name instead of .prefix when available. xattr_resolve_name will match - * whole name and reject anything that has .name only as prefix. + * Use .name instead of .prefix. xattr_resolve_name will match whole name and + * reject anything that has .name only as prefix. */ static xattr_handler_t zpl_xattr_acl_default_handler = { -#ifdef HAVE_XATTR_HANDLER_NAME .name = XATTR_NAME_POSIX_ACL_DEFAULT, -#else - .prefix = XATTR_NAME_POSIX_ACL_DEFAULT, -#endif .list = zpl_xattr_acl_list_default, .get = zpl_xattr_acl_get_default, .set = zpl_xattr_acl_set_default, From a0f51c582061d5a27b7d9d642a7a100e3410a293 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 18:17:39 +1000 Subject: [PATCH 143/223] config: remove HAVE_XATTR_(GET|SET|LIST)_HANDLER Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-xattr-handler.m4 | 100 ++----------------- include/os/linux/kernel/linux/xattr_compat.h | 38 ------- module/os/linux/zfs/zpl_xattr.c | 9 +- 3 files changed, 11 insertions(+), 136 deletions(-) diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4 index d85f6e5b2f38..2e60f8f57e08 100644 --- a/config/kernel-xattr-handler.m4 +++ b/config/kernel-xattr-handler.m4 @@ -49,18 +49,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET], [ }; ],[]) - ZFS_LINUX_TEST_SRC([xattr_handler_get_xattr_handler], [ - #include - - static int get(const struct xattr_handler *handler, - struct dentry *dentry, const char *name, - void *buffer, size_t size) { return 0; } - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .get = get, - }; - ],[]) - ZFS_LINUX_TEST_SRC([xattr_handler_get_dentry_inode_flags], [ #include @@ -88,34 +76,19 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [ [xattr_handler->get() wants both dentry and inode]) ],[ dnl # - dnl # 4.4 API change, - dnl # The xattr_handler->get() callback was changed to take a - dnl # attr_handler, and handler_flags argument was removed and - dnl # should be accessed by handler->flags. + dnl # Android API change, + dnl # The xattr_handler->get() callback was + dnl # changed to take dentry, inode and flags. dnl # AC_MSG_RESULT(no) AC_MSG_CHECKING( - [whether xattr_handler->get() wants xattr_handler]) - ZFS_LINUX_TEST_RESULT([xattr_handler_get_xattr_handler], [ + [whether xattr_handler->get() wants dentry and inode and flags]) + ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_GET_HANDLER, 1, - [xattr_handler->get() wants xattr_handler]) + AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1, + [xattr_handler->get() wants dentry and inode and flags]) ],[ - dnl # - dnl # Android API change, - dnl # The xattr_handler->get() callback was - dnl # changed to take dentry, inode and flags. - dnl # - AC_MSG_RESULT(no) - AC_MSG_CHECKING( - [whether xattr_handler->get() wants dentry and inode and flags]) - ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1, - [xattr_handler->get() wants dentry and inode and flags]) - ],[ - ZFS_LINUX_TEST_ERROR([xattr get()]) - ]) + ZFS_LINUX_TEST_ERROR([xattr get()]) ]) ]) ]) @@ -167,19 +140,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET], [ .set = set, }; ],[]) - - ZFS_LINUX_TEST_SRC([xattr_handler_set_xattr_handler], [ - #include - - static int set(const struct xattr_handler *handler, - struct dentry *dentry, const char *name, - const void *buffer, size_t size, int flags) - { return 0; } - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .set = set, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [ @@ -215,22 +175,7 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [ AC_DEFINE(HAVE_XATTR_SET_DENTRY_INODE, 1, [xattr_handler->set() wants both dentry and inode]) ],[ - dnl # - dnl # 4.4 API change, - dnl # The xattr_handler->set() callback was changed to take a - dnl # xattr_handler, and handler_flags argument was removed and - dnl # should be accessed by handler->flags. - dnl # - AC_MSG_RESULT(no) - AC_MSG_CHECKING( - [whether xattr_handler->set() wants xattr_handler]) - ZFS_LINUX_TEST_RESULT([xattr_handler_set_xattr_handler], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_SET_HANDLER, 1, - [xattr_handler->set() wants xattr_handler]) - ],[ - ZFS_LINUX_TEST_ERROR([xattr set()]) - ]) + ZFS_LINUX_TEST_ERROR([xattr set()]) ]) ]) ]) @@ -249,18 +194,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_LIST], [ .list = list, }; ],[]) - - ZFS_LINUX_TEST_SRC([xattr_handler_list_xattr_handler], [ - #include - - static size_t list(const struct xattr_handler *handler, - struct dentry *dentry, char *list, size_t list_size, - const char *name, size_t name_len) { return 0; } - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .list = list, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_LIST], [ @@ -273,22 +206,7 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_LIST], [ AC_DEFINE(HAVE_XATTR_LIST_SIMPLE, 1, [xattr_handler->list() wants simple]) ],[ - dnl # - dnl # 4.4 API change, - dnl # The xattr_handler->list() callback was changed to take a - dnl # xattr_handler, and handler_flags argument was removed - dnl # and should be accessed by handler->flags. - dnl # AC_MSG_RESULT(no) - AC_MSG_CHECKING( - [whether xattr_handler->list() wants xattr_handler]) - ZFS_LINUX_TEST_RESULT([xattr_handler_list_xattr_handler], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_LIST_HANDLER, 1, - [xattr_handler->list() wants xattr_handler]) - ],[ - ZFS_LINUX_TEST_ERROR([xattr list()]) - ]) ]) ]) diff --git a/include/os/linux/kernel/linux/xattr_compat.h b/include/os/linux/kernel/linux/xattr_compat.h index b3761a422d39..956c2b73db3b 100644 --- a/include/os/linux/kernel/linux/xattr_compat.h +++ b/include/os/linux/kernel/linux/xattr_compat.h @@ -47,15 +47,6 @@ fn(struct dentry *dentry) \ { \ return (!!__ ## fn(dentry->d_inode, NULL, 0, NULL, 0)); \ } -#elif defined(HAVE_XATTR_LIST_HANDLER) -#define ZPL_XATTR_LIST_WRAPPER(fn) \ -static size_t \ -fn(const struct xattr_handler *handler, struct dentry *dentry, \ - char *list, size_t list_size, const char *name, size_t name_len) \ -{ \ - return (__ ## fn(dentry->d_inode, \ - list, list_size, name, name_len)); \ -} #else #error "Unsupported kernel" #endif @@ -73,20 +64,6 @@ fn(const struct xattr_handler *handler, struct dentry *dentry, \ { \ return (__ ## fn(inode, name, buffer, size)); \ } -/* - * 4.4 API change, - * The xattr_handler->get() callback was changed to take a xattr_handler, - * and handler_flags argument was removed and should be accessed by - * handler->flags. - */ -#elif defined(HAVE_XATTR_GET_HANDLER) -#define ZPL_XATTR_GET_WRAPPER(fn) \ -static int \ -fn(const struct xattr_handler *handler, struct dentry *dentry, \ - const char *name, void *buffer, size_t size) \ -{ \ - return (__ ## fn(dentry->d_inode, name, buffer, size)); \ -} /* * Android API change, * The xattr_handler->get() callback was changed to take a dentry and inode @@ -149,21 +126,6 @@ fn(const struct xattr_handler *handler, struct dentry *dentry, \ { \ return (__ ## fn(kcred->user_ns, inode, name, buffer, size, flags));\ } -/* - * 4.4 API change, - * The xattr_handler->set() callback was changed to take a xattr_handler, - * and handler_flags argument was removed and should be accessed by - * handler->flags. - */ -#elif defined(HAVE_XATTR_SET_HANDLER) -#define ZPL_XATTR_SET_WRAPPER(fn) \ -static int \ -fn(const struct xattr_handler *handler, struct dentry *dentry, \ - const char *name, const void *buffer, size_t size, int flags) \ -{ \ - return (__ ## fn(kcred->user_ns, dentry->d_inode, name, \ - buffer, size, flags)); \ -} #else #error "Unsupported kernel" #endif diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index bd313d36ac29..183160ead1a3 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1363,8 +1363,7 @@ static xattr_handler_t zpl_xattr_acl_access_handler = { .list = zpl_xattr_acl_list_access, .get = zpl_xattr_acl_get_access, .set = zpl_xattr_acl_set_access, -#if defined(HAVE_XATTR_LIST_SIMPLE) || \ - defined(HAVE_XATTR_LIST_HANDLER) +#if defined(HAVE_XATTR_LIST_SIMPLE) .flags = ACL_TYPE_ACCESS, #endif }; @@ -1380,8 +1379,7 @@ static xattr_handler_t zpl_xattr_acl_default_handler = { .list = zpl_xattr_acl_list_default, .get = zpl_xattr_acl_get_default, .set = zpl_xattr_acl_set_default, -#if defined(HAVE_XATTR_LIST_SIMPLE) || \ - defined(HAVE_XATTR_LIST_HANDLER) +#if defined(HAVE_XATTR_LIST_SIMPLE) .flags = ACL_TYPE_DEFAULT, #endif }; @@ -1451,9 +1449,6 @@ zpl_xattr_permission(xattr_filldir_t *xf, const char *name, int name_len) #if defined(HAVE_XATTR_LIST_SIMPLE) if (!handler->list(d)) return (XAPERM_DENY); -#elif defined(HAVE_XATTR_LIST_HANDLER) - if (!handler->list(handler, d, NULL, 0, name, name_len)) - return (XAPERM_DENY); #endif } From 7ed1dd44dd23f98bcaa8decea5f145f729d0f0a1 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 18:19:35 +1000 Subject: [PATCH 144/223] config: remove HAVE_XATTR_LIST_SIMPLE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-xattr-handler.m4 | 31 -------------------- include/os/linux/kernel/linux/xattr_compat.h | 4 --- module/os/linux/zfs/zpl_xattr.c | 6 ---- 3 files changed, 41 deletions(-) diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4 index 2e60f8f57e08..f83e33b00676 100644 --- a/config/kernel-xattr-handler.m4 +++ b/config/kernel-xattr-handler.m4 @@ -181,35 +181,6 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [ ]) ]) -dnl # -dnl # Supported xattr handler list() interfaces checked newest to oldest. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_LIST], [ - ZFS_LINUX_TEST_SRC([xattr_handler_list_simple], [ - #include - - static bool list(struct dentry *dentry) { return 0; } - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .list = list, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_LIST], [ - dnl # 4.5 API change, - dnl # The xattr_handler->list() callback was changed to take only a - dnl # dentry and it only needs to return if it's accessible. - AC_MSG_CHECKING([whether xattr_handler->list() wants simple]) - ZFS_LINUX_TEST_RESULT([xattr_handler_list_simple], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_LIST_SIMPLE, 1, - [xattr_handler->list() wants simple]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 4.9 API change, dnl # iops->{set,get,remove}xattr and generic_{set,get,remove}xattr are @@ -242,7 +213,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR], [ ZFS_AC_KERNEL_SRC_CONST_XATTR_HANDLER ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET - ZFS_AC_KERNEL_SRC_XATTR_HANDLER_LIST ZFS_AC_KERNEL_SRC_GENERIC_SETXATTR ]) @@ -250,6 +220,5 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR], [ ZFS_AC_KERNEL_CONST_XATTR_HANDLER ZFS_AC_KERNEL_XATTR_HANDLER_GET ZFS_AC_KERNEL_XATTR_HANDLER_SET - ZFS_AC_KERNEL_XATTR_HANDLER_LIST ZFS_AC_KERNEL_GENERIC_SETXATTR ]) diff --git a/include/os/linux/kernel/linux/xattr_compat.h b/include/os/linux/kernel/linux/xattr_compat.h index 956c2b73db3b..9f3b78a7e251 100644 --- a/include/os/linux/kernel/linux/xattr_compat.h +++ b/include/os/linux/kernel/linux/xattr_compat.h @@ -40,16 +40,12 @@ typedef const struct xattr_handler xattr_handler_t; /* * 4.5 API change, */ -#if defined(HAVE_XATTR_LIST_SIMPLE) #define ZPL_XATTR_LIST_WRAPPER(fn) \ static bool \ fn(struct dentry *dentry) \ { \ return (!!__ ## fn(dentry->d_inode, NULL, 0, NULL, 0)); \ } -#else -#error "Unsupported kernel" -#endif /* * 4.7 API change, diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index 183160ead1a3..958af83ef8fa 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1363,9 +1363,7 @@ static xattr_handler_t zpl_xattr_acl_access_handler = { .list = zpl_xattr_acl_list_access, .get = zpl_xattr_acl_get_access, .set = zpl_xattr_acl_set_access, -#if defined(HAVE_XATTR_LIST_SIMPLE) .flags = ACL_TYPE_ACCESS, -#endif }; /* @@ -1379,9 +1377,7 @@ static xattr_handler_t zpl_xattr_acl_default_handler = { .list = zpl_xattr_acl_list_default, .get = zpl_xattr_acl_get_default, .set = zpl_xattr_acl_set_default, -#if defined(HAVE_XATTR_LIST_SIMPLE) .flags = ACL_TYPE_DEFAULT, -#endif }; #endif /* CONFIG_FS_POSIX_ACL */ @@ -1446,10 +1442,8 @@ zpl_xattr_permission(xattr_filldir_t *xf, const char *name, int name_len) } if (handler->list) { -#if defined(HAVE_XATTR_LIST_SIMPLE) if (!handler->list(d)) return (XAPERM_DENY); -#endif } return (perm); From 5bffb7ee9cc991a630d8065d18e3070c40ff4909 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 18:50:48 +1000 Subject: [PATCH 145/223] config: remove HAVE_XATTR_GET_DENTRY_INODE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-xattr-handler.m4 | 53 +++++--------------- include/os/linux/kernel/linux/xattr_compat.h | 22 +++----- 2 files changed, 20 insertions(+), 55 deletions(-) diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4 index f83e33b00676..704b1d74e900 100644 --- a/config/kernel-xattr-handler.m4 +++ b/config/kernel-xattr-handler.m4 @@ -34,21 +34,11 @@ AC_DEFUN([ZFS_AC_KERNEL_CONST_XATTR_HANDLER], [ ]) dnl # -dnl # Supported xattr handler get() interfaces checked newest to oldest. +dnl # Android API change, +dnl # The xattr_handler->get() callback was +dnl # changed to take dentry, inode and flags. dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET], [ - ZFS_LINUX_TEST_SRC([xattr_handler_get_dentry_inode], [ - #include - - static int get(const struct xattr_handler *handler, - struct dentry *dentry, struct inode *inode, - const char *name, void *buffer, size_t size) { return 0; } - static const struct xattr_handler - xops __attribute__ ((unused)) = { - .get = get, - }; - ],[]) - +AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS], [ ZFS_LINUX_TEST_SRC([xattr_handler_get_dentry_inode_flags], [ #include @@ -63,33 +53,16 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET], [ ],[]) ]) -AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [ - dnl # - dnl # 4.7 API change, - dnl # The xattr_handler->get() callback was changed to take both - dnl # dentry and inode. - dnl # - AC_MSG_CHECKING([whether xattr_handler->get() wants dentry and inode]) - ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode], [ +AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS], [ + AC_MSG_RESULT(no) + AC_MSG_CHECKING( + [whether xattr_handler->get() wants dentry and inode and flags]) + ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE, 1, - [xattr_handler->get() wants both dentry and inode]) + AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1, + [xattr_handler->get() wants dentry and inode and flags]) ],[ - dnl # - dnl # Android API change, - dnl # The xattr_handler->get() callback was - dnl # changed to take dentry, inode and flags. - dnl # AC_MSG_RESULT(no) - AC_MSG_CHECKING( - [whether xattr_handler->get() wants dentry and inode and flags]) - ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1, - [xattr_handler->get() wants dentry and inode and flags]) - ],[ - ZFS_LINUX_TEST_ERROR([xattr get()]) - ]) ]) ]) @@ -211,14 +184,14 @@ AC_DEFUN([ZFS_AC_KERNEL_GENERIC_SETXATTR], [ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR], [ ZFS_AC_KERNEL_SRC_CONST_XATTR_HANDLER - ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET + ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET ZFS_AC_KERNEL_SRC_GENERIC_SETXATTR ]) AC_DEFUN([ZFS_AC_KERNEL_XATTR], [ ZFS_AC_KERNEL_CONST_XATTR_HANDLER - ZFS_AC_KERNEL_XATTR_HANDLER_GET + ZFS_AC_KERNEL_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS ZFS_AC_KERNEL_XATTR_HANDLER_SET ZFS_AC_KERNEL_GENERIC_SETXATTR ]) diff --git a/include/os/linux/kernel/linux/xattr_compat.h b/include/os/linux/kernel/linux/xattr_compat.h index 9f3b78a7e251..f7e62da62007 100644 --- a/include/os/linux/kernel/linux/xattr_compat.h +++ b/include/os/linux/kernel/linux/xattr_compat.h @@ -47,35 +47,27 @@ fn(struct dentry *dentry) \ return (!!__ ## fn(dentry->d_inode, NULL, 0, NULL, 0)); \ } +#ifdef HAVE_XATTR_GET_DENTRY_INODE_FLAGS /* - * 4.7 API change, - * The xattr_handler->get() callback was changed to take a both dentry and - * inode, because the dentry might not be attached to an inode yet. + * Android API change, + * The xattr_handler->get() callback also takes a flags arg. */ -#if defined(HAVE_XATTR_GET_DENTRY_INODE) #define ZPL_XATTR_GET_WRAPPER(fn) \ static int \ fn(const struct xattr_handler *handler, struct dentry *dentry, \ - struct inode *inode, const char *name, void *buffer, size_t size) \ + struct inode *inode, const char *name, void *buffer, \ + size_t size, int flags) \ { \ return (__ ## fn(inode, name, buffer, size)); \ } -/* - * Android API change, - * The xattr_handler->get() callback was changed to take a dentry and inode - * and flags, because the dentry might not be attached to an inode yet. - */ -#elif defined(HAVE_XATTR_GET_DENTRY_INODE_FLAGS) +#else #define ZPL_XATTR_GET_WRAPPER(fn) \ static int \ fn(const struct xattr_handler *handler, struct dentry *dentry, \ - struct inode *inode, const char *name, void *buffer, \ - size_t size, int flags) \ + struct inode *inode, const char *name, void *buffer, size_t size) \ { \ return (__ ## fn(inode, name, buffer, size)); \ } -#else -#error "Unsupported kernel" #endif /* From 31952dc1c1027e18e1f65533108e2e0427fd413a Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 20:17:19 +1000 Subject: [PATCH 146/223] config: remove ZFS_GLOBAL_NODE_PAGE_STATE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-global_page_state.m4 | 28 --------------------- include/os/linux/kernel/linux/page_compat.h | 9 +------ 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/config/kernel-global_page_state.m4 b/config/kernel-global_page_state.m4 index 76f2bba202a1..114f3c8dc8fc 100644 --- a/config/kernel-global_page_state.m4 +++ b/config/kernel-global_page_state.m4 @@ -1,29 +1,3 @@ -dnl # -dnl # 4.8 API change -dnl # -dnl # 75ef71840539 mm, vmstat: add infrastructure for per-node vmstats -dnl # 599d0c954f91 mm, vmscan: move LRU lists to node -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_GLOBAL_NODE_PAGE_STATE], [ - ZFS_LINUX_TEST_SRC([global_node_page_state], [ - #include - #include - ],[ - (void) global_node_page_state(0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_NODE_PAGE_STATE], [ - AC_MSG_CHECKING([whether global_node_page_state() exists]) - ZFS_LINUX_TEST_RESULT([global_node_page_state], [ - AC_MSG_RESULT(yes) - AC_DEFINE(ZFS_GLOBAL_NODE_PAGE_STATE, 1, - [global_node_page_state() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 4.14 API change dnl # @@ -99,7 +73,6 @@ AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE_SANITY], [ ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE], [ - ZFS_AC_KERNEL_SRC_GLOBAL_NODE_PAGE_STATE ZFS_AC_KERNEL_SRC_GLOBAL_ZONE_PAGE_STATE ]) @@ -107,7 +80,6 @@ dnl # dnl # enum members in which we're interested dnl # AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE], [ - ZFS_AC_KERNEL_GLOBAL_NODE_PAGE_STATE ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE ZFS_AC_KERNEL_ENUM_MEMBER([NR_FILE_PAGES], diff --git a/include/os/linux/kernel/linux/page_compat.h b/include/os/linux/kernel/linux/page_compat.h index bd6cb398b0c0..040c9b6a91f7 100644 --- a/include/os/linux/kernel/linux/page_compat.h +++ b/include/os/linux/kernel/linux/page_compat.h @@ -36,7 +36,7 @@ #define nr_inactive_file_pages() global_zone_page_state(NR_INACTIVE_FILE) #endif -#elif defined(ZFS_GLOBAL_NODE_PAGE_STATE) +#else /* global_node_page_state() introduced */ #if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_FILE_PAGES) @@ -55,13 +55,6 @@ #define nr_inactive_file_pages() global_page_state(NR_INACTIVE_FILE) #endif -#else - -/* global_page_state() only */ -#define nr_file_pages() global_page_state(NR_FILE_PAGES) -#define nr_inactive_anon_pages() global_page_state(NR_INACTIVE_ANON) -#define nr_inactive_file_pages() global_page_state(NR_INACTIVE_FILE) - #endif /* ZFS_GLOBAL_ZONE_PAGE_STATE */ #endif /* _ZFS_PAGE_COMPAT_H */ From 0155b9d83130c9a3ce075996614dd9005af4e06f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 21:01:17 +1000 Subject: [PATCH 147/223] config: remove HAVE_FILE_AIO_FSYNC Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-aio-fsync.m4 | 23 ----------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_file.c | 11 ----------- 3 files changed, 36 deletions(-) delete mode 100644 config/kernel-aio-fsync.m4 diff --git a/config/kernel-aio-fsync.m4 b/config/kernel-aio-fsync.m4 deleted file mode 100644 index b4dbf29ba781..000000000000 --- a/config/kernel-aio-fsync.m4 +++ /dev/null @@ -1,23 +0,0 @@ -dnl # -dnl # Linux 4.9-rc5+ ABI, removal of the .aio_fsync field -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_AIO_FSYNC], [ - ZFS_LINUX_TEST_SRC([aio_fsync], [ - #include - - static const struct file_operations - fops __attribute__ ((unused)) = { - .aio_fsync = NULL, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_AIO_FSYNC], [ - AC_MSG_CHECKING([whether fops->aio_fsync() exists]) - ZFS_LINUX_TEST_RESULT([aio_fsync], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILE_AIO_FSYNC, 1, [fops->aio_fsync() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 20893f58d3af..3c1e493f3c02 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -70,7 +70,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_INODE_GETATTR ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION ZFS_AC_KERNEL_SRC_SHOW_OPTIONS - ZFS_AC_KERNEL_SRC_AIO_FSYNC ZFS_AC_KERNEL_SRC_SHRINKER ZFS_AC_KERNEL_SRC_MKDIR ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS @@ -195,7 +194,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_INODE_GETATTR ZFS_AC_KERNEL_INODE_SET_IVERSION ZFS_AC_KERNEL_SHOW_OPTIONS - ZFS_AC_KERNEL_AIO_FSYNC ZFS_AC_KERNEL_SHRINKER ZFS_AC_KERNEL_MKDIR ZFS_AC_KERNEL_LOOKUP_FLAGS diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index e854834fc10c..96b374ad96b6 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -173,14 +173,6 @@ zpl_fsync(struct file *filp, loff_t start, loff_t end, int datasync) return (error); } -#ifdef HAVE_FILE_AIO_FSYNC -static int -zpl_aio_fsync(struct kiocb *kiocb, int datasync) -{ - return (zpl_fsync(kiocb->ki_filp, kiocb->ki_pos, -1, datasync)); -} -#endif - static inline int zfs_io_flags(struct kiocb *kiocb) { @@ -1127,9 +1119,6 @@ const struct file_operations zpl_file_operations = { #endif .mmap = zpl_mmap, .fsync = zpl_fsync, -#ifdef HAVE_FILE_AIO_FSYNC - .aio_fsync = zpl_aio_fsync, -#endif .fallocate = zpl_fallocate, .copy_file_range = zpl_copy_file_range, #ifdef HAVE_VFS_CLONE_FILE_RANGE From 4a78c5e71be90bc445a86e4bf8b408554d74777b Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 16 Aug 2024 21:05:04 +1000 Subject: [PATCH 148/223] config: remove HAVE_GENERIC_SETXATTR Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-xattr-handler.m4 | 13 ------------- module/os/linux/zfs/zpl_inode.c | 20 -------------------- 2 files changed, 33 deletions(-) diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4 index 704b1d74e900..2a19ac04166f 100644 --- a/config/kernel-xattr-handler.m4 +++ b/config/kernel-xattr-handler.m4 @@ -171,27 +171,14 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_SETXATTR], [ ],[]) ]) -AC_DEFUN([ZFS_AC_KERNEL_GENERIC_SETXATTR], [ - AC_MSG_CHECKING([whether generic_setxattr() exists]) - ZFS_LINUX_TEST_RESULT([have_generic_setxattr], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GENERIC_SETXATTR, 1, - [generic_setxattr() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR], [ ZFS_AC_KERNEL_SRC_CONST_XATTR_HANDLER ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET - ZFS_AC_KERNEL_SRC_GENERIC_SETXATTR ]) AC_DEFUN([ZFS_AC_KERNEL_XATTR], [ ZFS_AC_KERNEL_CONST_XATTR_HANDLER ZFS_AC_KERNEL_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS ZFS_AC_KERNEL_XATTR_HANDLER_SET - ZFS_AC_KERNEL_GENERIC_SETXATTR ]) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index 9d9c49d187af..ed2e3b325d41 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -737,11 +737,6 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) const struct inode_operations zpl_inode_operations = { .setattr = zpl_setattr, .getattr = zpl_getattr, -#ifdef HAVE_GENERIC_SETXATTR - .setxattr = generic_setxattr, - .getxattr = generic_getxattr, - .removexattr = generic_removexattr, -#endif .listxattr = zpl_xattr_list, #if defined(CONFIG_FS_POSIX_ACL) .set_acl = zpl_set_acl, @@ -776,11 +771,6 @@ const struct inode_operations zpl_dir_inode_operations = { #endif .setattr = zpl_setattr, .getattr = zpl_getattr, -#ifdef HAVE_GENERIC_SETXATTR - .setxattr = generic_setxattr, - .getxattr = generic_getxattr, - .removexattr = generic_removexattr, -#endif .listxattr = zpl_xattr_list, #if defined(CONFIG_FS_POSIX_ACL) .set_acl = zpl_set_acl, @@ -799,22 +789,12 @@ const struct inode_operations zpl_symlink_inode_operations = { .get_link = zpl_get_link, .setattr = zpl_setattr, .getattr = zpl_getattr, -#ifdef HAVE_GENERIC_SETXATTR - .setxattr = generic_setxattr, - .getxattr = generic_getxattr, - .removexattr = generic_removexattr, -#endif .listxattr = zpl_xattr_list, }; const struct inode_operations zpl_special_inode_operations = { .setattr = zpl_setattr, .getattr = zpl_getattr, -#ifdef HAVE_GENERIC_SETXATTR - .setxattr = generic_setxattr, - .getxattr = generic_getxattr, - .removexattr = generic_removexattr, -#endif .listxattr = zpl_xattr_list, #if defined(CONFIG_FS_POSIX_ACL) .set_acl = zpl_set_acl, From fd1c7c75c18e64bb6f9a1ec9ec43a491817499cc Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 18 Aug 2024 11:37:31 +1000 Subject: [PATCH 149/223] config: remove HAVE_RENAME2 Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-rename.m4 | 35 ++++----------------------------- module/os/linux/zfs/zpl_inode.c | 5 +---- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/config/kernel-rename.m4 b/config/kernel-rename.m4 index cbb27082b247..d4846a509b45 100644 --- a/config/kernel-rename.m4 +++ b/config/kernel-rename.m4 @@ -1,23 +1,4 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_RENAME], [ - dnl # - dnl # 3.9 (to 4.9) API change, - dnl # - dnl # A new version of iops->rename() was added (rename2) that takes a flag - dnl # argument (to support renameat2). However this separate function was - dnl # merged back into iops->rename() in Linux 4.9. - dnl # - ZFS_LINUX_TEST_SRC([inode_operations_rename2], [ - #include - static int rename2_fn(struct inode *sip, struct dentry *sdp, - struct inode *tip, struct dentry *tdp, - unsigned int flags) { return 0; } - - static const struct inode_operations - iops __attribute__ ((unused)) = { - .rename2 = rename2_fn, - }; - ],[]) - dnl # dnl # 4.9 API change, dnl # @@ -85,21 +66,13 @@ AC_DEFUN([ZFS_AC_KERNEL_RENAME], [ ],[ AC_MSG_RESULT(no) - AC_MSG_CHECKING([whether iops->rename2() exists]) - ZFS_LINUX_TEST_RESULT([inode_operations_rename2], [ + AC_MSG_CHECKING([whether iops->rename() wants flags]) + ZFS_LINUX_TEST_RESULT([inode_operations_rename_flags], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_RENAME2, 1, [iops->rename2() exists]) + AC_DEFINE(HAVE_RENAME_WANTS_FLAGS, 1, + [iops->rename() wants flags]) ],[ AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether iops->rename() wants flags]) - ZFS_LINUX_TEST_RESULT([inode_operations_rename_flags], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_RENAME_WANTS_FLAGS, 1, - [iops->rename() wants flags]) - ],[ - AC_MSG_RESULT(no) - ]) ]) ]) ]) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index ed2e3b325d41..3cd18ac787ae 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -591,7 +591,6 @@ zpl_rename2(struct inode *sdip, struct dentry *sdentry, #if !defined(HAVE_IOPS_RENAME_USERNS) && \ !defined(HAVE_RENAME_WANTS_FLAGS) && \ - !defined(HAVE_RENAME2) && \ !defined(HAVE_IOPS_RENAME_IDMAP) static int zpl_rename(struct inode *sdip, struct dentry *sdentry, @@ -757,9 +756,7 @@ const struct inode_operations zpl_dir_inode_operations = { .mkdir = zpl_mkdir, .rmdir = zpl_rmdir, .mknod = zpl_mknod, -#ifdef HAVE_RENAME2 - .rename2 = zpl_rename2, -#elif defined(HAVE_RENAME_WANTS_FLAGS) || defined(HAVE_IOPS_RENAME_USERNS) +#if defined(HAVE_RENAME_WANTS_FLAGS) || defined(HAVE_IOPS_RENAME_USERNS) .rename = zpl_rename2, #elif defined(HAVE_IOPS_RENAME_IDMAP) .rename = zpl_rename2, From 99ec9197c5f3ae7fbd8d21520422f1a7a113eb70 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 18 Aug 2024 11:41:00 +1000 Subject: [PATCH 150/223] config: remove HAVE_BLK_QUEUE_SECDISCARD Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-blk-queue.m4 | 22 +------------------ include/os/linux/kernel/linux/blkdev_compat.h | 5 ----- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/config/kernel-blk-queue.m4 b/config/kernel-blk-queue.m4 index f5fb8f664752..04919fa88700 100644 --- a/config/kernel-blk-queue.m4 +++ b/config/kernel-blk-queue.m4 @@ -161,7 +161,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [ dnl # dnl # 5.19: bdev_max_secure_erase_sectors() available dnl # 4.8: blk_queue_secure_erase() available -dnl # 2.6.36: blk_queue_secdiscard() available dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [ ZFS_LINUX_TEST_SRC([bdev_max_secure_erase_sectors], [ @@ -182,16 +181,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [ memset(q, 0, sizeof(r)); value = blk_queue_secure_erase(q); ],[-Wframe-larger-than=8192]) - - ZFS_LINUX_TEST_SRC([blk_queue_secdiscard], [ - #include - ],[ - struct request_queue r; - struct request_queue *q = &r; - int value __attribute__ ((unused)); - memset(q, 0, sizeof(r)); - value = blk_queue_secdiscard(q); - ]) ]) AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE], [ @@ -209,16 +198,7 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE], [ AC_DEFINE(HAVE_BLK_QUEUE_SECURE_ERASE, 1, [blk_queue_secure_erase() is available]) ],[ - AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether blk_queue_secdiscard() is available]) - ZFS_LINUX_TEST_RESULT([blk_queue_secdiscard], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_QUEUE_SECDISCARD, 1, - [blk_queue_secdiscard() is available]) - ],[ - ZFS_LINUX_TEST_ERROR([blk_queue_secure_erase]) - ]) + ZFS_LINUX_TEST_ERROR([blk_queue_secure_erase]) ]) ]) ]) diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 87154003bf34..5b23fd0c51e2 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -474,9 +474,6 @@ bdev_discard_supported(struct block_device *bdev) * * 4.8 API, * blk_queue_secure_erase() - * - * 2.6.36 - 4.7 API, - * blk_queue_secdiscard() */ static inline boolean_t bdev_secure_discard_supported(struct block_device *bdev) @@ -485,8 +482,6 @@ bdev_secure_discard_supported(struct block_device *bdev) return (!!bdev_max_secure_erase_sectors(bdev)); #elif defined(HAVE_BLK_QUEUE_SECURE_ERASE) return (!!blk_queue_secure_erase(bdev_get_queue(bdev))); -#elif defined(HAVE_BLK_QUEUE_SECDISCARD) - return (!!blk_queue_secdiscard(bdev_get_queue(bdev))); #else #error "Unsupported kernel" #endif From 1b200c1284a8640cf9ae480165454e946f5a7246 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:06:53 +1000 Subject: [PATCH 151/223] config: remove HAVE_[24]ARGS_VFS_GETATTR Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-vfs-getattr.m4 | 59 ------------------------------- config/kernel.m4 | 2 -- module/os/linux/spl/spl-generic.c | 6 ---- module/os/linux/zfs/zfs_file_os.c | 6 ---- 4 files changed, 73 deletions(-) delete mode 100644 config/kernel-vfs-getattr.m4 diff --git a/config/kernel-vfs-getattr.m4 b/config/kernel-vfs-getattr.m4 deleted file mode 100644 index 1923d4ce8e82..000000000000 --- a/config/kernel-vfs-getattr.m4 +++ /dev/null @@ -1,59 +0,0 @@ -dnl # -dnl # 4.11 API, a528d35e@torvalds/linux -dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f) -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_GETATTR_4ARGS], [ - ZFS_LINUX_TEST_SRC([vfs_getattr_4args], [ - #include - ],[ - vfs_getattr((const struct path *)NULL, - (struct kstat *)NULL, - (u32)0, - (unsigned int)0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_VFS_GETATTR_4ARGS], [ - AC_MSG_CHECKING([whether vfs_getattr() wants 4 args]) - ZFS_LINUX_TEST_RESULT([vfs_getattr_4args], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1, - [vfs_getattr wants 4 args]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -dnl # -dnl # 3.9 API -dnl # vfs_getattr(struct path *p, struct kstat *s) -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_GETATTR_2ARGS], [ - ZFS_LINUX_TEST_SRC([vfs_getattr_2args], [ - #include - ],[ - vfs_getattr((struct path *) NULL, - (struct kstat *)NULL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_VFS_GETATTR_2ARGS], [ - AC_MSG_CHECKING([whether vfs_getattr() wants 2 args]) - ZFS_LINUX_TEST_RESULT([vfs_getattr_2args], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1, - [vfs_getattr wants 2 args]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_GETATTR], [ - ZFS_AC_KERNEL_SRC_VFS_GETATTR_4ARGS - ZFS_AC_KERNEL_SRC_VFS_GETATTR_2ARGS -]) - -AC_DEFUN([ZFS_AC_KERNEL_VFS_GETATTR], [ - ZFS_AC_KERNEL_VFS_GETATTR_4ARGS - ZFS_AC_KERNEL_VFS_GETATTR_2ARGS -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 3c1e493f3c02..2d39329be473 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -88,7 +88,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SGET ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO - ZFS_AC_KERNEL_SRC_VFS_GETATTR ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO ZFS_AC_KERNEL_SRC_VFS_READPAGES @@ -212,7 +211,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SGET ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO ZFS_AC_KERNEL_VFS_READ_FOLIO - ZFS_AC_KERNEL_VFS_GETATTR ZFS_AC_KERNEL_VFS_FSYNC_2ARGS ZFS_AC_KERNEL_VFS_DIRECT_IO ZFS_AC_KERNEL_VFS_READPAGES diff --git a/module/os/linux/spl/spl-generic.c b/module/os/linux/spl/spl-generic.c index a40b4216c4cd..38af322d42b9 100644 --- a/module/os/linux/spl/spl-generic.c +++ b/module/os/linux/spl/spl-generic.c @@ -651,14 +651,8 @@ spl_getattr(struct file *filp, struct kstat *stat) ASSERT(filp); ASSERT(stat); -#if defined(HAVE_4ARGS_VFS_GETATTR) rc = vfs_getattr(&filp->f_path, stat, STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT); -#elif defined(HAVE_2ARGS_VFS_GETATTR) - rc = vfs_getattr(&filp->f_path, stat); -#else -#error "No available vfs_getattr()" -#endif if (rc) return (-rc); diff --git a/module/os/linux/zfs/zfs_file_os.c b/module/os/linux/zfs/zfs_file_os.c index 32e71bf374a5..1a0bb5056205 100644 --- a/module/os/linux/zfs/zfs_file_os.c +++ b/module/os/linux/zfs/zfs_file_os.c @@ -274,14 +274,8 @@ zfs_file_getattr(zfs_file_t *filp, zfs_file_attr_t *zfattr) struct kstat stat; int rc; -#if defined(HAVE_4ARGS_VFS_GETATTR) rc = vfs_getattr(&filp->f_path, &stat, STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT); -#elif defined(HAVE_2ARGS_VFS_GETATTR) - rc = vfs_getattr(&filp->f_path, &stat); -#else -#error "No available vfs_getattr()" -#endif if (rc) return (-rc); From 32a62ac233bec02ea8552f7dac2f22c44d3f28b1 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:08:27 +1000 Subject: [PATCH 152/223] config: remove HAVE_ACL_REFCOUNT Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-acl.m4 | 27 ---------------------- include/os/linux/kernel/linux/vfs_compat.h | 5 ---- 2 files changed, 32 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index 0903818582c9..3dbd97948189 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -171,41 +171,14 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [ ]) ]) -dnl # -dnl # 4.16 kernel: check if struct posix_acl acl.a_refcount is a refcount_t. -dnl # It's an atomic_t on older kernels. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL_HAS_REFCOUNT], [ - ZFS_LINUX_TEST_SRC([acl_refcount], [ - #include - #include - #include - ],[ - struct posix_acl acl; - refcount_t *r __attribute__ ((unused)) = &acl.a_refcount; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_ACL_HAS_REFCOUNT], [ - AC_MSG_CHECKING([whether posix_acl has refcount_t]) - ZFS_LINUX_TEST_RESULT([acl_refcount], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_ACL_REFCOUNT, 1, [posix_acl has refcount_t]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [ ZFS_AC_KERNEL_SRC_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL - ZFS_AC_KERNEL_SRC_ACL_HAS_REFCOUNT ]) AC_DEFUN([ZFS_AC_KERNEL_ACL], [ ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL - ZFS_AC_KERNEL_ACL_HAS_REFCOUNT ]) diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index affd6caa0254..056cd9c825a9 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -153,13 +153,8 @@ zpl_posix_acl_release(struct posix_acl *acl) { if ((acl == NULL) || (acl == ACL_NOT_CACHED)) return; -#ifdef HAVE_ACL_REFCOUNT if (refcount_dec_and_test(&acl->a_refcount)) zpl_posix_acl_release_impl(acl); -#else - if (atomic_dec_and_test(&acl->a_refcount)) - zpl_posix_acl_release_impl(acl); -#endif } #endif /* CONFIG_FS_POSIX_ACL */ From f648a854ff5c78d02269cebb1d4cd4f17e37cf17 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:19:40 +1000 Subject: [PATCH 153/223] config: remove HAVE_BIO_BI_STATUS and bio error compat Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bio.m4 | 27 ------------------- include/os/linux/kernel/linux/blkdev_compat.h | 26 ------------------ module/os/linux/zfs/vdev_disk.c | 22 ++++++++------- module/os/linux/zfs/zvol_os.c | 8 ++++-- 4 files changed, 19 insertions(+), 64 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index 6d3a020ede13..85d26bae6e10 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -93,31 +93,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [ ]) ]) -dnl # -dnl # 4.13 API change -dnl # The bio->bi_error field was replaced with bio->bi_status which is an -dnl # enum which describes all possible error types. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BI_STATUS], [ - ZFS_LINUX_TEST_SRC([bio_bi_status], [ - #include - ], [ - struct bio bio __attribute__ ((unused)); - blk_status_t status __attribute__ ((unused)) = BLK_STS_OK; - bio.bi_status = status; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_STATUS], [ - AC_MSG_CHECKING([whether bio->bi_status exists]) - ZFS_LINUX_TEST_RESULT([bio_bi_status], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BIO_BI_STATUS, 1, [bio->bi_status exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.34 API change dnl # current->bio_list @@ -269,7 +244,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_ALLOC_4ARG], [ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_BIO_OPS ZFS_AC_KERNEL_SRC_BIO_SET_DEV - ZFS_AC_KERNEL_SRC_BIO_BI_STATUS ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_SRC_BLKG_TRYGET ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK @@ -281,7 +255,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BIO_SET_OP_ATTRS ZFS_AC_KERNEL_BIO_SET_DEV - ZFS_AC_KERNEL_BIO_BI_STATUS ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_BLKG_TRYGET ZFS_AC_KERNEL_BIO_BDEV_DISK diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 5b23fd0c51e2..3af6d94763bc 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -139,7 +139,6 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags, bool dev, #define DISK_NAME_LEN 32 #endif /* DISK_NAME_LEN */ -#ifdef HAVE_BIO_BI_STATUS static inline int bi_status_to_errno(blk_status_t status) { @@ -213,31 +212,6 @@ errno_to_bi_status(int error) return (BLK_STS_IOERR); } } -#endif /* HAVE_BIO_BI_STATUS */ - -#ifdef HAVE_BIO_BI_STATUS -#define BIO_END_IO_ERROR(bio) bi_status_to_errno(bio->bi_status) -#define BIO_END_IO_PROTO(fn, x, z) static void fn(struct bio *x) -#define BIO_END_IO(bio, error) bio_set_bi_status(bio, error) -static inline void -bio_set_bi_status(struct bio *bio, int error) -{ - ASSERT3S(error, <=, 0); - bio->bi_status = errno_to_bi_status(-error); - bio_endio(bio); -} -#else -#define BIO_END_IO_ERROR(bio) (-(bio->bi_error)) -#define BIO_END_IO_PROTO(fn, x, z) static void fn(struct bio *x) -#define BIO_END_IO(bio, error) bio_set_bi_error(bio, error) -static inline void -bio_set_bi_error(struct bio *bio, int error) -{ - ASSERT3S(error, <=, 0); - bio->bi_error = error; - bio_endio(bio); -} -#endif /* HAVE_BIO_BI_STATUS */ /* * 5.15 MACRO, diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index 690667210cab..71aff3c40e6c 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -694,7 +694,7 @@ vbio_alloc(zio_t *zio, struct block_device *bdev, int flags) return (vbio); } -BIO_END_IO_PROTO(vbio_completion, bio, error); +static void vbio_completion(struct bio *bio); static int vbio_add_page(vbio_t *vbio, struct page *page, uint_t size, uint_t offset) @@ -790,7 +790,8 @@ vbio_submit(vbio_t *vbio, abd_t *abd, uint64_t size) } /* IO completion callback */ -BIO_END_IO_PROTO(vbio_completion, bio, error) +static void +vbio_completion(struct bio *bio) { vbio_t *vbio = bio->bi_private; zio_t *zio = vbio->vbio_zio; @@ -798,7 +799,7 @@ BIO_END_IO_PROTO(vbio_completion, bio, error) ASSERT(zio); /* Capture and log any errors */ - zio->io_error = BIO_END_IO_ERROR(bio); + zio->io_error = bi_status_to_errno(bio->bi_status); ASSERT3U(zio->io_error, >=, 0); if (zio->io_error) @@ -1053,12 +1054,13 @@ vdev_classic_dio_put(dio_request_t *dr) } } -BIO_END_IO_PROTO(vdev_classic_physio_completion, bio, error) +static void +vdev_classic_physio_completion(struct bio *bio) { dio_request_t *dr = bio->bi_private; if (dr->dr_error == 0) { - dr->dr_error = BIO_END_IO_ERROR(bio); + dr->dr_error = bi_status_to_errno(bio->bi_status); } /* Drop reference acquired by vdev_classic_physio */ @@ -1197,10 +1199,11 @@ vdev_classic_physio(zio_t *zio) /* ========== */ -BIO_END_IO_PROTO(vdev_disk_io_flush_completion, bio, error) +static void +vdev_disk_io_flush_completion(struct bio *bio) { zio_t *zio = bio->bi_private; - zio->io_error = BIO_END_IO_ERROR(bio); + zio->io_error = bi_status_to_errno(bio->bi_status); if (zio->io_error && (zio->io_error == EOPNOTSUPP)) zio->io_vd->vdev_nowritecache = B_TRUE; @@ -1235,10 +1238,11 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio) return (0); } -BIO_END_IO_PROTO(vdev_disk_discard_end_io, bio, error) +static void +vdev_disk_discard_end_io(struct bio *bio) { zio_t *zio = bio->bi_private; - zio->io_error = BIO_END_IO_ERROR(bio); + zio->io_error = bi_status_to_errno(bio->bi_status); bio_put(bio); if (zio->io_error) diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index b5f5656b0ab0..7e7276f068da 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -99,13 +99,17 @@ static unsigned int zvol_num_taskqs = 0; #ifdef HAVE_BLK_MQ #define END_IO(zv, bio, rq, error) do { \ if (bio) { \ - BIO_END_IO(bio, error); \ + bio->bi_status = errno_to_bi_status(-error); \ + bio_endio(bio); \ } else { \ blk_mq_end_request(rq, errno_to_bi_status(error)); \ } \ } while (0) #else -#define END_IO(zv, bio, rq, error) BIO_END_IO(bio, error) +#define END_IO(zv, bio, rq, error) do { \ + bio->bi_status = errno_to_bi_status(-error); \ + bio_endio(bio); \ +} while (0) #endif #ifdef HAVE_BLK_MQ From e7ab71a4e7f5ce8b74f4b6b0b975632ded378334 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:33:08 +1000 Subject: [PATCH 154/223] config: remove HAVE_FILE_FADVISE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-fadvise.m4 | 23 ----------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_file.c | 6 ------ 3 files changed, 31 deletions(-) delete mode 100644 config/kernel-fadvise.m4 diff --git a/config/kernel-fadvise.m4 b/config/kernel-fadvise.m4 deleted file mode 100644 index 08912de16ed8..000000000000 --- a/config/kernel-fadvise.m4 +++ /dev/null @@ -1,23 +0,0 @@ -dnl # -dnl # Linux 4.19 API -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_FADVISE], [ - ZFS_LINUX_TEST_SRC([file_fadvise], [ - #include - - static const struct file_operations - fops __attribute__ ((unused)) = { - .fadvise = NULL, - }; - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_FADVISE], [ - AC_MSG_CHECKING([whether fops->fadvise() exists]) - ZFS_LINUX_TEST_RESULT([file_fadvise], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILE_FADVISE, 1, [fops->fadvise() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 2d39329be473..5fa18db4f580 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -42,7 +42,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE ZFS_AC_KERNEL_SRC_PDE_DATA - ZFS_AC_KERNEL_SRC_FADVISE ZFS_AC_KERNEL_SRC_GENERIC_FADVISE ZFS_AC_KERNEL_SRC_SCHED ZFS_AC_KERNEL_SRC_USLEEP_RANGE @@ -165,7 +164,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_GLOBAL_PAGE_STATE ZFS_AC_KERNEL_OBJTOOL ZFS_AC_KERNEL_PDE_DATA - ZFS_AC_KERNEL_FADVISE ZFS_AC_KERNEL_GENERIC_FADVISE ZFS_AC_KERNEL_SCHED ZFS_AC_KERNEL_USLEEP_RANGE diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 96b374ad96b6..25aa43416b14 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -38,9 +38,7 @@ defined(HAVE_VFS_FILEMAP_DIRTY_FOLIO) #include #endif -#ifdef HAVE_FILE_FADVISE #include -#endif #ifdef HAVE_VFS_FILEMAP_DIRTY_FOLIO #include #endif @@ -717,7 +715,6 @@ zpl_ioctl_getversion(struct file *filp, void __user *arg) return (copy_to_user(arg, &generation, sizeof (generation))); } -#ifdef HAVE_FILE_FADVISE static int zpl_fadvise(struct file *filp, loff_t offset, loff_t len, int advice) { @@ -770,7 +767,6 @@ zpl_fadvise(struct file *filp, loff_t offset, loff_t len, int advice) return (error); } -#endif /* HAVE_FILE_FADVISE */ #define ZFS_FL_USER_VISIBLE (FS_FL_USER_VISIBLE | ZFS_PROJINHERIT_FL) #define ZFS_FL_USER_MODIFIABLE (FS_FL_USER_MODIFIABLE | ZFS_PROJINHERIT_FL) @@ -1130,9 +1126,7 @@ const struct file_operations zpl_file_operations = { #ifdef HAVE_VFS_DEDUPE_FILE_RANGE .dedupe_file_range = zpl_dedupe_file_range, #endif -#ifdef HAVE_FILE_FADVISE .fadvise = zpl_fadvise, -#endif .unlocked_ioctl = zpl_ioctl, #ifdef CONFIG_COMPAT .compat_ioctl = zpl_compat_ioctl, From c787133711aa219ecaf5438c3124167d86726b67 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:36:14 +1000 Subject: [PATCH 155/223] config: remove HAVE_FILEMAP_RANGE_HAS_PAGE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-filemap.m4 | 27 ----------------------- config/kernel.m4 | 2 -- include/os/linux/zfs/sys/zfs_znode_impl.h | 12 ---------- module/os/linux/zfs/zfs_ctldir.c | 3 --- module/os/linux/zfs/zfs_znode.c | 3 --- module/os/linux/zfs/zpl_file.c | 7 ------ 6 files changed, 54 deletions(-) delete mode 100644 config/kernel-filemap.m4 diff --git a/config/kernel-filemap.m4 b/config/kernel-filemap.m4 deleted file mode 100644 index 0b7da828d299..000000000000 --- a/config/kernel-filemap.m4 +++ /dev/null @@ -1,27 +0,0 @@ -dnl # -dnl # filemap_range_has_page was not available till 4.13 -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_FILEMAP], [ - ZFS_LINUX_TEST_SRC([filemap_range_has_page], [ - #include - #include - ],[ - struct address_space *mapping = NULL; - loff_t lstart = 0; - loff_t lend = 0; - bool ret __attribute__ ((unused)); - - ret = filemap_range_has_page(mapping, lstart, lend); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_FILEMAP], [ - AC_MSG_CHECKING([whether filemap_range_has_page() is available]) - ZFS_LINUX_TEST_RESULT([filemap_range_has_page], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILEMAP_RANGE_HAS_PAGE, 1, - [filemap_range_has_page() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 5fa18db4f580..c5df3ffe2802 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -130,7 +130,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_IDMAP_MNT_API ZFS_AC_KERNEL_SRC_IDMAP_NO_USERNS ZFS_AC_KERNEL_SRC_IATTR_VFSID - ZFS_AC_KERNEL_SRC_FILEMAP ZFS_AC_KERNEL_SRC_WRITEPAGE_T ZFS_AC_KERNEL_SRC_RECLAIMED ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE @@ -252,7 +251,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_IDMAP_MNT_API ZFS_AC_KERNEL_IDMAP_NO_USERNS ZFS_AC_KERNEL_IATTR_VFSID - ZFS_AC_KERNEL_FILEMAP ZFS_AC_KERNEL_WRITEPAGE_T ZFS_AC_KERNEL_RECLAIMED ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE diff --git a/include/os/linux/zfs/sys/zfs_znode_impl.h b/include/os/linux/zfs/sys/zfs_znode_impl.h index 0be2c445ab76..65928757d16a 100644 --- a/include/os/linux/zfs/sys/zfs_znode_impl.h +++ b/include/os/linux/zfs/sys/zfs_znode_impl.h @@ -47,16 +47,9 @@ extern "C" { #endif -#if defined(HAVE_FILEMAP_RANGE_HAS_PAGE) #define ZNODE_OS_FIELDS \ inode_timespec_t z_btime; /* creation/birth time (cached) */ \ struct inode z_inode; -#else -#define ZNODE_OS_FIELDS \ - inode_timespec_t z_btime; /* creation/birth time (cached) */ \ - struct inode z_inode; \ - boolean_t z_is_mapped; /* we are mmap'ed */ -#endif /* * Convert between znode pointers and inode pointers @@ -77,13 +70,8 @@ extern "C" { #define Z_ISDEV(type) (S_ISCHR(type) || S_ISBLK(type) || S_ISFIFO(type)) #define Z_ISDIR(type) S_ISDIR(type) -#if defined(HAVE_FILEMAP_RANGE_HAS_PAGE) #define zn_has_cached_data(zp, start, end) \ filemap_range_has_page(ZTOI(zp)->i_mapping, start, end) -#else -#define zn_has_cached_data(zp, start, end) \ - ((zp)->z_is_mapped) -#endif #define zn_flush_cached_data(zp, sync) write_inode_now(ZTOI(zp), sync) #define zn_rlimit_fsize(size) (0) diff --git a/module/os/linux/zfs/zfs_ctldir.c b/module/os/linux/zfs/zfs_ctldir.c index 25ce66f5385a..368028dbc1ed 100644 --- a/module/os/linux/zfs/zfs_ctldir.c +++ b/module/os/linux/zfs/zfs_ctldir.c @@ -500,9 +500,6 @@ zfsctl_inode_alloc(zfsvfs_t *zfsvfs, uint64_t id, zp->z_atime_dirty = B_FALSE; zp->z_zn_prefetch = B_FALSE; zp->z_is_sa = B_FALSE; -#if !defined(HAVE_FILEMAP_RANGE_HAS_PAGE) - zp->z_is_mapped = B_FALSE; -#endif zp->z_is_ctldir = B_TRUE; zp->z_sa_hdl = NULL; zp->z_blksz = 0; diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index 7f031d16fb47..8b0011c37c53 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -535,9 +535,6 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, ASSERT3P(zp->z_xattr_cached, ==, NULL); zp->z_unlinked = B_FALSE; zp->z_atime_dirty = B_FALSE; -#if !defined(HAVE_FILEMAP_RANGE_HAS_PAGE) - zp->z_is_mapped = B_FALSE; -#endif zp->z_is_ctldir = B_FALSE; zp->z_suspended = B_FALSE; zp->z_sa_hdl = NULL; diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 25aa43416b14..4d1bf1d5477f 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -432,13 +432,6 @@ zpl_mmap(struct file *filp, struct vm_area_struct *vma) if (error) return (error); -#if !defined(HAVE_FILEMAP_RANGE_HAS_PAGE) - znode_t *zp = ITOZ(ip); - mutex_enter(&zp->z_lock); - zp->z_is_mapped = B_TRUE; - mutex_exit(&zp->z_lock); -#endif - return (error); } From cba8ffc2cfa3eb3967f83ef47b13b498fb0185b1 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:38:37 +1000 Subject: [PATCH 156/223] config: remove HAVE_INODE_SET_IVERSION Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-inode-set-iversion.m4 | 23 ---------------------- config/kernel.m4 | 2 -- include/os/linux/kernel/linux/vfs_compat.h | 14 ------------- module/os/linux/zfs/zpl_super.c | 1 + 4 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 config/kernel-inode-set-iversion.m4 diff --git a/config/kernel-inode-set-iversion.m4 b/config/kernel-inode-set-iversion.m4 deleted file mode 100644 index dd415de324a7..000000000000 --- a/config/kernel-inode-set-iversion.m4 +++ /dev/null @@ -1,23 +0,0 @@ -dnl # -dnl # 4.16 API change -dnl # inode_set_iversion introduced to set i_version -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION], [ - ZFS_LINUX_TEST_SRC([inode_set_iversion], [ - #include - ],[ - struct inode inode; - inode_set_iversion(&inode, 1); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_INODE_SET_IVERSION], [ - AC_MSG_CHECKING([whether inode_set_iversion() exists]) - ZFS_LINUX_TEST_RESULT([inode_set_iversion], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_INODE_SET_IVERSION, 1, - [inode_set_iversion() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index c5df3ffe2802..e8f140f579b4 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -67,7 +67,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_ACL ZFS_AC_KERNEL_SRC_INODE_SETATTR ZFS_AC_KERNEL_SRC_INODE_GETATTR - ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION ZFS_AC_KERNEL_SRC_SHOW_OPTIONS ZFS_AC_KERNEL_SRC_SHRINKER ZFS_AC_KERNEL_SRC_MKDIR @@ -188,7 +187,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_ACL ZFS_AC_KERNEL_INODE_SETATTR ZFS_AC_KERNEL_INODE_GETATTR - ZFS_AC_KERNEL_INODE_SET_IVERSION ZFS_AC_KERNEL_SHOW_OPTIONS ZFS_AC_KERNEL_SHRINKER ZFS_AC_KERNEL_MKDIR diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 056cd9c825a9..369829a8f653 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -274,20 +274,6 @@ func(struct mnt_idmap *user_ns, const struct path *path, \ #error #endif -/* - * 4.16 API change - * Added iversion interface for managing inode version field. - */ -#ifdef HAVE_INODE_SET_IVERSION -#include -#else -static inline void -inode_set_iversion(struct inode *ip, u64 val) -{ - ip->i_version = val; -} -#endif - /* * Returns true when called in the context of a 32-bit system call. */ diff --git a/module/os/linux/zfs/zpl_super.c b/module/os/linux/zfs/zpl_super.c index 66014eb87486..9de3bdcac62c 100644 --- a/module/os/linux/zfs/zpl_super.c +++ b/module/os/linux/zfs/zpl_super.c @@ -29,6 +29,7 @@ #include #include #include +#include static struct inode * From e2a58faf858a6617ab7f240d6b0e03439e57f76f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:41:49 +1000 Subject: [PATCH 157/223] config: remove HAVE_INODE_TIMESPEC64_TIMES Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-inode-times.m4 | 23 ----------------------- include/os/linux/spl/sys/time.h | 15 --------------- include/os/linux/zfs/sys/zfs_znode_impl.h | 13 ------------- include/os/linux/zfs/sys/zpl.h | 5 +---- module/os/linux/zfs/zfs_znode.c | 10 ++-------- 5 files changed, 3 insertions(+), 63 deletions(-) diff --git a/config/kernel-inode-times.m4 b/config/kernel-inode-times.m4 index 4d861596ed0b..59988e937929 100644 --- a/config/kernel-inode-times.m4 +++ b/config/kernel-inode-times.m4 @@ -14,20 +14,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [ ts = timestamp_truncate(ts, &ip); ]) - dnl # - dnl # 4.18 API change - dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64. - dnl # - ZFS_LINUX_TEST_SRC([inode_times], [ - #include - ],[ - struct inode ip; - struct timespec ts; - - memset(&ip, 0, sizeof(ip)); - ts = ip.i_mtime; - ]) - dnl # dnl # 6.6 API change dnl # i_ctime no longer directly accessible, must use @@ -106,15 +92,6 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [ AC_MSG_RESULT(no) ]) - AC_MSG_CHECKING([whether inode->i_*time's are timespec64]) - ZFS_LINUX_TEST_RESULT([inode_times], [ - AC_MSG_RESULT(no) - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_INODE_TIMESPEC64_TIMES, 1, - [inode->i_*time's are timespec64]) - ]) - AC_MSG_CHECKING([whether inode_get_ctime() exists]) ZFS_LINUX_TEST_RESULT([inode_get_ctime], [ AC_MSG_RESULT(yes) diff --git a/include/os/linux/spl/sys/time.h b/include/os/linux/spl/sys/time.h index fec85f8b8d13..2b3363c1c462 100644 --- a/include/os/linux/spl/sys/time.h +++ b/include/os/linux/spl/sys/time.h @@ -59,11 +59,7 @@ typedef struct timespec timespec_t; #define TIMESPEC_OVERFLOW(ts) \ ((ts)->tv_sec < TIME_MIN || (ts)->tv_sec > TIME_MAX) -#if defined(HAVE_INODE_TIMESPEC64_TIMES) typedef struct timespec64 inode_timespec_t; -#else -typedef struct timespec inode_timespec_t; -#endif /* Include for Lustre compatibility */ #define timestruc_t inode_timespec_t @@ -71,33 +67,22 @@ typedef struct timespec inode_timespec_t; static inline void gethrestime(inode_timespec_t *ts) { -#if defined(HAVE_INODE_TIMESPEC64_TIMES) - #if defined(HAVE_KTIME_GET_COARSE_REAL_TS64) ktime_get_coarse_real_ts64(ts); #else *ts = current_kernel_time64(); #endif /* HAVE_KTIME_GET_COARSE_REAL_TS64 */ - -#else - *ts = current_kernel_time(); -#endif } static inline uint64_t gethrestime_sec(void) { -#if defined(HAVE_INODE_TIMESPEC64_TIMES) #if defined(HAVE_KTIME_GET_COARSE_REAL_TS64) inode_timespec_t ts; ktime_get_coarse_real_ts64(&ts); #else inode_timespec_t ts = current_kernel_time64(); #endif /* HAVE_KTIME_GET_COARSE_REAL_TS64 */ - -#else - inode_timespec_t ts = current_kernel_time(); -#endif return (ts.tv_sec); } diff --git a/include/os/linux/zfs/sys/zfs_znode_impl.h b/include/os/linux/zfs/sys/zfs_znode_impl.h index 65928757d16a..2d456452f8cc 100644 --- a/include/os/linux/zfs/sys/zfs_znode_impl.h +++ b/include/os/linux/zfs/sys/zfs_znode_impl.h @@ -141,27 +141,14 @@ do { \ (stmp)[1] = (uint64_t)(tp)->tv_nsec; \ } while (0) -#if defined(HAVE_INODE_TIMESPEC64_TIMES) /* * Decode ZFS stored time values to a struct timespec64 - * 4.18 and newer kernels. */ #define ZFS_TIME_DECODE(tp, stmp) \ do { \ (tp)->tv_sec = (time64_t)(stmp)[0]; \ (tp)->tv_nsec = (long)(stmp)[1]; \ } while (0) -#else -/* - * Decode ZFS stored time values to a struct timespec - * 4.17 and older kernels. - */ -#define ZFS_TIME_DECODE(tp, stmp) \ -do { \ - (tp)->tv_sec = (time_t)(stmp)[0]; \ - (tp)->tv_nsec = (long)(stmp)[1]; \ -} while (0) -#endif /* HAVE_INODE_TIMESPEC64_TIMES */ #define ZFS_ACCESSTIME_STAMP(zfsvfs, zp) diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index 8ac459ead8a7..fb56a93d22b5 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -161,12 +161,9 @@ extern long zpl_ioctl_fideduperange(struct file *filp, void *arg); #if defined(HAVE_INODE_TIMESTAMP_TRUNCATE) #define zpl_inode_timestamp_truncate(ts, ip) timestamp_truncate(ts, ip) -#elif defined(HAVE_INODE_TIMESPEC64_TIMES) -#define zpl_inode_timestamp_truncate(ts, ip) \ - timespec64_trunc(ts, (ip)->i_sb->s_time_gran) #else #define zpl_inode_timestamp_truncate(ts, ip) \ - timespec_trunc(ts, (ip)->i_sb->s_time_gran) + timespec64_trunc(ts, (ip)->i_sb->s_time_gran) #endif #if defined(HAVE_INODE_OWNER_OR_CAPABLE) diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index 8b0011c37c53..4d18187b715b 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -1363,12 +1363,6 @@ zfs_zinactive(znode_t *zp) zfs_znode_hold_exit(zfsvfs, zh); } -#if defined(HAVE_INODE_TIMESPEC64_TIMES) -#define zfs_compare_timespec timespec64_compare -#else -#define zfs_compare_timespec timespec_compare -#endif - /* * Determine whether the znode's atime must be updated. The logic mostly * duplicates the Linux kernel's relatime_need_update() functionality. @@ -1388,11 +1382,11 @@ zfs_relatime_need_update(const struct inode *ip) * has passed since the last update of atime. */ tmp_ts = zpl_inode_get_mtime(ip); - if (zfs_compare_timespec(&tmp_ts, &tmp_atime) >= 0) + if (timespec64_compare(&tmp_ts, &tmp_atime) >= 0) return (B_TRUE); tmp_ts = zpl_inode_get_ctime(ip); - if (zfs_compare_timespec(&tmp_ts, &tmp_atime) >= 0) + if (timespec64_compare(&tmp_ts, &tmp_atime) >= 0) return (B_TRUE); if ((hrtime_t)now.tv_sec - (hrtime_t)tmp_atime.tv_sec >= 24*60*60) From 2639abe1e87cede0ad7c33fe611d17f4ec629b58 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:46:34 +1000 Subject: [PATCH 158/223] config: remove HAVE_KERNEL_(READ|WRITE)_PPOS Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-rw.m4 | 69 ------------------------------- config/kernel.m4 | 2 - module/os/linux/spl/spl-generic.c | 22 +--------- module/os/linux/zfs/zfs_file_os.c | 47 ++------------------- 4 files changed, 5 insertions(+), 135 deletions(-) delete mode 100644 config/kernel-rw.m4 diff --git a/config/kernel-rw.m4 b/config/kernel-rw.m4 deleted file mode 100644 index 85b47d5c6fc2..000000000000 --- a/config/kernel-rw.m4 +++ /dev/null @@ -1,69 +0,0 @@ -dnl # -dnl # 4.14 API change -dnl # kernel_write() which was introduced in 3.9 was updated to take -dnl # the offset as a pointer which is needed by vn_rdwr(). -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_WRITE], [ - ZFS_LINUX_TEST_SRC([kernel_write], [ - #include - ],[ - struct file *file = NULL; - const void *buf = NULL; - size_t count = 0; - loff_t *pos = NULL; - ssize_t ret; - - ret = kernel_write(file, buf, count, pos); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_WRITE], [ - AC_MSG_CHECKING([whether kernel_write() takes loff_t pointer]) - ZFS_LINUX_TEST_RESULT([kernel_write], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KERNEL_WRITE_PPOS, 1, - [kernel_write() take loff_t pointer]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -dnl # -dnl # 4.14 API change -dnl # kernel_read() which has existed for forever was updated to take -dnl # the offset as a pointer which is needed by vn_rdwr(). -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_READ], [ - ZFS_LINUX_TEST_SRC([kernel_read], [ - #include - ],[ - struct file *file = NULL; - void *buf = NULL; - size_t count = 0; - loff_t *pos = NULL; - ssize_t ret; - - ret = kernel_read(file, buf, count, pos); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_READ], [ - AC_MSG_CHECKING([whether kernel_read() takes loff_t pointer]) - ZFS_LINUX_TEST_RESULT([kernel_read], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KERNEL_READ_PPOS, 1, - [kernel_read() take loff_t pointer]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SRC_RW], [ - ZFS_AC_KERNEL_SRC_WRITE - ZFS_AC_KERNEL_SRC_READ -]) - -AC_DEFUN([ZFS_AC_KERNEL_RW], [ - ZFS_AC_KERNEL_WRITE - ZFS_AC_KERNEL_READ -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index e8f140f579b4..1ac218583f43 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -50,7 +50,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_SRC_WAIT ZFS_AC_KERNEL_SRC_INODE_TIMES - ZFS_AC_KERNEL_SRC_RW ZFS_AC_KERNEL_SRC_TIMER_SETUP ZFS_AC_KERNEL_SRC_PROC_OPERATIONS ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS @@ -170,7 +169,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_WAIT ZFS_AC_KERNEL_INODE_TIMES - ZFS_AC_KERNEL_RW ZFS_AC_KERNEL_TIMER_SETUP ZFS_AC_KERNEL_PROC_OPERATIONS ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS diff --git a/module/os/linux/spl/spl-generic.c b/module/os/linux/spl/spl-generic.c index 38af322d42b9..7c3b965894f0 100644 --- a/module/os/linux/spl/spl-generic.c +++ b/module/os/linux/spl/spl-generic.c @@ -623,26 +623,6 @@ ddi_copyout(const void *from, void *to, size_t len, int flags) } EXPORT_SYMBOL(ddi_copyout); -static ssize_t -spl_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) -{ -#if defined(HAVE_KERNEL_READ_PPOS) - return (kernel_read(file, buf, count, pos)); -#else - mm_segment_t saved_fs; - ssize_t ret; - - saved_fs = get_fs(); - set_fs(KERNEL_DS); - - ret = vfs_read(file, (void __user *)buf, count, pos); - - set_fs(saved_fs); - - return (ret); -#endif -} - static int spl_getattr(struct file *filp, struct kstat *stat) { @@ -730,7 +710,7 @@ hostid_read(uint32_t *hostid) * Read directly into the variable like eglibc does. * Short reads are okay; native behavior is preserved. */ - error = spl_kernel_read(filp, &value, sizeof (value), &off); + error = kernel_read(filp, &value, sizeof (value), &off); if (error < 0) { filp_close(filp, 0); return (EIO); diff --git a/module/os/linux/zfs/zfs_file_os.c b/module/os/linux/zfs/zfs_file_os.c index 1a0bb5056205..1b52dbe4f365 100644 --- a/module/os/linux/zfs/zfs_file_os.c +++ b/module/os/linux/zfs/zfs_file_os.c @@ -69,26 +69,6 @@ zfs_file_close(zfs_file_t *fp) filp_close(fp, 0); } -static ssize_t -zfs_file_write_impl(zfs_file_t *fp, const void *buf, size_t count, loff_t *off) -{ -#if defined(HAVE_KERNEL_WRITE_PPOS) - return (kernel_write(fp, buf, count, off)); -#else - mm_segment_t saved_fs; - ssize_t rc; - - saved_fs = get_fs(); - set_fs(KERNEL_DS); - - rc = vfs_write(fp, (__force const char __user __user *)buf, count, off); - - set_fs(saved_fs); - - return (rc); -#endif -} - /* * Stateful write - use os internal file pointer to determine where to * write and update on successful completion. @@ -106,7 +86,7 @@ zfs_file_write(zfs_file_t *fp, const void *buf, size_t count, ssize_t *resid) loff_t off = fp->f_pos; ssize_t rc; - rc = zfs_file_write_impl(fp, buf, count, &off); + rc = kernel_write(fp, buf, count, &off); if (rc < 0) return (-rc); @@ -138,7 +118,7 @@ zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t count, loff_t off, { ssize_t rc; - rc = zfs_file_write_impl(fp, buf, count, &off); + rc = kernel_write(fp, buf, count, &off); if (rc < 0) return (-rc); @@ -151,25 +131,6 @@ zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t count, loff_t off, return (0); } -static ssize_t -zfs_file_read_impl(zfs_file_t *fp, void *buf, size_t count, loff_t *off) -{ -#if defined(HAVE_KERNEL_READ_PPOS) - return (kernel_read(fp, buf, count, off)); -#else - mm_segment_t saved_fs; - ssize_t rc; - - saved_fs = get_fs(); - set_fs(KERNEL_DS); - - rc = vfs_read(fp, (void __user *)buf, count, off); - set_fs(saved_fs); - - return (rc); -#endif -} - /* * Stateful read - use os internal file pointer to determine where to * read and update on successful completion. @@ -187,7 +148,7 @@ zfs_file_read(zfs_file_t *fp, void *buf, size_t count, ssize_t *resid) loff_t off = fp->f_pos; ssize_t rc; - rc = zfs_file_read_impl(fp, buf, count, &off); + rc = kernel_read(fp, buf, count, &off); if (rc < 0) return (-rc); @@ -219,7 +180,7 @@ zfs_file_pread(zfs_file_t *fp, void *buf, size_t count, loff_t off, { ssize_t rc; - rc = zfs_file_read_impl(fp, buf, count, &off); + rc = kernel_read(fp, buf, count, &off); if (rc < 0) return (-rc); From b333618ffaa4398516b06b304ebb3ae33a610bff Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:48:01 +1000 Subject: [PATCH 159/223] config: remove HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-timer.m4 | 17 ----------------- include/os/linux/spl/sys/timer.h | 4 ---- 2 files changed, 21 deletions(-) diff --git a/config/kernel-timer.m4 b/config/kernel-timer.m4 index 94c2c443f195..78574318e8e9 100644 --- a/config/kernel-timer.m4 +++ b/config/kernel-timer.m4 @@ -28,14 +28,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_TIMER_SETUP], [ struct my_task_timer task_timer; timer_setup(&task_timer.timer, task_expire, 0); ]) - - ZFS_LINUX_TEST_SRC([timer_list_function], [ - #include - static void task_expire(struct timer_list *tl) {} - ],[ - struct timer_list tl; - tl.function = task_expire; - ]) ]) AC_DEFUN([ZFS_AC_KERNEL_TIMER_SETUP], [ @@ -47,13 +39,4 @@ AC_DEFUN([ZFS_AC_KERNEL_TIMER_SETUP], [ ],[ AC_MSG_RESULT(no) ]) - - AC_MSG_CHECKING([whether timer function expects timer_list]) - ZFS_LINUX_TEST_RESULT([timer_list_function], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST, 1, - [timer_list.function gets a timer_list]) - ],[ - AC_MSG_RESULT(no) - ]) ]) diff --git a/include/os/linux/spl/sys/timer.h b/include/os/linux/spl/sys/timer.h index bcc58dbd8ea2..67ee4a455e06 100644 --- a/include/os/linux/spl/sys/timer.h +++ b/include/os/linux/spl/sys/timer.h @@ -62,11 +62,7 @@ container_of(timer, typeof(*var), timer_field) #endif -#ifdef HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST typedef struct timer_list *spl_timer_list_t; -#else -typedef unsigned long spl_timer_list_t; -#endif #ifndef HAVE_KERNEL_TIMER_SETUP From 9bf3282990fe142abc3c26f6c5733dde2daf8fdb Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:49:42 +1000 Subject: [PATCH 160/223] config: remove HAVE_KERNEL_TIMER_SETUP Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-timer.m4 | 42 -------------------------------- config/kernel.m4 | 2 -- include/os/linux/spl/sys/timer.h | 14 ----------- module/os/linux/spl/spl-taskq.c | 2 +- 4 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 config/kernel-timer.m4 diff --git a/config/kernel-timer.m4 b/config/kernel-timer.m4 deleted file mode 100644 index 78574318e8e9..000000000000 --- a/config/kernel-timer.m4 +++ /dev/null @@ -1,42 +0,0 @@ -dnl # 4.14-rc3 API change -dnl # https://lwn.net/Articles/735887/ -dnl # -dnl # Check if timer_list.func get passed a timer_list or an unsigned long -dnl # (older kernels). Also sanity check the from_timer() and timer_setup() -dnl # macros are available as well, since they will be used in the same newer -dnl # kernels that support the new timer_list.func signature. -dnl # -dnl # Also check for the existence of flags in struct timer_list, they were -dnl # added in 4.1-rc8 via 0eeda71bc30d. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_TIMER_SETUP], [ - ZFS_LINUX_TEST_SRC([timer_setup], [ - #include - - struct my_task_timer { - struct timer_list timer; - int data; - }; - - static void task_expire(struct timer_list *tl) - { - struct my_task_timer *task_timer = - from_timer(task_timer, tl, timer); - task_timer->data = 42; - } - ],[ - struct my_task_timer task_timer; - timer_setup(&task_timer.timer, task_expire, 0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_TIMER_SETUP], [ - AC_MSG_CHECKING([whether timer_setup() is available]) - ZFS_LINUX_TEST_RESULT([timer_setup], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KERNEL_TIMER_SETUP, 1, - [timer_setup() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 1ac218583f43..eaaa70228c64 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -50,7 +50,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_SRC_WAIT ZFS_AC_KERNEL_SRC_INODE_TIMES - ZFS_AC_KERNEL_SRC_TIMER_SETUP ZFS_AC_KERNEL_SRC_PROC_OPERATIONS ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS ZFS_AC_KERNEL_SRC_BIO @@ -169,7 +168,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_WAIT ZFS_AC_KERNEL_INODE_TIMES - ZFS_AC_KERNEL_TIMER_SETUP ZFS_AC_KERNEL_PROC_OPERATIONS ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS ZFS_AC_KERNEL_BIO diff --git a/include/os/linux/spl/sys/timer.h b/include/os/linux/spl/sys/timer.h index 67ee4a455e06..61a1fa6aeffb 100644 --- a/include/os/linux/spl/sys/timer.h +++ b/include/os/linux/spl/sys/timer.h @@ -62,18 +62,4 @@ container_of(timer, typeof(*var), timer_field) #endif -typedef struct timer_list *spl_timer_list_t; - -#ifndef HAVE_KERNEL_TIMER_SETUP - -static inline void -timer_setup(struct timer_list *timer, void (*func)(spl_timer_list_t), u32 fl) -{ - (timer)->flags = fl; - init_timer(timer); - setup_timer(timer, func, (spl_timer_list_t)(timer)); -} - -#endif /* HAVE_KERNEL_TIMER_SETUP */ - #endif /* _SPL_TIMER_H */ diff --git a/module/os/linux/spl/spl-taskq.c b/module/os/linux/spl/spl-taskq.c index 1c35cf3e43d4..7f6780909973 100644 --- a/module/os/linux/spl/spl-taskq.c +++ b/module/os/linux/spl/spl-taskq.c @@ -262,7 +262,7 @@ task_expire_impl(taskq_ent_t *t) } static void -task_expire(spl_timer_list_t tl) +task_expire(struct timer_list *tl) { struct timer_list *tmr = (struct timer_list *)tl; taskq_ent_t *t = from_timer(t, tmr, tqent_timer); From 0cbf4f7e9c00407c83b9636d61640c0ce851a69a Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:52:58 +1000 Subject: [PATCH 161/223] config: remove HAVE_KMEM_CACHE_CREATE_USERCOPY Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-kmem-cache.m4 | 41 ---------------------------- config/kernel.m4 | 2 -- module/os/linux/spl/spl-kmem-cache.c | 17 ------------ 3 files changed, 60 deletions(-) delete mode 100644 config/kernel-kmem-cache.m4 diff --git a/config/kernel-kmem-cache.m4 b/config/kernel-kmem-cache.m4 deleted file mode 100644 index 0e9fe9eb2a90..000000000000 --- a/config/kernel-kmem-cache.m4 +++ /dev/null @@ -1,41 +0,0 @@ -dnl # -dnl # grsecurity API change, -dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by -dnl # kmem_cache_create_usercopy(). -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_KMEM_CACHE_CREATE_USERCOPY], [ - ZFS_LINUX_TEST_SRC([kmem_cache_create_usercopy], [ - #include - static void ctor(void *foo) { /* fake ctor */ } - ],[ - struct kmem_cache *skc_linux_cache; - const char *name = "test"; - size_t size = 4096; - size_t align = 8; - unsigned long flags = 0; - size_t useroffset = 0; - size_t usersize = size - useroffset; - - skc_linux_cache = kmem_cache_create_usercopy( - name, size, align, flags, useroffset, usersize, ctor); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_KMEM_CACHE_CREATE_USERCOPY], [ - AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists]) - ZFS_LINUX_TEST_RESULT([kmem_cache_create_usercopy], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1, - [kmem_cache_create_usercopy() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SRC_KMEM_CACHE], [ - ZFS_AC_KERNEL_SRC_KMEM_CACHE_CREATE_USERCOPY -]) - -AC_DEFUN([ZFS_AC_KERNEL_KMEM_CACHE], [ - ZFS_AC_KERNEL_KMEM_CACHE_CREATE_USERCOPY -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index eaaa70228c64..51459d487677 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -45,7 +45,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_GENERIC_FADVISE ZFS_AC_KERNEL_SRC_SCHED ZFS_AC_KERNEL_SRC_USLEEP_RANGE - ZFS_AC_KERNEL_SRC_KMEM_CACHE ZFS_AC_KERNEL_SRC_KVMALLOC ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_SRC_WAIT @@ -163,7 +162,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_GENERIC_FADVISE ZFS_AC_KERNEL_SCHED ZFS_AC_KERNEL_USLEEP_RANGE - ZFS_AC_KERNEL_KMEM_CACHE ZFS_AC_KERNEL_KVMALLOC ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_WAIT diff --git a/module/os/linux/spl/spl-kmem-cache.c b/module/os/linux/spl/spl-kmem-cache.c index 7596f97b4984..7e806bd5699c 100644 --- a/module/os/linux/spl/spl-kmem-cache.c +++ b/module/os/linux/spl/spl-kmem-cache.c @@ -786,25 +786,8 @@ spl_kmem_cache_create(const char *name, size_t size, size_t align, if (skc->skc_flags & KMC_RECLAIMABLE) slabflags |= SLAB_RECLAIM_ACCOUNT; -#if defined(SLAB_USERCOPY) - /* - * Required for PAX-enabled kernels if the slab is to be - * used for copying between user and kernel space. - */ - slabflags |= SLAB_USERCOPY; -#endif - -#if defined(HAVE_KMEM_CACHE_CREATE_USERCOPY) - /* - * Newer grsec patchset uses kmem_cache_create_usercopy() - * instead of SLAB_USERCOPY flag - */ skc->skc_linux_cache = kmem_cache_create_usercopy( skc->skc_name, size, align, slabflags, 0, size, NULL); -#else - skc->skc_linux_cache = kmem_cache_create( - skc->skc_name, size, align, slabflags, NULL); -#endif if (skc->skc_linux_cache == NULL) goto out; } From e2fcc6ad9e8b1a807a7342c7fd80025e7d365854 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:54:29 +1000 Subject: [PATCH 162/223] config: remove HAVE_KTIME_GET_COARSE_REAL_TS64 Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-ktime.m4 | 25 ------------------------- include/os/linux/spl/sys/time.h | 8 -------- 2 files changed, 33 deletions(-) diff --git a/config/kernel-ktime.m4 b/config/kernel-ktime.m4 index 64c3b5f90328..ba9cf14a22cf 100644 --- a/config/kernel-ktime.m4 +++ b/config/kernel-ktime.m4 @@ -1,26 +1,3 @@ -dnl # -dnl # 4.18: ktime_get_coarse_real_ts64() replaces current_kernel_time64(). -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64], [ - ZFS_LINUX_TEST_SRC([ktime_get_coarse_real_ts64], [ - #include - ], [ - struct timespec64 ts; - ktime_get_coarse_real_ts64(&ts); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64], [ - AC_MSG_CHECKING([whether ktime_get_coarse_real_ts64() exists]) - ZFS_LINUX_TEST_RESULT([ktime_get_coarse_real_ts64], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1, - [ktime_get_coarse_real_ts64() exists]) - ], [ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 4.18: ktime_get_raw_ts64() replaces getrawmonotonic64(). dnl # @@ -45,11 +22,9 @@ AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_RAW_TS64], [ ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME], [ - ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64 ZFS_AC_KERNEL_SRC_KTIME_GET_RAW_TS64 ]) AC_DEFUN([ZFS_AC_KERNEL_KTIME], [ - ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64 ZFS_AC_KERNEL_KTIME_GET_RAW_TS64 ]) diff --git a/include/os/linux/spl/sys/time.h b/include/os/linux/spl/sys/time.h index 2b3363c1c462..f76903705088 100644 --- a/include/os/linux/spl/sys/time.h +++ b/include/os/linux/spl/sys/time.h @@ -67,22 +67,14 @@ typedef struct timespec64 inode_timespec_t; static inline void gethrestime(inode_timespec_t *ts) { -#if defined(HAVE_KTIME_GET_COARSE_REAL_TS64) ktime_get_coarse_real_ts64(ts); -#else - *ts = current_kernel_time64(); -#endif /* HAVE_KTIME_GET_COARSE_REAL_TS64 */ } static inline uint64_t gethrestime_sec(void) { -#if defined(HAVE_KTIME_GET_COARSE_REAL_TS64) inode_timespec_t ts; ktime_get_coarse_real_ts64(&ts); -#else - inode_timespec_t ts = current_kernel_time64(); -#endif /* HAVE_KTIME_GET_COARSE_REAL_TS64 */ return (ts.tv_sec); } From 706fbd4cd677346a44781978f771e0c8d9f42a20 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:55:36 +1000 Subject: [PATCH 163/223] config: remove HAVE_KTIME_GET_RAW_TS64 Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-ktime.m4 | 30 ------------------------------ config/kernel.m4 | 2 -- include/os/linux/spl/sys/time.h | 5 ----- 3 files changed, 37 deletions(-) delete mode 100644 config/kernel-ktime.m4 diff --git a/config/kernel-ktime.m4 b/config/kernel-ktime.m4 deleted file mode 100644 index ba9cf14a22cf..000000000000 --- a/config/kernel-ktime.m4 +++ /dev/null @@ -1,30 +0,0 @@ -dnl # -dnl # 4.18: ktime_get_raw_ts64() replaces getrawmonotonic64(). -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME_GET_RAW_TS64], [ - ZFS_LINUX_TEST_SRC([ktime_get_raw_ts64], [ - #include - ], [ - struct timespec64 ts; - ktime_get_raw_ts64(&ts); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_RAW_TS64], [ - AC_MSG_CHECKING([whether ktime_get_raw_ts64() exists]) - ZFS_LINUX_TEST_RESULT([ktime_get_raw_ts64], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KTIME_GET_RAW_TS64, 1, - [ktime_get_raw_ts64() exists]) - ], [ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME], [ - ZFS_AC_KERNEL_SRC_KTIME_GET_RAW_TS64 -]) - -AC_DEFUN([ZFS_AC_KERNEL_KTIME], [ - ZFS_AC_KERNEL_KTIME_GET_RAW_TS64 -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 51459d487677..19d001db0ac7 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -104,7 +104,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_KUID_HELPERS ZFS_AC_KERNEL_SRC_RENAME ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES - ZFS_AC_KERNEL_SRC_KTIME ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES ZFS_AC_KERNEL_SRC_PERCPU @@ -221,7 +220,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_KUID_HELPERS ZFS_AC_KERNEL_RENAME ZFS_AC_KERNEL_USERNS_CAPABILITIES - ZFS_AC_KERNEL_KTIME ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_TOTALHIGH_PAGES ZFS_AC_KERNEL_PERCPU diff --git a/include/os/linux/spl/sys/time.h b/include/os/linux/spl/sys/time.h index f76903705088..036948d87aae 100644 --- a/include/os/linux/spl/sys/time.h +++ b/include/os/linux/spl/sys/time.h @@ -81,13 +81,8 @@ gethrestime_sec(void) static inline hrtime_t gethrtime(void) { -#if defined(HAVE_KTIME_GET_RAW_TS64) struct timespec64 ts; ktime_get_raw_ts64(&ts); -#else - struct timespec ts; - getrawmonotonic(&ts); -#endif return (((hrtime_t)ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec); } From 335c00f2ce3883066fb3abb08ddf2c7d2a0187ad Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:57:00 +1000 Subject: [PATCH 164/223] config: remove HAVE_KVMALLOC Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-kmem.m4 | 27 +-------------------------- config/kernel.m4 | 2 -- module/os/linux/spl/spl-kmem.c | 2 -- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/config/kernel-kmem.m4 b/config/kernel-kmem.m4 index 03c2a41fbdb2..f1c0d24125ce 100644 --- a/config/kernel-kmem.m4 +++ b/config/kernel-kmem.m4 @@ -57,31 +57,6 @@ AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ AC_MSG_RESULT([$enable_debug_kmem_tracking]) ]) -dnl # -dnl # 4.12 API, -dnl # Added kvmalloc allocation strategy -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_KVMALLOC], [ - ZFS_LINUX_TEST_SRC([kvmalloc], [ - #include - #include - ],[ - void *p __attribute__ ((unused)); - - p = kvmalloc(0, GFP_KERNEL); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_KVMALLOC], [ - AC_MSG_CHECKING([whether kvmalloc(ptr, flags) is available]) - ZFS_LINUX_TEST_RESULT([kvmalloc], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_KVMALLOC, 1, [kvmalloc exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 5.8 API, dnl # __vmalloc PAGE_KERNEL removal @@ -106,4 +81,4 @@ AC_DEFUN([ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL], [ AC_MSG_RESULT(no) ]) ]) -- \ No newline at end of file +- diff --git a/config/kernel.m4 b/config/kernel.m4 index 19d001db0ac7..2d8c99751bf0 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -45,7 +45,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_GENERIC_FADVISE ZFS_AC_KERNEL_SRC_SCHED ZFS_AC_KERNEL_SRC_USLEEP_RANGE - ZFS_AC_KERNEL_SRC_KVMALLOC ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_SRC_WAIT ZFS_AC_KERNEL_SRC_INODE_TIMES @@ -161,7 +160,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_GENERIC_FADVISE ZFS_AC_KERNEL_SCHED ZFS_AC_KERNEL_USLEEP_RANGE - ZFS_AC_KERNEL_KVMALLOC ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL ZFS_AC_KERNEL_WAIT ZFS_AC_KERNEL_INODE_TIMES diff --git a/module/os/linux/spl/spl-kmem.c b/module/os/linux/spl/spl-kmem.c index d85e2a7daa8d..cae304d33bc3 100644 --- a/module/os/linux/spl/spl-kmem.c +++ b/module/os/linux/spl/spl-kmem.c @@ -134,7 +134,6 @@ EXPORT_SYMBOL(kmem_strfree); void * spl_kvmalloc(size_t size, gfp_t lflags) { -#ifdef HAVE_KVMALLOC /* * GFP_KERNEL allocations can safely use kvmalloc which may * improve performance by avoiding a) high latency caused by @@ -146,7 +145,6 @@ spl_kvmalloc(size_t size, gfp_t lflags) */ if ((lflags & GFP_KERNEL) == GFP_KERNEL) return (kvmalloc(size, lflags)); -#endif gfp_t kmalloc_lflags = lflags; From f51bf385d29b04863638ed2470845fe5e2dd2151 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:57:43 +1000 Subject: [PATCH 165/223] config: remove HAVE_PERCPU_COUNTER_ADD_BATCH Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-percpu.m4 | 27 --------------------------- include/os/linux/spl/sys/wmsum.h | 4 ---- 2 files changed, 31 deletions(-) diff --git a/config/kernel-percpu.m4 b/config/kernel-percpu.m4 index f42b27bd5267..12e81892cb6b 100644 --- a/config/kernel-percpu.m4 +++ b/config/kernel-percpu.m4 @@ -1,28 +1,3 @@ -dnl # -dnl # 4.13 API change, -dnl # __percpu_counter_add() was renamed to percpu_counter_add_batch(). -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_ADD_BATCH], [ - ZFS_LINUX_TEST_SRC([percpu_counter_add_batch], [ - #include - ],[ - struct percpu_counter counter; - - percpu_counter_add_batch(&counter, 1, 1); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_PERCPU_COUNTER_ADD_BATCH], [ - AC_MSG_CHECKING([whether percpu_counter_add_batch() is defined]) - ZFS_LINUX_TEST_RESULT([percpu_counter_add_batch], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PERCPU_COUNTER_ADD_BATCH, 1, - [percpu_counter_add_batch() is defined]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 5.10 API change, dnl # The "count" was moved into ref->data, from ref @@ -48,11 +23,9 @@ AC_DEFUN([ZFS_AC_KERNEL_PERCPU_REF_COUNT_IN_DATA], [ ]) ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_PERCPU], [ - ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_ADD_BATCH ZFS_AC_KERNEL_SRC_PERCPU_REF_COUNT_IN_DATA ]) AC_DEFUN([ZFS_AC_KERNEL_PERCPU], [ - ZFS_AC_KERNEL_PERCPU_COUNTER_ADD_BATCH ZFS_AC_KERNEL_PERCPU_REF_COUNT_IN_DATA ]) diff --git a/include/os/linux/spl/sys/wmsum.h b/include/os/linux/spl/sys/wmsum.h index 8fdc3f4b1663..1c87f56e13ac 100644 --- a/include/os/linux/spl/sys/wmsum.h +++ b/include/os/linux/spl/sys/wmsum.h @@ -57,11 +57,7 @@ static inline void wmsum_add(wmsum_t *ws, int64_t delta) { -#ifdef HAVE_PERCPU_COUNTER_ADD_BATCH percpu_counter_add_batch(ws, delta, INT_MAX / 2); -#else - __percpu_counter_add(ws, delta, INT_MAX / 2); -#endif } #ifdef __cplusplus From 5f486de3127a9dd41cccf1de4cfaa1687f7d7113 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:58:57 +1000 Subject: [PATCH 166/223] config: remove HAVE_SCHED_SIGNAL_HEADER Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-sched.m4 | 26 -------------------------- include/os/linux/spl/sys/signal.h | 3 --- module/os/linux/spl/spl-condvar.c | 3 --- 3 files changed, 32 deletions(-) diff --git a/config/kernel-sched.m4 b/config/kernel-sched.m4 index 91c1e91faa94..8ef4cc6ee4cc 100644 --- a/config/kernel-sched.m4 +++ b/config/kernel-sched.m4 @@ -20,36 +20,10 @@ AC_DEFUN([ZFS_AC_KERNEL_SCHED_RT_HEADER], [ ]) ]) -dnl # -dnl # 4.11 API change, -dnl # Moved things from linux/sched.h to linux/sched/signal.h -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_SCHED_SIGNAL_HEADER], [ - ZFS_LINUX_TEST_SRC([sched_signal_header], [ - #include - #include - ],[ - return 0; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SCHED_SIGNAL_HEADER], [ - AC_MSG_CHECKING([whether header linux/sched/signal.h exists]) - ZFS_LINUX_TEST_RESULT([sched_signal_header], [ - AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, - [linux/sched/signal.h exists]) - AC_MSG_RESULT(yes) - ],[ - AC_MSG_RESULT(no) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_SRC_SCHED], [ ZFS_AC_KERNEL_SRC_SCHED_RT_HEADER - ZFS_AC_KERNEL_SRC_SCHED_SIGNAL_HEADER ]) AC_DEFUN([ZFS_AC_KERNEL_SCHED], [ ZFS_AC_KERNEL_SCHED_RT_HEADER - ZFS_AC_KERNEL_SCHED_SIGNAL_HEADER ]) diff --git a/include/os/linux/spl/sys/signal.h b/include/os/linux/spl/sys/signal.h index cb4b33261647..473a1be14c34 100644 --- a/include/os/linux/spl/sys/signal.h +++ b/include/os/linux/spl/sys/signal.h @@ -25,10 +25,7 @@ #define _SPL_SIGNAL_H #include - -#ifdef HAVE_SCHED_SIGNAL_HEADER #include -#endif extern int issig(void); diff --git a/module/os/linux/spl/spl-condvar.c b/module/os/linux/spl/spl-condvar.c index c44cc018b6e5..1cb0aeebcb67 100644 --- a/module/os/linux/spl/spl-condvar.c +++ b/module/os/linux/spl/spl-condvar.c @@ -31,10 +31,7 @@ #include #include - -#ifdef HAVE_SCHED_SIGNAL_HEADER #include -#endif #define MAX_HRTIMEOUT_SLACK_US 1000 static unsigned int spl_schedule_hrtimeout_slack_us = 0; From 430cb85a969db114f87f573e29bed9defb89961b Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 20:59:56 +1000 Subject: [PATCH 167/223] config: remove HAVE_SET_SPECIAL_STATE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-special-state.m4 | 21 --------------------- config/kernel.m4 | 2 -- include/os/linux/spl/sys/thread.h | 7 ------- module/os/linux/spl/spl-thread.c | 2 +- 4 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 config/kernel-special-state.m4 diff --git a/config/kernel-special-state.m4 b/config/kernel-special-state.m4 deleted file mode 100644 index aa60aabebc43..000000000000 --- a/config/kernel-special-state.m4 +++ /dev/null @@ -1,21 +0,0 @@ -dnl # -dnl # 4.17 API change -dnl # Added set_special_state() function -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE], [ - ZFS_LINUX_TEST_SRC([set_special_state], [ - #include - ],[ - set_special_state(TASK_STOPPED); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SET_SPECIAL_STATE], [ - AC_MSG_CHECKING([whether set_special_state() exists]) - ZFS_LINUX_TEST_RESULT([set_special_state], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SET_SPECIAL_STATE, 1, [set_special_state() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 2d8c99751bf0..f39dc395487a 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -113,7 +113,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SIGNAL_STOP ZFS_AC_KERNEL_SRC_SIGINFO ZFS_AC_KERNEL_SRC_SYSFS - ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_SRC_STRLCPY ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT @@ -228,7 +227,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SIGNAL_STOP ZFS_AC_KERNEL_SIGINFO ZFS_AC_KERNEL_SYSFS - ZFS_AC_KERNEL_SET_SPECIAL_STATE ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_STRLCPY ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT diff --git a/include/os/linux/spl/sys/thread.h b/include/os/linux/spl/sys/thread.h index bc88ff4efb67..4f7f659e528d 100644 --- a/include/os/linux/spl/sys/thread.h +++ b/include/os/linux/spl/sys/thread.h @@ -80,11 +80,4 @@ typedef kernel_siginfo_t spl_kernel_siginfo_t; typedef siginfo_t spl_kernel_siginfo_t; #endif -#ifdef HAVE_SET_SPECIAL_STATE -#define spl_set_special_state(x) set_special_state((x)) -#else -#define spl_set_special_state(x) __set_current_state((x)) -#endif - - #endif /* _SPL_THREAD_H */ diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c index 2af766ac2049..6f261b4d8727 100644 --- a/module/os/linux/spl/spl-thread.c +++ b/module/os/linux/spl/spl-thread.c @@ -180,7 +180,7 @@ issig(void) kernel_signal_stop(); #else if (current->jobctl & JOBCTL_STOP_DEQUEUED) - spl_set_special_state(TASK_STOPPED); + set_special_state(TASK_STOPPED); spin_unlock_irq(¤t->sighand->siglock); From 656b666bdb79022979bb801156fbcf9770155a03 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:01:04 +1000 Subject: [PATCH 168/223] config: remove HAVE_SIGNAL_STOP Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-signal-stop.m4 | 21 --------------------- config/kernel.m4 | 2 -- module/os/linux/spl/spl-thread.c | 8 -------- 3 files changed, 31 deletions(-) delete mode 100644 config/kernel-signal-stop.m4 diff --git a/config/kernel-signal-stop.m4 b/config/kernel-signal-stop.m4 deleted file mode 100644 index 6cb86e7c4cde..000000000000 --- a/config/kernel-signal-stop.m4 +++ /dev/null @@ -1,21 +0,0 @@ -dnl # -dnl # 4.4 API change -dnl # Added kernel_signal_stop -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_SIGNAL_STOP], [ - ZFS_LINUX_TEST_SRC([signal_stop], [ - #include - ],[ - kernel_signal_stop(); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SIGNAL_STOP], [ - AC_MSG_CHECKING([whether signal_stop() exists]) - ZFS_LINUX_TEST_RESULT([signal_stop], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SIGNAL_STOP, 1, [signal_stop() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index f39dc395487a..47c661e333ec 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -110,7 +110,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_MKNOD ZFS_AC_KERNEL_SRC_SYMLINK ZFS_AC_KERNEL_SRC_BIO_MAX_SEGS - ZFS_AC_KERNEL_SRC_SIGNAL_STOP ZFS_AC_KERNEL_SRC_SIGINFO ZFS_AC_KERNEL_SRC_SYSFS ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG @@ -224,7 +223,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_MKNOD ZFS_AC_KERNEL_SYMLINK ZFS_AC_KERNEL_BIO_MAX_SEGS - ZFS_AC_KERNEL_SIGNAL_STOP ZFS_AC_KERNEL_SIGINFO ZFS_AC_KERNEL_SYSFS ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c index 6f261b4d8727..80acd0201b3b 100644 --- a/module/os/linux/spl/spl-thread.c +++ b/module/os/linux/spl/spl-thread.c @@ -175,17 +175,9 @@ issig(void) #else if (dequeue_signal(task, &set, &__info) != 0) { #endif -#ifdef HAVE_SIGNAL_STOP spin_unlock_irq(&task->sighand->siglock); kernel_signal_stop(); -#else - if (current->jobctl & JOBCTL_STOP_DEQUEUED) - set_special_state(TASK_STOPPED); - - spin_unlock_irq(¤t->sighand->siglock); - schedule(); -#endif /* * Dequeued SIGSTOP/SIGTSTP. * Check if process has other singal pending. From 2326e2eb7463f3c820d5050f74b1bfc2a40d82ea Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:05:51 +1000 Subject: [PATCH 169/223] config: remove HAVE_SUPER_SETUP_BDI_NAME Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bdi.m4 | 56 ---------------------- config/kernel.m4 | 2 - include/os/linux/kernel/linux/vfs_compat.h | 48 ------------------- module/os/linux/zfs/zfs_vfsops.c | 8 ++-- 4 files changed, 3 insertions(+), 111 deletions(-) delete mode 100644 config/kernel-bdi.m4 diff --git a/config/kernel-bdi.m4 b/config/kernel-bdi.m4 deleted file mode 100644 index 95f1291dde8c..000000000000 --- a/config/kernel-bdi.m4 +++ /dev/null @@ -1,56 +0,0 @@ -dnl # -dnl # Check available BDI interfaces. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BDI], [ - ZFS_LINUX_TEST_SRC([super_setup_bdi_name], [ - #include - struct super_block sb; - ], [ - char *name = "bdi"; - atomic_long_t zfs_bdi_seq; - int error __attribute__((unused)); - atomic_long_set(&zfs_bdi_seq, 0); - error = - super_setup_bdi_name(&sb, "%.28s-%ld", name, - atomic_long_inc_return(&zfs_bdi_seq)); - ]) - - ZFS_LINUX_TEST_SRC([bdi_setup_and_register], [ - #include - struct backing_dev_info bdi; - ], [ - char *name = "bdi"; - int error __attribute__((unused)) = - bdi_setup_and_register(&bdi, name); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BDI], [ - dnl # - dnl # 4.12, super_setup_bdi_name() introduced. - dnl # - AC_MSG_CHECKING([whether super_setup_bdi_name() exists]) - ZFS_LINUX_TEST_RESULT_SYMBOL([super_setup_bdi_name], - [super_setup_bdi_name], [fs/super.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SUPER_SETUP_BDI_NAME, 1, - [super_setup_bdi_name() exits]) - ], [ - AC_MSG_RESULT(no) - - dnl # - dnl # 4.0 - 4.11, bdi_setup_and_register() takes 2 arguments. - dnl # - AC_MSG_CHECKING( - [whether bdi_setup_and_register() wants 2 args]) - ZFS_LINUX_TEST_RESULT_SYMBOL([bdi_setup_and_register], - [bdi_setup_and_register], [mm/backing-dev.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_2ARGS_BDI_SETUP_AND_REGISTER, 1, - [bdi_setup_and_register() wants 2 args]) - ], [ - AC_MSG_RESULT(no) - ZFS_LINUX_TEST_ERROR([bdi_setup]) - ]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 47c661e333ec..1ae8cc419829 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -77,7 +77,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE ZFS_AC_KERNEL_SRC_SECURITY_INODE ZFS_AC_KERNEL_SRC_FST_MOUNT - ZFS_AC_KERNEL_SRC_BDI ZFS_AC_KERNEL_SRC_SET_NLINK ZFS_AC_KERNEL_SRC_SGET ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO @@ -190,7 +189,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_TRUNCATE_SETSIZE ZFS_AC_KERNEL_SECURITY_INODE ZFS_AC_KERNEL_FST_MOUNT - ZFS_AC_KERNEL_BDI ZFS_AC_KERNEL_SET_NLINK ZFS_AC_KERNEL_SGET ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 369829a8f653..3caa61ec514f 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -32,54 +32,6 @@ #include #include -/* - * 4.0 - 4.11, bdi_setup_and_register() takes 2 arguments. - * 4.12 - x.y, super_setup_bdi_name() new interface. - */ -#if defined(HAVE_SUPER_SETUP_BDI_NAME) -extern atomic_long_t zfs_bdi_seq; - -static inline int -zpl_bdi_setup(struct super_block *sb, char *name) -{ - return super_setup_bdi_name(sb, "%.28s-%ld", name, - atomic_long_inc_return(&zfs_bdi_seq)); -} -static inline void -zpl_bdi_destroy(struct super_block *sb) -{ -} -#elif defined(HAVE_2ARGS_BDI_SETUP_AND_REGISTER) -static inline int -zpl_bdi_setup(struct super_block *sb, char *name) -{ - struct backing_dev_info *bdi; - int error; - - bdi = kmem_zalloc(sizeof (struct backing_dev_info), KM_SLEEP); - error = bdi_setup_and_register(bdi, name); - if (error) { - kmem_free(bdi, sizeof (struct backing_dev_info)); - return (error); - } - - sb->s_bdi = bdi; - - return (0); -} -static inline void -zpl_bdi_destroy(struct super_block *sb) -{ - struct backing_dev_info *bdi = sb->s_bdi; - - bdi_destroy(bdi); - kmem_free(bdi, sizeof (struct backing_dev_info)); - sb->s_bdi = NULL; -} -#else -#error "Unsupported kernel" -#endif - /* * 4.14 adds SB_* flag definitions, define them to MS_* equivalents * if not set. diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index 92c97d2584cf..1f72cce07dd1 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -1378,9 +1378,7 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting) return (0); } -#if defined(HAVE_SUPER_SETUP_BDI_NAME) -atomic_long_t zfs_bdi_seq = ATOMIC_LONG_INIT(0); -#endif +static atomic_long_t zfs_bdi_seq = ATOMIC_LONG_INIT(0); int zfs_domount(struct super_block *sb, zfs_mnt_t *zm, int silent) @@ -1441,7 +1439,8 @@ zfs_domount(struct super_block *sb, zfs_mnt_t *zm, int silent) sb->s_blocksize = recordsize; sb->s_blocksize_bits = ilog2(recordsize); - error = -zpl_bdi_setup(sb, "zfs"); + error = -super_setup_bdi_name(sb, "%.28s-%ld", "zfs", + atomic_long_inc_return(&zfs_bdi_seq)); if (error) goto out; @@ -1569,7 +1568,6 @@ zfs_umount(struct super_block *sb) arc_remove_prune_callback(zfsvfs->z_arc_prune); VERIFY(zfsvfs_teardown(zfsvfs, B_TRUE) == 0); os = zfsvfs->z_os; - zpl_bdi_destroy(sb); /* * z_os will be NULL if there was an error in From e16c21d65997263a5ceac0aa08109dd8418f77da Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:09:43 +1000 Subject: [PATCH 170/223] config: remove HAVE_TMPFILE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-tmpfile.m4 | 4 ---- module/os/linux/zfs/zfs_vnops_os.c | 4 ++-- module/os/linux/zfs/zpl_inode.c | 4 ---- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/config/kernel-tmpfile.m4 b/config/kernel-tmpfile.m4 index 7439514186e4..a711d67ed558 100644 --- a/config/kernel-tmpfile.m4 +++ b/config/kernel-tmpfile.m4 @@ -59,23 +59,19 @@ AC_DEFUN([ZFS_AC_KERNEL_TMPFILE], [ AC_MSG_CHECKING([whether i_op->tmpfile() exists]) ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_mnt_idmap], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists]) AC_DEFINE(HAVE_TMPFILE_IDMAP, 1, [i_op->tmpfile() has mnt_idmap]) ], [ ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists]) AC_DEFINE(HAVE_TMPFILE_USERNS, 1, [i_op->tmpfile() has userns]) ],[ ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_dentry_userns], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists]) AC_DEFINE(HAVE_TMPFILE_USERNS, 1, [i_op->tmpfile() has userns]) AC_DEFINE(HAVE_TMPFILE_DENTRY, 1, [i_op->tmpfile() uses old dentry signature]) ],[ ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_dentry], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists]) AC_DEFINE(HAVE_TMPFILE_DENTRY, 1, [i_op->tmpfile() uses old dentry signature]) ],[ ZFS_LINUX_REQUIRE_API([i_op->tmpfile()], [3.11]) diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c index 581e2e531771..97de89767d93 100644 --- a/module/os/linux/zfs/zfs_vnops_os.c +++ b/module/os/linux/zfs/zfs_vnops_os.c @@ -3442,9 +3442,9 @@ zfs_link(znode_t *tdzp, znode_t *szp, char *name, cred_t *cr, boolean_t waited = B_FALSE; boolean_t is_tmpfile = 0; uint64_t txg; -#ifdef HAVE_TMPFILE + is_tmpfile = (sip->i_nlink == 0 && (sip->i_state & I_LINKABLE)); -#endif + ASSERT(S_ISDIR(ZTOI(tdzp)->i_mode)); if (name == NULL) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index 3cd18ac787ae..e2fe5c3b0f4a 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -238,7 +238,6 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, return (error); } -#ifdef HAVE_TMPFILE static int #ifdef HAVE_TMPFILE_IDMAP zpl_tmpfile(struct mnt_idmap *userns, struct inode *dir, @@ -307,7 +306,6 @@ zpl_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) return (error); } -#endif static int zpl_unlink(struct inode *dir, struct dentry *dentry) @@ -763,9 +761,7 @@ const struct inode_operations zpl_dir_inode_operations = { #else .rename = zpl_rename, #endif -#ifdef HAVE_TMPFILE .tmpfile = zpl_tmpfile, -#endif .setattr = zpl_setattr, .getattr = zpl_getattr, .listxattr = zpl_xattr_list, From 517d491a59825a6c1438d414e948ca25d7fd14a3 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:14:34 +1000 Subject: [PATCH 171/223] config: remove HAVE_WAIT_QUEUE_* Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-wait.m4 | 68 --------------------------- config/kernel.m4 | 3 -- include/os/linux/spl/sys/condvar.h | 4 +- include/os/linux/spl/sys/kmem_cache.h | 2 +- include/os/linux/spl/sys/taskq.h | 6 +-- include/os/linux/spl/sys/wait.h | 8 ---- module/os/linux/spl/spl-proc.c | 13 +---- 7 files changed, 8 insertions(+), 96 deletions(-) delete mode 100644 config/kernel-wait.m4 diff --git a/config/kernel-wait.m4 b/config/kernel-wait.m4 deleted file mode 100644 index dbc6b423dc37..000000000000 --- a/config/kernel-wait.m4 +++ /dev/null @@ -1,68 +0,0 @@ -dnl # -dnl # 4.13 API change -dnl # Renamed struct wait_queue -> struct wait_queue_entry. -dnl # -dnl # N.B. The type check is performed before all other checks -dnl # since ZFS_AC_KERNEL_SRC_WAIT_QUEUE_HEAD_ENTRY depends on -dnl # HAVE_WAIT_QUEUE_ENTRY_T being set in confdefs.h. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T], [ - AC_MSG_CHECKING([whether wait_queue_entry_t exists]) - ZFS_LINUX_TRY_COMPILE([ - #include - ],[ - wait_queue_entry_t *entry __attribute__ ((unused)); - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1, - [wait_queue_entry_t exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -dnl # -dnl # 4.13 API change -dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head -dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_WAIT_QUEUE_HEAD_ENTRY], [ - ZFS_LINUX_TEST_SRC([wait_queue_head_entry], [ - #include - - #ifdef HAVE_WAIT_QUEUE_ENTRY_T - typedef wait_queue_head_t spl_wait_queue_head_t; - typedef wait_queue_entry_t spl_wait_queue_entry_t; - #else - typedef wait_queue_head_t spl_wait_queue_head_t; - typedef wait_queue_t spl_wait_queue_entry_t; - #endif - ],[ - spl_wait_queue_head_t wq_head; - spl_wait_queue_entry_t wq_entry; - struct list_head *head __attribute__ ((unused)); - struct list_head *entry __attribute__ ((unused)); - - head = &wq_head.head; - entry = &wq_entry.entry; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_WAIT_QUEUE_HEAD_ENTRY], [ - AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist]) - ZFS_LINUX_TEST_RESULT([wait_queue_head_entry], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1, - [wq_head->head and wq_entry->entry exist]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SRC_WAIT], [ - ZFS_AC_KERNEL_SRC_WAIT_QUEUE_HEAD_ENTRY -]) - -AC_DEFUN([ZFS_AC_KERNEL_WAIT], [ - ZFS_AC_KERNEL_WAIT_QUEUE_HEAD_ENTRY -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 1ae8cc419829..b74dea1385e6 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -14,7 +14,6 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ dnl # Sequential ZFS_LINUX_TRY_COMPILE tests ZFS_AC_KERNEL_FPU_HEADER ZFS_AC_KERNEL_OBJTOOL_HEADER - ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T ZFS_AC_KERNEL_MISC_MINOR ZFS_AC_KERNEL_DECLARE_EVENT_CLASS @@ -46,7 +45,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SCHED ZFS_AC_KERNEL_SRC_USLEEP_RANGE ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL - ZFS_AC_KERNEL_SRC_WAIT ZFS_AC_KERNEL_SRC_INODE_TIMES ZFS_AC_KERNEL_SRC_PROC_OPERATIONS ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS @@ -158,7 +156,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SCHED ZFS_AC_KERNEL_USLEEP_RANGE ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL - ZFS_AC_KERNEL_WAIT ZFS_AC_KERNEL_INODE_TIMES ZFS_AC_KERNEL_PROC_OPERATIONS ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS diff --git a/include/os/linux/spl/sys/condvar.h b/include/os/linux/spl/sys/condvar.h index ef405763ca56..cb94ae89c866 100644 --- a/include/os/linux/spl/sys/condvar.h +++ b/include/os/linux/spl/sys/condvar.h @@ -66,8 +66,8 @@ typedef struct { int cv_magic; - spl_wait_queue_head_t cv_event; - spl_wait_queue_head_t cv_destroy; + wait_queue_head_t cv_event; + wait_queue_head_t cv_destroy; atomic_t cv_refs; atomic_t cv_waiters; kmutex_t *cv_mutex; diff --git a/include/os/linux/spl/sys/kmem_cache.h b/include/os/linux/spl/sys/kmem_cache.h index 2b4f120e6427..cfdb0ba750f7 100644 --- a/include/os/linux/spl/sys/kmem_cache.h +++ b/include/os/linux/spl/sys/kmem_cache.h @@ -160,7 +160,7 @@ typedef struct spl_kmem_cache { struct list_head skc_partial_list; /* Partially alloc'ed */ struct rb_root skc_emergency_tree; /* Min sized objects */ spinlock_t skc_lock; /* Cache lock */ - spl_wait_queue_head_t skc_waitq; /* Allocation waiters */ + wait_queue_head_t skc_waitq; /* Allocation waiters */ uint64_t skc_slab_fail; /* Slab alloc failures */ uint64_t skc_slab_create; /* Slab creates */ uint64_t skc_slab_destroy; /* Slab destroys */ diff --git a/include/os/linux/spl/sys/taskq.h b/include/os/linux/spl/sys/taskq.h index 6c0dbbefda7f..8c4fee5299ff 100644 --- a/include/os/linux/spl/sys/taskq.h +++ b/include/os/linux/spl/sys/taskq.h @@ -98,8 +98,8 @@ typedef struct taskq { struct list_head tq_prio_list; /* priority taskq_ent_t's */ struct list_head tq_delay_list; /* delayed taskq_ent_t's */ struct list_head tq_taskqs; /* all taskq_t's */ - spl_wait_queue_head_t tq_work_waitq; /* new work waitq */ - spl_wait_queue_head_t tq_wait_waitq; /* wait waitq */ + wait_queue_head_t tq_work_waitq; /* new work waitq */ + wait_queue_head_t tq_wait_waitq; /* wait waitq */ tq_lock_role_t tq_lock_class; /* class when taking tq_lock */ /* list node for the cpu hotplug callback */ struct hlist_node tq_hp_cb_node; @@ -109,7 +109,7 @@ typedef struct taskq { typedef struct taskq_ent { spinlock_t tqent_lock; - spl_wait_queue_head_t tqent_waitq; + wait_queue_head_t tqent_waitq; struct timer_list tqent_timer; struct list_head tqent_list; taskqid_t tqent_id; diff --git a/include/os/linux/spl/sys/wait.h b/include/os/linux/spl/sys/wait.h index da30ccdf672e..78ec62b08155 100644 --- a/include/os/linux/spl/sys/wait.h +++ b/include/os/linux/spl/sys/wait.h @@ -27,12 +27,4 @@ #include #include -#ifdef HAVE_WAIT_QUEUE_ENTRY_T -typedef wait_queue_head_t spl_wait_queue_head_t; -typedef wait_queue_entry_t spl_wait_queue_entry_t; -#else -typedef wait_queue_head_t spl_wait_queue_head_t; -typedef wait_queue_t spl_wait_queue_entry_t; -#endif - #endif /* SPL_WAIT_H */ diff --git a/module/os/linux/spl/spl-proc.c b/module/os/linux/spl/spl-proc.c index 2c0cdd9febf5..3b1d6e0b24ba 100644 --- a/module/os/linux/spl/spl-proc.c +++ b/module/os/linux/spl/spl-proc.c @@ -203,7 +203,7 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag) { taskq_t *tq = p; taskq_thread_t *tqt = NULL; - spl_wait_queue_entry_t *wq; + wait_queue_entry_t *wq; struct task_struct *tsk; taskq_ent_t *tqe; char name[100]; @@ -220,11 +220,7 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag) lheads[LHEAD_PEND] = &tq->tq_pend_list; lheads[LHEAD_PRIO] = &tq->tq_prio_list; lheads[LHEAD_DELAY] = &tq->tq_delay_list; -#ifdef HAVE_WAIT_QUEUE_HEAD_ENTRY lheads[LHEAD_WAIT] = &tq->tq_wait_waitq.head; -#else - lheads[LHEAD_WAIT] = &tq->tq_wait_waitq.task_list; -#endif lheads[LHEAD_ACTIVE] = &tq->tq_active_list; for (i = 0; i < LHEAD_SIZE; ++i) { @@ -284,13 +280,8 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag) } /* show the wait waitq list */ if (i == LHEAD_WAIT) { -#ifdef HAVE_WAIT_QUEUE_HEAD_ENTRY wq = list_entry(lh, - spl_wait_queue_entry_t, entry); -#else - wq = list_entry(lh, - spl_wait_queue_entry_t, task_list); -#endif + wait_queue_entry_t, entry); if (j == 0) seq_printf(f, "\t%s:", list_names[i]); From e05f8c2d72b2ae83349d2415984c24d7edbc102c Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:17:57 +1000 Subject: [PATCH 172/223] config: remove ZFS_GLOBAL_ZONE_PAGE_STATE Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-global_page_state.m4 | 31 --------------------- config/kernel.m4 | 1 - include/os/linux/kernel/linux/page_compat.h | 23 --------------- 3 files changed, 55 deletions(-) diff --git a/config/kernel-global_page_state.m4 b/config/kernel-global_page_state.m4 index 114f3c8dc8fc..fd256cc24b0b 100644 --- a/config/kernel-global_page_state.m4 +++ b/config/kernel-global_page_state.m4 @@ -1,28 +1,3 @@ -dnl # -dnl # 4.14 API change -dnl # -dnl # c41f012ade0b mm: rename global_page_state to global_zone_page_state -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_GLOBAL_ZONE_PAGE_STATE], [ - ZFS_LINUX_TEST_SRC([global_zone_page_state], [ - #include - #include - ],[ - (void) global_zone_page_state(0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE], [ - AC_MSG_CHECKING([whether global_zone_page_state() exists]) - ZFS_LINUX_TEST_RESULT([global_zone_page_state], [ - AC_MSG_RESULT(yes) - AC_DEFINE(ZFS_GLOBAL_ZONE_PAGE_STATE, 1, - [global_zone_page_state() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # Create a define and autoconf variable for an enum member dnl # @@ -72,16 +47,10 @@ AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE_SANITY], [ AC_MSG_RESULT(yes) ]) -AC_DEFUN([ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE], [ - ZFS_AC_KERNEL_SRC_GLOBAL_ZONE_PAGE_STATE -]) - dnl # dnl # enum members in which we're interested dnl # AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE], [ - ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE - ZFS_AC_KERNEL_ENUM_MEMBER([NR_FILE_PAGES], [node_stat_item], [$LINUX/include/linux/mmzone.h]) ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_ANON], diff --git a/config/kernel.m4 b/config/kernel.m4 index b74dea1385e6..73e08e56457a 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -38,7 +38,6 @@ dnl # AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_TYPES ZFS_AC_KERNEL_SRC_OBJTOOL - ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE ZFS_AC_KERNEL_SRC_PDE_DATA ZFS_AC_KERNEL_SRC_GENERIC_FADVISE diff --git a/include/os/linux/kernel/linux/page_compat.h b/include/os/linux/kernel/linux/page_compat.h index 040c9b6a91f7..45e4fbe744b3 100644 --- a/include/os/linux/kernel/linux/page_compat.h +++ b/include/os/linux/kernel/linux/page_compat.h @@ -17,9 +17,7 @@ /* * Create our own accessor functions to follow the Linux API changes */ -#if defined(ZFS_GLOBAL_ZONE_PAGE_STATE) -/* global_zone_page_state() introduced */ #if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_FILE_PAGES) #define nr_file_pages() global_node_page_state(NR_FILE_PAGES) #else @@ -36,25 +34,4 @@ #define nr_inactive_file_pages() global_zone_page_state(NR_INACTIVE_FILE) #endif -#else - -/* global_node_page_state() introduced */ -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_FILE_PAGES) -#define nr_file_pages() global_node_page_state(NR_FILE_PAGES) -#else -#define nr_file_pages() global_page_state(NR_FILE_PAGES) -#endif -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_ANON) -#define nr_inactive_anon_pages() global_node_page_state(NR_INACTIVE_ANON) -#else -#define nr_inactive_anon_pages() global_page_state(NR_INACTIVE_ANON) -#endif -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_FILE) -#define nr_inactive_file_pages() global_node_page_state(NR_INACTIVE_FILE) -#else -#define nr_inactive_file_pages() global_page_state(NR_INACTIVE_FILE) -#endif - -#endif /* ZFS_GLOBAL_ZONE_PAGE_STATE */ - #endif /* _ZFS_PAGE_COMPAT_H */ From 3c5a1180b43b515eab0b5155b63c726d2c9349c0 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:24:59 +1000 Subject: [PATCH 173/223] config: remove ZFS_GLOBAL_ZONE_PAGE_STATE and ZFS_ENUM_* generation Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-global_page_state.m4 | 69 --------------------- config/kernel.m4 | 1 - contrib/debian/not-installed | 1 - contrib/debian/rules.in | 1 - include/os/linux/kernel/linux/page_compat.h | 26 -------- scripts/Makefile.am | 1 - scripts/enum-extract.pl | 58 ----------------- 7 files changed, 157 deletions(-) delete mode 100644 config/kernel-global_page_state.m4 delete mode 100755 scripts/enum-extract.pl diff --git a/config/kernel-global_page_state.m4 b/config/kernel-global_page_state.m4 deleted file mode 100644 index fd256cc24b0b..000000000000 --- a/config/kernel-global_page_state.m4 +++ /dev/null @@ -1,69 +0,0 @@ -dnl # -dnl # Create a define and autoconf variable for an enum member -dnl # -AC_DEFUN([ZFS_AC_KERNEL_ENUM_MEMBER], [ - AC_MSG_CHECKING([whether enum $2 contains $1]) - AS_IF([AC_TRY_COMMAND( - "${srcdir}/scripts/enum-extract.pl" "$2" "$3" | grep -Eqx $1)],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(m4_join([_], [ZFS_ENUM], m4_toupper($2), $1), 1, - [enum $2 contains $1]) - m4_join([_], [ZFS_ENUM], m4_toupper($2), $1)=1 - ],[ - AC_MSG_RESULT([no]) - ]) -]) - -dnl # -dnl # Sanity check helpers -dnl # -AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_ERROR],[ - AC_MSG_RESULT(no) - AC_MSG_RESULT([$1 in either node_stat_item or zone_stat_item: $2]) - ZFS_LINUX_TEST_ERROR([global page state]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK], [ - enum_check_a="m4_join([_], [$ZFS_ENUM_NODE_STAT_ITEM], $1)" - enum_check_b="m4_join([_], [$ZFS_ENUM_ZONE_STAT_ITEM], $1)" - AS_IF([test -n "$enum_check_a" -a -n "$enum_check_b"],[ - ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_ERROR([$1], [DUPLICATE]) - ]) - AS_IF([test -z "$enum_check_a" -a -z "$enum_check_b"],[ - ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_ERROR([$1], [NOT FOUND]) - ]) -]) - -dnl # -dnl # Ensure the config tests are finding one and only one of each enum. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE_SANITY], [ - AC_MSG_CHECKING([whether global_page_state enums are sane]) - - ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_FILE_PAGES]) - ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_INACTIVE_ANON]) - ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_INACTIVE_FILE]) - - AC_MSG_RESULT(yes) -]) - -dnl # -dnl # enum members in which we're interested -dnl # -AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE], [ - ZFS_AC_KERNEL_ENUM_MEMBER([NR_FILE_PAGES], - [node_stat_item], [$LINUX/include/linux/mmzone.h]) - ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_ANON], - [node_stat_item], [$LINUX/include/linux/mmzone.h]) - ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_FILE], - [node_stat_item], [$LINUX/include/linux/mmzone.h]) - - ZFS_AC_KERNEL_ENUM_MEMBER([NR_FILE_PAGES], - [zone_stat_item], [$LINUX/include/linux/mmzone.h]) - ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_ANON], - [zone_stat_item], [$LINUX/include/linux/mmzone.h]) - ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_FILE], - [zone_stat_item], [$LINUX/include/linux/mmzone.h]) - - ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE_SANITY -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 73e08e56457a..e8ecb9eacee5 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -148,7 +148,6 @@ dnl # AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_TYPES ZFS_AC_KERNEL_ACCESS_OK_TYPE - ZFS_AC_KERNEL_GLOBAL_PAGE_STATE ZFS_AC_KERNEL_OBJTOOL ZFS_AC_KERNEL_PDE_DATA ZFS_AC_KERNEL_GENERIC_FADVISE diff --git a/contrib/debian/not-installed b/contrib/debian/not-installed index ad14776f3b7e..88557f76fcae 100644 --- a/contrib/debian/not-installed +++ b/contrib/debian/not-installed @@ -1,5 +1,4 @@ usr/bin/arc_summary.py -usr/share/zfs/enum-extract.pl usr/share/zfs/zfs-helpers.sh etc/default/zfs etc/init.d diff --git a/contrib/debian/rules.in b/contrib/debian/rules.in index 35853f4dc30c..3226d604546c 100755 --- a/contrib/debian/rules.in +++ b/contrib/debian/rules.in @@ -93,7 +93,6 @@ override_dh_auto_install: @# Install the DKMS source. @# We only want the files needed to build the modules install -D -t '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/scripts' \ - '$(CURDIR)/scripts/enum-extract.pl' \ '$(CURDIR)/scripts/dkms.postbuild' $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' || exit 1;) diff --git a/include/os/linux/kernel/linux/page_compat.h b/include/os/linux/kernel/linux/page_compat.h index 45e4fbe744b3..963b96ba6351 100644 --- a/include/os/linux/kernel/linux/page_compat.h +++ b/include/os/linux/kernel/linux/page_compat.h @@ -1,37 +1,11 @@ #ifndef _ZFS_PAGE_COMPAT_H #define _ZFS_PAGE_COMPAT_H -/* - * We have various enum members moving between two separate enum types, - * and accessed by different functions at various times. Centralise the - * insanity. - * - * < v4.8: all enums in zone_stat_item, via global_page_state() - * v4.8: some enums moved to node_stat_item, global_node_page_state() introduced - * v4.13: some enums moved from zone_stat_item to node_state_item - * v4.14: global_page_state() rename to global_zone_page_state() - * - * The defines used here are created by config/kernel-global_page_state.m4 - */ - /* * Create our own accessor functions to follow the Linux API changes */ - -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_FILE_PAGES) #define nr_file_pages() global_node_page_state(NR_FILE_PAGES) -#else -#define nr_file_pages() global_zone_page_state(NR_FILE_PAGES) -#endif -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_ANON) #define nr_inactive_anon_pages() global_node_page_state(NR_INACTIVE_ANON) -#else -#define nr_inactive_anon_pages() global_zone_page_state(NR_INACTIVE_ANON) -#endif -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_FILE) #define nr_inactive_file_pages() global_node_page_state(NR_INACTIVE_FILE) -#else -#define nr_inactive_file_pages() global_zone_page_state(NR_INACTIVE_FILE) -#endif #endif /* _ZFS_PAGE_COMPAT_H */ diff --git a/scripts/Makefile.am b/scripts/Makefile.am index b43bf97dbdf4..7d9cef83d2c6 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -28,7 +28,6 @@ endif dist_noinst_DATA += \ %D%/cstyle.pl \ - %D%/enum-extract.pl \ %D%/update_authors.pl \ %D%/zfs2zol-patch.sed \ %D%/zol2zfs-patch.sed diff --git a/scripts/enum-extract.pl b/scripts/enum-extract.pl deleted file mode 100755 index 5dc2e3455145..000000000000 --- a/scripts/enum-extract.pl +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env perl - -my $usage = <) { - # comments - s/\/\*.*\*\///; - if (m/\/\*/) { - while ($_ .= <>) { - last if s/\/\*.*\*\///s; - } - } - - # preprocessor stuff - next if /^#/; - - # find our enum - $in_enum = 1 if s/^\s*enum\s+${enum}(?:\s|$)//; - next unless $in_enum; - - # remove explicit values - s/\s*=[^,]+,/,/g; - - # extract each identifier - while (m/\b([a-z_][a-z0-9_]*)\b/ig) { - print $1, "\n"; - } - - # - # don't exit: there may be multiple versions of the same enum, e.g. - # inside different #ifdef blocks. Let's explicitly return all of - # them and let external tooling deal with it. - # - $in_enum = 0 if m/}\s*;/; -} - -exit 0; From 56a82c6b6f1130ec15f65df460b0fefd901d93e5 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:26:50 +1000 Subject: [PATCH 174/223] config: remove HAVE_BLK_QUEUE_FLAG_* Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-blk-queue.m4 | 50 ------------------- include/os/linux/kernel/linux/blkdev_compat.h | 15 ------ 2 files changed, 65 deletions(-) diff --git a/config/kernel-blk-queue.m4 b/config/kernel-blk-queue.m4 index 04919fa88700..fedbb6dfb8d8 100644 --- a/config/kernel-blk-queue.m4 +++ b/config/kernel-blk-queue.m4 @@ -203,52 +203,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE], [ ]) ]) -dnl # -dnl # 4.16 API change, -dnl # Introduction of blk_queue_flag_set and blk_queue_flag_clear -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET], [ - ZFS_LINUX_TEST_SRC([blk_queue_flag_set], [ - #include - #include - ],[ - struct request_queue *q = NULL; - blk_queue_flag_set(0, q); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET], [ - AC_MSG_CHECKING([whether blk_queue_flag_set() exists]) - ZFS_LINUX_TEST_RESULT([blk_queue_flag_set], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_QUEUE_FLAG_SET, 1, - [blk_queue_flag_set() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR], [ - ZFS_LINUX_TEST_SRC([blk_queue_flag_clear], [ - #include - #include - ],[ - struct request_queue *q = NULL; - blk_queue_flag_clear(0, q); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR], [ - AC_MSG_CHECKING([whether blk_queue_flag_clear() exists]) - ZFS_LINUX_TEST_RESULT([blk_queue_flag_clear], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_QUEUE_FLAG_CLEAR, 1, - [blk_queue_flag_clear() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.34 API change dnl # blk_queue_max_hw_sectors() replaces blk_queue_max_sectors(). @@ -346,8 +300,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [ ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE - ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET - ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS ZFS_AC_KERNEL_SRC_BLK_MQ @@ -360,8 +312,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [ ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD ZFS_AC_KERNEL_BLK_QUEUE_DISCARD ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE - ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET - ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS ZFS_AC_KERNEL_BLK_MQ diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 3af6d94763bc..d5aa7e07c75d 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -40,21 +40,6 @@ #include #endif -#ifndef HAVE_BLK_QUEUE_FLAG_SET -static inline void -blk_queue_flag_set(unsigned int flag, struct request_queue *q) -{ - queue_flag_set(flag, q); -} -#endif - -#ifndef HAVE_BLK_QUEUE_FLAG_CLEAR -static inline void -blk_queue_flag_clear(unsigned int flag, struct request_queue *q) -{ - queue_flag_clear(flag, q); -} -#endif /* * 6.11 API From 9601eeea1c48d7b8075413b6daf8779346058867 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:33:35 +1000 Subject: [PATCH 175/223] config: remove HAVE_BLK_MQ Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-blk-queue.m4 | 38 ++++--------------- include/os/linux/kernel/linux/blkdev_compat.h | 36 ------------------ module/os/linux/zfs/zfs_uio.c | 6 --- module/os/linux/zfs/zvol_os.c | 34 +---------------- 4 files changed, 8 insertions(+), 106 deletions(-) diff --git a/config/kernel-blk-queue.m4 b/config/kernel-blk-queue.m4 index fedbb6dfb8d8..cd2b143e89a0 100644 --- a/config/kernel-blk-queue.m4 +++ b/config/kernel-blk-queue.m4 @@ -248,24 +248,7 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS], [ ]) ]) -dnl # -dnl # See if kernel supports block multi-queue and blk_status_t. -dnl # blk_status_t represents the new status codes introduced in the 4.13 -dnl # kernel patch: -dnl # -dnl # block: introduce new block status code type -dnl # -dnl # We do not currently support the "old" block multi-queue interfaces from -dnl # prior kernels. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ], [ - ZFS_LINUX_TEST_SRC([blk_mq], [ - #include - ], [ - struct blk_mq_tag_set tag_set __attribute__ ((unused)) = {0}; - (void) blk_mq_alloc_tag_set(&tag_set); - return BLK_STS_OK; - ], []) +AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ_RQ_HCTX], [ ZFS_LINUX_TEST_SRC([blk_mq_rq_hctx], [ #include #include @@ -276,18 +259,11 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ], [ ], []) ]) -AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ], [ - AC_MSG_CHECKING([whether block multiqueue with blk_status_t is available]) - ZFS_LINUX_TEST_RESULT([blk_mq], [ +AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ_RQ_HCTX], [ + AC_MSG_CHECKING([whether block multiqueue hardware context is cached in struct request]) + ZFS_LINUX_TEST_RESULT([blk_mq_rq_hctx], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_MQ, 1, [block multiqueue is available]) - AC_MSG_CHECKING([whether block multiqueue hardware context is cached in struct request]) - ZFS_LINUX_TEST_RESULT([blk_mq_rq_hctx], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BLK_MQ_RQ_HCTX, 1, [block multiqueue hardware context is cached in struct request]) - ], [ - AC_MSG_RESULT(no) - ]) + AC_DEFINE(HAVE_BLK_MQ_RQ_HCTX, 1, [block multiqueue hardware context is cached in struct request]) ], [ AC_MSG_RESULT(no) ]) @@ -302,7 +278,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [ ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS - ZFS_AC_KERNEL_SRC_BLK_MQ + ZFS_AC_KERNEL_SRC_BLK_MQ_RQ_HCTX ]) AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [ @@ -314,5 +290,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [ ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS - ZFS_AC_KERNEL_BLK_MQ + ZFS_AC_KERNEL_BLK_MQ_RQ_HCTX ]) diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index d5aa7e07c75d..23c2e0e94098 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -35,11 +35,7 @@ #include #include /* for SECTOR_* */ #include - -#ifdef HAVE_BLK_MQ #include -#endif - /* * 6.11 API @@ -531,7 +527,6 @@ blk_generic_alloc_queue(make_request_fn make_request, int node_id) static inline int io_data_dir(struct bio *bio, struct request *rq) { -#ifdef HAVE_BLK_MQ if (rq != NULL) { if (op_is_write(req_op(rq))) { return (WRITE); @@ -539,57 +534,38 @@ io_data_dir(struct bio *bio, struct request *rq) return (READ); } } -#else - ASSERT3P(rq, ==, NULL); -#endif return (bio_data_dir(bio)); } static inline int io_is_flush(struct bio *bio, struct request *rq) { -#ifdef HAVE_BLK_MQ if (rq != NULL) return (req_op(rq) == REQ_OP_FLUSH); -#else - ASSERT3P(rq, ==, NULL); -#endif return (bio_is_flush(bio)); } static inline int io_is_discard(struct bio *bio, struct request *rq) { -#ifdef HAVE_BLK_MQ if (rq != NULL) return (req_op(rq) == REQ_OP_DISCARD); -#else - ASSERT3P(rq, ==, NULL); -#endif return (bio_is_discard(bio)); } static inline int io_is_secure_erase(struct bio *bio, struct request *rq) { -#ifdef HAVE_BLK_MQ if (rq != NULL) return (req_op(rq) == REQ_OP_SECURE_ERASE); -#else - ASSERT3P(rq, ==, NULL); -#endif return (bio_is_secure_erase(bio)); } static inline int io_is_fua(struct bio *bio, struct request *rq) { -#ifdef HAVE_BLK_MQ if (rq != NULL) return (rq->cmd_flags & REQ_FUA); -#else - ASSERT3P(rq, ==, NULL); -#endif return (bio_is_fua(bio)); } @@ -597,36 +573,24 @@ io_is_fua(struct bio *bio, struct request *rq) static inline uint64_t io_offset(struct bio *bio, struct request *rq) { -#ifdef HAVE_BLK_MQ if (rq != NULL) return (blk_rq_pos(rq) << 9); -#else - ASSERT3P(rq, ==, NULL); -#endif return (BIO_BI_SECTOR(bio) << 9); } static inline uint64_t io_size(struct bio *bio, struct request *rq) { -#ifdef HAVE_BLK_MQ if (rq != NULL) return (blk_rq_bytes(rq)); -#else - ASSERT3P(rq, ==, NULL); -#endif return (BIO_BI_SIZE(bio)); } static inline int io_has_data(struct bio *bio, struct request *rq) { -#ifdef HAVE_BLK_MQ if (rq != NULL) return (bio_has_data(rq->bio)); -#else - ASSERT3P(rq, ==, NULL); -#endif return (bio_has_data(bio)); } #endif /* _ZFS_BLKDEV_H */ diff --git a/module/os/linux/zfs/zfs_uio.c b/module/os/linux/zfs/zfs_uio.c index a99a1ba88256..feba18fdaf4d 100644 --- a/module/os/linux/zfs/zfs_uio.c +++ b/module/os/linux/zfs/zfs_uio.c @@ -161,7 +161,6 @@ zfs_uiomove_bvec_impl(void *p, size_t n, zfs_uio_rw_t rw, zfs_uio_t *uio) return (0); } -#ifdef HAVE_BLK_MQ static void zfs_copy_bvec(void *p, size_t skip, size_t cnt, zfs_uio_rw_t rw, struct bio_vec *bv) @@ -253,17 +252,12 @@ zfs_uiomove_bvec_rq(void *p, size_t n, zfs_uio_rw_t rw, zfs_uio_t *uio) } return (0); } -#endif static int zfs_uiomove_bvec(void *p, size_t n, zfs_uio_rw_t rw, zfs_uio_t *uio) { -#ifdef HAVE_BLK_MQ if (uio->rq != NULL) return (zfs_uiomove_bvec_rq(p, n, rw, uio)); -#else - ASSERT3P(uio->rq, ==, NULL); -#endif return (zfs_uiomove_bvec_impl(p, n, rw, uio)); } diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 7e7276f068da..6b2c14e935e0 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -44,10 +44,7 @@ #include #include #include - -#ifdef HAVE_BLK_MQ #include -#endif static void zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq, boolean_t force_sync); @@ -68,7 +65,6 @@ static unsigned int zvol_open_timeout_ms = 1000; #endif static unsigned int zvol_threads = 0; -#ifdef HAVE_BLK_MQ static unsigned int zvol_blk_mq_threads = 0; static unsigned int zvol_blk_mq_actual_threads; static boolean_t zvol_use_blk_mq = B_FALSE; @@ -84,7 +80,6 @@ static boolean_t zvol_use_blk_mq = B_FALSE; * read and write tests to a zvol in an NVMe pool (with 16 CPUs). */ static unsigned int zvol_blk_mq_blocks_per_thread = 8; -#endif static unsigned int zvol_num_taskqs = 0; @@ -96,7 +91,6 @@ static unsigned int zvol_num_taskqs = 0; /* * Finalize our BIO or request. */ -#ifdef HAVE_BLK_MQ #define END_IO(zv, bio, rq, error) do { \ if (bio) { \ bio->bi_status = errno_to_bi_status(-error); \ @@ -105,26 +99,16 @@ static unsigned int zvol_num_taskqs = 0; blk_mq_end_request(rq, errno_to_bi_status(error)); \ } \ } while (0) -#else -#define END_IO(zv, bio, rq, error) do { \ - bio->bi_status = errno_to_bi_status(-error); \ - bio_endio(bio); \ -} while (0) -#endif -#ifdef HAVE_BLK_MQ static unsigned int zvol_blk_mq_queue_depth = BLKDEV_DEFAULT_RQ; static unsigned int zvol_actual_blk_mq_queue_depth; -#endif struct zvol_state_os { struct gendisk *zvo_disk; /* generic disk */ struct request_queue *zvo_queue; /* request queue */ dev_t zvo_dev; /* device id */ -#ifdef HAVE_BLK_MQ struct blk_mq_tag_set tag_set; -#endif /* Set from the global 'zvol_use_blk_mq' at zvol load */ boolean_t use_blk_mq; @@ -169,8 +153,6 @@ zv_request_task_free(zv_request_task_t *task) kmem_free(task, sizeof (*task)); } -#ifdef HAVE_BLK_MQ - /* * This is called when a new block multiqueue request comes in. A request * contains one or more BIOs. @@ -223,7 +205,6 @@ static int zvol_blk_mq_alloc_tag_set(zvol_state_t *zv) return (blk_mq_alloc_tag_set(&zso->tag_set)); } -#endif /* HAVE_BLK_MQ */ /* * Given a path, return TRUE if path is a ZVOL. @@ -561,14 +542,12 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq, uint_t blk_mq_hw_queue = 0; uint_t tq_idx; uint_t taskq_hash; -#ifdef HAVE_BLK_MQ if (rq) #ifdef HAVE_BLK_MQ_RQ_HCTX blk_mq_hw_queue = rq->mq_hctx->queue_num; #else blk_mq_hw_queue = rq->q->queue_hw_ctx[rq->q->mq_map[rq->cpu]]->queue_num; -#endif #endif taskq_hash = cityhash4((uintptr_t)zv, offset >> ZVOL_TASKQ_OFFSET_SHIFT, blk_mq_hw_queue, 0); @@ -1174,7 +1153,6 @@ zvol_queue_limits_init(zvol_queue_limits_t *limits, zvol_state_t *zv, * the correct number of segments for the volblocksize and * number of chunks you want. */ -#ifdef HAVE_BLK_MQ if (zvol_blk_mq_blocks_per_thread != 0) { unsigned int chunks; chunks = MIN(zvol_blk_mq_blocks_per_thread, UINT16_MAX); @@ -1191,7 +1169,6 @@ zvol_queue_limits_init(zvol_queue_limits_t *limits, zvol_state_t *zv, limits->zql_max_segment_size = UINT_MAX; } } else { -#endif limits->zql_max_segments = UINT16_MAX; limits->zql_max_segment_size = UINT_MAX; } @@ -1304,7 +1281,6 @@ zvol_alloc_non_blk_mq(struct zvol_state_os *zso, zvol_queue_limits_t *limits) static int zvol_alloc_blk_mq(zvol_state_t *zv, zvol_queue_limits_t *limits) { -#ifdef HAVE_BLK_MQ struct zvol_state_os *zso = zv->zv_zso; /* Allocate our blk-mq tag_set */ @@ -1351,7 +1327,6 @@ zvol_alloc_blk_mq(zvol_state_t *zv, zvol_queue_limits_t *limits) #endif zvol_queue_limits_apply(limits, zso->zvo_queue); -#endif return (0); } @@ -1387,9 +1362,7 @@ zvol_alloc(dev_t dev, const char *name, uint64_t volblocksize) mutex_init(&zv->zv_state_lock, NULL, MUTEX_DEFAULT, NULL); cv_init(&zv->zv_removing_cv, NULL, CV_DEFAULT, NULL); -#ifdef HAVE_BLK_MQ zv->zv_zso->use_blk_mq = zvol_use_blk_mq; -#endif zvol_queue_limits_t limits; zvol_queue_limits_init(&limits, zv, zv->zv_zso->use_blk_mq); @@ -1498,10 +1471,8 @@ zvol_os_free(zvol_state_t *zv) put_disk(zv->zv_zso->zvo_disk); #endif -#ifdef HAVE_BLK_MQ if (zv->zv_zso->use_blk_mq) blk_mq_free_tag_set(&zv->zv_zso->tag_set); -#endif ida_simple_remove(&zvol_ida, MINOR(zv->zv_zso->zvo_dev) >> ZVOL_MINOR_BITS); @@ -1859,7 +1830,6 @@ zvol_init(void) return (error); } -#ifdef HAVE_BLK_MQ if (zvol_blk_mq_queue_depth == 0) { zvol_actual_blk_mq_queue_depth = BLKDEV_DEFAULT_RQ; } else { @@ -1873,7 +1843,7 @@ zvol_init(void) zvol_blk_mq_actual_threads = MIN(MAX(zvol_blk_mq_threads, 1), 1024); } -#endif + for (uint_t i = 0; i < num_tqs; i++) { char name[32]; (void) snprintf(name, sizeof (name), "%s_tq-%u", @@ -1945,7 +1915,6 @@ MODULE_PARM_DESC(zvol_prefetch_bytes, "Prefetch N bytes at zvol start+end"); module_param(zvol_volmode, uint, 0644); MODULE_PARM_DESC(zvol_volmode, "Default volmode property value"); -#ifdef HAVE_BLK_MQ module_param(zvol_blk_mq_queue_depth, uint, 0644); MODULE_PARM_DESC(zvol_blk_mq_queue_depth, "Default blk-mq queue depth"); @@ -1955,7 +1924,6 @@ MODULE_PARM_DESC(zvol_use_blk_mq, "Use the blk-mq API for zvols"); module_param(zvol_blk_mq_blocks_per_thread, uint, 0644); MODULE_PARM_DESC(zvol_blk_mq_blocks_per_thread, "Process volblocksize blocks per thread"); -#endif #ifndef HAVE_BLKDEV_GET_ERESTARTSYS module_param(zvol_open_timeout_ms, uint, 0644); From 701c3c158243b48a0443c4462ec1e53a0329ebdb Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:37:30 +1000 Subject: [PATCH 176/223] linux/zvol_os: convert END_IO macro to inline function Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- module/os/linux/zfs/zvol_os.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 6b2c14e935e0..6f43e9283807 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -91,14 +91,16 @@ static unsigned int zvol_num_taskqs = 0; /* * Finalize our BIO or request. */ -#define END_IO(zv, bio, rq, error) do { \ - if (bio) { \ - bio->bi_status = errno_to_bi_status(-error); \ - bio_endio(bio); \ - } else { \ - blk_mq_end_request(rq, errno_to_bi_status(error)); \ - } \ -} while (0) +static inline void +zvol_end_io(struct bio *bio, struct request *rq, int error) +{ + if (bio) { + bio->bi_status = errno_to_bi_status(-error); + bio_endio(bio); + } else { + blk_mq_end_request(rq, errno_to_bi_status(error)); + } +} static unsigned int zvol_blk_mq_queue_depth = BLKDEV_DEFAULT_RQ; static unsigned int zvol_actual_blk_mq_queue_depth; @@ -250,7 +252,7 @@ zvol_write(zv_request_t *zvr) /* Some requests are just for flush and nothing else. */ if (io_size(bio, rq) == 0) { rw_exit(&zv->zv_suspend_lock); - END_IO(zv, bio, rq, 0); + zvol_end_io(bio, rq, 0); return; } @@ -317,7 +319,7 @@ zvol_write(zv_request_t *zvr) blk_generic_end_io_acct(q, disk, WRITE, bio, start_time); } - END_IO(zv, bio, rq, -error); + zvol_end_io(bio, rq, -error); } static void @@ -406,7 +408,7 @@ zvol_discard(zv_request_t *zvr) start_time); } - END_IO(zv, bio, rq, -error); + zvol_end_io(bio, rq, -error); } static void @@ -483,7 +485,7 @@ zvol_read(zv_request_t *zvr) blk_generic_end_io_acct(q, disk, READ, bio, start_time); } - END_IO(zv, bio, rq, -error); + zvol_end_io(bio, rq, -error); } static void @@ -514,7 +516,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq, int rw = io_data_dir(bio, rq); if (unlikely(zv->zv_flags & ZVOL_REMOVING)) { - END_IO(zv, bio, rq, -SET_ERROR(ENXIO)); + zvol_end_io(bio, rq, -SET_ERROR(ENXIO)); goto out; } @@ -533,7 +535,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq, (long long unsigned)offset, (long unsigned)size); - END_IO(zv, bio, rq, -SET_ERROR(EIO)); + zvol_end_io(bio, rq, -SET_ERROR(EIO)); goto out; } @@ -555,7 +557,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq, if (rw == WRITE) { if (unlikely(zv->zv_flags & ZVOL_RDONLY)) { - END_IO(zv, bio, rq, -SET_ERROR(EROFS)); + zvol_end_io(bio, rq, -SET_ERROR(EROFS)); goto out; } @@ -640,7 +642,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq, * data and require no additional handling. */ if (size == 0) { - END_IO(zv, bio, rq, 0); + zvol_end_io(bio, rq, 0); goto out; } From 0da3b420c33ee2232c3828031eb04f9c36d80bc2 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:39:48 +1000 Subject: [PATCH 177/223] config: remove HAVE_GENERIC_READLINK Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-generic_readlink.m4 | 25 ------------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/zpl_inode.c | 3 --- 3 files changed, 30 deletions(-) delete mode 100644 config/kernel-generic_readlink.m4 diff --git a/config/kernel-generic_readlink.m4 b/config/kernel-generic_readlink.m4 deleted file mode 100644 index a7a33b408abd..000000000000 --- a/config/kernel-generic_readlink.m4 +++ /dev/null @@ -1,25 +0,0 @@ -dnl # -dnl # 4.10 API -dnl # -dnl # NULL inode_operations.readlink implies generic_readlink(), which -dnl # has been made static. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL], [ - ZFS_LINUX_TEST_SRC([generic_readlink_global], [ - #include - ],[ - int i __attribute__ ((unused)); - i = generic_readlink(NULL, NULL, 0); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL], [ - AC_MSG_CHECKING([whether generic_readlink is global]) - ZFS_LINUX_TEST_RESULT([generic_readlink_global], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_GENERIC_READLINK, 1, - [generic_readlink is global]) - ],[ - AC_MSG_RESULT([no]) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index e8ecb9eacee5..0183ce7c1d8c 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -53,7 +53,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_GENHD_FLAGS ZFS_AC_KERNEL_SRC_REVALIDATE_DISK ZFS_AC_KERNEL_SRC_GET_DISK_RO - ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY ZFS_AC_KERNEL_SRC_INODE_OWNER_OR_CAPABLE ZFS_AC_KERNEL_SRC_XATTR @@ -163,7 +162,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_GENHD_FLAGS ZFS_AC_KERNEL_REVALIDATE_DISK ZFS_AC_KERNEL_GET_DISK_RO - ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL ZFS_AC_KERNEL_DISCARD_GRANULARITY ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE ZFS_AC_KERNEL_XATTR diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index e2fe5c3b0f4a..8386fc2ae0ce 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -776,9 +776,6 @@ const struct inode_operations zpl_dir_inode_operations = { }; const struct inode_operations zpl_symlink_inode_operations = { -#ifdef HAVE_GENERIC_READLINK - .readlink = generic_readlink, -#endif .get_link = zpl_get_link, .setattr = zpl_setattr, .getattr = zpl_getattr, From 9076aecb4ed12984db0b550160a6f449d3d674fd Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:43:41 +1000 Subject: [PATCH 178/223] config: remove HAVE_VFSMOUNT_IOPS_GETATTR Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-inode-getattr.m4 | 26 ---------------------- include/os/linux/kernel/linux/vfs_compat.h | 11 +-------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/config/kernel-inode-getattr.m4 b/config/kernel-inode-getattr.m4 index 5f7ce1ad9a5d..73b8213109fb 100644 --- a/config/kernel-inode-getattr.m4 +++ b/config/kernel-inode-getattr.m4 @@ -57,20 +57,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_GETATTR], [ .getattr = test_getattr, }; ],[]) - - ZFS_LINUX_TEST_SRC([inode_operations_getattr_vfsmount], [ - #include - - static int test_getattr( - struct vfsmount *mnt, struct dentry *d, - struct kstat *k) - { return 0; } - - static const struct inode_operations - iops __attribute__ ((unused)) = { - .getattr = test_getattr, - }; - ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_INODE_GETATTR], [ @@ -105,18 +91,6 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_GETATTR], [ [iops->getattr() takes a path]) ],[ AC_MSG_RESULT(no) - - dnl # - dnl # Kernel < 4.11 test - dnl # - AC_MSG_CHECKING([whether iops->getattr() takes a vfsmount]) - ZFS_LINUX_TEST_RESULT([inode_operations_getattr_vfsmount], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_VFSMOUNT_IOPS_GETATTR, 1, - [iops->getattr() takes a vfsmount]) - ],[ - AC_MSG_RESULT(no) - ]) ]) ]) ]) diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 3caa61ec514f..075b9e111b10 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -187,16 +187,7 @@ setattr_prepare(struct dentry *dentry, struct iattr *ia) * 4.11 takes struct path *, < 4.11 takes vfsmount * */ -#ifdef HAVE_VFSMOUNT_IOPS_GETATTR -#define ZPL_GETATTR_WRAPPER(func) \ -static int \ -func(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) \ -{ \ - struct path path = { .mnt = mnt, .dentry = dentry }; \ - return func##_impl(&path, stat, STATX_BASIC_STATS, \ - AT_STATX_SYNC_AS_STAT); \ -} -#elif defined(HAVE_PATH_IOPS_GETATTR) +#if defined(HAVE_PATH_IOPS_GETATTR) #define ZPL_GETATTR_WRAPPER(func) \ static int \ func(const struct path *path, struct kstat *stat, u32 request_mask, \ From d30056887e2b9a0c7f569f4706872803c23fc3ad Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 21:45:25 +1000 Subject: [PATCH 179/223] config: remove HAVE_GENERIC_IO_ACCT_3ARG Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-generic_io_acct.m4 | 29 ------------------- include/os/linux/kernel/linux/blkdev_compat.h | 6 ---- 2 files changed, 35 deletions(-) diff --git a/config/kernel-generic_io_acct.m4 b/config/kernel-generic_io_acct.m4 index a6a109004294..da92aad058cb 100644 --- a/config/kernel-generic_io_acct.m4 +++ b/config/kernel-generic_io_acct.m4 @@ -49,18 +49,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [ bio_end_io_acct(bio, start_time); ]) - ZFS_LINUX_TEST_SRC([generic_acct_3args], [ - #include - - void (*generic_start_io_acct_f)(int, unsigned long, - struct hd_struct *) = &generic_start_io_acct; - void (*generic_end_io_acct_f)(int, struct hd_struct *, - unsigned long) = &generic_end_io_acct; - ], [ - generic_start_io_acct(0, 0, NULL); - generic_end_io_acct(0, NULL, 0); - ]) - ZFS_LINUX_TEST_SRC([generic_acct_4args], [ #include @@ -138,23 +126,6 @@ AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [ [generic_*_io_acct() 4 arg available]) ], [ AC_MSG_RESULT(no) - - dnl # - dnl # 3.19 API addition - dnl # - dnl # torvalds/linux@394ffa50 allows us to increment - dnl # iostat counters without generic_make_request(). - dnl # - AC_MSG_CHECKING( - [whether generic_*_io_acct wants 3 args]) - ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args], - [generic_start_io_acct], [block/bio.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1, - [generic_*_io_acct() 3 arg available]) - ], [ - AC_MSG_RESULT(no) - ]) ]) ]) ]) diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 23c2e0e94098..672f9b00ca7a 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -466,10 +466,6 @@ blk_generic_start_io_acct(struct request_queue *q __attribute__((unused)), return (disk_start_io_acct(disk, bio_sectors(bio), bio_op(bio))); #elif defined(HAVE_BIO_IO_ACCT) return (bio_start_io_acct(bio)); -#elif defined(HAVE_GENERIC_IO_ACCT_3ARG) - unsigned long start_time = jiffies; - generic_start_io_acct(rw, bio_sectors(bio), &disk->part0); - return (start_time); #elif defined(HAVE_GENERIC_IO_ACCT_4ARG) unsigned long start_time = jiffies; generic_start_io_acct(q, rw, bio_sectors(bio), &disk->part0); @@ -494,8 +490,6 @@ blk_generic_end_io_acct(struct request_queue *q __attribute__((unused)), disk_end_io_acct(disk, bio_op(bio), start_time); #elif defined(HAVE_BIO_IO_ACCT) bio_end_io_acct(bio, start_time); -#elif defined(HAVE_GENERIC_IO_ACCT_3ARG) - generic_end_io_acct(rw, &disk->part0, start_time); #elif defined(HAVE_GENERIC_IO_ACCT_4ARG) generic_end_io_acct(q, rw, &disk->part0, start_time); #endif From 701dc172fb2bc2640301ec940e4d53fbdefd87e5 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 22:06:22 +1000 Subject: [PATCH 180/223] config: rework ZFS_GENHD_FL_* Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-genhd-flags.m4 | 21 ++----------------- include/os/linux/kernel/linux/blkdev_compat.h | 13 ++++++++++++ module/os/linux/zfs/zvol_os.c | 4 ++-- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/config/kernel-genhd-flags.m4 b/config/kernel-genhd-flags.m4 index af6a8a086bc9..60cc3173397c 100644 --- a/config/kernel-genhd-flags.m4 +++ b/config/kernel-genhd-flags.m4 @@ -17,12 +17,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENHD_FLAGS], [ ], [ int flags __attribute__ ((unused)) = GENHD_FL_NO_PART; ]) - - ZFS_LINUX_TEST_SRC([genhd_fl_no_part_scan], [ - #include - ], [ - int flags __attribute__ ((unused)) = GENHD_FL_NO_PART_SCAN; - ]) ]) AC_DEFUN([ZFS_AC_KERNEL_GENHD_FLAGS], [ @@ -30,29 +24,18 @@ AC_DEFUN([ZFS_AC_KERNEL_GENHD_FLAGS], [ AC_MSG_CHECKING([whether GENHD_FL_EXT_DEVT flag is available]) ZFS_LINUX_TEST_RESULT([genhd_fl_ext_devt], [ AC_MSG_RESULT(yes) - AC_DEFINE(ZFS_GENHD_FL_EXT_DEVT, GENHD_FL_EXT_DEVT, + AC_DEFINE(HAVE_GENHD_FL_EXT_DEVT, 1, [GENHD_FL_EXT_DEVT flag is available]) ], [ AC_MSG_RESULT(no) - AC_DEFINE(ZFS_GENHD_FL_EXT_DEVT, 0, - [GENHD_FL_EXT_DEVT flag is not available]) ]) AC_MSG_CHECKING([whether GENHD_FL_NO_PART flag is available]) ZFS_LINUX_TEST_RESULT([genhd_fl_no_part], [ AC_MSG_RESULT(yes) - AC_DEFINE(ZFS_GENHD_FL_NO_PART, GENHD_FL_NO_PART, + AC_DEFINE(HAVE_GENHD_FL_NO_PART, 1, [GENHD_FL_NO_PART flag is available]) ], [ AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether GENHD_FL_NO_PART_SCAN flag is available]) - ZFS_LINUX_TEST_RESULT([genhd_fl_no_part_scan], [ - AC_MSG_RESULT(yes) - AC_DEFINE(ZFS_GENHD_FL_NO_PART, GENHD_FL_NO_PART_SCAN, - [GENHD_FL_NO_PART_SCAN flag is available]) - ], [ - ZFS_LINUX_TEST_ERROR([GENHD_FL_NO_PART|GENHD_FL_NO_PART_SCAN]) - ]) ]) ]) diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 672f9b00ca7a..80c2b9c068ef 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -220,6 +220,19 @@ zfs_check_disk_status(struct block_device *bdev) #endif } +/* + * 5.17 API change + * + * GENHD_FL_EXT_DEVT flag removed + * GENHD_FL_NO_PART_SCAN renamed GENHD_FL_NO_PART + */ +#ifndef HAVE_GENHD_FL_EXT_DEVT +#define GENHD_FL_EXT_DEVT (0) +#endif +#ifndef HAVE_GENHD_FL_NO_PART +#define GENHD_FL_NO_PART (GENHD_FL_NO_PART_SCAN) +#endif + /* * 4.1 API, * 3.10.0 CentOS 7.x API, diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 6f43e9283807..01f812b8e814 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -1420,8 +1420,8 @@ zvol_alloc(dev_t dev, const char *name, uint64_t volblocksize) */ if (volmode == ZFS_VOLMODE_DEV) { zso->zvo_disk->minors = 1; - zso->zvo_disk->flags &= ~ZFS_GENHD_FL_EXT_DEVT; - zso->zvo_disk->flags |= ZFS_GENHD_FL_NO_PART; + zso->zvo_disk->flags &= ~GENHD_FL_EXT_DEVT; + zso->zvo_disk->flags |= GENHD_FL_NO_PART; } zso->zvo_disk->first_minor = (dev & MINORMASK); From 3abb84df9be8b12c383c37d21848f136f03491e5 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 24 Aug 2024 22:11:04 +1000 Subject: [PATCH 181/223] config: remove HAVE_BIO_SET_DEV Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-bio.m4 | 32 ++++++++++++-------------------- module/os/linux/zfs/vdev_disk.c | 11 ----------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index 85d26bae6e10..8afc9c59ddad 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -66,28 +66,20 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO], [ ]) AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [ - AC_MSG_CHECKING([whether bio_set_dev() is available]) - ZFS_LINUX_TEST_RESULT([bio_set_dev], [ + AC_MSG_CHECKING([whether bio_set_dev() is GPL-only]) + ZFS_LINUX_TEST_RESULT([bio_set_dev_license], [ + AC_MSG_RESULT(no) + ],[ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BIO_SET_DEV, 1, [bio_set_dev() is available]) - - AC_MSG_CHECKING([whether bio_set_dev() is GPL-only]) - ZFS_LINUX_TEST_RESULT([bio_set_dev_license], [ - AC_MSG_RESULT(no) - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1, - [bio_set_dev() GPL-only]) - ]) + AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1, + [bio_set_dev() GPL-only]) + ]) - AC_MSG_CHECKING([whether bio_set_dev() is a macro]) - ZFS_LINUX_TEST_RESULT([bio_set_dev_macro], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_BIO_SET_DEV_MACRO, 1, - [bio_set_dev() is a macro]) - ],[ - AC_MSG_RESULT(no) - ]) + AC_MSG_CHECKING([whether bio_set_dev() is a macro]) + ZFS_LINUX_TEST_RESULT([bio_set_dev_macro], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BIO_SET_DEV_MACRO, 1, + [bio_set_dev() is a macro]) ],[ AC_MSG_RESULT(no) ]) diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index 71aff3c40e6c..a1d03188d826 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -493,7 +493,6 @@ vdev_disk_close(vdev_t *v) */ #if !defined(HAVE_BIO_ALLOC_4ARG) -#ifdef HAVE_BIO_SET_DEV #if defined(CONFIG_BLK_CGROUP) && defined(HAVE_BIO_SET_DEV_GPL_ONLY) /* * The Linux 5.5 kernel updated percpu_ref_tryget() which is inlined by @@ -579,16 +578,6 @@ vdev_bio_set_dev(struct bio *bio, struct block_device *bdev) #define bio_set_dev vdev_bio_set_dev #endif #endif -#else -/* - * Provide a bio_set_dev() helper macro for pre-Linux 4.14 kernels. - */ -static inline void -bio_set_dev(struct bio *bio, struct block_device *bdev) -{ - bio->bi_bdev = bdev; -} -#endif /* HAVE_BIO_SET_DEV */ #endif /* !HAVE_BIO_ALLOC_4ARG */ static inline void From a759b1e5fc70849bd9dba7b6df31f2f0a0bfd324 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 25 Aug 2024 16:00:01 +1000 Subject: [PATCH 182/223] config: remove HAVE_HAS_CAPABILITY Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-userns-capabilities.m4 | 27 --------------------------- config/kernel.m4 | 2 -- module/os/linux/zfs/policy.c | 9 --------- 3 files changed, 38 deletions(-) diff --git a/config/kernel-userns-capabilities.m4 b/config/kernel-userns-capabilities.m4 index 026503623a2b..f4e24fb1606a 100644 --- a/config/kernel-userns-capabilities.m4 +++ b/config/kernel-userns-capabilities.m4 @@ -19,33 +19,6 @@ AC_DEFUN([ZFS_AC_KERNEL_NS_CAPABLE], [ ]) ]) -dnl # -dnl # 4.10 API change -dnl # has_capability() was exported. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_HAS_CAPABILITY], [ - ZFS_LINUX_TEST_SRC([has_capability], [ - #include - ],[ - struct task_struct *task = NULL; - int cap = 0; - bool result __attribute__ ((unused)); - - result = has_capability(task, cap); - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_HAS_CAPABILITY], [ - AC_MSG_CHECKING([whether has_capability() is available]) - ZFS_LINUX_TEST_RESULT_SYMBOL([has_capability], - [has_capability], [kernel/capability.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_HAS_CAPABILITY, 1, [has_capability() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.39 API change dnl # struct user_namespace was added to struct cred_t as cred->user_ns member diff --git a/config/kernel.m4 b/config/kernel.m4 index 0183ce7c1d8c..465f69b72b36 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -97,7 +97,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_KUIDGID_T ZFS_AC_KERNEL_SRC_KUID_HELPERS ZFS_AC_KERNEL_SRC_RENAME - ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES ZFS_AC_KERNEL_SRC_PERCPU @@ -206,7 +205,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_KUIDGID_T ZFS_AC_KERNEL_KUID_HELPERS ZFS_AC_KERNEL_RENAME - ZFS_AC_KERNEL_USERNS_CAPABILITIES ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC ZFS_AC_KERNEL_TOTALHIGH_PAGES ZFS_AC_KERNEL_PERCPU diff --git a/module/os/linux/zfs/policy.c b/module/os/linux/zfs/policy.c index 5d1b4383412a..d21bc667ba69 100644 --- a/module/os/linux/zfs/policy.c +++ b/module/os/linux/zfs/policy.c @@ -252,22 +252,13 @@ secpolicy_zfs(const cred_t *cr) * Equivalent to secpolicy_zfs(), but works even if the cred_t is not that of * the current process. Takes both cred_t and proc_t so that this can work * easily on all platforms. - * - * The has_capability() function was first exported in the 4.10 Linux kernel - * then backported to some LTS kernels. Prior to this change there was no - * mechanism to perform this check therefore EACCES is returned when the - * functionality is not present in the kernel. */ int secpolicy_zfs_proc(const cred_t *cr, proc_t *proc) { -#if defined(HAVE_HAS_CAPABILITY) if (!has_capability(proc, CAP_SYS_ADMIN)) return (EACCES); return (0); -#else - return (EACCES); -#endif } void From 2b905a87f3d0834b442f2201574a546338c2f558 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 26 Aug 2024 17:47:33 +1000 Subject: [PATCH 183/223] config: remove HAVE_MODE_LOOKUP_BDEV Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-blkdev.m4 | 22 +------------------ include/os/linux/kernel/linux/blkdev_compat.h | 12 ---------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/config/kernel-blkdev.m4 b/config/kernel-blkdev.m4 index 4f60f96acb56..83190c6fbe3f 100644 --- a/config/kernel-blkdev.m4 +++ b/config/kernel-blkdev.m4 @@ -396,7 +396,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV], [ dnl # dnl # 5.11 API, lookup_bdev() takes dev_t argument. dnl # 2.6.27 API, lookup_bdev() was first exported. -dnl # 4.4.0-6.21 API, lookup_bdev() on Ubuntu takes mode argument. dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [ ZFS_LINUX_TEST_SRC([lookup_bdev_devt], [ @@ -418,15 +417,6 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [ bdev = lookup_bdev(path); ]) - - ZFS_LINUX_TEST_SRC([lookup_bdev_mode], [ - #include - ], [ - struct block_device *bdev __attribute__ ((unused)); - const char path[] = "/example/path"; - - bdev = lookup_bdev(path, FMODE_READ); - ]) ]) AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV], [ @@ -446,17 +436,7 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV], [ AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1, [lookup_bdev() wants 1 arg]) ], [ - AC_MSG_RESULT(no) - - AC_MSG_CHECKING([whether lookup_bdev() wants mode arg]) - ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_mode], - [lookup_bdev], [fs/block_dev.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_MODE_LOOKUP_BDEV, 1, - [lookup_bdev() wants mode arg]) - ], [ - ZFS_LINUX_TEST_ERROR([lookup_bdev()]) - ]) + ZFS_LINUX_TEST_ERROR([lookup_bdev()]) ]) ]) ]) diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 80c2b9c068ef..c0d3770748ea 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -295,9 +295,6 @@ zfs_check_media_change(struct block_device *bdev) * The function was exported for use, prior to this it existed but the * symbol was not exported. * - * 4.4.0-6.21 API change for Ubuntu - * lookup_bdev() gained a second argument, FMODE_*, to check inode permissions. - * * 5.11 API change * Changed to take a dev_t argument which is set on success and return a * non-zero error code on failure. @@ -315,15 +312,6 @@ vdev_lookup_bdev(const char *path, dev_t *dev) *dev = bdev->bd_dev; bdput(bdev); - return (0); -#elif defined(HAVE_MODE_LOOKUP_BDEV) - struct block_device *bdev = lookup_bdev(path, FMODE_READ); - if (IS_ERR(bdev)) - return (PTR_ERR(bdev)); - - *dev = bdev->bd_dev; - bdput(bdev); - return (0); #else #error "Unsupported kernel" From 721530ffdb7d2fd78a7ca45f84f4e4630c168e0f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 26 Aug 2024 20:44:36 +1000 Subject: [PATCH 184/223] config: remove test for unused s_d_op Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-dentry-operations.m4 | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/config/kernel-dentry-operations.m4 b/config/kernel-dentry-operations.m4 index 0166ab888d3c..aa5a9f2aff39 100644 --- a/config/kernel-dentry-operations.m4 +++ b/config/kernel-dentry-operations.m4 @@ -42,28 +42,6 @@ AC_DEFUN([ZFS_AC_KERNEL_D_SET_D_OP], [ ]) ]) -dnl # -dnl # 2.6.38 API change -dnl # Added sb->s_d_op default dentry_operations member -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_S_D_OP], [ - ZFS_LINUX_TEST_SRC([super_block_s_d_op], [ - #include - ],[ - struct super_block sb __attribute__ ((unused)); - sb.s_d_op = NULL; - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_S_D_OP], [ - AC_MSG_CHECKING([whether super_block has s_d_op]) - ZFS_LINUX_TEST_RESULT([super_block_s_d_op], [ - AC_MSG_RESULT(yes) - ], [ - ZFS_LINUX_TEST_ERROR([super_block s_d_op]) - ]) -]) - AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY], [ ZFS_AC_KERNEL_SRC_D_OBTAIN_ALIAS ZFS_AC_KERNEL_SRC_D_SET_D_OP From 3894844b62130d39ccb5ada286e8b2277f657807 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 5 Aug 2024 23:22:50 +1000 Subject: [PATCH 185/223] config: fix various bits of missing output Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-generic_fillattr.m4 | 4 ++++ config/kernel-inode-permission.m4 | 2 ++ config/kernel-mkdir.m4 | 2 ++ config/kernel-rename.m4 | 2 ++ config/kernel-setattr-prepare.m4 | 2 ++ config/kernel-shrink.m4 | 1 + config/kernel-symlink.m4 | 2 ++ config/kernel-xattr-handler.m4 | 1 + 8 files changed, 16 insertions(+) diff --git a/config/kernel-generic_fillattr.m4 b/config/kernel-generic_fillattr.m4 index f5323f0dcb9f..d355f9006bd3 100644 --- a/config/kernel-generic_fillattr.m4 +++ b/config/kernel-generic_fillattr.m4 @@ -48,12 +48,16 @@ AC_DEFUN([ZFS_AC_KERNEL_GENERIC_FILLATTR], [ AC_DEFINE(HAVE_GENERIC_FILLATTR_IDMAP_REQMASK, 1, [generic_fillattr requires struct mnt_idmap* and u32 request_mask]) ],[ + AC_MSG_RESULT([no]) + AC_MSG_CHECKING([whether generic_fillattr requires struct mnt_idmap*]) ZFS_LINUX_TEST_RESULT([generic_fillattr_mnt_idmap], [ AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_GENERIC_FILLATTR_IDMAP, 1, [generic_fillattr requires struct mnt_idmap*]) ],[ + AC_MSG_RESULT([no]) + AC_MSG_CHECKING([whether generic_fillattr requires struct user_namespace*]) ZFS_LINUX_TEST_RESULT([generic_fillattr_userns], [ AC_MSG_RESULT([yes]) diff --git a/config/kernel-inode-permission.m4 b/config/kernel-inode-permission.m4 index f7fc16439093..286f73bb047e 100644 --- a/config/kernel-inode-permission.m4 +++ b/config/kernel-inode-permission.m4 @@ -42,6 +42,8 @@ AC_DEFUN([ZFS_AC_KERNEL_PERMISSION], [ AC_DEFINE(HAVE_IOPS_PERMISSION_IDMAP, 1, [iops->permission() takes struct mnt_idmap*]) ],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([whether iops->permission() takes struct user_namespace*]) ZFS_LINUX_TEST_RESULT([permission_userns], [ AC_MSG_RESULT(yes) diff --git a/config/kernel-mkdir.m4 b/config/kernel-mkdir.m4 index bad79f3aacfc..8e084443c7b4 100644 --- a/config/kernel-mkdir.m4 +++ b/config/kernel-mkdir.m4 @@ -68,6 +68,8 @@ AC_DEFUN([ZFS_AC_KERNEL_MKDIR], [ AC_DEFINE(HAVE_IOPS_MKDIR_IDMAP, 1, [iops->mkdir() takes struct mnt_idmap*]) ],[ + AC_MSG_RESULT(no) + dnl # dnl # 5.12 API change dnl # The struct user_namespace arg was added as the first argument to diff --git a/config/kernel-rename.m4 b/config/kernel-rename.m4 index d4846a509b45..1c47222bdc30 100644 --- a/config/kernel-rename.m4 +++ b/config/kernel-rename.m4 @@ -58,6 +58,8 @@ AC_DEFUN([ZFS_AC_KERNEL_RENAME], [ AC_DEFINE(HAVE_IOPS_RENAME_IDMAP, 1, [iops->rename() takes struct mnt_idmap*]) ],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([whether iops->rename() takes struct user_namespace*]) ZFS_LINUX_TEST_RESULT([inode_operations_rename_userns], [ AC_MSG_RESULT(yes) diff --git a/config/kernel-setattr-prepare.m4 b/config/kernel-setattr-prepare.m4 index e02d6263e9c9..b10ddafc054b 100644 --- a/config/kernel-setattr-prepare.m4 +++ b/config/kernel-setattr-prepare.m4 @@ -51,6 +51,8 @@ AC_DEFUN([ZFS_AC_KERNEL_SETATTR_PREPARE], [ AC_DEFINE(HAVE_SETATTR_PREPARE_IDMAP, 1, [setattr_prepare() accepts mnt_idmap]) ], [ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([whether setattr_prepare() is available and accepts struct user_namespace*]) ZFS_LINUX_TEST_RESULT_SYMBOL([setattr_prepare_userns], [setattr_prepare], [fs/attr.c], [ diff --git a/config/kernel-shrink.m4 b/config/kernel-shrink.m4 index 77300e1589e1..c4258f4e40d6 100644 --- a/config/kernel-shrink.m4 +++ b/config/kernel-shrink.m4 @@ -108,6 +108,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER], [ ]) AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_REGISTER], [ + AC_MSG_CHECKING([whether shrinker_register() exists]) ZFS_LINUX_TEST_RESULT([shrinker_register], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_SHRINKER_REGISTER, 1, [shrinker_register exists]) diff --git a/config/kernel-symlink.m4 b/config/kernel-symlink.m4 index 804fceab28f0..fb6d23f61cbf 100644 --- a/config/kernel-symlink.m4 +++ b/config/kernel-symlink.m4 @@ -41,6 +41,8 @@ AC_DEFUN([ZFS_AC_KERNEL_SYMLINK], [ AC_DEFINE(HAVE_IOPS_SYMLINK_IDMAP, 1, [iops->symlink() takes struct mnt_idmap*]) ],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([whether iops->symlink() takes struct user_namespace*]) ZFS_LINUX_TEST_RESULT([symlink_userns], [ AC_MSG_RESULT(yes) diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4 index 2a19ac04166f..d933cff7a4b9 100644 --- a/config/kernel-xattr-handler.m4 +++ b/config/kernel-xattr-handler.m4 @@ -130,6 +130,7 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [ AC_DEFINE(HAVE_XATTR_SET_IDMAP, 1, [xattr_handler->set() takes mnt_idmap]) ], [ + AC_MSG_RESULT(no) AC_MSG_CHECKING([whether xattr_handler->set() wants dentry, inode, and user_namespace]) ZFS_LINUX_TEST_RESULT([xattr_handler_set_userns], [ AC_MSG_RESULT(yes) From 05aeaca7de1fbc377bf862cedb27aa7201e34be3 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 16 Sep 2024 11:11:29 +1000 Subject: [PATCH 186/223] config: fix page_mapping test It always failed from "unused variable" warnings-errors. The resulting `#define page_mapping(...)` happend to work because it always overrode the kernel's function prototype, but that's brittle. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16479 --- config/kernel-mm-pagemap.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/kernel-mm-pagemap.m4 b/config/kernel-mm-pagemap.m4 index 466b6fa07d9a..def6f5f4b3aa 100644 --- a/config/kernel-mm-pagemap.m4 +++ b/config/kernel-mm-pagemap.m4 @@ -21,8 +21,8 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING], [ ZFS_LINUX_TEST_SRC([page_mapping], [ #include ],[ - struct page *p = NULL; - struct address_space *m = page_mapping(NULL); + struct address_space *m; + m = page_mapping(NULL); ]) ]) AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_MAPPING], [ From 022bf86370bd0e01264c130de86c553f5dcef133 Mon Sep 17 00:00:00 2001 From: shodanshok Date: Thu, 9 Nov 2023 01:30:47 +0100 Subject: [PATCH 187/223] Increase L2ARC write rate and headroom Current L2ARC write rate and headroom parameters are very conservative: l2arc_write_max=8M and l2arc_headroom=2 (ie: a full L2ARC writes at 8 MB/s, scanning 16/32 MB of ARC tail each time; a warming L2ARC runs at 2x these rates). These values were selected 15+ years ago based on then-current SSDs size, performance and endurance. Today we have multi-TB, fast and cheap SSDs which can sustain much higher read/write rates. For this reason, this patch increases l2arc_write_max to 32M and l2arc_headroom to 8 (4x increase for both). Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Gionatan Danti Closes #15457 --- man/man4/zfs.4 | 6 +++--- module/zfs/arc.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/man/man4/zfs.4 b/man/man4/zfs.4 index a20924002d4c..9d3fc1055732 100644 --- a/man/man4/zfs.4 +++ b/man/man4/zfs.4 @@ -98,7 +98,7 @@ and only applicable in related situations. .It Sy l2arc_feed_secs Ns = Ns Sy 1 Pq u64 Seconds between L2ARC writing. . -.It Sy l2arc_headroom Ns = Ns Sy 2 Pq u64 +.It Sy l2arc_headroom Ns = Ns Sy 8 Pq u64 How far through the ARC lists to search for L2ARC cacheable content, expressed as a multiplier of .Sy l2arc_write_max . @@ -207,12 +207,12 @@ to enable caching/reading prefetches to/from L2ARC. .It Sy l2arc_norw Ns = Ns Sy 0 Ns | Ns 1 Pq int No reads during writes. . -.It Sy l2arc_write_boost Ns = Ns Sy 8388608 Ns B Po 8 MiB Pc Pq u64 +.It Sy l2arc_write_boost Ns = Ns Sy 33554432 Ns B Po 32 MiB Pc Pq u64 Cold L2ARC devices will have .Sy l2arc_write_max increased by this amount while they remain cold. . -.It Sy l2arc_write_max Ns = Ns Sy 8388608 Ns B Po 8 MiB Pc Pq u64 +.It Sy l2arc_write_max Ns = Ns Sy 33554432 Ns B Po 32 MiB Pc Pq u64 Max write bytes per interval. . .It Sy l2arc_rebuild_enabled Ns = Ns Sy 1 Ns | Ns 0 Pq int diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 00f551710173..0aef27e10cc3 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -776,8 +776,8 @@ uint64_t zfs_crc64_table[256]; * Level 2 ARC */ -#define L2ARC_WRITE_SIZE (8 * 1024 * 1024) /* initial write max */ -#define L2ARC_HEADROOM 2 /* num of writes */ +#define L2ARC_WRITE_SIZE (32 * 1024 * 1024) /* initial write max */ +#define L2ARC_HEADROOM 8 /* num of writes */ /* * If we discover during ARC scan any buffers to be compressed, we boost From 2e646b5e5afc0967eec09684f04a9ff1531b1a9f Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 20 Sep 2024 15:48:12 -0700 Subject: [PATCH 188/223] Add SIMD metadata in /proc on Linux follow up This change accidentally broke the FreeBSD build due to a conflict between the simd_stat_init()/simd_stat_fini() macros on FreeBSD and the extern function prototype. Reviewed-by: Tony Hutter Signed-off-by: Brian Behlendorf Closes #16552 --- module/zcommon/zfs_prop.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 4eb0cf38aeb2..e2101ed26c6f 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -1062,9 +1062,6 @@ EXPORT_SYMBOL(zfs_kfpu_fpregs); extern int __init zcommon_init(void); extern void zcommon_fini(void); -extern void simd_stat_init(void); -extern void simd_stat_fini(void); - int __init zcommon_init(void) { From f1694496aa97f8d63ec6adc21fd96c78494f4780 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 1 Sep 2024 12:31:56 +1000 Subject: [PATCH 189/223] zfs_file: rename zfs_file_fallocate to zfs_file_deallocate We only use it on a specific way: to punch a hole in (make sparse) a region of a file, in order to implement TRIM-like behaviour. So, call the op "deallocate", and move the Linux-style mode flags down into the Linux implementation, since they're an implementation detail. FreeBSD gets a no-op stub (for the moment). Sponsored-by: https://despairlabs.com/sponsor/ Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16496 --- include/sys/zfs_file.h | 2 +- lib/libzpool/kernel.c | 24 +++++++++++++----------- module/os/freebsd/zfs/vdev_file.c | 11 ++--------- module/os/freebsd/zfs/zfs_file_os.c | 14 ++++++++++++++ module/os/linux/zfs/vdev_file.c | 9 ++------- module/os/linux/zfs/zfs_file_os.c | 19 ++++++++++--------- 6 files changed, 42 insertions(+), 37 deletions(-) diff --git a/include/sys/zfs_file.h b/include/sys/zfs_file.h index e944165adc40..64f116c21ba7 100644 --- a/include/sys/zfs_file.h +++ b/include/sys/zfs_file.h @@ -53,7 +53,7 @@ int zfs_file_pread(zfs_file_t *fp, void *buf, size_t len, loff_t off, int zfs_file_seek(zfs_file_t *fp, loff_t *offp, int whence); int zfs_file_getattr(zfs_file_t *fp, zfs_file_attr_t *zfattr); int zfs_file_fsync(zfs_file_t *fp, int flags); -int zfs_file_fallocate(zfs_file_t *fp, int mode, loff_t offset, loff_t len); +int zfs_file_deallocate(zfs_file_t *fp, loff_t offset, loff_t len); loff_t zfs_file_off(zfs_file_t *fp); int zfs_file_unlink(const char *); diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index ffad7fc02bc9..a02bee72b8df 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -1364,24 +1364,26 @@ zfs_file_fsync(zfs_file_t *fp, int flags) } /* - * fallocate - allocate or free space on disk + * deallocate - zero and/or deallocate file storage * * fp - file pointer - * mode (non-standard options for hole punching etc) - * offset - offset to start allocating or freeing from - * len - length to free / allocate - * - * OPTIONAL + * offset - offset to start zeroing or deallocating + * len - length to zero or deallocate */ int -zfs_file_fallocate(zfs_file_t *fp, int mode, loff_t offset, loff_t len) +zfs_file_deallocate(zfs_file_t *fp, loff_t offset, loff_t len) { -#ifdef __linux__ - return (fallocate(fp->f_fd, mode, offset, len)); + int rc; +#if defined(__linux__) + rc = fallocate(fp->f_fd, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, len); #else - (void) fp, (void) mode, (void) offset, (void) len; - return (EOPNOTSUPP); + (void) fp, (void) offset, (void) len; + rc = EOPNOTSUPP; #endif + if (rc) + return (SET_ERROR(rc)); + return (0); } /* diff --git a/module/os/freebsd/zfs/vdev_file.c b/module/os/freebsd/zfs/vdev_file.c index a65dfec86caf..73e1cce058ea 100644 --- a/module/os/freebsd/zfs/vdev_file.c +++ b/module/os/freebsd/zfs/vdev_file.c @@ -267,16 +267,9 @@ vdev_file_io_start(zio_t *zio) zio_execute(zio); return; } else if (zio->io_type == ZIO_TYPE_TRIM) { -#ifdef notyet - int mode = 0; - ASSERT3U(zio->io_size, !=, 0); - - /* XXX FreeBSD has no fallocate routine in file ops */ - zio->io_error = zfs_file_fallocate(vf->vf_file, - mode, zio->io_offset, zio->io_size); -#endif - zio->io_error = SET_ERROR(ENOTSUP); + zio->io_error = zfs_file_deallocate(vf->vf_file, + zio->io_offset, zio->io_size); zio_execute(zio); return; } diff --git a/module/os/freebsd/zfs/zfs_file_os.c b/module/os/freebsd/zfs/zfs_file_os.c index f7f2be2cf95a..77fedf7c36b6 100644 --- a/module/os/freebsd/zfs/zfs_file_os.c +++ b/module/os/freebsd/zfs/zfs_file_os.c @@ -288,6 +288,20 @@ zfs_file_fsync(zfs_file_t *fp, int flags) return (zfs_vop_fsync(fp->f_vnode)); } +/* + * deallocate - zero and/or deallocate file storage + * + * fp - file pointer + * offset - offset to start zeroing or deallocating + * len - length to zero or deallocate + */ +int +zfs_file_deallocate(zfs_file_t *fp, loff_t offset, loff_t len) +{ + (void) fp, (void) offset, (void) len; + return (SET_ERROR(EOPNOTSUPP)); +} + zfs_file_t * zfs_file_get(int fd) { diff --git a/module/os/linux/zfs/vdev_file.c b/module/os/linux/zfs/vdev_file.c index 5abc0426d1a7..6d5841a2f0c9 100644 --- a/module/os/linux/zfs/vdev_file.c +++ b/module/os/linux/zfs/vdev_file.c @@ -280,14 +280,9 @@ vdev_file_io_start(zio_t *zio) zio_execute(zio); return; } else if (zio->io_type == ZIO_TYPE_TRIM) { - int mode = 0; - ASSERT3U(zio->io_size, !=, 0); -#ifdef __linux__ - mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE; -#endif - zio->io_error = zfs_file_fallocate(vf->vf_file, - mode, zio->io_offset, zio->io_size); + zio->io_error = zfs_file_deallocate(vf->vf_file, + zio->io_offset, zio->io_size); zio_execute(zio); return; } diff --git a/module/os/linux/zfs/zfs_file_os.c b/module/os/linux/zfs/zfs_file_os.c index 1b52dbe4f365..4acdc6a4156a 100644 --- a/module/os/linux/zfs/zfs_file_os.c +++ b/module/os/linux/zfs/zfs_file_os.c @@ -281,17 +281,14 @@ zfs_file_fsync(zfs_file_t *filp, int flags) } /* - * fallocate - allocate or free space on disk + * deallocate - zero and/or deallocate file storage * * fp - file pointer - * mode (non-standard options for hole punching etc) - * offset - offset to start allocating or freeing from - * len - length to free / allocate - * - * OPTIONAL + * offset - offset to start zeroing or deallocating + * len - length to zero or deallocate */ int -zfs_file_fallocate(zfs_file_t *fp, int mode, loff_t offset, loff_t len) +zfs_file_deallocate(zfs_file_t *fp, loff_t offset, loff_t len) { /* * May enter XFS which generates a warning when PF_FSTRANS is set. @@ -307,12 +304,16 @@ zfs_file_fallocate(zfs_file_t *fp, int mode, loff_t offset, loff_t len) */ int error = EOPNOTSUPP; if (fp->f_op->fallocate) - error = fp->f_op->fallocate(fp, mode, offset, len); + error = -fp->f_op->fallocate(fp, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, len); if (fstrans) current->flags |= __SPL_PF_FSTRANS; - return (error); + if (error) + return (SET_ERROR(error)); + + return (0); } /* From 94f84d2a754ae604392dfa26c43b3e243de3a54e Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 19 Sep 2024 12:55:48 +1000 Subject: [PATCH 190/223] linux/abd_os: remove kernel version check for compound page support All kernels we support have compound pages that work the way we would like. However, this code is new and this knowledge was hard won, so I'd like to leave the description and option there for a little while, even if it can only be disabled with a recompile. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Tino Reichardt Signed-off-by: Rob Norris Closes #16545 --- module/os/linux/zfs/abd_os.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/module/os/linux/zfs/abd_os.c b/module/os/linux/zfs/abd_os.c index f7af20c619a4..ade56290b028 100644 --- a/module/os/linux/zfs/abd_os.c +++ b/module/os/linux/zfs/abd_os.c @@ -1039,23 +1039,30 @@ abd_cache_reap_now(void) * Before kernel 4.5 however, compound page heads were refcounted separately * from tail pages, such that moving back to the head page would require us to * take a reference to it and releasing it once we're completely finished with - * it. In practice, that means when our caller is done with the ABD, which we + * it. In practice, that meant when our caller is done with the ABD, which we * have no insight into from here. Rather than contort this API to track head - * page references on such ancient kernels, we disable this special compound - * page handling on 4.5, instead just using treating each page within it as a - * regular PAGESIZE page (which it is). This is slightly less efficient, but - * makes everything far simpler. + * page references on such ancient kernels, we disabled this special compound + * page handling on kernels before 4.5, instead just using treating each page + * within it as a regular PAGESIZE page (which it is). This is slightly less + * efficient, but makes everything far simpler. * - * The below test sets/clears ABD_ITER_COMPOUND_PAGES to enable/disable the - * special handling, and also defines the ABD_ITER_PAGE_SIZE(page) macro to - * understand compound pages, or not, as required. + * We no longer support kernels before 4.5, so in theory none of this is + * necessary. However, this code is still relatively new in the grand scheme of + * things, so I'm leaving the ability to compile this out for the moment. + * + * Setting/clearing ABD_ITER_COMPOUND_PAGES below enables/disables the special + * handling, by defining the ABD_ITER_PAGE_SIZE(page) macro to understand + * compound pages, or not, and compiling in/out the support to detect compound + * tail pages and move back to the start. */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) -#define ABD_ITER_COMPOUND_PAGES 1 + +/* On by default */ +#define ABD_ITER_COMPOUND_PAGES + +#ifdef ABD_ITER_COMPOUND_PAGES #define ABD_ITER_PAGE_SIZE(page) \ (PageCompound(page) ? page_size(page) : PAGESIZE) #else -#undef ABD_ITER_COMPOUND_PAGES #define ABD_ITER_PAGE_SIZE(page) (PAGESIZE) #endif From c1055d9ffbcfdda038102808d81a87090d10c033 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 25 Dec 2023 22:25:48 +1100 Subject: [PATCH 191/223] abd_os: split userspace and Linux kernel code The Linux abd_os.c serves double-duty as the userspace scatter abd implementation, by carrying an emulation of kernel scatterlists. This commit lifts common and userspace-specific parts out into a separate abd_os.c for libzpool. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Alexander Motin Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16253 --- include/sys/abd.h | 2 + lib/libzpool/Makefile.am | 2 +- lib/libzpool/abd_os.c | 492 +++++++++++++++++++++++++++++++++++ module/os/linux/zfs/abd_os.c | 151 +---------- 4 files changed, 498 insertions(+), 149 deletions(-) create mode 100644 lib/libzpool/abd_os.c diff --git a/include/sys/abd.h b/include/sys/abd.h index bee38b831bc0..6944f5997cad 100644 --- a/include/sys/abd.h +++ b/include/sys/abd.h @@ -69,7 +69,9 @@ typedef struct abd { } abd_scatter; struct abd_linear { void *abd_buf; +#if defined(__linux__) && defined(_KERNEL) struct scatterlist *abd_sgl; /* for LINEAR_PAGE */ +#endif } abd_linear; struct abd_gang { list_t abd_gang_chain; diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 99621b60e6c3..bd6ab8102c33 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -9,6 +9,7 @@ lib_LTLIBRARIES += libzpool.la CPPCHECKTARGETS += libzpool.la dist_libzpool_la_SOURCES = \ + %D%/abd_os.c \ %D%/kernel.c \ %D%/taskq.c \ %D%/util.c @@ -39,7 +40,6 @@ nodist_libzpool_la_SOURCES = \ module/lua/lvm.c \ module/lua/lzio.c \ \ - module/os/linux/zfs/abd_os.c \ module/os/linux/zfs/arc_os.c \ module/os/linux/zfs/trace.c \ module/os/linux/zfs/vdev_file.c \ diff --git a/lib/libzpool/abd_os.c b/lib/libzpool/abd_os.c new file mode 100644 index 000000000000..de93f99a556a --- /dev/null +++ b/lib/libzpool/abd_os.c @@ -0,0 +1,492 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2014 by Chunwei Chen. All rights reserved. + * Copyright (c) 2019 by Delphix. All rights reserved. + * Copyright (c) 2023, 2024, Klara Inc. + */ + +/* + * See abd.c for a general overview of the arc buffered data (ABD). + * + * Linear buffers act exactly like normal buffers and are always mapped into the + * kernel's virtual memory space, while scattered ABD data chunks are allocated + * as physical pages and then mapped in only while they are actually being + * accessed through one of the abd_* library functions. Using scattered ABDs + * provides several benefits: + * + * (1) They avoid use of kmem_*, preventing performance problems where running + * kmem_reap on very large memory systems never finishes and causes + * constant TLB shootdowns. + * + * (2) Fragmentation is less of an issue since when we are at the limit of + * allocatable space, we won't have to search around for a long free + * hole in the VA space for large ARC allocations. Each chunk is mapped in + * individually, so even if we are using HIGHMEM (see next point) we + * wouldn't need to worry about finding a contiguous address range. + * + * (3) If we are not using HIGHMEM, then all physical memory is always + * mapped into the kernel's address space, so we also avoid the map / + * unmap costs on each ABD access. + * + * If we are not using HIGHMEM, scattered buffers which have only one chunk + * can be treated as linear buffers, because they are contiguous in the + * kernel's virtual address space. See abd_alloc_chunks() for details. + */ + +#include +#include +#include +#include +#include +#include + + +#define abd_for_each_sg(abd, sg, n, i) \ + for_each_sg(ABD_SCATTER(abd).abd_sgl, sg, n, i) + +/* + * zfs_abd_scatter_min_size is the minimum allocation size to use scatter + * ABD's. Smaller allocations will use linear ABD's which uses + * zio_[data_]buf_alloc(). + * + * Scatter ABD's use at least one page each, so sub-page allocations waste + * some space when allocated as scatter (e.g. 2KB scatter allocation wastes + * half of each page). Using linear ABD's for small allocations means that + * they will be put on slabs which contain many allocations. This can + * improve memory efficiency, but it also makes it much harder for ARC + * evictions to actually free pages, because all the buffers on one slab need + * to be freed in order for the slab (and underlying pages) to be freed. + * Typically, 512B and 1KB kmem caches have 16 buffers per slab, so it's + * possible for them to actually waste more memory than scatter (one page per + * buf = wasting 3/4 or 7/8th; one buf per slab = wasting 15/16th). + * + * Spill blocks are typically 512B and are heavily used on systems running + * selinux with the default dnode size and the `xattr=sa` property set. + * + * By default we use linear allocations for 512B and 1KB, and scatter + * allocations for larger (1.5KB and up). + */ +static int zfs_abd_scatter_min_size = 512 * 3; + +/* + * We use a scattered SPA_MAXBLOCKSIZE sized ABD whose pages are + * just a single zero'd page. This allows us to conserve memory by + * only using a single zero page for the scatterlist. + */ +abd_t *abd_zero_scatter = NULL; + +struct page; +/* + * abd_zero_page will be allocated with a zero'ed PAGESIZE buffer, which is + * assigned to each of the pages of abd_zero_scatter. + */ +static struct page *abd_zero_page = NULL; + +static kmem_cache_t *abd_cache = NULL; + +static uint_t +abd_chunkcnt_for_bytes(size_t size) +{ + return (P2ROUNDUP(size, PAGESIZE) / PAGESIZE); +} + +abd_t * +abd_alloc_struct_impl(size_t size) +{ + /* + * In Linux we do not use the size passed in during ABD + * allocation, so we just ignore it. + */ + (void) size; + abd_t *abd = kmem_cache_alloc(abd_cache, KM_PUSHPAGE); + ASSERT3P(abd, !=, NULL); + + return (abd); +} + +void +abd_free_struct_impl(abd_t *abd) +{ + kmem_cache_free(abd_cache, abd); +} + +#define nth_page(pg, i) \ + ((struct page *)((void *)(pg) + (i) * PAGESIZE)) + +struct scatterlist { + struct page *page; + int length; + int end; +}; + +static void +sg_init_table(struct scatterlist *sg, int nr) +{ + memset(sg, 0, nr * sizeof (struct scatterlist)); + sg[nr - 1].end = 1; +} + +/* + * This must be called if any of the sg_table allocation functions + * are called. + */ +static void +abd_free_sg_table(abd_t *abd) +{ + int nents = ABD_SCATTER(abd).abd_nents; + vmem_free(ABD_SCATTER(abd).abd_sgl, + nents * sizeof (struct scatterlist)); +} + +#define for_each_sg(sgl, sg, nr, i) \ + for ((i) = 0, (sg) = (sgl); (i) < (nr); (i)++, (sg) = sg_next(sg)) + +static inline void +sg_set_page(struct scatterlist *sg, struct page *page, unsigned int len, + unsigned int offset) +{ + /* currently we don't use offset */ + ASSERT(offset == 0); + sg->page = page; + sg->length = len; +} + +static inline struct page * +sg_page(struct scatterlist *sg) +{ + return (sg->page); +} + +static inline struct scatterlist * +sg_next(struct scatterlist *sg) +{ + if (sg->end) + return (NULL); + + return (sg + 1); +} + +void +abd_alloc_chunks(abd_t *abd, size_t size) +{ + unsigned nr_pages = abd_chunkcnt_for_bytes(size); + struct scatterlist *sg; + int i; + + ABD_SCATTER(abd).abd_sgl = vmem_alloc(nr_pages * + sizeof (struct scatterlist), KM_SLEEP); + sg_init_table(ABD_SCATTER(abd).abd_sgl, nr_pages); + + abd_for_each_sg(abd, sg, nr_pages, i) { + struct page *p = umem_alloc_aligned(PAGESIZE, 64, KM_SLEEP); + sg_set_page(sg, p, PAGESIZE, 0); + } + ABD_SCATTER(abd).abd_nents = nr_pages; +} + +void +abd_free_chunks(abd_t *abd) +{ + int i, n = ABD_SCATTER(abd).abd_nents; + struct scatterlist *sg; + + abd_for_each_sg(abd, sg, n, i) { + struct page *p = nth_page(sg_page(sg), 0); + umem_free_aligned(p, PAGESIZE); + } + abd_free_sg_table(abd); +} + +static void +abd_alloc_zero_scatter(void) +{ + unsigned nr_pages = abd_chunkcnt_for_bytes(SPA_MAXBLOCKSIZE); + struct scatterlist *sg; + int i; + + abd_zero_page = umem_alloc_aligned(PAGESIZE, 64, KM_SLEEP); + memset(abd_zero_page, 0, PAGESIZE); + abd_zero_scatter = abd_alloc_struct(SPA_MAXBLOCKSIZE); + abd_zero_scatter->abd_flags |= ABD_FLAG_OWNER; + abd_zero_scatter->abd_flags |= ABD_FLAG_MULTI_CHUNK; + ABD_SCATTER(abd_zero_scatter).abd_offset = 0; + ABD_SCATTER(abd_zero_scatter).abd_nents = nr_pages; + abd_zero_scatter->abd_size = SPA_MAXBLOCKSIZE; + ABD_SCATTER(abd_zero_scatter).abd_sgl = vmem_alloc(nr_pages * + sizeof (struct scatterlist), KM_SLEEP); + + sg_init_table(ABD_SCATTER(abd_zero_scatter).abd_sgl, nr_pages); + + abd_for_each_sg(abd_zero_scatter, sg, nr_pages, i) { + sg_set_page(sg, abd_zero_page, PAGESIZE, 0); + } +} + +boolean_t +abd_size_alloc_linear(size_t size) +{ + return (!zfs_abd_scatter_enabled || size < zfs_abd_scatter_min_size); +} + +void +abd_update_scatter_stats(abd_t *abd, abd_stats_op_t op) +{ + ASSERT(op == ABDSTAT_INCR || op == ABDSTAT_DECR); + int waste = P2ROUNDUP(abd->abd_size, PAGESIZE) - abd->abd_size; + if (op == ABDSTAT_INCR) { + arc_space_consume(waste, ARC_SPACE_ABD_CHUNK_WASTE); + } else { + arc_space_return(waste, ARC_SPACE_ABD_CHUNK_WASTE); + } +} + +void +abd_update_linear_stats(abd_t *abd, abd_stats_op_t op) +{ + (void) abd; + (void) op; + ASSERT(op == ABDSTAT_INCR || op == ABDSTAT_DECR); +} + +void +abd_verify_scatter(abd_t *abd) +{ + size_t n; + int i = 0; + struct scatterlist *sg = NULL; + + ASSERT3U(ABD_SCATTER(abd).abd_nents, >, 0); + ASSERT3U(ABD_SCATTER(abd).abd_offset, <, + ABD_SCATTER(abd).abd_sgl->length); + n = ABD_SCATTER(abd).abd_nents; + abd_for_each_sg(abd, sg, n, i) { + ASSERT3P(sg_page(sg), !=, NULL); + } +} + +static void +abd_free_zero_scatter(void) +{ + abd_free_sg_table(abd_zero_scatter); + abd_free_struct(abd_zero_scatter); + abd_zero_scatter = NULL; + ASSERT3P(abd_zero_page, !=, NULL); + umem_free_aligned(abd_zero_page, PAGESIZE); +} + +void +abd_init(void) +{ + abd_cache = kmem_cache_create("abd_t", sizeof (abd_t), + 0, NULL, NULL, NULL, NULL, NULL, 0); + + abd_alloc_zero_scatter(); +} + +void +abd_fini(void) +{ + abd_free_zero_scatter(); + + if (abd_cache) { + kmem_cache_destroy(abd_cache); + abd_cache = NULL; + } +} + +void +abd_free_linear_page(abd_t *abd) +{ + (void) abd; + __builtin_unreachable(); +} + +/* + * If we're going to use this ABD for doing I/O using the block layer, the + * consumer of the ABD data doesn't care if it's scattered or not, and we don't + * plan to store this ABD in memory for a long period of time, we should + * allocate the ABD type that requires the least data copying to do the I/O. + * + * On Linux the optimal thing to do would be to use abd_get_offset() and + * construct a new ABD which shares the original pages thereby eliminating + * the copy. But for the moment a new linear ABD is allocated until this + * performance optimization can be implemented. + */ +abd_t * +abd_alloc_for_io(size_t size, boolean_t is_metadata) +{ + return (abd_alloc(size, is_metadata)); +} + +abd_t * +abd_get_offset_scatter(abd_t *abd, abd_t *sabd, size_t off, + size_t size) +{ + (void) size; + int i = 0; + struct scatterlist *sg = NULL; + + abd_verify(sabd); + ASSERT3U(off, <=, sabd->abd_size); + + size_t new_offset = ABD_SCATTER(sabd).abd_offset + off; + + if (abd == NULL) + abd = abd_alloc_struct(0); + + /* + * Even if this buf is filesystem metadata, we only track that + * if we own the underlying data buffer, which is not true in + * this case. Therefore, we don't ever use ABD_FLAG_META here. + */ + + abd_for_each_sg(sabd, sg, ABD_SCATTER(sabd).abd_nents, i) { + if (new_offset < sg->length) + break; + new_offset -= sg->length; + } + + ABD_SCATTER(abd).abd_sgl = sg; + ABD_SCATTER(abd).abd_offset = new_offset; + ABD_SCATTER(abd).abd_nents = ABD_SCATTER(sabd).abd_nents - i; + + return (abd); +} + +/* + * Initialize the abd_iter. + */ +void +abd_iter_init(struct abd_iter *aiter, abd_t *abd) +{ + ASSERT(!abd_is_gang(abd)); + abd_verify(abd); + memset(aiter, 0, sizeof (struct abd_iter)); + aiter->iter_abd = abd; + if (!abd_is_linear(abd)) { + aiter->iter_offset = ABD_SCATTER(abd).abd_offset; + aiter->iter_sg = ABD_SCATTER(abd).abd_sgl; + } +} + +/* + * This is just a helper function to see if we have exhausted the + * abd_iter and reached the end. + */ +boolean_t +abd_iter_at_end(struct abd_iter *aiter) +{ + ASSERT3U(aiter->iter_pos, <=, aiter->iter_abd->abd_size); + return (aiter->iter_pos == aiter->iter_abd->abd_size); +} + +/* + * Advance the iterator by a certain amount. Cannot be called when a chunk is + * in use. This can be safely called when the aiter has already exhausted, in + * which case this does nothing. + */ +void +abd_iter_advance(struct abd_iter *aiter, size_t amount) +{ + /* + * Ensure that last chunk is not in use. abd_iterate_*() must clear + * this state (directly or abd_iter_unmap()) before advancing. + */ + ASSERT3P(aiter->iter_mapaddr, ==, NULL); + ASSERT0(aiter->iter_mapsize); + ASSERT3P(aiter->iter_page, ==, NULL); + ASSERT0(aiter->iter_page_doff); + ASSERT0(aiter->iter_page_dsize); + + /* There's nothing left to advance to, so do nothing */ + if (abd_iter_at_end(aiter)) + return; + + aiter->iter_pos += amount; + aiter->iter_offset += amount; + if (!abd_is_linear(aiter->iter_abd)) { + while (aiter->iter_offset >= aiter->iter_sg->length) { + aiter->iter_offset -= aiter->iter_sg->length; + aiter->iter_sg = sg_next(aiter->iter_sg); + if (aiter->iter_sg == NULL) { + ASSERT0(aiter->iter_offset); + break; + } + } + } +} + +/* + * Map the current chunk into aiter. This can be safely called when the aiter + * has already exhausted, in which case this does nothing. + */ +void +abd_iter_map(struct abd_iter *aiter) +{ + void *paddr; + size_t offset = 0; + + ASSERT3P(aiter->iter_mapaddr, ==, NULL); + ASSERT0(aiter->iter_mapsize); + + /* There's nothing left to iterate over, so do nothing */ + if (abd_iter_at_end(aiter)) + return; + + if (abd_is_linear(aiter->iter_abd)) { + ASSERT3U(aiter->iter_pos, ==, aiter->iter_offset); + offset = aiter->iter_offset; + aiter->iter_mapsize = aiter->iter_abd->abd_size - offset; + paddr = ABD_LINEAR_BUF(aiter->iter_abd); + } else { + offset = aiter->iter_offset; + aiter->iter_mapsize = MIN(aiter->iter_sg->length - offset, + aiter->iter_abd->abd_size - aiter->iter_pos); + + paddr = sg_page(aiter->iter_sg); + } + + aiter->iter_mapaddr = (char *)paddr + offset; +} + +/* + * Unmap the current chunk from aiter. This can be safely called when the aiter + * has already exhausted, in which case this does nothing. + */ +void +abd_iter_unmap(struct abd_iter *aiter) +{ + /* There's nothing left to unmap, so do nothing */ + if (abd_iter_at_end(aiter)) + return; + + ASSERT3P(aiter->iter_mapaddr, !=, NULL); + ASSERT3U(aiter->iter_mapsize, >, 0); + + aiter->iter_mapaddr = NULL; + aiter->iter_mapsize = 0; +} + +void +abd_cache_reap_now(void) +{ +} diff --git a/module/os/linux/zfs/abd_os.c b/module/os/linux/zfs/abd_os.c index ade56290b028..ce6d6cff1574 100644 --- a/module/os/linux/zfs/abd_os.c +++ b/module/os/linux/zfs/abd_os.c @@ -58,22 +58,16 @@ #include #include #include -#ifdef _KERNEL #include #include #include #include -#endif -#ifdef _KERNEL #if defined(MAX_ORDER) #define ABD_MAX_ORDER (MAX_ORDER) #elif defined(MAX_PAGE_ORDER) #define ABD_MAX_ORDER (MAX_PAGE_ORDER) #endif -#else -#define ABD_MAX_ORDER (1) -#endif typedef struct abd_stats { kstat_named_t abdstat_struct_size; @@ -193,11 +187,9 @@ abd_t *abd_zero_scatter = NULL; struct page; /* - * _KERNEL - Will point to ZERO_PAGE if it is available or it will be - * an allocated zero'd PAGESIZE buffer. - * Userspace - Will be an allocated zero'ed PAGESIZE buffer. - * - * abd_zero_page is assigned to each of the pages of abd_zero_scatter. + * abd_zero_page is assigned to each of the pages of abd_zero_scatter. It will + * point to ZERO_PAGE if it is available or it will be an allocated zero'd + * PAGESIZE buffer. */ static struct page *abd_zero_page = NULL; @@ -232,7 +224,6 @@ abd_free_struct_impl(abd_t *abd) ABDSTAT_INCR(abdstat_struct_size, -(int)sizeof (abd_t)); } -#ifdef _KERNEL static unsigned zfs_abd_scatter_max_order = ABD_MAX_ORDER - 1; /* @@ -520,134 +511,6 @@ abd_alloc_zero_scatter(void) ABDSTAT_BUMP(abdstat_scatter_page_multi_chunk); } -#else /* _KERNEL */ - -#ifndef PAGE_SHIFT -#define PAGE_SHIFT (highbit64(PAGESIZE)-1) -#endif - -#define zfs_kmap_local(chunk) ((void *)chunk) -#define zfs_kunmap_local(addr) do { (void)(addr); } while (0) -#define local_irq_save(flags) do { (void)(flags); } while (0) -#define local_irq_restore(flags) do { (void)(flags); } while (0) -#define nth_page(pg, i) \ - ((struct page *)((void *)(pg) + (i) * PAGESIZE)) - -struct scatterlist { - struct page *page; - int length; - int end; -}; - -static void -sg_init_table(struct scatterlist *sg, int nr) -{ - memset(sg, 0, nr * sizeof (struct scatterlist)); - sg[nr - 1].end = 1; -} - -/* - * This must be called if any of the sg_table allocation functions - * are called. - */ -static void -abd_free_sg_table(abd_t *abd) -{ - int nents = ABD_SCATTER(abd).abd_nents; - vmem_free(ABD_SCATTER(abd).abd_sgl, - nents * sizeof (struct scatterlist)); -} - -#define for_each_sg(sgl, sg, nr, i) \ - for ((i) = 0, (sg) = (sgl); (i) < (nr); (i)++, (sg) = sg_next(sg)) - -static inline void -sg_set_page(struct scatterlist *sg, struct page *page, unsigned int len, - unsigned int offset) -{ - /* currently we don't use offset */ - ASSERT(offset == 0); - sg->page = page; - sg->length = len; -} - -static inline struct page * -sg_page(struct scatterlist *sg) -{ - return (sg->page); -} - -static inline struct scatterlist * -sg_next(struct scatterlist *sg) -{ - if (sg->end) - return (NULL); - - return (sg + 1); -} - -void -abd_alloc_chunks(abd_t *abd, size_t size) -{ - unsigned nr_pages = abd_chunkcnt_for_bytes(size); - struct scatterlist *sg; - int i; - - ABD_SCATTER(abd).abd_sgl = vmem_alloc(nr_pages * - sizeof (struct scatterlist), KM_SLEEP); - sg_init_table(ABD_SCATTER(abd).abd_sgl, nr_pages); - - abd_for_each_sg(abd, sg, nr_pages, i) { - struct page *p = umem_alloc_aligned(PAGESIZE, 64, KM_SLEEP); - sg_set_page(sg, p, PAGESIZE, 0); - } - ABD_SCATTER(abd).abd_nents = nr_pages; -} - -void -abd_free_chunks(abd_t *abd) -{ - int i, n = ABD_SCATTER(abd).abd_nents; - struct scatterlist *sg; - - abd_for_each_sg(abd, sg, n, i) { - struct page *p = nth_page(sg_page(sg), 0); - umem_free_aligned(p, PAGESIZE); - } - abd_free_sg_table(abd); -} - -static void -abd_alloc_zero_scatter(void) -{ - unsigned nr_pages = abd_chunkcnt_for_bytes(SPA_MAXBLOCKSIZE); - struct scatterlist *sg; - int i; - - abd_zero_page = umem_alloc_aligned(PAGESIZE, 64, KM_SLEEP); - memset(abd_zero_page, 0, PAGESIZE); - abd_zero_scatter = abd_alloc_struct(SPA_MAXBLOCKSIZE); - abd_zero_scatter->abd_flags |= ABD_FLAG_OWNER; - abd_zero_scatter->abd_flags |= ABD_FLAG_MULTI_CHUNK | ABD_FLAG_ZEROS; - ABD_SCATTER(abd_zero_scatter).abd_offset = 0; - ABD_SCATTER(abd_zero_scatter).abd_nents = nr_pages; - abd_zero_scatter->abd_size = SPA_MAXBLOCKSIZE; - ABD_SCATTER(abd_zero_scatter).abd_sgl = vmem_alloc(nr_pages * - sizeof (struct scatterlist), KM_SLEEP); - - sg_init_table(ABD_SCATTER(abd_zero_scatter).abd_sgl, nr_pages); - - abd_for_each_sg(abd_zero_scatter, sg, nr_pages, i) { - sg_set_page(sg, abd_zero_page, PAGESIZE, 0); - } - - ABDSTAT_BUMP(abdstat_scatter_cnt); - ABDSTAT_INCR(abdstat_scatter_data_size, PAGESIZE); - ABDSTAT_BUMP(abdstat_scatter_page_multi_chunk); -} - -#endif /* _KERNEL */ - boolean_t abd_size_alloc_linear(size_t size) { @@ -712,14 +575,10 @@ abd_free_zero_scatter(void) abd_free_struct(abd_zero_scatter); abd_zero_scatter = NULL; ASSERT3P(abd_zero_page, !=, NULL); -#if defined(_KERNEL) #if defined(HAVE_ZERO_PAGE_GPL_ONLY) abd_unmark_zfs_page(abd_zero_page); __free_page(abd_zero_page); #endif /* HAVE_ZERO_PAGE_GPL_ONLY */ -#else - umem_free_aligned(abd_zero_page, PAGESIZE); -#endif /* _KERNEL */ } static int @@ -1014,8 +873,6 @@ abd_cache_reap_now(void) { } -#if defined(_KERNEL) - /* * This is abd_iter_page(), the function underneath abd_iterate_page_func(). * It yields the next page struct and data offset and size within it, without @@ -1304,5 +1161,3 @@ MODULE_PARM_DESC(zfs_abd_scatter_min_size, module_param(zfs_abd_scatter_max_order, uint, 0644); MODULE_PARM_DESC(zfs_abd_scatter_max_order, "Maximum order allocation used for a scatter ABD."); - -#endif /* _KERNEL */ From d8458202ca8fa830e9bc14e8052f47b1a89e86f0 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 1 Apr 2024 15:37:34 +1100 Subject: [PATCH 192/223] abd_os: break out platform-specific header parts Removing the platform #ifdefs from shared headers in favour of per-platform headers. Makes abd_t much leaner, among other things. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Alexander Motin Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16253 --- config/Rules.am | 3 +- include/os/freebsd/Makefile.am | 2 + include/os/freebsd/zfs/sys/abd_impl_os.h | 41 ++++++++++++++++ include/os/freebsd/zfs/sys/abd_os.h | 46 ++++++++++++++++++ include/os/linux/Makefile.am | 2 + include/os/linux/zfs/sys/abd_impl_os.h | 41 ++++++++++++++++ include/os/linux/zfs/sys/abd_os.h | 62 ++++++++++++++++++++++++ include/sys/abd.h | 35 ++----------- include/sys/abd_impl.h | 14 +----- lib/libzpool/Makefile.am | 2 + lib/libzpool/include/Makefile.am | 4 ++ lib/libzpool/include/sys/abd_impl_os.h | 41 ++++++++++++++++ lib/libzpool/include/sys/abd_os.h | 47 ++++++++++++++++++ module/os/freebsd/zfs/abd_os.c | 2 - 14 files changed, 294 insertions(+), 48 deletions(-) create mode 100644 include/os/freebsd/zfs/sys/abd_impl_os.h create mode 100644 include/os/freebsd/zfs/sys/abd_os.h create mode 100644 include/os/linux/zfs/sys/abd_impl_os.h create mode 100644 include/os/linux/zfs/sys/abd_os.h create mode 100644 lib/libzpool/include/Makefile.am create mode 100644 lib/libzpool/include/sys/abd_impl_os.h create mode 100644 lib/libzpool/include/sys/abd_os.h diff --git a/config/Rules.am b/config/Rules.am index 2e463ae6083a..cb4066b7c9ab 100644 --- a/config/Rules.am +++ b/config/Rules.am @@ -10,7 +10,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/module/icp/include \ -I$(top_srcdir)/lib/libspl/include \ - -I$(top_srcdir)/lib/libspl/include/os/@ac_system_l@ + -I$(top_srcdir)/lib/libspl/include/os/@ac_system_l@ \ + -I$(top_srcdir)/lib/libzpool/include AM_LIBTOOLFLAGS = --silent diff --git a/include/os/freebsd/Makefile.am b/include/os/freebsd/Makefile.am index d4103c2f062a..e2c358f5ea45 100644 --- a/include/os/freebsd/Makefile.am +++ b/include/os/freebsd/Makefile.am @@ -78,6 +78,8 @@ noinst_HEADERS = \ %D%/spl/sys/zmod.h \ %D%/spl/sys/zone.h \ \ + %D%/zfs/sys/abd_os.h \ + %D%/zfs/sys/abd_impl_os.h \ %D%/zfs/sys/arc_os.h \ %D%/zfs/sys/freebsd_crypto.h \ %D%/zfs/sys/freebsd_event.h \ diff --git a/include/os/freebsd/zfs/sys/abd_impl_os.h b/include/os/freebsd/zfs/sys/abd_impl_os.h new file mode 100644 index 000000000000..309e77110d3c --- /dev/null +++ b/include/os/freebsd/zfs/sys/abd_impl_os.h @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2014 by Chunwei Chen. All rights reserved. + * Copyright (c) 2016, 2019 by Delphix. All rights reserved. + * Copyright (c) 2023, 2024, Klara Inc. + */ + +#ifndef _ABD_IMPL_OS_H +#define _ABD_IMPL_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define abd_enter_critical(flags) critical_enter() +#define abd_exit_critical(flags) critical_exit() + +#ifdef __cplusplus +} +#endif + +#endif /* _ABD_IMPL_OS_H */ diff --git a/include/os/freebsd/zfs/sys/abd_os.h b/include/os/freebsd/zfs/sys/abd_os.h new file mode 100644 index 000000000000..57122ee83e8d --- /dev/null +++ b/include/os/freebsd/zfs/sys/abd_os.h @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2014 by Chunwei Chen. All rights reserved. + * Copyright (c) 2016, 2019 by Delphix. All rights reserved. + */ + +#ifndef _ABD_OS_H +#define _ABD_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct abd_scatter { + uint_t abd_offset; + void *abd_chunks[1]; /* actually variable-length */ +}; + +struct abd_linear { + void *abd_buf; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _ABD_H */ diff --git a/include/os/linux/Makefile.am b/include/os/linux/Makefile.am index 28f4e62efbd6..b4ffbcff9533 100644 --- a/include/os/linux/Makefile.am +++ b/include/os/linux/Makefile.am @@ -19,6 +19,8 @@ kernel_linux_HEADERS = \ kernel_sysdir = $(kerneldir)/sys kernel_sys_HEADERS = \ + %D%/zfs/sys/abd_os.h \ + %D%/zfs/sys/abd_impl_os.h \ %D%/zfs/sys/policy.h \ %D%/zfs/sys/trace_acl.h \ %D%/zfs/sys/trace_arc.h \ diff --git a/include/os/linux/zfs/sys/abd_impl_os.h b/include/os/linux/zfs/sys/abd_impl_os.h new file mode 100644 index 000000000000..8192522cd229 --- /dev/null +++ b/include/os/linux/zfs/sys/abd_impl_os.h @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2014 by Chunwei Chen. All rights reserved. + * Copyright (c) 2016, 2019 by Delphix. All rights reserved. + * Copyright (c) 2023, 2024, Klara Inc. + */ + +#ifndef _ABD_IMPL_OS_H +#define _ABD_IMPL_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define abd_enter_critical(flags) local_irq_save(flags) +#define abd_exit_critical(flags) local_irq_restore(flags) + +#ifdef __cplusplus +} +#endif + +#endif /* _ABD_IMPL_OS_H */ diff --git a/include/os/linux/zfs/sys/abd_os.h b/include/os/linux/zfs/sys/abd_os.h new file mode 100644 index 000000000000..ce4f5a2bdf9b --- /dev/null +++ b/include/os/linux/zfs/sys/abd_os.h @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2014 by Chunwei Chen. All rights reserved. + * Copyright (c) 2016, 2019 by Delphix. All rights reserved. + */ + +#ifndef _ABD_OS_H +#define _ABD_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct abd_scatter { + uint_t abd_offset; + uint_t abd_nents; + struct scatterlist *abd_sgl; +}; + +struct abd_linear { + void *abd_buf; + struct scatterlist *abd_sgl; /* for LINEAR_PAGE */ +}; + +typedef struct abd abd_t; + +typedef int abd_iter_page_func_t(struct page *, size_t, size_t, void *); +int abd_iterate_page_func(abd_t *, size_t, size_t, abd_iter_page_func_t *, + void *); + +/* + * Linux ABD bio functions + * Note: these are only needed to support vdev_classic. See comment in + * vdev_disk.c. + */ +unsigned int abd_bio_map_off(struct bio *, abd_t *, unsigned int, size_t); +unsigned long abd_nr_pages_off(abd_t *, unsigned int, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _ABD_H */ diff --git a/include/sys/abd.h b/include/sys/abd.h index 6944f5997cad..4994cd3f6919 100644 --- a/include/sys/abd.h +++ b/include/sys/abd.h @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -58,21 +59,8 @@ typedef struct abd { #endif kmutex_t abd_mtx; union { - struct abd_scatter { - uint_t abd_offset; -#if defined(__FreeBSD__) && defined(_KERNEL) - void *abd_chunks[1]; /* actually variable-length */ -#else - uint_t abd_nents; - struct scatterlist *abd_sgl; -#endif - } abd_scatter; - struct abd_linear { - void *abd_buf; -#if defined(__linux__) && defined(_KERNEL) - struct scatterlist *abd_sgl; /* for LINEAR_PAGE */ -#endif - } abd_linear; + struct abd_scatter abd_scatter; + struct abd_linear abd_linear; struct abd_gang { list_t abd_gang_chain; } abd_gang; @@ -81,9 +69,6 @@ typedef struct abd { typedef int abd_iter_func_t(void *buf, size_t len, void *priv); typedef int abd_iter_func2_t(void *bufa, void *bufb, size_t len, void *priv); -#if defined(__linux__) && defined(_KERNEL) -typedef int abd_iter_page_func_t(struct page *, size_t, size_t, void *); -#endif extern int zfs_abd_scatter_enabled; @@ -130,10 +115,6 @@ void abd_release_ownership_of_buf(abd_t *); int abd_iterate_func(abd_t *, size_t, size_t, abd_iter_func_t *, void *); int abd_iterate_func2(abd_t *, abd_t *, size_t, size_t, size_t, abd_iter_func2_t *, void *); -#if defined(__linux__) && defined(_KERNEL) -int abd_iterate_page_func(abd_t *, size_t, size_t, abd_iter_page_func_t *, - void *); -#endif void abd_copy_off(abd_t *, abd_t *, size_t, size_t, size_t); void abd_copy_from_buf_off(abd_t *, const void *, size_t, size_t); void abd_copy_to_buf_off(void *, abd_t *, size_t, size_t); @@ -220,16 +201,6 @@ abd_get_size(abd_t *abd) void abd_init(void); void abd_fini(void); -/* - * Linux ABD bio functions - * Note: these are only needed to support vdev_classic. See comment in - * vdev_disk.c. - */ -#if defined(__linux__) && defined(_KERNEL) -unsigned int abd_bio_map_off(struct bio *, abd_t *, unsigned int, size_t); -unsigned long abd_nr_pages_off(abd_t *, unsigned int, size_t); -#endif - #ifdef __cplusplus } #endif diff --git a/include/sys/abd_impl.h b/include/sys/abd_impl.h index f88ea25e245d..1eb25d94adc5 100644 --- a/include/sys/abd_impl.h +++ b/include/sys/abd_impl.h @@ -28,6 +28,7 @@ #define _ABD_IMPL_H #include +#include #include #ifdef __cplusplus @@ -111,19 +112,6 @@ void abd_iter_page(struct abd_iter *); #define ABD_LINEAR_BUF(abd) (abd->abd_u.abd_linear.abd_buf) #define ABD_GANG(abd) (abd->abd_u.abd_gang) -#if defined(_KERNEL) -#if defined(__FreeBSD__) -#define abd_enter_critical(flags) critical_enter() -#define abd_exit_critical(flags) critical_exit() -#else -#define abd_enter_critical(flags) local_irq_save(flags) -#define abd_exit_critical(flags) local_irq_restore(flags) -#endif -#else /* !_KERNEL */ -#define abd_enter_critical(flags) ((void)0) -#define abd_exit_critical(flags) ((void)0) -#endif - #ifdef __cplusplus } #endif diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index bd6ab8102c33..52d97d16d314 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -1,3 +1,5 @@ +include $(srcdir)/%D%/include/Makefile.am + libzpool_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) $(LIBRARY_CFLAGS) libzpool_la_CFLAGS += $(ZLIB_CFLAGS) diff --git a/lib/libzpool/include/Makefile.am b/lib/libzpool/include/Makefile.am new file mode 100644 index 000000000000..2e0c4c5610be --- /dev/null +++ b/lib/libzpool/include/Makefile.am @@ -0,0 +1,4 @@ +libzpooldir = $(includedir)/libzpool +libzpool_HEADERS = \ + %D%/sys/abd_os.h \ + %D%/sys/abd_impl_os.h diff --git a/lib/libzpool/include/sys/abd_impl_os.h b/lib/libzpool/include/sys/abd_impl_os.h new file mode 100644 index 000000000000..3137346f3bb2 --- /dev/null +++ b/lib/libzpool/include/sys/abd_impl_os.h @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2014 by Chunwei Chen. All rights reserved. + * Copyright (c) 2016, 2019 by Delphix. All rights reserved. + * Copyright (c) 2023, 2024, Klara Inc. + */ + +#ifndef _ABD_IMPL_OS_H +#define _ABD_IMPL_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define abd_enter_critical(flags) ((void)0) +#define abd_exit_critical(flags) ((void)0) + +#ifdef __cplusplus +} +#endif + +#endif /* _ABD_IMPL_OS_H */ diff --git a/lib/libzpool/include/sys/abd_os.h b/lib/libzpool/include/sys/abd_os.h new file mode 100644 index 000000000000..67f7e5606bec --- /dev/null +++ b/lib/libzpool/include/sys/abd_os.h @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2014 by Chunwei Chen. All rights reserved. + * Copyright (c) 2016, 2019 by Delphix. All rights reserved. + */ + +#ifndef _ABD_OS_H +#define _ABD_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct abd_scatter { + uint_t abd_offset; + uint_t abd_nents; + struct scatterlist *abd_sgl; +}; + +struct abd_linear { + void *abd_buf; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _ABD_H */ diff --git a/module/os/freebsd/zfs/abd_os.c b/module/os/freebsd/zfs/abd_os.c index fb5c46ecf7c2..accf37716c46 100644 --- a/module/os/freebsd/zfs/abd_os.c +++ b/module/os/freebsd/zfs/abd_os.c @@ -95,14 +95,12 @@ struct { */ static size_t zfs_abd_scatter_min_size = PAGE_SIZE + 1; -#if defined(_KERNEL) SYSCTL_DECL(_vfs_zfs); SYSCTL_INT(_vfs_zfs, OID_AUTO, abd_scatter_enabled, CTLFLAG_RWTUN, &zfs_abd_scatter_enabled, 0, "Enable scattered ARC data buffers"); SYSCTL_ULONG(_vfs_zfs, OID_AUTO, abd_scatter_min_size, CTLFLAG_RWTUN, &zfs_abd_scatter_min_size, 0, "Minimum size of scatter allocations."); -#endif kmem_cache_t *abd_chunk_cache; static kstat_t *abd_ksp; From 0dee309471838612d9c158594dc078f616ddcb01 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 29 Feb 2024 11:25:24 +1100 Subject: [PATCH 193/223] value strings: pretty printers for flags and enums This adds zfs_valstr, a collection of pretty printers for bitfields and enums. These are useful in debugging, logging and other display contexts where raw values are difficult for the untrained (or even trained!) eye to decipher. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris --- include/Makefile.am | 1 + include/sys/zio.h | 3 + include/sys/zio_impl.h | 3 + include/sys/zio_priority.h | 4 + include/zfs_valstr.h | 84 +++++++++++ lib/libzfs/Makefile.am | 1 + lib/libzfs/libzfs.abi | 51 +++++++ lib/libzpool/Makefile.am | 1 + module/Kbuild.in | 1 + module/Makefile.bsd | 1 + module/zcommon/zfs_valstr.c | 277 ++++++++++++++++++++++++++++++++++++ 11 files changed, 427 insertions(+) create mode 100644 include/zfs_valstr.h create mode 100644 module/zcommon/zfs_valstr.c diff --git a/include/Makefile.am b/include/Makefile.am index 5f38f6ac6ddb..f3e8b0a1fde4 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -14,6 +14,7 @@ COMMON_H = \ zfs_fletcher.h \ zfs_namecheck.h \ zfs_prop.h \ + zfs_valstr.h \ \ sys/abd.h \ sys/abd_impl.h \ diff --git a/include/sys/zio.h b/include/sys/zio.h index e1f4d5c04499..15d78db2b42b 100644 --- a/include/sys/zio.h +++ b/include/sys/zio.h @@ -167,6 +167,9 @@ typedef enum zio_suspend_reason { * This was originally an enum type. However, those are 32-bit and there is no * way to make a 64-bit enum type. Since we ran out of bits for flags, we were * forced to upgrade it to a uint64_t. + * + * NOTE: PLEASE UPDATE THE BITFIELD STRINGS IN zfs_valstr.c IF YOU ADD ANOTHER + * FLAG. */ typedef uint64_t zio_flag_t; /* diff --git a/include/sys/zio_impl.h b/include/sys/zio_impl.h index 29a05986cd4f..10133d3785d4 100644 --- a/include/sys/zio_impl.h +++ b/include/sys/zio_impl.h @@ -118,6 +118,9 @@ extern "C" { /* * zio pipeline stage definitions + * + * NOTE: PLEASE UPDATE THE BITFIELD STRINGS IN zfs_valstr.c IF YOU ADD ANOTHER + * FLAG. */ enum zio_stage { ZIO_STAGE_OPEN = 1 << 0, /* RWFCI */ diff --git a/include/sys/zio_priority.h b/include/sys/zio_priority.h index 2d8e7fc36bae..bdf5f9b8ff35 100644 --- a/include/sys/zio_priority.h +++ b/include/sys/zio_priority.h @@ -22,6 +22,10 @@ extern "C" { #endif +/* + * NOTE: PLEASE UPDATE THE ENUM STRINGS IN zfs_valstr.c IF YOU ADD ANOTHER + * VALUE. + */ typedef enum zio_priority { ZIO_PRIORITY_SYNC_READ, ZIO_PRIORITY_SYNC_WRITE, /* ZIL */ diff --git a/include/zfs_valstr.h b/include/zfs_valstr.h new file mode 100644 index 000000000000..77c26ce1ae7d --- /dev/null +++ b/include/zfs_valstr.h @@ -0,0 +1,84 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2024, Klara Inc. + */ + +#ifndef _ZFS_VALSTR_H +#define _ZFS_VALSTR_H extern __attribute__((visibility("default"))) + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * These macros create function prototypes for pretty-printing or stringifying + * certain kinds of numeric types. + * + * _ZFS_VALSTR_DECLARE_BITFIELD(name) creates: + * + * size_t zfs_valstr__bits(uint64_t bits, char *out, size_t outlen); + * expands single char for each set bit, and space for each clear bit + * + * size_t zfs_valstr__pairs(uint64_t bits, char *out, size_t outlen); + * expands two-char mnemonic for each bit set in `bits`, separated by `|` + * + * size_t zfs_valstr_(uint64_t bits, char *out, size_t outlen); + * expands full name of each bit set in `bits`, separated by spaces + * + * _ZFS_VALSTR_DECLARE_ENUM(name) creates: + * + * size_t zfs_valstr_(int v, char *out, size_t outlen); + * expands full name of enum value + * + * Each _ZFS_VALSTR_DECLARE_xxx needs a corresponding _VALSTR_xxx_IMPL string + * table in vfs_valstr.c. + */ + +#define _ZFS_VALSTR_DECLARE_BITFIELD(name) \ + _ZFS_VALSTR_H size_t zfs_valstr_ ## name ## _bits( \ + uint64_t bits, char *out, size_t outlen); \ + _ZFS_VALSTR_H size_t zfs_valstr_ ## name ## _pairs( \ + uint64_t bits, char *out, size_t outlen); \ + _ZFS_VALSTR_H size_t zfs_valstr_ ## name( \ + uint64_t bits, char *out, size_t outlen); \ + +#define _ZFS_VALSTR_DECLARE_ENUM(name) \ + _ZFS_VALSTR_H size_t zfs_valstr_ ## name( \ + int v, char *out, size_t outlen); \ + +_ZFS_VALSTR_DECLARE_BITFIELD(zio_flag) +_ZFS_VALSTR_DECLARE_BITFIELD(zio_stage) + +_ZFS_VALSTR_DECLARE_ENUM(zio_priority) + +#undef _ZFS_VALSTR_DECLARE_BITFIELD +#undef _ZFS_VALSTR_DECLARE_ENUM + +#ifdef __cplusplus +} +#endif + +#endif /* _ZFS_VALSTR_H */ diff --git a/lib/libzfs/Makefile.am b/lib/libzfs/Makefile.am index 5e74d908de3d..a976faaf9913 100644 --- a/lib/libzfs/Makefile.am +++ b/lib/libzfs/Makefile.am @@ -47,6 +47,7 @@ nodist_libzfs_la_SOURCES = \ module/zcommon/zfs_fletcher_superscalar4.c \ module/zcommon/zfs_namecheck.c \ module/zcommon/zfs_prop.c \ + module/zcommon/zfs_valstr.c \ module/zcommon/zpool_prop.c \ module/zcommon/zprop_common.c diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 8bedfe72294c..656d80f4cfc2 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -450,6 +450,13 @@ + + + + + + + @@ -9490,6 +9497,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 52d97d16d314..ab81fdc60fda 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -64,6 +64,7 @@ nodist_libzpool_la_SOURCES = \ module/zcommon/zfs_fletcher_superscalar4.c \ module/zcommon/zfs_namecheck.c \ module/zcommon/zfs_prop.c \ + module/zcommon/zfs_valstr.c \ module/zcommon/zpool_prop.c \ module/zcommon/zprop_common.c \ \ diff --git a/module/Kbuild.in b/module/Kbuild.in index e6b3ffd8f319..555522cff116 100644 --- a/module/Kbuild.in +++ b/module/Kbuild.in @@ -245,6 +245,7 @@ ZCOMMON_OBJS := \ zfs_fletcher_superscalar4.o \ zfs_namecheck.o \ zfs_prop.o \ + zfs_valstr.o \ zpool_prop.o \ zprop_common.o diff --git a/module/Makefile.bsd b/module/Makefile.bsd index 0c4d8bfe1159..de08de588571 100644 --- a/module/Makefile.bsd +++ b/module/Makefile.bsd @@ -232,6 +232,7 @@ SRCS+= zfeature_common.c \ zfs_fletcher_superscalar4.c \ zfs_namecheck.c \ zfs_prop.c \ + zfs_valstr.c \ zpool_prop.c \ zprop_common.c diff --git a/module/zcommon/zfs_valstr.c b/module/zcommon/zfs_valstr.c new file mode 100644 index 000000000000..e2d4d1aefefb --- /dev/null +++ b/module/zcommon/zfs_valstr.c @@ -0,0 +1,277 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2024, Klara Inc. + */ + +#include +#include +#include +#include +#include +#include "zfs_valstr.h" + +/* + * Each bit in a bitfield has three possible string representations: + * - single char + * - two-char pair + * - full name + */ +typedef struct { + const char vb_bit; + const char vb_pair[2]; + const char *vb_name; +} valstr_bit_t; + +/* + * Emits a character for each bit in `bits`, up to the number of elements + * in the table. Set bits get the character in vb_bit, clear bits get a + * space. This results in all strings having the same width, for easier + * visual comparison. + */ +static size_t +valstr_bitfield_bits(const valstr_bit_t *table, const size_t nelems, + uint64_t bits, char *out, size_t outlen) +{ + ASSERT(out); + size_t n = 0; + for (int b = 0; b < nelems; b++) { + if (n == outlen) + break; + uint64_t mask = (1ULL << b); + out[n++] = (bits & mask) ? table[b].vb_bit : ' '; + } + if (n < outlen) + out[n++] = '\0'; + return (n); +} + +/* + * Emits a two-char pair for each bit set in `bits`, taken from vb_pair, and + * separated by a `|` character. This gives a concise representation of the + * whole value. + */ +static size_t +valstr_bitfield_pairs(const valstr_bit_t *table, const size_t nelems, + uint64_t bits, char *out, size_t outlen) +{ + ASSERT(out); + size_t n = 0; + for (int b = 0; b < nelems; b++) { + ASSERT3U(n, <=, outlen); + if (n == outlen) + break; + uint64_t mask = (1ULL << b); + if (bits & mask) { + size_t len = (n > 0) ? 3 : 2; + if (n > outlen-len) + break; + if (n > 0) + out[n++] = '|'; + out[n++] = table[b].vb_pair[0]; + out[n++] = table[b].vb_pair[1]; + } + } + if (n < outlen) + out[n++] = '\0'; + return (n); +} + +/* + * Emits the full name for each bit set in `bits`, taken from vb_name, and + * separated by a space. This unambiguously shows the entire set of bits, but + * can get very long. + */ +static size_t +valstr_bitfield_str(const valstr_bit_t *table, const size_t nelems, + uint64_t bits, char *out, size_t outlen) +{ + ASSERT(out); + size_t n = 0; + for (int b = 0; b < nelems; b++) { + ASSERT3U(n, <=, outlen); + if (n == outlen) + break; + uint64_t mask = (1ULL << b); + if (bits & mask) { + size_t len = strlen(table[b].vb_name); + if (n > 0) + len++; + if (n > outlen-len) + break; + if (n > 0) { + out[n++] = ' '; + len--; + } + memcpy(&out[n], table[b].vb_name, len); + n += len; + } + } + if (n < outlen) + out[n++] = '\0'; + return (n); +} + +/* + * Emits the name of the given enum value in the table. + */ +static size_t +valstr_enum_str(const char **table, const size_t nelems, + int v, char *out, size_t outlen) +{ + ASSERT(out); + ASSERT3U(v, <, nelems); + if (v >= nelems) + return (0); + return (MIN(strlcpy(out, table[v], outlen), outlen)); +} + +/* + * These macros create the string tables for the given name, and implement + * the public functions described in zfs_valstr.h. + */ +#define _VALSTR_BITFIELD_IMPL(name, ...) \ +static const valstr_bit_t valstr_ ## name ## _table[] = { __VA_ARGS__ };\ +size_t \ +zfs_valstr_ ## name ## _bits(uint64_t bits, char *out, size_t outlen) \ +{ \ + return (valstr_bitfield_bits(valstr_ ## name ## _table, \ + ARRAY_SIZE(valstr_ ## name ## _table), bits, out, outlen)); \ +} \ + \ +size_t \ +zfs_valstr_ ## name ## _pairs(uint64_t bits, char *out, size_t outlen) \ +{ \ + return (valstr_bitfield_pairs(valstr_ ## name ## _table, \ + ARRAY_SIZE(valstr_ ## name ## _table), bits, out, outlen)); \ +} \ + \ +size_t \ +zfs_valstr_ ## name(uint64_t bits, char *out, size_t outlen) \ +{ \ + return (valstr_bitfield_str(valstr_ ## name ## _table, \ + ARRAY_SIZE(valstr_ ## name ## _table), bits, out, outlen)); \ +} \ + +#define _VALSTR_ENUM_IMPL(name, ...) \ +static const char *valstr_ ## name ## _table[] = { __VA_ARGS__ }; \ +size_t \ +zfs_valstr_ ## name(int v, char *out, size_t outlen) \ +{ \ + return (valstr_enum_str(valstr_ ## name ## _table, \ + ARRAY_SIZE(valstr_ ## name ## _table), v, out, outlen)); \ +} \ + + +/* String tables */ + +/* ZIO flags: zio_flag_t, typically zio->io_flags */ +/* BEGIN CSTYLED */ +_VALSTR_BITFIELD_IMPL(zio_flag, + { '.', "DA", "DONT_AGGREGATE" }, + { '.', "RP", "IO_REPAIR" }, + { '.', "SH", "SELF_HEAL" }, + { '.', "RS", "RESILVER" }, + { '.', "SC", "SCRUB" }, + { '.', "ST", "SCAN_THREAD" }, + { '.', "PH", "PHYSICAL" }, + { '.', "CF", "CANFAIL" }, + { '.', "SP", "SPECULATIVE" }, + { '.', "CW", "CONFIG_WRITER" }, + { '.', "DR", "DONT_RETRY" }, + { '?', "??", "[UNUSED 11]" }, + { '.', "ND", "NODATA" }, + { '.', "ID", "INDUCE_DAMAGE" }, + { '.', "AL", "IO_ALLOCATING" }, + { '.', "RE", "IO_RETRY" }, + { '.', "PR", "PROBE" }, + { '.', "TH", "TRYHARD" }, + { '.', "OP", "OPTIONAL" }, + { '.', "DQ", "DONT_QUEUE" }, + { '.', "DP", "DONT_PROPAGATE" }, + { '.', "BY", "IO_BYPASS" }, + { '.', "RW", "IO_REWRITE" }, + { '.', "CM", "RAW_COMPRESS" }, + { '.', "EN", "RAW_ENCRYPT" }, + { '.', "GG", "GANG_CHILD" }, + { '.', "DD", "DDT_CHILD" }, + { '.', "GF", "GODFATHER" }, + { '.', "NP", "NOPWRITE" }, + { '.', "EX", "REEXECUTED" }, + { '.', "DG", "DELEGATED" }, +) +/* END CSTYLED */ + +/* + * ZIO pipeline stage(s): enum zio_stage, typically zio->io_stage or + * zio->io_pipeline. + */ +/* BEGIN CSTYLED */ +_VALSTR_BITFIELD_IMPL(zio_stage, + { 'O', "O ", "OPEN" }, + { 'I', "RI", "READ_BP_INIT" }, + { 'I', "WI", "WRITE_BP_INIT" }, + { 'I', "FI", "FREE_BP_INIT" }, + { 'A', "IA", "ISSUE_ASYNC" }, + { 'W', "WC", "WRITE_COMPRESS" }, + { 'E', "EN", "ENCRYPT" }, + { 'C', "CG", "CHECKSUM_GENERATE" }, + { 'N', "NW", "NOP_WRITE" }, + { 'B', "BF", "BRT_FREE" }, + { 'd', "dS", "DDT_READ_START" }, + { 'd', "dD", "DDT_READ_DONE" }, + { 'd', "dW", "DDT_WRITE" }, + { 'd', "dF", "DDT_FREE" }, + { 'G', "GA", "GANG_ASSEMBLE" }, + { 'G', "GI", "GANG_ISSUE" }, + { 'D', "DT", "DVA_THROTTLE" }, + { 'D', "DA", "DVA_ALLOCATE" }, + { 'D', "DF", "DVA_FREE" }, + { 'D', "DC", "DVA_CLAIM" }, + { 'R', "R ", "READY" }, + { 'V', "VS", "VDEV_IO_START" }, + { 'V', "VD", "VDEV_IO_DONE" }, + { 'V', "VA", "VDEV_IO_ASSESS" }, + { 'C', "CV", "CHECKSUM_VERIFY" }, + { 'X', "X ", "DONE" }, +) +/* END CSTYLED */ + +/* ZIO priority: zio_priority_t, typically zio->io_priority */ +/* BEGIN CSTYLED */ +_VALSTR_ENUM_IMPL(zio_priority, + "SYNC_READ", + "SYNC_WRITE", + "ASYNC_READ", + "ASYNC_WRITE", + "SCRUB", + "REMOVAL", + "INITIALIZING", + "TRIM", + "REBUILD", + "[NUM_QUEUEABLE]", + "NOW", +) +/* END CSTYLED */ + +#undef _VALSTR_BITFIELD_IMPL +#undef _VALSTR_ENUM_IMPL From c07f9a2aa6b9cc589748f6810649bcb74a161b2b Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 28 Aug 2024 22:22:51 +1000 Subject: [PATCH 194/223] arc_os: split userspace and Linux kernel code The Linux arc_os.c carries userspace and kernel code, with very little overlap between the two. This lifts the userspace parts out into a separate arc_os.c for libzpool and removes it from the Linux side. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Sponsored-by: https://despairlabs.com/sponsor/ Closes #16492 --- lib/libzpool/Makefile.am | 2 +- lib/libzpool/arc_os.c | 87 ++++++++++++++++++++++++++++++++++++ module/os/linux/zfs/arc_os.c | 45 ------------------- 3 files changed, 88 insertions(+), 46 deletions(-) create mode 100644 lib/libzpool/arc_os.c diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index ab81fdc60fda..62efdea642d0 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -12,6 +12,7 @@ CPPCHECKTARGETS += libzpool.la dist_libzpool_la_SOURCES = \ %D%/abd_os.c \ + %D%/arc_os.c \ %D%/kernel.c \ %D%/taskq.c \ %D%/util.c @@ -42,7 +43,6 @@ nodist_libzpool_la_SOURCES = \ module/lua/lvm.c \ module/lua/lzio.c \ \ - module/os/linux/zfs/arc_os.c \ module/os/linux/zfs/trace.c \ module/os/linux/zfs/vdev_file.c \ module/os/linux/zfs/zfs_debug.c \ diff --git a/lib/libzpool/arc_os.c b/lib/libzpool/arc_os.c new file mode 100644 index 000000000000..ed99322ddb05 --- /dev/null +++ b/lib/libzpool/arc_os.c @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. + * Copyright (c) 2011, 2019 by Delphix. All rights reserved. + * Copyright (c) 2014 by Saso Kiselkov. All rights reserved. + * Copyright 2017 Nexenta Systems, Inc. All rights reserved. + */ + +#include +#include + +/* + * Return a default max arc size based on the amount of physical memory. + * This may be overridden by tuning the zfs_arc_max module parameter. + */ +uint64_t +arc_default_max(uint64_t min, uint64_t allmem) +{ + uint64_t size; + + if (allmem >= 1 << 30) + size = allmem - (1 << 30); + else + size = min; + return (MAX(allmem * 5 / 8, size)); +} + +int64_t +arc_available_memory(void) +{ + int64_t lowest = INT64_MAX; + + /* Every 100 calls, free a small amount */ + if (random_in_range(100) == 0) + lowest = -1024; + + return (lowest); +} + +int +arc_memory_throttle(spa_t *spa, uint64_t reserve, uint64_t txg) +{ + (void) spa, (void) reserve, (void) txg; + return (0); +} + +uint64_t +arc_all_memory(void) +{ + return (ptob(physmem) / 2); +} + +uint64_t +arc_free_memory(void) +{ + return (random_in_range(arc_all_memory() * 20 / 100)); +} + +void +arc_register_hotplug(void) +{ +} + +void +arc_unregister_hotplug(void) +{ +} diff --git a/module/os/linux/zfs/arc_os.c b/module/os/linux/zfs/arc_os.c index 1fa9f3eb3f5b..02583e49ca79 100644 --- a/module/os/linux/zfs/arc_os.c +++ b/module/os/linux/zfs/arc_os.c @@ -42,14 +42,12 @@ #include #include #include -#ifdef _KERNEL #include #include #include #include #include #include -#endif #include #include #include @@ -88,7 +86,6 @@ arc_default_max(uint64_t min, uint64_t allmem) return (MAX(allmem / 2, min)); } -#ifdef _KERNEL /* * Return maximum amount of memory that we could possibly use. Reduced * to half of all memory in user space which is primarily used for testing. @@ -449,48 +446,6 @@ arc_unregister_hotplug(void) unregister_memory_notifier(&arc_hotplug_callback_mem_nb); #endif } -#else /* _KERNEL */ -int64_t -arc_available_memory(void) -{ - int64_t lowest = INT64_MAX; - - /* Every 100 calls, free a small amount */ - if (random_in_range(100) == 0) - lowest = -1024; - - return (lowest); -} - -int -arc_memory_throttle(spa_t *spa, uint64_t reserve, uint64_t txg) -{ - (void) spa, (void) reserve, (void) txg; - return (0); -} - -uint64_t -arc_all_memory(void) -{ - return (ptob(physmem) / 2); -} - -uint64_t -arc_free_memory(void) -{ - return (random_in_range(arc_all_memory() * 20 / 100)); -} - -void -arc_register_hotplug(void) -{ -} - -void -arc_unregister_hotplug(void) -{ -} -#endif /* _KERNEL */ ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, shrinker_limit, INT, ZMOD_RW, "Limit on number of pages that ARC shrinker can reclaim at once"); From 190c66a3bc4b3c1192e19b711b5789cb20028704 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 28 Aug 2024 22:27:13 +1000 Subject: [PATCH 195/223] vdev_label_os: copy Linux implementation for userspace The no-op is fine for both. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Sponsored-by: https://despairlabs.com/sponsor/ Closes #16492 --- lib/libzpool/Makefile.am | 3 ++- lib/libzpool/vdev_label_os.c | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 lib/libzpool/vdev_label_os.c diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 62efdea642d0..5ddb50179987 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -15,7 +15,8 @@ dist_libzpool_la_SOURCES = \ %D%/arc_os.c \ %D%/kernel.c \ %D%/taskq.c \ - %D%/util.c + %D%/util.c \ + %D%/vdev_label_os.c nodist_libzpool_la_SOURCES = \ module/lua/lapi.c \ diff --git a/lib/libzpool/vdev_label_os.c b/lib/libzpool/vdev_label_os.c new file mode 100644 index 000000000000..3d965b89a962 --- /dev/null +++ b/lib/libzpool/vdev_label_os.c @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2023 by iXsystems, Inc. + */ + +#include +#include +#include +#include +#include + +/* + * Check if the reserved boot area is in-use. + * + * This function always returns 0, as there are no known external uses + * of the reserved area on Linux. + */ +int +vdev_check_boot_reserve(spa_t *spa, vdev_t *childvd) +{ + (void) spa; + (void) childvd; + + return (0); +} From def131415cdd0b5d8e41a8cf984a8fb1635cbd65 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 28 Aug 2024 22:27:27 +1000 Subject: [PATCH 196/223] libzpool: don't include trace.c It does nothing in userspace anyway. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Sponsored-by: https://despairlabs.com/sponsor/ Closes #16492 --- lib/libzpool/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 5ddb50179987..06a630ca48f1 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -44,7 +44,6 @@ nodist_libzpool_la_SOURCES = \ module/lua/lvm.c \ module/lua/lzio.c \ \ - module/os/linux/zfs/trace.c \ module/os/linux/zfs/vdev_file.c \ module/os/linux/zfs/zfs_debug.c \ module/os/linux/zfs/zfs_racct.c \ From 845b7b7e66d3c558c6995eda7b6a4d2ad07e18e5 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 28 Aug 2024 22:28:16 +1000 Subject: [PATCH 197/223] zfs_racct: copy Linux implementation for userspace The no-op is fine for both. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Sponsored-by: https://despairlabs.com/sponsor/ Closes #16492 --- lib/libzpool/Makefile.am | 4 ++-- lib/libzpool/zfs_racct.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 lib/libzpool/zfs_racct.c diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 06a630ca48f1..64ae1a90e12f 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -16,7 +16,8 @@ dist_libzpool_la_SOURCES = \ %D%/kernel.c \ %D%/taskq.c \ %D%/util.c \ - %D%/vdev_label_os.c + %D%/vdev_label_os.c \ + %D%/zfs_racct.c nodist_libzpool_la_SOURCES = \ module/lua/lapi.c \ @@ -46,7 +47,6 @@ nodist_libzpool_la_SOURCES = \ \ module/os/linux/zfs/vdev_file.c \ module/os/linux/zfs/zfs_debug.c \ - module/os/linux/zfs/zfs_racct.c \ module/os/linux/zfs/zfs_znode.c \ module/os/linux/zfs/zio_crypt.c \ \ diff --git a/lib/libzpool/zfs_racct.c b/lib/libzpool/zfs_racct.c new file mode 100644 index 000000000000..ce623ef9d185 --- /dev/null +++ b/lib/libzpool/zfs_racct.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 iXsystems, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +void +zfs_racct_read(uint64_t size, uint64_t iops) +{ + (void) size, (void) iops; +} + +void +zfs_racct_write(uint64_t size, uint64_t iops) +{ + (void) size, (void) iops; +} From 3f9ee8089d2d964f587706152da3517f5d0a7a1a Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 6 Aug 2024 09:56:45 +1000 Subject: [PATCH 198/223] FreeBSD: remove support for FreeBSD < 13.0-RELEASE (#16372) This includes the last 12.x release (now EOL) and 13.0 development versions (<1300139). Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Rob Norris Reviewed-by: Alexander Motin Reviewed-by: Tino Reichardt Reviewed-by: Tony Hutter --- README.md | 2 +- include/os/freebsd/spl/sys/ccompat.h | 42 --- include/os/freebsd/spl/sys/policy.h | 6 - include/os/freebsd/spl/sys/proc.h | 3 - include/os/freebsd/spl/sys/random.h | 4 +- include/os/freebsd/spl/sys/vm.h | 16 -- include/os/freebsd/spl/sys/vnode.h | 6 +- include/os/freebsd/zfs/sys/zfs_vfsops_os.h | 77 ------ module/os/freebsd/spl/spl_kmem.c | 8 - module/os/freebsd/spl/spl_policy.c | 52 ++-- module/os/freebsd/spl/spl_taskq.c | 5 - module/os/freebsd/spl/spl_vfs.c | 12 +- module/os/freebsd/spl/spl_zone.c | 4 +- module/os/freebsd/zfs/crypto_os.c | 249 ------------------ module/os/freebsd/zfs/dmu_os.c | 27 +- module/os/freebsd/zfs/event_os.c | 19 -- module/os/freebsd/zfs/kmod_core.c | 4 - module/os/freebsd/zfs/vdev_geom.c | 4 - module/os/freebsd/zfs/zfs_ctldir.c | 28 +- module/os/freebsd/zfs/zfs_dir.c | 4 +- module/os/freebsd/zfs/zfs_file_os.c | 10 +- module/os/freebsd/zfs/zfs_ioctl_os.c | 4 - module/os/freebsd/zfs/zfs_vfsops.c | 36 +-- module/os/freebsd/zfs/zfs_vnops_os.c | 292 +++------------------ module/os/freebsd/zfs/zfs_znode.c | 17 +- module/os/freebsd/zfs/zvol_os.c | 8 - module/zfs/zfs_replay.c | 4 +- 27 files changed, 86 insertions(+), 857 deletions(-) diff --git a/README.md b/README.md index af244c1fff14..a90736bb56b7 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ For more details see the NOTICE, LICENSE and COPYRIGHT files; `UCRL-CODE-235197` # Supported Kernels * The `META` file contains the officially recognized supported Linux kernel versions. - * Supported FreeBSD versions are any supported branches and releases starting from 12.4-RELEASE. + * Supported FreeBSD versions are any supported branches and releases starting from 13.0-RELEASE. diff --git a/include/os/freebsd/spl/sys/ccompat.h b/include/os/freebsd/spl/sys/ccompat.h index e34bab7e896d..48749fb8eea2 100644 --- a/include/os/freebsd/spl/sys/ccompat.h +++ b/include/os/freebsd/spl/sys/ccompat.h @@ -28,48 +28,6 @@ #ifndef _SYS_CCOMPAT_H #define _SYS_CCOMPAT_H -#if __FreeBSD_version < 1300051 -#define vm_page_valid(m) (m)->valid = VM_PAGE_BITS_ALL -#define vm_page_do_sunbusy(m) -#define vm_page_none_valid(m) ((m)->valid == 0) -#else -#define vm_page_do_sunbusy(m) vm_page_sunbusy(m) -#endif - -#if __FreeBSD_version < 1300074 -#define VOP_UNLOCK1(x) VOP_UNLOCK(x, 0) -#else -#define VOP_UNLOCK1(x) VOP_UNLOCK(x) -#endif - -#if __FreeBSD_version < 1300064 -#define VN_IS_DOOMED(vp) ((vp)->v_iflag & VI_DOOMED) -#endif - -#if __FreeBSD_version < 1300068 -#define VFS_VOP_VECTOR_REGISTER(x) -#endif - -#if __FreeBSD_version >= 1300076 -#define getnewvnode_reserve_() getnewvnode_reserve() -#else -#define getnewvnode_reserve_() getnewvnode_reserve(1) -#endif - -#if __FreeBSD_version < 1300102 -#define ASSERT_VOP_IN_SEQC(zp) -#define MNTK_FPLOOKUP 0 -#define vn_seqc_write_begin(vp) -#define vn_seqc_write_end(vp) - -#ifndef VFS_SMR_DECLARE -#define VFS_SMR_DECLARE -#endif -#ifndef VFS_SMR_ZONE_SET -#define VFS_SMR_ZONE_SET(zone) -#endif -#endif - struct hlist_node { struct hlist_node *next, **pprev; }; diff --git a/include/os/freebsd/spl/sys/policy.h b/include/os/freebsd/spl/sys/policy.h index 909ae3886e9c..32c10bdca90e 100644 --- a/include/os/freebsd/spl/sys/policy.h +++ b/include/os/freebsd/spl/sys/policy.h @@ -70,10 +70,4 @@ int secpolicy_xvattr(vnode_t *vp, xvattr_t *xvap, uid_t owner, cred_t *cr, vtype_t vtype); int secpolicy_smb(cred_t *cr); - -#if __FreeBSD_version >= 1300005 -#define spl_priv_check_cred(a, b) priv_check_cred((a), (b)) -#else -#define spl_priv_check_cred(a, b) priv_check_cred((a), (b), 0) -#endif #endif /* _OPENSOLARIS_SYS_POLICY_H_ */ diff --git a/include/os/freebsd/spl/sys/proc.h b/include/os/freebsd/spl/sys/proc.h index 8583df509b55..96ba10e5679e 100644 --- a/include/os/freebsd/spl/sys/proc.h +++ b/include/os/freebsd/spl/sys/proc.h @@ -88,9 +88,6 @@ do_thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg, thread_lock(td); sched_prio(td, pri); sched_add(td, SRQ_BORING); -#if __FreeBSD_version < 1300068 - thread_unlock(td); -#endif } return (td); } diff --git a/include/os/freebsd/spl/sys/random.h b/include/os/freebsd/spl/sys/random.h index 7583166e727b..146fa9e5d133 100644 --- a/include/os/freebsd/spl/sys/random.h +++ b/include/os/freebsd/spl/sys/random.h @@ -30,9 +30,7 @@ #define _OPENSOLARIS_SYS_RANDOM_H_ #include_next -#if __FreeBSD_version >= 1300108 #include -#endif static inline int random_get_bytes(uint8_t *p, size_t s) @@ -51,7 +49,7 @@ random_get_pseudo_bytes(uint8_t *p, size_t s) static inline uint32_t random_in_range(uint32_t range) { -#if defined(_KERNEL) && __FreeBSD_version >= 1300108 +#if defined(_KERNEL) return (prng32_bounded(range)); #else uint32_t r; diff --git a/include/os/freebsd/spl/sys/vm.h b/include/os/freebsd/spl/sys/vm.h index 7b3830be8a57..07ee6bc191a7 100644 --- a/include/os/freebsd/spl/sys/vm.h +++ b/include/os/freebsd/spl/sys/vm.h @@ -41,22 +41,6 @@ void zfs_vmobject_assert_wlocked(vm_object_t object); void zfs_vmobject_wlock(vm_object_t object); void zfs_vmobject_wunlock(vm_object_t object); -#if __FreeBSD_version >= 1300081 -#define zfs_vmobject_assert_wlocked_12(x) -#define zfs_vmobject_wlock_12(x) -#define zfs_vmobject_wunlock_12(x) -#else -#define zfs_vmobject_assert_wlocked_12(x) \ - zfs_vmobject_assert_wlocked((x)) -#define zfs_vmobject_wlock_12(x) \ - zfs_vmobject_wlock(x) -#define zfs_vmobject_wunlock_12(x) \ - zfs_vmobject_wunlock(x) -#define vm_page_grab_unlocked(obj, idx, flags) \ - vm_page_grab((obj), (idx), (flags)) -#define vm_page_grab_valid_unlocked(m, obj, idx, flags) \ - vm_page_grab_valid((m), (obj), (idx), (flags)) -#endif static inline caddr_t zfs_map_page(vm_page_t pp, struct sf_buf **sfp) { diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h index 75c32f221ffd..76ea3eff3792 100644 --- a/include/os/freebsd/spl/sys/vnode.h +++ b/include/os/freebsd/spl/sys/vnode.h @@ -95,17 +95,13 @@ vn_is_readonly(vnode_t *vp) static __inline void vn_flush_cached_data(vnode_t *vp, boolean_t sync) { -#if __FreeBSD_version > 1300054 if (vm_object_mightbedirty(vp->v_object)) { -#else - if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) { -#endif int flags = sync ? OBJPC_SYNC : 0; vn_lock(vp, LK_SHARED | LK_RETRY); zfs_vmobject_wlock(vp->v_object); vm_object_page_clean(vp->v_object, 0, 0, flags); zfs_vmobject_wunlock(vp->v_object); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); } } #endif diff --git a/include/os/freebsd/zfs/sys/zfs_vfsops_os.h b/include/os/freebsd/zfs/sys/zfs_vfsops_os.h index 24bb03575f33..8a6342504c06 100644 --- a/include/os/freebsd/zfs/sys/zfs_vfsops_os.h +++ b/include/os/freebsd/zfs/sys/zfs_vfsops_os.h @@ -27,40 +27,21 @@ #ifndef _SYS_FS_ZFS_VFSOPS_H #define _SYS_FS_ZFS_VFSOPS_H -#if __FreeBSD_version >= 1300125 -#define TEARDOWN_RMS -#endif - -#if __FreeBSD_version >= 1300109 -#define TEARDOWN_INACTIVE_RMS -#endif - #include #include #include #include #include #include -#ifdef TEARDOWN_INACTIVE_RMS #include -#endif #include #ifdef __cplusplus extern "C" { #endif -#ifdef TEARDOWN_RMS typedef struct rmslock zfs_teardown_lock_t; -#else -#define zfs_teardown_lock_t rrmlock_t -#endif - -#ifdef TEARDOWN_INACTIVE_RMS typedef struct rmslock zfs_teardown_inactive_lock_t; -#else -#define zfs_teardown_inactive_lock_t krwlock_t -#endif typedef struct zfsvfs zfsvfs_t; struct znode; @@ -120,7 +101,6 @@ struct zfsvfs { struct task z_unlinked_drain_task; }; -#ifdef TEARDOWN_RMS #define ZFS_TEARDOWN_INIT(zfsvfs) \ rms_init(&(zfsvfs)->z_teardown_lock, "zfs teardown") @@ -150,39 +130,7 @@ struct zfsvfs { #define ZFS_TEARDOWN_HELD(zfsvfs) \ rms_owned_any(&(zfsvfs)->z_teardown_lock) -#else -#define ZFS_TEARDOWN_INIT(zfsvfs) \ - rrm_init(&(zfsvfs)->z_teardown_lock, B_FALSE) - -#define ZFS_TEARDOWN_DESTROY(zfsvfs) \ - rrm_destroy(&(zfsvfs)->z_teardown_lock) - -#define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag) \ - rrm_enter_read(&(zfsvfs)->z_teardown_lock, tag); - -#define ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag) \ - rrm_exit(&(zfsvfs)->z_teardown_lock, tag) - -#define ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, tag) \ - rrm_enter(&(zfsvfs)->z_teardown_lock, RW_WRITER, tag) - -#define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs) \ - rrm_exit(&(zfsvfs)->z_teardown_lock, tag) - -#define ZFS_TEARDOWN_EXIT(zfsvfs, tag) \ - rrm_exit(&(zfsvfs)->z_teardown_lock, tag) - -#define ZFS_TEARDOWN_READ_HELD(zfsvfs) \ - RRM_READ_HELD(&(zfsvfs)->z_teardown_lock) - -#define ZFS_TEARDOWN_WRITE_HELD(zfsvfs) \ - RRM_WRITE_HELD(&(zfsvfs)->z_teardown_lock) - -#define ZFS_TEARDOWN_HELD(zfsvfs) \ - RRM_LOCK_HELD(&(zfsvfs)->z_teardown_lock) -#endif -#ifdef TEARDOWN_INACTIVE_RMS #define ZFS_TEARDOWN_INACTIVE_INIT(zfsvfs) \ rms_init(&(zfsvfs)->z_teardown_inactive_lock, "zfs teardown inactive") @@ -206,31 +154,6 @@ struct zfsvfs { #define ZFS_TEARDOWN_INACTIVE_WRITE_HELD(zfsvfs) \ rms_wowned(&(zfsvfs)->z_teardown_inactive_lock) -#else -#define ZFS_TEARDOWN_INACTIVE_INIT(zfsvfs) \ - rw_init(&(zfsvfs)->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL) - -#define ZFS_TEARDOWN_INACTIVE_DESTROY(zfsvfs) \ - rw_destroy(&(zfsvfs)->z_teardown_inactive_lock) - -#define ZFS_TEARDOWN_INACTIVE_TRY_ENTER_READ(zfsvfs) \ - rw_tryenter(&(zfsvfs)->z_teardown_inactive_lock, RW_READER) - -#define ZFS_TEARDOWN_INACTIVE_ENTER_READ(zfsvfs) \ - rw_enter(&(zfsvfs)->z_teardown_inactive_lock, RW_READER) - -#define ZFS_TEARDOWN_INACTIVE_EXIT_READ(zfsvfs) \ - rw_exit(&(zfsvfs)->z_teardown_inactive_lock) - -#define ZFS_TEARDOWN_INACTIVE_ENTER_WRITE(zfsvfs) \ - rw_enter(&(zfsvfs)->z_teardown_inactive_lock, RW_WRITER) - -#define ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs) \ - rw_exit(&(zfsvfs)->z_teardown_inactive_lock) - -#define ZFS_TEARDOWN_INACTIVE_WRITE_HELD(zfsvfs) \ - RW_WRITE_HELD(&(zfsvfs)->z_teardown_inactive_lock) -#endif #define ZSB_XATTR 0x0001 /* Enable user xattrs */ /* diff --git a/module/os/freebsd/spl/spl_kmem.c b/module/os/freebsd/spl/spl_kmem.c index ca9a677567d9..c35375b729f8 100644 --- a/module/os/freebsd/spl/spl_kmem.c +++ b/module/os/freebsd/spl/spl_kmem.c @@ -243,22 +243,14 @@ void kmem_cache_reap_soon(kmem_cache_t *cache) { #ifndef KMEM_DEBUG -#if __FreeBSD_version >= 1300043 uma_zone_reclaim(cache->kc_zone, UMA_RECLAIM_DRAIN); -#else - zone_drain(cache->kc_zone); -#endif #endif } void kmem_reap(void) { -#if __FreeBSD_version >= 1300043 uma_reclaim(UMA_RECLAIM_TRIM); -#else - uma_reclaim(); -#endif } #else void diff --git a/module/os/freebsd/spl/spl_policy.c b/module/os/freebsd/spl/spl_policy.c index 5ecd3d310361..01551f53f208 100644 --- a/module/os/freebsd/spl/spl_policy.c +++ b/module/os/freebsd/spl/spl_policy.c @@ -44,42 +44,42 @@ int secpolicy_nfs(cred_t *cr) { - return (spl_priv_check_cred(cr, PRIV_NFS_DAEMON)); + return (priv_check_cred(cr, PRIV_NFS_DAEMON)); } int secpolicy_zfs(cred_t *cr) { - return (spl_priv_check_cred(cr, PRIV_VFS_MOUNT)); + return (priv_check_cred(cr, PRIV_VFS_MOUNT)); } int secpolicy_zfs_proc(cred_t *cr, proc_t *proc) { - return (spl_priv_check_cred(cr, PRIV_VFS_MOUNT)); + return (priv_check_cred(cr, PRIV_VFS_MOUNT)); } int secpolicy_sys_config(cred_t *cr, int checkonly __unused) { - return (spl_priv_check_cred(cr, PRIV_ZFS_POOL_CONFIG)); + return (priv_check_cred(cr, PRIV_ZFS_POOL_CONFIG)); } int secpolicy_zinject(cred_t *cr) { - return (spl_priv_check_cred(cr, PRIV_ZFS_INJECT)); + return (priv_check_cred(cr, PRIV_ZFS_INJECT)); } int secpolicy_fs_unmount(cred_t *cr, struct mount *vfsp __unused) { - return (spl_priv_check_cred(cr, PRIV_VFS_UNMOUNT)); + return (priv_check_cred(cr, PRIV_VFS_UNMOUNT)); } int @@ -107,7 +107,7 @@ secpolicy_basic_link(vnode_t *vp, cred_t *cr) return (0); if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_LINK)); + return (priv_check_cred(cr, PRIV_VFS_LINK)); } int @@ -123,7 +123,7 @@ secpolicy_vnode_remove(vnode_t *vp, cred_t *cr) if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_ADMIN)); + return (priv_check_cred(cr, PRIV_VFS_ADMIN)); } int @@ -133,18 +133,18 @@ secpolicy_vnode_access(cred_t *cr, vnode_t *vp, uid_t owner, accmode_t accmode) if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - if ((accmode & VREAD) && spl_priv_check_cred(cr, PRIV_VFS_READ) != 0) + if ((accmode & VREAD) && priv_check_cred(cr, PRIV_VFS_READ) != 0) return (EACCES); if ((accmode & VWRITE) && - spl_priv_check_cred(cr, PRIV_VFS_WRITE) != 0) { + priv_check_cred(cr, PRIV_VFS_WRITE) != 0) { return (EACCES); } if (accmode & VEXEC) { if (vp->v_type == VDIR) { - if (spl_priv_check_cred(cr, PRIV_VFS_LOOKUP) != 0) + if (priv_check_cred(cr, PRIV_VFS_LOOKUP) != 0) return (EACCES); } else { - if (spl_priv_check_cred(cr, PRIV_VFS_EXEC) != 0) + if (priv_check_cred(cr, PRIV_VFS_EXEC) != 0) return (EACCES); } } @@ -201,7 +201,7 @@ secpolicy_vnode_any_access(cred_t *cr, vnode_t *vp, uid_t owner) continue; break; } - if (spl_priv_check_cred(cr, priv) == 0) + if (priv_check_cred(cr, priv) == 0) return (0); } return (EPERM); @@ -215,7 +215,7 @@ secpolicy_vnode_setdac(vnode_t *vp, cred_t *cr, uid_t owner) return (0); if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_ADMIN)); + return (priv_check_cred(cr, PRIV_VFS_ADMIN)); } int @@ -265,7 +265,7 @@ secpolicy_vnode_setattr(cred_t *cr, vnode_t *vp, struct vattr *vap, ((mask & AT_GID) && vap->va_gid != ovap->va_gid && !groupmember(vap->va_gid, cr))) { if (secpolicy_fs_owner(vp->v_mount, cr) != 0) { - error = spl_priv_check_cred(cr, PRIV_VFS_CHOWN); + error = priv_check_cred(cr, PRIV_VFS_CHOWN); if (error) return (error); } @@ -309,7 +309,7 @@ secpolicy_vnode_setids_setgids(vnode_t *vp, cred_t *cr, gid_t gid) return (0); if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_SETGID)); + return (priv_check_cred(cr, PRIV_VFS_SETGID)); } int @@ -319,7 +319,7 @@ secpolicy_vnode_setid_retain(znode_t *zp, cred_t *cr, if (secpolicy_fs_owner(ZTOV(zp)->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_RETAINSUGID)); + return (priv_check_cred(cr, PRIV_VFS_RETAINSUGID)); } void @@ -330,7 +330,7 @@ secpolicy_setid_clear(struct vattr *vap, vnode_t *vp, cred_t *cr) return; if ((vap->va_mode & (S_ISUID | S_ISGID)) != 0) { - if (spl_priv_check_cred(cr, PRIV_VFS_RETAINSUGID)) { + if (priv_check_cred(cr, PRIV_VFS_RETAINSUGID)) { vap->va_mask |= AT_MODE; vap->va_mode &= ~(S_ISUID|S_ISGID); } @@ -352,7 +352,7 @@ secpolicy_setid_setsticky_clear(vnode_t *vp, struct vattr *vap, * is not a member of. Both of these are allowed in jail(8). */ if (vp->v_type != VDIR && (vap->va_mode & S_ISTXT)) { - if (spl_priv_check_cred(cr, PRIV_VFS_STICKYFILE)) + if (priv_check_cred(cr, PRIV_VFS_STICKYFILE)) return (EFTYPE); } /* @@ -368,7 +368,7 @@ secpolicy_setid_setsticky_clear(vnode_t *vp, struct vattr *vap, * Deny setting setuid if we are not the file owner. */ if ((vap->va_mode & S_ISUID) && ovap->va_uid != cr->cr_uid) { - error = spl_priv_check_cred(cr, PRIV_VFS_ADMIN); + error = priv_check_cred(cr, PRIV_VFS_ADMIN); if (error) return (error); } @@ -379,7 +379,7 @@ int secpolicy_fs_mount(cred_t *cr, vnode_t *mvp, struct mount *vfsp) { - return (spl_priv_check_cred(cr, PRIV_VFS_MOUNT)); + return (priv_check_cred(cr, PRIV_VFS_MOUNT)); } int @@ -392,7 +392,7 @@ secpolicy_vnode_owner(vnode_t *vp, cred_t *cr, uid_t owner) return (0); /* XXX: vfs_suser()? */ - return (spl_priv_check_cred(cr, PRIV_VFS_MOUNT_OWNER)); + return (priv_check_cred(cr, PRIV_VFS_MOUNT_OWNER)); } int @@ -401,14 +401,14 @@ secpolicy_vnode_chown(vnode_t *vp, cred_t *cr, uid_t owner) if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_CHOWN)); + return (priv_check_cred(cr, PRIV_VFS_CHOWN)); } void secpolicy_fs_mount_clearopts(cred_t *cr, struct mount *vfsp) { - if (spl_priv_check_cred(cr, PRIV_VFS_MOUNT_NONUSER) != 0) { + if (priv_check_cred(cr, PRIV_VFS_MOUNT_NONUSER) != 0) { MNT_ILOCK(vfsp); vfsp->vfs_flag |= VFS_NOSETUID | MNT_USER; vfs_clearmntopt(vfsp, MNTOPT_SETUID); @@ -427,12 +427,12 @@ secpolicy_xvattr(vnode_t *vp, xvattr_t *xvap, uid_t owner, cred_t *cr, if (secpolicy_fs_owner(vp->v_mount, cr) == 0) return (0); - return (spl_priv_check_cred(cr, PRIV_VFS_SYSFLAGS)); + return (priv_check_cred(cr, PRIV_VFS_SYSFLAGS)); } int secpolicy_smb(cred_t *cr) { - return (spl_priv_check_cred(cr, PRIV_NETSMB)); + return (priv_check_cred(cr, PRIV_NETSMB)); } diff --git a/module/os/freebsd/spl/spl_taskq.c b/module/os/freebsd/spl/spl_taskq.c index 266fe9a9a56d..4bf5cc9b8b26 100644 --- a/module/os/freebsd/spl/spl_taskq.c +++ b/module/os/freebsd/spl/spl_taskq.c @@ -45,11 +45,6 @@ __FBSDID("$FreeBSD$"); #include -#if __FreeBSD_version < 1201522 -#define taskqueue_start_threads_in_proc(tqp, count, pri, proc, name, ...) \ - taskqueue_start_threads(tqp, count, pri, name, __VA_ARGS__) -#endif - static uint_t taskq_tsd; static uma_zone_t taskq_zone; diff --git a/module/os/freebsd/spl/spl_vfs.c b/module/os/freebsd/spl/spl_vfs.c index 3f33547216eb..d29855eb9437 100644 --- a/module/os/freebsd/spl/spl_vfs.c +++ b/module/os/freebsd/spl/spl_vfs.c @@ -161,7 +161,7 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath, return (error); } vn_seqc_write_begin(vp); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); /* * Allocate and initialize the filesystem. @@ -252,10 +252,8 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath, if (VFS_ROOT(mp, LK_EXCLUSIVE, &mvp)) panic("mount: lost mount"); vn_seqc_write_end(vp); - VOP_UNLOCK1(vp); -#if __FreeBSD_version >= 1300048 + VOP_UNLOCK(vp); vfs_op_exit(mp); -#endif vfs_unbusy(mp); *vpp = mvp; return (0); @@ -275,12 +273,8 @@ void vn_rele_async(vnode_t *vp, taskq_t *taskq) { VERIFY3U(vp->v_usecount, >, 0); - if (refcount_release_if_not_last(&vp->v_usecount)) { -#if __FreeBSD_version < 1300045 - vdrop(vp); -#endif + if (refcount_release_if_not_last(&vp->v_usecount)) return; - } VERIFY3U(taskq_dispatch((taskq_t *)taskq, (task_func_t *)vrele, vp, TQ_SLEEP), !=, 0); } diff --git a/module/os/freebsd/spl/spl_zone.c b/module/os/freebsd/spl/spl_zone.c index 658ef0bf056d..f75d45f9de88 100644 --- a/module/os/freebsd/spl/spl_zone.c +++ b/module/os/freebsd/spl/spl_zone.c @@ -66,7 +66,7 @@ zone_dataset_attach(struct ucred *cred, const char *dataset, int jailid) struct prison *pr; int dofree, error; - if ((error = spl_priv_check_cred(cred, PRIV_ZFS_JAIL)) != 0) + if ((error = priv_check_cred(cred, PRIV_ZFS_JAIL)) != 0) return (error); /* Allocate memory before we grab prison's mutex. */ @@ -119,7 +119,7 @@ zone_dataset_detach(struct ucred *cred, const char *dataset, int jailid) struct prison *pr; int error; - if ((error = spl_priv_check_cred(cred, PRIV_ZFS_JAIL)) != 0) + if ((error = priv_check_cred(cred, PRIV_ZFS_JAIL)) != 0) return (error); sx_slock(&allprison_lock); diff --git a/module/os/freebsd/zfs/crypto_os.c b/module/os/freebsd/zfs/crypto_os.c index 1f139ea5b807..889a840f8085 100644 --- a/module/os/freebsd/zfs/crypto_os.c +++ b/module/os/freebsd/zfs/crypto_os.c @@ -200,13 +200,6 @@ zfs_crypto_dispatch(freebsd_crypt_session_t *session, struct cryptop *crp) crp->crp_etype = 0; crp->crp_flags &= ~CRYPTO_F_DONE; session->fs_done = false; -#if __FreeBSD_version < 1300087 - /* - * Session ID changed, so we should record that, - * and try again - */ - session->fs_sid = crp->crp_session; -#endif } return (error); } @@ -253,7 +246,6 @@ freebsd_crypt_uio_debug_log(boolean_t encrypt, * happen every time the key changes (including when * it's first loaded). */ -#if __FreeBSD_version >= 1300087 int freebsd_crypt_newsession(freebsd_crypt_session_t *sessp, const struct zio_crypt_info *c_info, crypto_key_t *key) @@ -392,244 +384,3 @@ freebsd_crypt_uio(boolean_t encrypt, } return (error); } - -#else -int -freebsd_crypt_newsession(freebsd_crypt_session_t *sessp, - const struct zio_crypt_info *c_info, crypto_key_t *key) -{ - struct cryptoini cria = {0}, crie = {0}, *crip; - struct enc_xform *xform; - struct auth_hash *xauth; - int error = 0; - crypto_session_t sid; - -#ifdef FCRYPTO_DEBUG - printf("%s(%p, { %s, %d, %d, %s }, { %p, %u })\n", - __FUNCTION__, sessp, - c_info->ci_algname, c_info->ci_crypt_type, - (unsigned int)c_info->ci_keylen, c_info->ci_name, - key->ck_data, (unsigned int)key->ck_length); - printf("\tkey = { "); - for (int i = 0; i < key->ck_length / 8; i++) { - uint8_t *b = (uint8_t *)key->ck_data; - printf("%02x ", b[i]); - } - printf("}\n"); -#endif - switch (c_info->ci_crypt_type) { - case ZC_TYPE_GCM: - xform = &enc_xform_aes_nist_gcm; - switch (key->ck_length/8) { - case AES_128_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_128; - break; - case AES_192_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_192; - break; - case AES_256_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_256; - break; - default: - error = EINVAL; - goto bad; - } - break; - case ZC_TYPE_CCM: - xform = &enc_xform_ccm; - switch (key->ck_length/8) { - case AES_128_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_128; - break; - case AES_192_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_192; - break; - case AES_256_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_256; - break; - default: - error = EINVAL; - goto bad; - break; - } - break; - default: - error = ENOTSUP; - goto bad; - } -#ifdef FCRYPTO_DEBUG - printf("%s(%d): Using crypt %s (key length %u [%u bytes]), " - "auth %s (key length %d)\n", - __FUNCTION__, __LINE__, - xform->name, (unsigned int)key->ck_length, - (unsigned int)key->ck_length/8, - xauth->name, xauth->keysize); -#endif - - crie.cri_alg = xform->type; - crie.cri_key = key->ck_data; - crie.cri_klen = key->ck_length; - - cria.cri_alg = xauth->type; - cria.cri_key = key->ck_data; - cria.cri_klen = key->ck_length; - - cria.cri_next = &crie; - crie.cri_next = NULL; - crip = &cria; - // Everything else is zero-initialised - - error = crypto_newsession(&sid, crip, - CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE); - if (error != 0) { - printf("%s(%d): crypto_newsession failed with %d\n", - __FUNCTION__, __LINE__, error); - goto bad; - } - sessp->fs_sid = sid; - mtx_init(&sessp->fs_lock, "FreeBSD Cryptographic Session Lock", - NULL, MTX_DEF); - crypt_sessions++; -bad: - return (error); -} - -/* - * The meat of encryption/decryption. - * If sessp is NULL, then it will create a - * temporary cryptographic session, and release - * it when done. - */ -int -freebsd_crypt_uio(boolean_t encrypt, - freebsd_crypt_session_t *input_sessionp, - const struct zio_crypt_info *c_info, - zfs_uio_t *data_uio, - crypto_key_t *key, - uint8_t *ivbuf, - size_t datalen, - size_t auth_len) -{ - struct cryptop *crp; - struct cryptodesc *enc_desc, *auth_desc; - struct enc_xform *xform; - struct auth_hash *xauth; - freebsd_crypt_session_t *session = NULL; - int error; - - freebsd_crypt_uio_debug_log(encrypt, input_sessionp, c_info, data_uio, - key, ivbuf, datalen, auth_len); - switch (c_info->ci_crypt_type) { - case ZC_TYPE_GCM: - xform = &enc_xform_aes_nist_gcm; - switch (key->ck_length/8) { - case AES_128_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_128; - break; - case AES_192_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_192; - break; - case AES_256_GMAC_KEY_LEN: - xauth = &auth_hash_nist_gmac_aes_256; - break; - default: - error = EINVAL; - goto bad; - } - break; - case ZC_TYPE_CCM: - xform = &enc_xform_ccm; - switch (key->ck_length/8) { - case AES_128_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_128; - break; - case AES_192_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_192; - break; - case AES_256_CBC_MAC_KEY_LEN: - xauth = &auth_hash_ccm_cbc_mac_256; - break; - default: - error = EINVAL; - goto bad; - break; - } - break; - default: - error = ENOTSUP; - goto bad; - } - -#ifdef FCRYPTO_DEBUG - printf("%s(%d): Using crypt %s (key length %u [%u bytes]), " - "auth %s (key length %d)\n", - __FUNCTION__, __LINE__, - xform->name, (unsigned int)key->ck_length, - (unsigned int)key->ck_length/8, - xauth->name, xauth->keysize); -#endif - - if (input_sessionp == NULL) { - session = kmem_zalloc(sizeof (*session), KM_SLEEP); - error = freebsd_crypt_newsession(session, c_info, key); - if (error) - goto out; - } else - session = input_sessionp; - - crp = crypto_getreq(2); - if (crp == NULL) { - error = ENOMEM; - goto bad; - } - - auth_desc = crp->crp_desc; - enc_desc = auth_desc->crd_next; - - crp->crp_session = session->fs_sid; - crp->crp_ilen = auth_len + datalen; - crp->crp_buf = (void*)GET_UIO_STRUCT(data_uio); - crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIFSYNC; - - auth_desc->crd_skip = 0; - auth_desc->crd_len = auth_len; - auth_desc->crd_inject = auth_len + datalen; - auth_desc->crd_alg = xauth->type; -#ifdef FCRYPTO_DEBUG - printf("%s: auth: skip = %u, len = %u, inject = %u\n", - __FUNCTION__, auth_desc->crd_skip, auth_desc->crd_len, - auth_desc->crd_inject); -#endif - - enc_desc->crd_skip = auth_len; - enc_desc->crd_len = datalen; - enc_desc->crd_inject = auth_len; - enc_desc->crd_alg = xform->type; - enc_desc->crd_flags = CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT; - memcpy(enc_desc->crd_iv, ivbuf, ZIO_DATA_IV_LEN); - enc_desc->crd_next = NULL; - -#ifdef FCRYPTO_DEBUG - printf("%s: enc: skip = %u, len = %u, inject = %u\n", - __FUNCTION__, enc_desc->crd_skip, enc_desc->crd_len, - enc_desc->crd_inject); -#endif - - if (encrypt) - enc_desc->crd_flags |= CRD_F_ENCRYPT; - - error = zfs_crypto_dispatch(session, crp); - crypto_freereq(crp); -out: - if (input_sessionp == NULL) { - freebsd_crypt_freesession(session); - kmem_free(session, sizeof (*session)); - } -bad: -#ifdef FCRYPTO_DEBUG - if (error) - printf("%s: returning error %d\n", __FUNCTION__, error); -#endif - return (error); -} -#endif diff --git a/module/os/freebsd/zfs/dmu_os.c b/module/os/freebsd/zfs/dmu_os.c index c33ce01ab39b..e0ff69290d0c 100644 --- a/module/os/freebsd/zfs/dmu_os.c +++ b/module/os/freebsd/zfs/dmu_os.c @@ -63,20 +63,7 @@ __FBSDID("$FreeBSD$"); #define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT) #endif -#if __FreeBSD_version < 1300051 -#define VM_ALLOC_BUSY_FLAGS VM_ALLOC_NOBUSY -#else #define VM_ALLOC_BUSY_FLAGS VM_ALLOC_SBUSY | VM_ALLOC_IGN_SBUSY -#endif - - -#if __FreeBSD_version < 1300072 -#define dmu_page_lock(m) vm_page_lock(m) -#define dmu_page_unlock(m) vm_page_unlock(m) -#else -#define dmu_page_lock(m) -#define dmu_page_unlock(m) -#endif int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, @@ -170,7 +157,6 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, #endif vmobj = ma[0]->object; - zfs_vmobject_wlock_12(vmobj); db = dbp[0]; for (i = 0; i < *rbehind; i++) { @@ -180,7 +166,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, break; if (!vm_page_none_valid(m)) { ASSERT3U(m->valid, ==, VM_PAGE_BITS_ALL); - vm_page_do_sunbusy(m); + vm_page_sunbusy(m); break; } ASSERT3U(m->dirty, ==, 0); @@ -192,13 +178,11 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, memcpy(va, (char *)db->db_data + bufoff, PAGESIZE); zfs_unmap_page(sf); vm_page_valid(m); - dmu_page_lock(m); if ((m->busy_lock & VPB_BIT_WAITERS) != 0) vm_page_activate(m); else vm_page_deactivate(m); - dmu_page_unlock(m); - vm_page_do_sunbusy(m); + vm_page_sunbusy(m); } *rbehind = i; @@ -299,7 +283,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, break; if (!vm_page_none_valid(m)) { ASSERT3U(m->valid, ==, VM_PAGE_BITS_ALL); - vm_page_do_sunbusy(m); + vm_page_sunbusy(m); break; } ASSERT3U(m->dirty, ==, 0); @@ -317,16 +301,13 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count, } zfs_unmap_page(sf); vm_page_valid(m); - dmu_page_lock(m); if ((m->busy_lock & VPB_BIT_WAITERS) != 0) vm_page_activate(m); else vm_page_deactivate(m); - dmu_page_unlock(m); - vm_page_do_sunbusy(m); + vm_page_sunbusy(m); } *rahead = i; - zfs_vmobject_wunlock_12(vmobj); dmu_buf_rele_array(dbp, numbufs, FTAG); return (0); diff --git a/module/os/freebsd/zfs/event_os.c b/module/os/freebsd/zfs/event_os.c index e774fbaaf867..ace0fa734013 100644 --- a/module/os/freebsd/zfs/event_os.c +++ b/module/os/freebsd/zfs/event_os.c @@ -46,7 +46,6 @@ knlist_sx_xunlock(void *arg) sx_xunlock((struct sx *)arg); } -#if __FreeBSD_version >= 1300128 static void knlist_sx_assert_lock(void *arg, int what) { @@ -56,28 +55,10 @@ knlist_sx_assert_lock(void *arg, int what) else sx_assert((struct sx *)arg, SX_UNLOCKED); } -#else -static void -knlist_sx_assert_locked(void *arg) -{ - sx_assert((struct sx *)arg, SX_LOCKED); -} -static void -knlist_sx_assert_unlocked(void *arg) -{ - sx_assert((struct sx *)arg, SX_UNLOCKED); -} -#endif void knlist_init_sx(struct knlist *knl, struct sx *lock) { - -#if __FreeBSD_version >= 1300128 knlist_init(knl, lock, knlist_sx_xlock, knlist_sx_xunlock, knlist_sx_assert_lock); -#else - knlist_init(knl, lock, knlist_sx_xlock, knlist_sx_xunlock, - knlist_sx_assert_locked, knlist_sx_assert_unlocked); -#endif } diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index 9a268573528c..9fd8fe51cbd9 100644 --- a/module/os/freebsd/zfs/kmod_core.c +++ b/module/os/freebsd/zfs/kmod_core.c @@ -338,11 +338,7 @@ EVENTHANDLER_DEFINE(mountroot, spa_boot_init, NULL, 0); DECLARE_MODULE(zfsctrl, zfs_mod, SI_SUB_CLOCKS, SI_ORDER_ANY); MODULE_VERSION(zfsctrl, 1); -#if __FreeBSD_version > 1300092 MODULE_DEPEND(zfsctrl, xdr, 1, 1, 1); -#else -MODULE_DEPEND(zfsctrl, krpc, 1, 1, 1); -#endif MODULE_DEPEND(zfsctrl, acl_nfs4, 1, 1, 1); MODULE_DEPEND(zfsctrl, crypto, 1, 1, 1); MODULE_DEPEND(zfsctrl, zlib, 1, 1, 1); diff --git a/module/os/freebsd/zfs/vdev_geom.c b/module/os/freebsd/zfs/vdev_geom.c index 2df13e7e187e..4ec33606743f 100644 --- a/module/os/freebsd/zfs/vdev_geom.c +++ b/module/os/freebsd/zfs/vdev_geom.c @@ -379,11 +379,7 @@ vdev_geom_io(struct g_consumer *cp, int *cmds, void **datas, off_t *offsets, int i, n_bios, j; size_t bios_size; -#if __FreeBSD_version > 1300130 maxio = maxphys - (maxphys % cp->provider->sectorsize); -#else - maxio = MAXPHYS - (MAXPHYS % cp->provider->sectorsize); -#endif n_bios = 0; /* How many bios are required for all commands ? */ diff --git a/module/os/freebsd/zfs/zfs_ctldir.c b/module/os/freebsd/zfs/zfs_ctldir.c index a753e91da4fe..4d539461886b 100644 --- a/module/os/freebsd/zfs/zfs_ctldir.c +++ b/module/os/freebsd/zfs/zfs_ctldir.c @@ -733,7 +733,7 @@ zfsctl_root_vptocnp(struct vop_vptocnp_args *ap) if (error != 0) return (SET_ERROR(error)); - VOP_UNLOCK1(dvp); + VOP_UNLOCK(dvp); *ap->a_vpp = dvp; *ap->a_buflen -= sizeof (dotzfs_name); memcpy(ap->a_buf + *ap->a_buflen, dotzfs_name, sizeof (dotzfs_name)); @@ -814,12 +814,8 @@ zfsctl_common_getacl(struct vop_getacl_args *ap) static struct vop_vector zfsctl_ops_root = { .vop_default = &default_vnodeops, -#if __FreeBSD_version >= 1300121 .vop_fplookup_vexec = VOP_EAGAIN, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = VOP_EAGAIN, -#endif .vop_open = zfsctl_common_open, .vop_close = zfsctl_common_close, .vop_ioctl = VOP_EINVAL, @@ -1146,12 +1142,8 @@ zfsctl_snapdir_getattr(struct vop_getattr_args *ap) static struct vop_vector zfsctl_ops_snapdir = { .vop_default = &default_vnodeops, -#if __FreeBSD_version >= 1300121 .vop_fplookup_vexec = VOP_EAGAIN, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = VOP_EAGAIN, -#endif .vop_open = zfsctl_common_open, .vop_close = zfsctl_common_close, .vop_getattr = zfsctl_snapdir_getattr, @@ -1226,27 +1218,19 @@ zfsctl_snapshot_vptocnp(struct vop_vptocnp_args *ap) * before we can lock the vnode again. */ locked = VOP_ISLOCKED(vp); -#if __FreeBSD_version >= 1300045 enum vgetstate vs = vget_prep(vp); -#else - vhold(vp); -#endif vput(vp); /* Look up .zfs/snapshot, our parent. */ error = zfsctl_snapdir_vnode(vp->v_mount, NULL, LK_SHARED, &dvp); if (error == 0) { - VOP_UNLOCK1(dvp); + VOP_UNLOCK(dvp); *ap->a_vpp = dvp; *ap->a_buflen -= len; memcpy(ap->a_buf + *ap->a_buflen, node->sn_name, len); } vfs_unbusy(mp); -#if __FreeBSD_version >= 1300045 vget_finish(vp, locked | LK_RETRY, vs); -#else - vget(vp, locked | LK_VNHELD | LK_RETRY, curthread); -#endif return (error); } @@ -1256,18 +1240,12 @@ zfsctl_snapshot_vptocnp(struct vop_vptocnp_args *ap) */ static struct vop_vector zfsctl_ops_snapshot = { .vop_default = NULL, /* ensure very restricted access */ -#if __FreeBSD_version >= 1300121 .vop_fplookup_vexec = VOP_EAGAIN, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = VOP_EAGAIN, -#endif .vop_open = zfsctl_common_open, .vop_close = zfsctl_common_close, .vop_inactive = zfsctl_snapshot_inactive, -#if __FreeBSD_version >= 1300045 - .vop_need_inactive = vop_stdneed_inactive, -#endif + .vop_need_inactive = vop_stdneed_inactive, .vop_reclaim = zfsctl_snapshot_reclaim, .vop_vptocnp = zfsctl_snapshot_vptocnp, .vop_lock1 = vop_stdlock, diff --git a/module/os/freebsd/zfs/zfs_dir.c b/module/os/freebsd/zfs/zfs_dir.c index 3cdb94d6cd53..00d499c8c63e 100644 --- a/module/os/freebsd/zfs/zfs_dir.c +++ b/module/os/freebsd/zfs/zfs_dir.c @@ -824,7 +824,7 @@ zfs_make_xattrdir(znode_t *zp, vattr_t *vap, znode_t **xvpp, cred_t *cr) return (SET_ERROR(EDQUOT)); } - getnewvnode_reserve_(); + getnewvnode_reserve(); tx = dmu_tx_create(zfsvfs->z_os); dmu_tx_hold_sa_create(tx, acl_ids.z_aclp->z_acl_bytes + @@ -926,7 +926,7 @@ zfs_get_xattrdir(znode_t *zp, znode_t **xzpp, cred_t *cr, int flags) goto top; } if (error == 0) - VOP_UNLOCK1(ZTOV(*xzpp)); + VOP_UNLOCK(ZTOV(*xzpp)); return (error); } diff --git a/module/os/freebsd/zfs/zfs_file_os.c b/module/os/freebsd/zfs/zfs_file_os.c index 77fedf7c36b6..b314489378f7 100644 --- a/module/os/freebsd/zfs/zfs_file_os.c +++ b/module/os/freebsd/zfs/zfs_file_os.c @@ -273,7 +273,7 @@ zfs_vop_fsync(vnode_t *vp) goto drop; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_FSYNC(vp, MNT_WAIT, curthread); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); vn_finished_write(mp); drop: return (SET_ERROR(error)); @@ -347,14 +347,6 @@ zfs_file_unlink(const char *fnamep) zfs_uio_seg_t seg = UIO_SYSSPACE; int rc; -#if __FreeBSD_version >= 1300018 rc = kern_funlinkat(curthread, AT_FDCWD, fnamep, FD_NONE, seg, 0, 0); -#elif __FreeBSD_version >= 1202504 || defined(AT_BENEATH) - rc = kern_unlinkat(curthread, AT_FDCWD, __DECONST(char *, fnamep), - seg, 0, 0); -#else - rc = kern_unlinkat(curthread, AT_FDCWD, __DECONST(char *, fnamep), - seg, 0); -#endif return (SET_ERROR(rc)); } diff --git a/module/os/freebsd/zfs/zfs_ioctl_os.c b/module/os/freebsd/zfs/zfs_ioctl_os.c index a835e013d630..a88f62aa08a1 100644 --- a/module/os/freebsd/zfs/zfs_ioctl_os.c +++ b/module/os/freebsd/zfs/zfs_ioctl_os.c @@ -39,10 +39,6 @@ __FBSDID("$FreeBSD$"); #include -#if __FreeBSD_version < 1201517 -#define vm_page_max_user_wired vm_page_max_wired -#endif - int zfs_vfs_ref(zfsvfs_t **zfvp) { diff --git a/module/os/freebsd/zfs/zfs_vfsops.c b/module/os/freebsd/zfs/zfs_vfsops.c index a972c720dfdb..a60195493550 100644 --- a/module/os/freebsd/zfs/zfs_vfsops.c +++ b/module/os/freebsd/zfs/zfs_vfsops.c @@ -126,25 +126,16 @@ static int zfs_root(vfs_t *vfsp, int flags, vnode_t **vpp); static int zfs_statfs(vfs_t *vfsp, struct statfs *statp); static int zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp); static int zfs_sync(vfs_t *vfsp, int waitfor); -#if __FreeBSD_version >= 1300098 static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, uint64_t *extflagsp, struct ucred **credanonp, int *numsecflavors, int *secflavors); -#else -static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, - struct ucred **credanonp, int *numsecflavors, int **secflavors); -#endif static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp); static void zfs_freevfs(vfs_t *vfsp); struct vfsops zfs_vfsops = { .vfs_mount = zfs_mount, .vfs_unmount = zfs_umount, -#if __FreeBSD_version >= 1300049 .vfs_root = vfs_cache_root, - .vfs_cachedroot = zfs_root, -#else - .vfs_root = zfs_root, -#endif + .vfs_cachedroot = zfs_root, .vfs_statfs = zfs_statfs, .vfs_vget = zfs_vget, .vfs_sync = zfs_sync, @@ -1357,16 +1348,16 @@ zfs_mount(vfs_t *vfsp) vn_lock(mvp, LK_SHARED | LK_RETRY); if (VOP_GETATTR(mvp, &vattr, cr)) { - VOP_UNLOCK1(mvp); + VOP_UNLOCK(mvp); goto out; } if (secpolicy_vnode_owner(mvp, cr, vattr.va_uid) != 0 && VOP_ACCESS(mvp, VWRITE, cr, td) != 0) { - VOP_UNLOCK1(mvp); + VOP_UNLOCK(mvp); goto out; } - VOP_UNLOCK1(mvp); + VOP_UNLOCK(mvp); } secpolicy_fs_mount_clearopts(cr, vfsp); @@ -1578,11 +1569,7 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting) * 'z_parent' is self referential for non-snapshots. */ #ifdef FREEBSD_NAMECACHE -#if __FreeBSD_version >= 1300117 cache_purgevfs(zfsvfs->z_parent->z_vfs); -#else - cache_purgevfs(zfsvfs->z_parent->z_vfs, true); -#endif #endif } @@ -1775,13 +1762,8 @@ zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp) } static int -#if __FreeBSD_version >= 1300098 zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, uint64_t *extflagsp, struct ucred **credanonp, int *numsecflavors, int *secflavors) -#else -zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, - struct ucred **credanonp, int *numsecflavors, int **secflavors) -#endif { zfsvfs_t *zfsvfs = vfsp->vfs_data; @@ -2070,10 +2052,8 @@ zfs_vnodes_adjust_back(void) #endif } -#if __FreeBSD_version >= 1300139 static struct sx zfs_vnlru_lock; static struct vnode *zfs_vnlru_marker; -#endif static arc_prune_t *zfs_prune; static void @@ -2081,13 +2061,9 @@ zfs_prune_task(uint64_t nr_to_scan, void *arg __unused) { if (nr_to_scan > INT_MAX) nr_to_scan = INT_MAX; -#if __FreeBSD_version >= 1300139 sx_xlock(&zfs_vnlru_lock); vnlru_free_vfsops(nr_to_scan, &zfs_vfsops, zfs_vnlru_marker); sx_xunlock(&zfs_vnlru_lock); -#else - vnlru_free(nr_to_scan, &zfs_vfsops); -#endif } void @@ -2117,10 +2093,8 @@ zfs_init(void) zfsvfs_taskq = taskq_create("zfsvfs", 1, minclsyspri, 0, 0, 0); -#if __FreeBSD_version >= 1300139 zfs_vnlru_marker = vnlru_alloc_marker(); sx_init(&zfs_vnlru_lock, "zfs vnlru lock"); -#endif zfs_prune = arc_add_prune_callback(zfs_prune_task, NULL); } @@ -2128,10 +2102,8 @@ void zfs_fini(void) { arc_remove_prune_callback(zfs_prune); -#if __FreeBSD_version >= 1300139 vnlru_free_marker(zfs_vnlru_marker); sx_destroy(&zfs_vnlru_lock); -#endif taskq_destroy(zfsvfs_taskq); zfsctl_fini(); diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index 68cf570748d5..fa3dd58e214f 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -39,9 +39,7 @@ #include #include #include -#if __FreeBSD_version >= 1300102 #include -#endif #include #include #include @@ -100,18 +98,6 @@ VFS_SMR_DECLARE; -#if __FreeBSD_version < 1300103 -#define NDFREE_PNBUF(ndp) NDFREE((ndp), NDF_ONLY_PNBUF) -#endif - -#if __FreeBSD_version >= 1300047 -#define vm_page_wire_lock(pp) -#define vm_page_wire_unlock(pp) -#else -#define vm_page_wire_lock(pp) vm_page_lock(pp) -#define vm_page_wire_unlock(pp) vm_page_unlock(pp) -#endif - #ifdef DEBUG_VFS_LOCKS #define VNCHECKREF(vp) \ VNASSERT((vp)->v_holdcnt > 0 && (vp)->v_usecount > 0, vp, \ @@ -332,39 +318,6 @@ page_busy(vnode_t *vp, int64_t start, int64_t off, int64_t nbytes) nbytes = end - off; obj = vp->v_object; - zfs_vmobject_assert_wlocked_12(obj); -#if __FreeBSD_version < 1300050 - for (;;) { - if ((pp = vm_page_lookup(obj, OFF_TO_IDX(start))) != NULL && - pp->valid) { - if (vm_page_xbusied(pp)) { - /* - * Reference the page before unlocking and - * sleeping so that the page daemon is less - * likely to reclaim it. - */ - vm_page_reference(pp); - vm_page_lock(pp); - zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb", true); - zfs_vmobject_wlock(obj); - continue; - } - vm_page_sbusy(pp); - } else if (pp != NULL) { - ASSERT(!pp->valid); - pp = NULL; - } - if (pp != NULL) { - ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL); - vm_object_pip_add(obj, 1); - pmap_remove_write(pp); - if (nbytes != 0) - vm_page_clear_dirty(pp, off, nbytes); - } - break; - } -#else vm_page_grab_valid_unlocked(&pp, obj, OFF_TO_IDX(start), VM_ALLOC_NOCREAT | VM_ALLOC_SBUSY | VM_ALLOC_NORMAL | VM_ALLOC_IGN_SBUSY); @@ -375,7 +328,6 @@ page_busy(vnode_t *vp, int64_t start, int64_t off, int64_t nbytes) if (nbytes != 0) vm_page_clear_dirty(pp, off, nbytes); } -#endif return (pp); } @@ -384,14 +336,9 @@ page_unbusy(vm_page_t pp) { vm_page_sunbusy(pp); -#if __FreeBSD_version >= 1300041 vm_object_pip_wakeup(pp->object); -#else - vm_object_pip_subtract(pp->object, 1); -#endif } -#if __FreeBSD_version > 1300051 static vm_page_t page_hold(vnode_t *vp, int64_t start) { @@ -404,57 +351,11 @@ page_hold(vnode_t *vp, int64_t start) VM_ALLOC_NOBUSY); return (m); } -#else -static vm_page_t -page_hold(vnode_t *vp, int64_t start) -{ - vm_object_t obj; - vm_page_t pp; - - obj = vp->v_object; - zfs_vmobject_assert_wlocked(obj); - - for (;;) { - if ((pp = vm_page_lookup(obj, OFF_TO_IDX(start))) != NULL && - pp->valid) { - if (vm_page_xbusied(pp)) { - /* - * Reference the page before unlocking and - * sleeping so that the page daemon is less - * likely to reclaim it. - */ - vm_page_reference(pp); - vm_page_lock(pp); - zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb", true); - zfs_vmobject_wlock(obj); - continue; - } - - ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL); - vm_page_wire_lock(pp); - vm_page_hold(pp); - vm_page_wire_unlock(pp); - - } else - pp = NULL; - break; - } - return (pp); -} -#endif static void page_unhold(vm_page_t pp) { - - vm_page_wire_lock(pp); -#if __FreeBSD_version >= 1300035 vm_page_unwire(pp, PQ_ACTIVE); -#else - vm_page_unhold(pp); -#endif - vm_page_wire_unlock(pp); } /* @@ -478,34 +379,22 @@ update_pages(znode_t *zp, int64_t start, int len, objset_t *os) ASSERT3P(obj, !=, NULL); off = start & PAGEOFFSET; - zfs_vmobject_wlock_12(obj); -#if __FreeBSD_version >= 1300041 vm_object_pip_add(obj, 1); -#endif for (start &= PAGEMASK; len > 0; start += PAGESIZE) { vm_page_t pp; int nbytes = imin(PAGESIZE - off, len); if ((pp = page_busy(vp, start, off, nbytes)) != NULL) { - zfs_vmobject_wunlock_12(obj); - va = zfs_map_page(pp, &sf); (void) dmu_read(os, zp->z_id, start + off, nbytes, va + off, DMU_READ_PREFETCH); zfs_unmap_page(sf); - - zfs_vmobject_wlock_12(obj); page_unbusy(pp); } len -= nbytes; off = 0; } -#if __FreeBSD_version >= 1300041 vm_object_pip_wakeup(obj); -#else - vm_object_pip_wakeupn(obj, 0); -#endif - zfs_vmobject_wunlock_12(obj); } /* @@ -536,26 +425,22 @@ mappedread_sf(znode_t *zp, int nbytes, zfs_uio_t *uio) ASSERT3P(obj, !=, NULL); ASSERT0(zfs_uio_offset(uio) & PAGEOFFSET); - zfs_vmobject_wlock_12(obj); for (start = zfs_uio_offset(uio); len > 0; start += PAGESIZE) { int bytes = MIN(PAGESIZE, len); pp = vm_page_grab_unlocked(obj, OFF_TO_IDX(start), VM_ALLOC_SBUSY | VM_ALLOC_NORMAL | VM_ALLOC_IGN_SBUSY); if (vm_page_none_valid(pp)) { - zfs_vmobject_wunlock_12(obj); va = zfs_map_page(pp, &sf); error = dmu_read(os, zp->z_id, start, bytes, va, DMU_READ_PREFETCH); if (bytes != PAGESIZE && error == 0) memset(va + bytes, 0, PAGESIZE - bytes); zfs_unmap_page(sf); - zfs_vmobject_wlock_12(obj); -#if __FreeBSD_version >= 1300081 if (error == 0) { vm_page_valid(pp); vm_page_activate(pp); - vm_page_do_sunbusy(pp); + vm_page_sunbusy(pp); } else { zfs_vmobject_wlock(obj); if (!vm_page_wired(pp) && pp->valid == 0 && @@ -565,29 +450,15 @@ mappedread_sf(znode_t *zp, int nbytes, zfs_uio_t *uio) vm_page_sunbusy(pp); zfs_vmobject_wunlock(obj); } -#else - vm_page_do_sunbusy(pp); - vm_page_lock(pp); - if (error) { - if (pp->wire_count == 0 && pp->valid == 0 && - !vm_page_busied(pp)) - vm_page_free(pp); - } else { - pp->valid = VM_PAGE_BITS_ALL; - vm_page_activate(pp); - } - vm_page_unlock(pp); -#endif } else { ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL); - vm_page_do_sunbusy(pp); + vm_page_sunbusy(pp); } if (error) break; zfs_uio_advance(uio, bytes); len -= bytes; } - zfs_vmobject_wunlock_12(obj); return (error); } @@ -617,7 +488,6 @@ mappedread(znode_t *zp, int nbytes, zfs_uio_t *uio) start = zfs_uio_offset(uio); off = start & PAGEOFFSET; - zfs_vmobject_wlock_12(obj); for (start &= PAGEMASK; len > 0; start += PAGESIZE) { vm_page_t pp; uint64_t bytes = MIN(PAGESIZE - off, len); @@ -626,25 +496,20 @@ mappedread(znode_t *zp, int nbytes, zfs_uio_t *uio) struct sf_buf *sf; caddr_t va; - zfs_vmobject_wunlock_12(obj); va = zfs_map_page(pp, &sf); error = vn_io_fault_uiomove(va + off, bytes, GET_UIO_STRUCT(uio)); zfs_unmap_page(sf); - zfs_vmobject_wlock_12(obj); page_unhold(pp); } else { - zfs_vmobject_wunlock_12(obj); error = dmu_read_uio_dbuf(sa_get_db(zp->z_sa_hdl), uio, bytes); - zfs_vmobject_wlock_12(obj); } len -= bytes; off = 0; if (error) break; } - zfs_vmobject_wunlock_12(obj); return (error); } @@ -780,9 +645,7 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, znode_t *zdp = VTOZ(dvp); znode_t *zp; zfsvfs_t *zfsvfs = zdp->z_zfsvfs; -#if __FreeBSD_version > 1300124 seqc_t dvp_seqc; -#endif int error = 0; /* @@ -808,9 +671,7 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, if ((error = zfs_enter_verify_zp(zfsvfs, zdp, FTAG)) != 0) return (error); -#if __FreeBSD_version > 1300124 dvp_seqc = vn_seqc_read_notmodify(dvp); -#endif *vpp = NULL; @@ -889,7 +750,7 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, zfs_exit(zfsvfs, FTAG); ltype = VOP_ISLOCKED(dvp); - VOP_UNLOCK1(dvp); + VOP_UNLOCK(dvp); error = zfsctl_root(zfsvfs->z_parent, LK_SHARED, &zfsctl_vp); if (error == 0) { @@ -990,7 +851,6 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, } } -#if __FreeBSD_version > 1300124 if ((cnp->cn_flags & ISDOTDOT) != 0) { /* * FIXME: zfs_lookup_lock relocks vnodes and does nothing to @@ -1008,7 +868,6 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, cnp->cn_flags &= ~MAKEENTRY; } } -#endif /* Insert name into cache (as non-existent) if appropriate. */ if (zfsvfs->z_use_namecache && !zfsvfs->z_replay && @@ -1143,7 +1002,7 @@ zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode, goto out; } - getnewvnode_reserve_(); + getnewvnode_reserve(); tx = dmu_tx_create(os); @@ -1177,7 +1036,7 @@ zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode, * delete the newly created dnode. */ zfs_znode_delete(zp, tx); - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); zrele(zp); zfs_acl_ids_free(&acl_ids); dmu_tx_commit(tx); @@ -1506,7 +1365,7 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp, /* * Add a new entry to the directory. */ - getnewvnode_reserve_(); + getnewvnode_reserve(); tx = dmu_tx_create(zfsvfs->z_os); dmu_tx_hold_zap(tx, dzp->z_id, TRUE, dirname); dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL); @@ -1541,7 +1400,7 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp, error = zfs_link_create(dzp, dirname, zp, tx, ZNEW); if (error != 0) { zfs_znode_delete(zp, tx); - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); zrele(zp); goto out; } @@ -1569,16 +1428,6 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp, return (error); } -#if __FreeBSD_version < 1300124 -static void -cache_vop_rmdir(struct vnode *dvp, struct vnode *vp) -{ - - cache_purge(dvp); - cache_purge(vp); -} -#endif - /* * Remove a directory subdir entry. If the current working * directory is the same as the subdir to be removed, the @@ -2976,9 +2825,9 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, znode_t *sdzp, *tdzp, *szp, *tzp; int error; - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(tdvp); if (*tvpp != NULL && *tvpp != tdvp) - VOP_UNLOCK1(*tvpp); + VOP_UNLOCK(*tvpp); relock: error = vn_lock(sdvp, LK_EXCLUSIVE); @@ -2986,13 +2835,13 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, goto out; error = vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT); if (error != 0) { - VOP_UNLOCK1(sdvp); + VOP_UNLOCK(sdvp); if (error != EBUSY) goto out; error = vn_lock(tdvp, LK_EXCLUSIVE); if (error) goto out; - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(tdvp); goto relock; } tdzp = VTOZ(tdvp); @@ -3000,8 +2849,8 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, error = zfs_rename_relock_lookup(sdzp, scnp, &szp, tdzp, tcnp, &tzp); if (error != 0) { - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(sdvp); + VOP_UNLOCK(tdvp); goto out; } svp = ZTOV(szp); @@ -3013,8 +2862,8 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, nvp = svp; error = vn_lock(nvp, LK_EXCLUSIVE | LK_NOWAIT); if (error != 0) { - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(sdvp); + VOP_UNLOCK(tdvp); if (tvp != NULL) vrele(tvp); if (error != EBUSY) { @@ -3026,7 +2875,7 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, vrele(nvp); goto out; } - VOP_UNLOCK1(nvp); + VOP_UNLOCK(nvp); /* * Concurrent rename race. * XXX ? @@ -3050,9 +2899,9 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, nvp = tvp; error = vn_lock(nvp, LK_EXCLUSIVE | LK_NOWAIT); if (error != 0) { - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(tdvp); - VOP_UNLOCK1(*svpp); + VOP_UNLOCK(sdvp); + VOP_UNLOCK(tdvp); + VOP_UNLOCK(*svpp); if (error != EBUSY) { vrele(nvp); goto out; @@ -3129,19 +2978,6 @@ zfs_rename_check(znode_t *szp, znode_t *sdzp, znode_t *tdzp) return (error); } -#if __FreeBSD_version < 1300124 -static void -cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp, - struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp) -{ - - cache_purge(fvp); - if (tvp != NULL) - cache_purge(tvp); - cache_purge_negative(tdvp); -} -#endif - static int zfs_do_rename_impl(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, vnode_t *tdvp, vnode_t **tvpp, struct componentname *tcnp, @@ -3197,13 +3033,13 @@ zfs_do_rename(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, } error = zfs_do_rename_impl(sdvp, svpp, scnp, tdvp, tvpp, tcnp, cr); - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(*svpp); + VOP_UNLOCK(sdvp); + VOP_UNLOCK(*svpp); out: if (*tvpp != NULL) - VOP_UNLOCK1(*tvpp); + VOP_UNLOCK(*tvpp); if (tdvp != *tvpp) - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(tdvp); return (error); } @@ -3455,17 +3291,17 @@ zfs_rename(znode_t *sdzp, const char *sname, znode_t *tdzp, const char *tname, tdvp = ZTOV(tdzp); error = zfs_lookup_internal(sdzp, sname, &svp, &scn, DELETE); if (sdzp->z_zfsvfs->z_replay == B_FALSE) - VOP_UNLOCK1(sdvp); + VOP_UNLOCK(sdvp); if (error != 0) goto fail; - VOP_UNLOCK1(svp); + VOP_UNLOCK(svp); vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY); error = zfs_lookup_internal(tdzp, tname, &tvp, &tcn, RENAME); if (error == EJUSTRETURN) tvp = NULL; else if (error != 0) { - VOP_UNLOCK1(tdvp); + VOP_UNLOCK(tdvp); goto fail; } @@ -3556,7 +3392,7 @@ zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap, return (SET_ERROR(EDQUOT)); } - getnewvnode_reserve_(); + getnewvnode_reserve(); tx = dmu_tx_create(zfsvfs->z_os); fuid_dirtied = zfsvfs->z_fuid_dirty; dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, MAX(1, len)); @@ -3603,7 +3439,7 @@ zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap, error = zfs_link_create(dzp, name, zp, tx, ZNEW); if (error != 0) { zfs_znode_delete(zp, tx); - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); zrele(zp); } else { zfs_log_symlink(zilog, tx, txtype, dzp, zp, name, link); @@ -4461,7 +4297,6 @@ zfs_freebsd_write(struct vop_write_args *ap) ap->a_cred)); } -#if __FreeBSD_version >= 1300102 /* * VOP_FPLOOKUP_VEXEC routines are subject to special circumstances, see * the comment above cache_fplookup for details. @@ -4486,9 +4321,7 @@ zfs_freebsd_fplookup_vexec(struct vop_fplookup_vexec_args *v) return (EAGAIN); return (0); } -#endif -#if __FreeBSD_version >= 1300139 static int zfs_freebsd_fplookup_symlink(struct vop_fplookup_symlink_args *v) { @@ -4508,7 +4341,6 @@ zfs_freebsd_fplookup_symlink(struct vop_fplookup_symlink_args *v) } return (cache_symlink_resolve(v->a_fpl, target, strlen(target))); } -#endif #ifndef _SYS_SYSPROTO_H_ struct vop_access_args { @@ -4546,13 +4378,8 @@ zfs_freebsd_access(struct vop_access_args *ap) if (error == 0) { accmode = ap->a_accmode & ~(VREAD|VWRITE|VEXEC|VAPPEND); if (accmode != 0) { -#if __FreeBSD_version >= 1300105 error = vaccess(vp->v_type, zp->z_mode, zp->z_uid, zp->z_gid, accmode, ap->a_cred); -#else - error = vaccess(vp->v_type, zp->z_mode, zp->z_uid, - zp->z_gid, accmode, ap->a_cred, NULL); -#endif } } @@ -4887,7 +4714,7 @@ zfs_freebsd_setattr(struct vop_setattr_args *ap) * otherwise, they behave like unprivileged processes. */ if (secpolicy_fs_owner(vp->v_mount, cred) == 0 || - spl_priv_check_cred(cred, PRIV_VFS_SYSFLAGS) == 0) { + priv_check_cred(cred, PRIV_VFS_SYSFLAGS) == 0) { if (zflags & (ZFS_IMMUTABLE | ZFS_APPENDONLY | ZFS_NOUNLINK)) { error = securelevel_gt(cred, 0); @@ -5006,10 +4833,8 @@ zfs_freebsd_symlink(struct vop_symlink_args *ap) struct componentname *cnp = ap->a_cnp; vattr_t *vap = ap->a_vap; znode_t *zp = NULL; -#if __FreeBSD_version >= 1300139 char *symlink; size_t symlink_len; -#endif int rc; #if __FreeBSD_version < 1400068 @@ -5025,7 +4850,6 @@ zfs_freebsd_symlink(struct vop_symlink_args *ap) if (rc == 0) { *ap->a_vpp = ZTOV(zp); ASSERT_VOP_ELOCKED(ZTOV(zp), __func__); -#if __FreeBSD_version >= 1300139 MPASS(zp->z_cached_symlink == NULL); symlink_len = strlen(ap->a_target); symlink = cache_symlink_alloc(symlink_len + 1, M_WAITOK); @@ -5035,7 +4859,6 @@ zfs_freebsd_symlink(struct vop_symlink_args *ap) atomic_store_rel_ptr((uintptr_t *)&zp->z_cached_symlink, (uintptr_t)symlink); } -#endif } return (rc); } @@ -5053,15 +4876,12 @@ zfs_freebsd_readlink(struct vop_readlink_args *ap) { zfs_uio_t uio; int error; -#if __FreeBSD_version >= 1300139 znode_t *zp = VTOZ(ap->a_vp); char *symlink, *base; size_t symlink_len; bool trycache; -#endif zfs_uio_init(&uio, ap->a_uio); -#if __FreeBSD_version >= 1300139 trycache = false; if (zfs_uio_segflg(&uio) == UIO_SYSSPACE && zfs_uio_iovcnt(&uio) == 1) { @@ -5069,9 +4889,7 @@ zfs_freebsd_readlink(struct vop_readlink_args *ap) symlink_len = zfs_uio_iovlen(&uio, 0); trycache = true; } -#endif error = zfs_readlink(ap->a_vp, &uio, ap->a_cred, NULL); -#if __FreeBSD_version >= 1300139 if (atomic_load_ptr(&zp->z_cached_symlink) != NULL || error != 0 || !trycache) { return (error); @@ -5086,7 +4904,6 @@ zfs_freebsd_readlink(struct vop_readlink_args *ap) cache_symlink_free(symlink, symlink_len + 1); } } -#endif return (error); } @@ -5128,15 +4945,10 @@ zfs_freebsd_inactive(struct vop_inactive_args *ap) { vnode_t *vp = ap->a_vp; -#if __FreeBSD_version >= 1300123 zfs_inactive(vp, curthread->td_ucred, NULL); -#else - zfs_inactive(vp, ap->a_td->td_ucred, NULL); -#endif return (0); } -#if __FreeBSD_version >= 1300042 #ifndef _SYS_SYSPROTO_H_ struct vop_need_inactive_args { struct vnode *a_vp; @@ -5162,7 +4974,6 @@ zfs_freebsd_need_inactive(struct vop_need_inactive_args *ap) return (need); } -#endif #ifndef _SYS_SYSPROTO_H_ struct vop_reclaim_args { @@ -5180,10 +4991,6 @@ zfs_freebsd_reclaim(struct vop_reclaim_args *ap) ASSERT3P(zp, !=, NULL); -#if __FreeBSD_version < 1300042 - /* Destroy the vm object and flush associated pages. */ - vnode_destroy_vobject(vp); -#endif /* * z_teardown_inactive_lock protects from a race with * zfs_znode_dmu_fini in zfsvfs_teardown during @@ -5394,7 +5201,7 @@ zfs_getextattr_dir(struct vop_getextattr_args *ap, const char *attrname) } else if (ap->a_uio != NULL) error = VOP_READ(vp, ap->a_uio, IO_UNIT, ap->a_cred); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); vn_close(vp, flags, ap->a_cred, td); return (error); } @@ -5681,7 +5488,7 @@ zfs_setextattr_dir(struct vop_setextattr_args *ap, const char *attrname) if (error == 0) VOP_WRITE(vp, ap->a_uio, IO_UNIT, ap->a_cred); - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); vn_close(vp, flags, ap->a_cred, td); return (error); } @@ -6164,26 +5971,13 @@ zfs_vptocnp(struct vop_vptocnp_args *ap) zfs_exit(zfsvfs, FTAG); covered_vp = vp->v_mount->mnt_vnodecovered; -#if __FreeBSD_version >= 1300045 enum vgetstate vs = vget_prep(covered_vp); -#else - vhold(covered_vp); -#endif ltype = VOP_ISLOCKED(vp); - VOP_UNLOCK1(vp); -#if __FreeBSD_version >= 1300045 + VOP_UNLOCK(vp); error = vget_finish(covered_vp, LK_SHARED, vs); -#else - error = vget(covered_vp, LK_SHARED | LK_VNHELD, curthread); -#endif if (error == 0) { -#if __FreeBSD_version >= 1300123 error = VOP_VPTOCNP(covered_vp, ap->a_vpp, ap->a_buf, ap->a_buflen); -#else - error = VOP_VPTOCNP(covered_vp, ap->a_vpp, ap->a_cred, - ap->a_buf, ap->a_buflen); -#endif vput(covered_vp); } vn_lock(vp, ltype | LK_RETRY); @@ -6241,7 +6035,6 @@ zfs_deallocate(struct vop_deallocate_args *ap) } #endif -#if __FreeBSD_version >= 1300039 #ifndef _SYS_SYSPROTO_H_ struct vop_copy_file_range_args { struct vnode *a_invp; @@ -6341,7 +6134,6 @@ zfs_freebsd_copy_file_range(struct vop_copy_file_range_args *ap) ap->a_incred, ap->a_outcred, ap->a_fsizetd); return (error); } -#endif struct vop_vector zfs_vnodeops; struct vop_vector zfs_fifoops; @@ -6350,16 +6142,10 @@ struct vop_vector zfs_shareops; struct vop_vector zfs_vnodeops = { .vop_default = &default_vnodeops, .vop_inactive = zfs_freebsd_inactive, -#if __FreeBSD_version >= 1300042 .vop_need_inactive = zfs_freebsd_need_inactive, -#endif .vop_reclaim = zfs_freebsd_reclaim, -#if __FreeBSD_version >= 1300102 .vop_fplookup_vexec = zfs_freebsd_fplookup_vexec, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = zfs_freebsd_fplookup_symlink, -#endif .vop_access = zfs_freebsd_access, .vop_allocate = VOP_EINVAL, #if __FreeBSD_version >= 1400032 @@ -6398,29 +6184,21 @@ struct vop_vector zfs_vnodeops = { .vop_getpages = zfs_freebsd_getpages, .vop_putpages = zfs_freebsd_putpages, .vop_vptocnp = zfs_vptocnp, -#if __FreeBSD_version >= 1300064 .vop_lock1 = vop_lock, .vop_unlock = vop_unlock, .vop_islocked = vop_islocked, -#endif #if __FreeBSD_version >= 1400043 .vop_add_writecount = vop_stdadd_writecount_nomsync, #endif -#if __FreeBSD_version >= 1300039 .vop_copy_file_range = zfs_freebsd_copy_file_range, -#endif }; VFS_VOP_VECTOR_REGISTER(zfs_vnodeops); struct vop_vector zfs_fifoops = { .vop_default = &fifo_specops, .vop_fsync = zfs_freebsd_fsync, -#if __FreeBSD_version >= 1300102 - .vop_fplookup_vexec = zfs_freebsd_fplookup_vexec, -#endif -#if __FreeBSD_version >= 1300139 + .vop_fplookup_vexec = zfs_freebsd_fplookup_vexec, .vop_fplookup_symlink = zfs_freebsd_fplookup_symlink, -#endif .vop_access = zfs_freebsd_access, .vop_getattr = zfs_freebsd_getattr, .vop_inactive = zfs_freebsd_inactive, @@ -6444,12 +6222,8 @@ VFS_VOP_VECTOR_REGISTER(zfs_fifoops); */ struct vop_vector zfs_shareops = { .vop_default = &default_vnodeops, -#if __FreeBSD_version >= 1300121 .vop_fplookup_vexec = VOP_EAGAIN, -#endif -#if __FreeBSD_version >= 1300139 .vop_fplookup_symlink = VOP_EAGAIN, -#endif .vop_access = zfs_freebsd_access, .vop_inactive = zfs_freebsd_inactive, .vop_reclaim = zfs_freebsd_reclaim, diff --git a/module/os/freebsd/zfs/zfs_znode.c b/module/os/freebsd/zfs/zfs_znode.c index afbea9798c33..e5c50874e1dd 100644 --- a/module/os/freebsd/zfs/zfs_znode.c +++ b/module/os/freebsd/zfs/zfs_znode.c @@ -92,7 +92,7 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, znode, CTLFLAG_RD, * (such as VFS logic) that will not compile easily in userland. */ #ifdef _KERNEL -#if !defined(KMEM_DEBUG) && __FreeBSD_version >= 1300102 +#if !defined(KMEM_DEBUG) #define _ZFS_USE_SMR static uma_zone_t znode_uma_zone; #else @@ -434,13 +434,8 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, ("%s: fast path lookup enabled without smr", __func__)); #endif -#if __FreeBSD_version >= 1300076 KASSERT(curthread->td_vp_reserved != NULL, ("zfs_znode_alloc: getnewvnode without any vnodes reserved")); -#else - KASSERT(curthread->td_vp_reserv > 0, - ("zfs_znode_alloc: getnewvnode without any vnodes reserved")); -#endif error = getnewvnode("zfs", zfsvfs->z_parent->z_vfs, &zfs_vnodeops, &vp); if (error != 0) { zfs_znode_free_kmem(zp); @@ -468,9 +463,7 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, zp->z_sync_cnt = 0; zp->z_sync_writes_cnt = 0; zp->z_async_writes_cnt = 0; -#if __FreeBSD_version >= 1300139 atomic_store_ptr(&zp->z_cached_symlink, NULL); -#endif zfs_znode_sa_init(zfsvfs, zp, db, obj_type, hdl); @@ -942,7 +935,7 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp) int locked; int err; - getnewvnode_reserve_(); + getnewvnode_reserve(); again: *zpp = NULL; ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num); @@ -1055,7 +1048,7 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp) err = insmntque(vp, zfsvfs->z_vfs); if (err == 0) { vp->v_hash = obj_num; - VOP_UNLOCK1(vp); + VOP_UNLOCK(vp); } else { zp->z_vnode = NULL; zfs_znode_dmu_fini(zp); @@ -1275,9 +1268,7 @@ void zfs_znode_free(znode_t *zp) { zfsvfs_t *zfsvfs = zp->z_zfsvfs; -#if __FreeBSD_version >= 1300139 char *symlink; -#endif ASSERT3P(zp->z_sa_hdl, ==, NULL); zp->z_vnode = NULL; @@ -1286,14 +1277,12 @@ zfs_znode_free(znode_t *zp) list_remove(&zfsvfs->z_all_znodes, zp); mutex_exit(&zfsvfs->z_znodes_lock); -#if __FreeBSD_version >= 1300139 symlink = atomic_load_ptr(&zp->z_cached_symlink); if (symlink != NULL) { atomic_store_rel_ptr((uintptr_t *)&zp->z_cached_symlink, (uintptr_t)NULL); cache_symlink_free(symlink, strlen(symlink) + 1); } -#endif if (zp->z_acl_cached) { zfs_acl_free(zp->z_acl_cached); diff --git a/module/os/freebsd/zfs/zvol_os.c b/module/os/freebsd/zfs/zvol_os.c index 12eb2b1e517e..63121b5b330d 100644 --- a/module/os/freebsd/zfs/zvol_os.c +++ b/module/os/freebsd/zfs/zvol_os.c @@ -1330,11 +1330,7 @@ zvol_os_rename_minor(zvol_state_t *zv, const char *newname) args.mda_si_drv2 = zv; if (make_dev_s(&args, &dev, "%s/%s", ZVOL_DRIVER, newname) == 0) { -#if __FreeBSD_version > 1300130 dev->si_iosize_max = maxphys; -#else - dev->si_iosize_max = MAXPHYS; -#endif zsd->zsd_cdev = dev; } } @@ -1476,11 +1472,7 @@ zvol_os_create_minor(const char *name) args.mda_si_drv2 = zv; if (make_dev_s(&args, &dev, "%s/%s", ZVOL_DRIVER, name) == 0) { -#if __FreeBSD_version > 1300130 dev->si_iosize_max = maxphys; -#else - dev->si_iosize_max = MAXPHYS; -#endif zsd->zsd_cdev = dev; knlist_init_sx(&zsd->zsd_selinfo.si_note, &zv->zv_state_lock); diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c index 3d735b5fb441..80c11d80f6c4 100644 --- a/module/zfs/zfs_replay.c +++ b/module/zfs/zfs_replay.c @@ -438,7 +438,7 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) bail: if (error == 0 && zp != NULL) { #ifdef __FreeBSD__ - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); #endif zrele(zp); } @@ -594,7 +594,7 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) out: if (error == 0 && zp != NULL) { #ifdef __FreeBSD__ - VOP_UNLOCK1(ZTOV(zp)); + VOP_UNLOCK(ZTOV(zp)); #endif zrele(zp); } From e580b543a8f4be9c2f0f97fec94fd24eeacfeaac Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 28 Aug 2024 22:28:24 +1000 Subject: [PATCH 199/223] zfs_znode: lift common code to a single shared file For now, userspace has no znode implementation. Some of the property and path handling code is used there though and is the same on all platforms, so we only need a single copy of it. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Sponsored-by: https://despairlabs.com/sponsor/ Closes #16492 --- include/sys/zfs_znode.h | 2 + lib/libzpool/Makefile.am | 2 +- module/Kbuild.in | 3 +- module/Makefile.bsd | 3 +- .../zfs/{zfs_znode.c => zfs_znode_os.c} | 381 ----------------- .../linux/zfs/{zfs_znode.c => zfs_znode_os.c} | 364 ---------------- module/zfs/zfs_znode.c | 397 ++++++++++++++++++ 7 files changed, 404 insertions(+), 748 deletions(-) rename module/os/freebsd/zfs/{zfs_znode.c => zfs_znode_os.c} (84%) rename module/os/linux/zfs/{zfs_znode.c => zfs_znode_os.c} (86%) create mode 100644 module/zfs/zfs_znode.c diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h index 2f266f53247e..1504633c34f7 100644 --- a/include/sys/zfs_znode.h +++ b/include/sys/zfs_znode.h @@ -158,6 +158,8 @@ extern "C" { #define ZFS_DIRENT_OBJ(de) BF64_GET(de, 0, 48) extern int zfs_obj_to_path(objset_t *osp, uint64_t obj, char *buf, int len); +extern int zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, + sa_attr_type_t *sa_table, uint64_t *pobjp, int *is_xattrdir); extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value); #ifdef _KERNEL diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 64ae1a90e12f..a353583eb430 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -47,7 +47,6 @@ nodist_libzpool_la_SOURCES = \ \ module/os/linux/zfs/vdev_file.c \ module/os/linux/zfs/zfs_debug.c \ - module/os/linux/zfs/zfs_znode.c \ module/os/linux/zfs/zio_crypt.c \ \ module/zcommon/cityhash.c \ @@ -181,6 +180,7 @@ nodist_libzpool_la_SOURCES = \ module/zfs/zfs_ratelimit.c \ module/zfs/zfs_rlock.c \ module/zfs/zfs_sa.c \ + module/zfs/zfs_znode.c \ module/zfs/zil.c \ module/zfs/zio.c \ module/zfs/zio_checksum.c \ diff --git a/module/Kbuild.in b/module/Kbuild.in index 555522cff116..4afd064930a3 100644 --- a/module/Kbuild.in +++ b/module/Kbuild.in @@ -426,6 +426,7 @@ ZFS_OBJS := \ zfs_rlock.o \ zfs_sa.o \ zfs_vnops.o \ + zfs_znode.o \ zil.o \ zio.o \ zio_checksum.o \ @@ -459,7 +460,7 @@ ZFS_OBJS_OS := \ zfs_uio.o \ zfs_vfsops.o \ zfs_vnops_os.o \ - zfs_znode.o \ + zfs_znode_os.o \ zio_crypt.o \ zpl_ctldir.o \ zpl_export.o \ diff --git a/module/Makefile.bsd b/module/Makefile.bsd index de08de588571..a0f2c750ce4c 100644 --- a/module/Makefile.bsd +++ b/module/Makefile.bsd @@ -212,7 +212,7 @@ SRCS+= abd_os.c \ zfs_racct.c \ zfs_vfsops.c \ zfs_vnops_os.c \ - zfs_znode.c \ + zfs_znode_os.c \ zio_crypt.c \ zvol_os.c @@ -356,6 +356,7 @@ SRCS+= abd.c \ zfs_rlock.c \ zfs_sa.c \ zfs_vnops.c \ + zfs_znode.c \ zil.c \ zio.c \ zio_checksum.c \ diff --git a/module/os/freebsd/zfs/zfs_znode.c b/module/os/freebsd/zfs/zfs_znode_os.c similarity index 84% rename from module/os/freebsd/zfs/zfs_znode.c rename to module/os/freebsd/zfs/zfs_znode_os.c index e5c50874e1dd..ca247576a0ab 100644 --- a/module/os/freebsd/zfs/zfs_znode.c +++ b/module/os/freebsd/zfs/zfs_znode_os.c @@ -27,7 +27,6 @@ /* Portions Copyright 2007 Jeremy Teo */ /* Portions Copyright 2011 Martin Matuska */ -#ifdef _KERNEL #include #include #include @@ -52,8 +51,6 @@ #include #include #include -#endif /* _KERNEL */ - #include #include #include @@ -86,12 +83,6 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, znode, CTLFLAG_RD, #define ZNODE_STAT_ADD(stat) /* nothing */ #endif /* ZNODE_STATS */ -/* - * Functions needed for userland (ie: libzpool) are not put under - * #ifdef_KERNEL; the rest of the functions have dependencies - * (such as VFS logic) that will not compile easily in userland. - */ -#ifdef _KERNEL #if !defined(KMEM_DEBUG) #define _ZFS_USE_SMR static uma_zone_t znode_uma_zone; @@ -1787,376 +1778,7 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx) mutex_destroy(&zfsvfs->z_hold_mtx[i]); kmem_free(zfsvfs, sizeof (zfsvfs_t)); } -#endif /* _KERNEL */ - -static int -zfs_sa_setup(objset_t *osp, sa_attr_type_t **sa_table) -{ - uint64_t sa_obj = 0; - int error; - - error = zap_lookup(osp, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1, &sa_obj); - if (error != 0 && error != ENOENT) - return (error); - - error = sa_setup(osp, sa_obj, zfs_attr_table, ZPL_END, sa_table); - return (error); -} - -static int -zfs_grab_sa_handle(objset_t *osp, uint64_t obj, sa_handle_t **hdlp, - dmu_buf_t **db, const void *tag) -{ - dmu_object_info_t doi; - int error; - - if ((error = sa_buf_hold(osp, obj, tag, db)) != 0) - return (error); - - dmu_object_info_from_db(*db, &doi); - if ((doi.doi_bonus_type != DMU_OT_SA && - doi.doi_bonus_type != DMU_OT_ZNODE) || - (doi.doi_bonus_type == DMU_OT_ZNODE && - doi.doi_bonus_size < sizeof (znode_phys_t))) { - sa_buf_rele(*db, tag); - return (SET_ERROR(ENOTSUP)); - } - - error = sa_handle_get(osp, obj, NULL, SA_HDL_PRIVATE, hdlp); - if (error != 0) { - sa_buf_rele(*db, tag); - return (error); - } - - return (0); -} - -static void -zfs_release_sa_handle(sa_handle_t *hdl, dmu_buf_t *db, const void *tag) -{ - sa_handle_destroy(hdl); - sa_buf_rele(db, tag); -} - -/* - * Given an object number, return its parent object number and whether - * or not the object is an extended attribute directory. - */ -static int -zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table, - uint64_t *pobjp, int *is_xattrdir) -{ - uint64_t parent; - uint64_t pflags; - uint64_t mode; - uint64_t parent_mode; - sa_bulk_attr_t bulk[3]; - sa_handle_t *sa_hdl; - dmu_buf_t *sa_db; - int count = 0; - int error; - - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_PARENT], NULL, - &parent, sizeof (parent)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_FLAGS], NULL, - &pflags, sizeof (pflags)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, - &mode, sizeof (mode)); - - if ((error = sa_bulk_lookup(hdl, bulk, count)) != 0) - return (error); - - /* - * When a link is removed its parent pointer is not changed and will - * be invalid. There are two cases where a link is removed but the - * file stays around, when it goes to the delete queue and when there - * are additional links. - */ - error = zfs_grab_sa_handle(osp, parent, &sa_hdl, &sa_db, FTAG); - if (error != 0) - return (error); - - error = sa_lookup(sa_hdl, ZPL_MODE, &parent_mode, sizeof (parent_mode)); - zfs_release_sa_handle(sa_hdl, sa_db, FTAG); - if (error != 0) - return (error); - - *is_xattrdir = ((pflags & ZFS_XATTR) != 0) && S_ISDIR(mode); - - /* - * Extended attributes can be applied to files, directories, etc. - * Otherwise the parent must be a directory. - */ - if (!*is_xattrdir && !S_ISDIR(parent_mode)) - return (SET_ERROR(EINVAL)); - - *pobjp = parent; - - return (0); -} - -/* - * Given an object number, return some zpl level statistics - */ -static int -zfs_obj_to_stats_impl(sa_handle_t *hdl, sa_attr_type_t *sa_table, - zfs_stat_t *sb) -{ - sa_bulk_attr_t bulk[4]; - int count = 0; - - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, - &sb->zs_mode, sizeof (sb->zs_mode)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_GEN], NULL, - &sb->zs_gen, sizeof (sb->zs_gen)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_LINKS], NULL, - &sb->zs_links, sizeof (sb->zs_links)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_CTIME], NULL, - &sb->zs_ctime, sizeof (sb->zs_ctime)); - - return (sa_bulk_lookup(hdl, bulk, count)); -} - -static int -zfs_obj_to_path_impl(objset_t *osp, uint64_t obj, sa_handle_t *hdl, - sa_attr_type_t *sa_table, char *buf, int len) -{ - sa_handle_t *sa_hdl; - sa_handle_t *prevhdl = NULL; - dmu_buf_t *prevdb = NULL; - dmu_buf_t *sa_db = NULL; - char *path = buf + len - 1; - int error; - - *path = '\0'; - sa_hdl = hdl; - - uint64_t deleteq_obj; - VERIFY0(zap_lookup(osp, MASTER_NODE_OBJ, - ZFS_UNLINKED_SET, sizeof (uint64_t), 1, &deleteq_obj)); - error = zap_lookup_int(osp, deleteq_obj, obj); - if (error == 0) { - return (ESTALE); - } else if (error != ENOENT) { - return (error); - } - - for (;;) { - uint64_t pobj; - char component[MAXNAMELEN + 2]; - size_t complen; - int is_xattrdir; - - if (prevdb) { - ASSERT3P(prevhdl, !=, NULL); - zfs_release_sa_handle(prevhdl, prevdb, FTAG); - } - - if ((error = zfs_obj_to_pobj(osp, sa_hdl, sa_table, &pobj, - &is_xattrdir)) != 0) - break; - - if (pobj == obj) { - if (path[0] != '/') - *--path = '/'; - break; - } - - component[0] = '/'; - if (is_xattrdir) { - (void) sprintf(component + 1, ""); - } else { - error = zap_value_search(osp, pobj, obj, - ZFS_DIRENT_OBJ(-1ULL), component + 1); - if (error != 0) - break; - } - - complen = strlen(component); - path -= complen; - ASSERT3P(path, >=, buf); - memcpy(path, component, complen); - obj = pobj; - - if (sa_hdl != hdl) { - prevhdl = sa_hdl; - prevdb = sa_db; - } - error = zfs_grab_sa_handle(osp, obj, &sa_hdl, &sa_db, FTAG); - if (error != 0) { - sa_hdl = prevhdl; - sa_db = prevdb; - break; - } - } - - if (sa_hdl != NULL && sa_hdl != hdl) { - ASSERT3P(sa_db, !=, NULL); - zfs_release_sa_handle(sa_hdl, sa_db, FTAG); - } - - if (error == 0) - (void) memmove(buf, path, buf + len - path); - - return (error); -} - -int -zfs_obj_to_path(objset_t *osp, uint64_t obj, char *buf, int len) -{ - sa_attr_type_t *sa_table; - sa_handle_t *hdl; - dmu_buf_t *db; - int error; - - error = zfs_sa_setup(osp, &sa_table); - if (error != 0) - return (error); - - error = zfs_grab_sa_handle(osp, obj, &hdl, &db, FTAG); - if (error != 0) - return (error); - - error = zfs_obj_to_path_impl(osp, obj, hdl, sa_table, buf, len); - - zfs_release_sa_handle(hdl, db, FTAG); - return (error); -} - -int -zfs_obj_to_stats(objset_t *osp, uint64_t obj, zfs_stat_t *sb, - char *buf, int len) -{ - char *path = buf + len - 1; - sa_attr_type_t *sa_table; - sa_handle_t *hdl; - dmu_buf_t *db; - int error; - - *path = '\0'; - - error = zfs_sa_setup(osp, &sa_table); - if (error != 0) - return (error); - - error = zfs_grab_sa_handle(osp, obj, &hdl, &db, FTAG); - if (error != 0) - return (error); - - error = zfs_obj_to_stats_impl(hdl, sa_table, sb); - if (error != 0) { - zfs_release_sa_handle(hdl, db, FTAG); - return (error); - } - - error = zfs_obj_to_path_impl(osp, obj, hdl, sa_table, buf, len); - - zfs_release_sa_handle(hdl, db, FTAG); - return (error); -} - -/* - * Read a property stored within the master node. - */ -int -zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value) -{ - uint64_t *cached_copy = NULL; - - /* - * Figure out where in the objset_t the cached copy would live, if it - * is available for the requested property. - */ - if (os != NULL) { - switch (prop) { - case ZFS_PROP_VERSION: - cached_copy = &os->os_version; - break; - case ZFS_PROP_NORMALIZE: - cached_copy = &os->os_normalization; - break; - case ZFS_PROP_UTF8ONLY: - cached_copy = &os->os_utf8only; - break; - case ZFS_PROP_CASE: - cached_copy = &os->os_casesensitivity; - break; - default: - break; - } - } - if (cached_copy != NULL && *cached_copy != OBJSET_PROP_UNINITIALIZED) { - *value = *cached_copy; - return (0); - } - - /* - * If the property wasn't cached, look up the file system's value for - * the property. For the version property, we look up a slightly - * different string. - */ - const char *pname; - int error = ENOENT; - if (prop == ZFS_PROP_VERSION) { - pname = ZPL_VERSION_STR; - } else { - pname = zfs_prop_to_name(prop); - } - - if (os != NULL) { - ASSERT3U(os->os_phys->os_type, ==, DMU_OST_ZFS); - error = zap_lookup(os, MASTER_NODE_OBJ, pname, 8, 1, value); - } - - if (error == ENOENT) { - /* No value set, use the default value */ - switch (prop) { - case ZFS_PROP_VERSION: - *value = ZPL_VERSION; - break; - case ZFS_PROP_NORMALIZE: - case ZFS_PROP_UTF8ONLY: - *value = 0; - break; - case ZFS_PROP_CASE: - *value = ZFS_CASE_SENSITIVE; - break; - case ZFS_PROP_ACLTYPE: - *value = ZFS_ACLTYPE_NFSV4; - break; - default: - return (error); - } - error = 0; - } - - /* - * If one of the methods for getting the property value above worked, - * copy it into the objset_t's cache. - */ - if (error == 0 && cached_copy != NULL) { - *cached_copy = *value; - } - - return (error); -} - - - -void -zfs_znode_update_vfs(znode_t *zp) -{ - vm_object_t object; - - if ((object = ZTOV(zp)->v_object) == NULL || - zp->z_size == object->un_pager.vnp.vnp_size) - return; - - vnode_pager_setsize(ZTOV(zp), zp->z_size); -} - -#ifdef _KERNEL int zfs_znode_parent_and_name(znode_t *zp, znode_t **dzpp, char *buf) { @@ -2186,9 +1808,7 @@ zfs_znode_parent_and_name(znode_t *zp, znode_t **dzpp, char *buf) err = zfs_zget(zfsvfs, parent, dzpp); return (err); } -#endif /* _KERNEL */ -#ifdef _KERNEL int zfs_rlimit_fsize(off_t fsize) { @@ -2211,4 +1831,3 @@ zfs_rlimit_fsize(off_t fsize) return (EFBIG); } -#endif /* _KERNEL */ diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode_os.c similarity index 86% rename from module/os/linux/zfs/zfs_znode.c rename to module/os/linux/zfs/zfs_znode_os.c index 4d18187b715b..e135f9044679 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode_os.c @@ -25,7 +25,6 @@ /* Portions Copyright 2007 Jeremy Teo */ -#ifdef _KERNEL #include #include #include @@ -49,8 +48,6 @@ #include #include #include -#endif /* _KERNEL */ - #include #include #include @@ -65,13 +62,6 @@ #include "zfs_prop.h" #include "zfs_comutil.h" -/* - * Functions needed for userland (ie: libzpool) are not put under - * #ifdef_KERNEL; the rest of the functions have dependencies - * (such as VFS logic) that will not compile easily in userland. - */ -#ifdef _KERNEL - static kmem_cache_t *znode_cache = NULL; static kmem_cache_t *znode_hold_cache = NULL; unsigned int zfs_object_mutex_size = ZFS_OBJ_MTX_SZ; @@ -1972,360 +1962,7 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx) kmem_free(sb, sizeof (struct super_block)); kmem_free(zfsvfs, sizeof (zfsvfs_t)); } -#endif /* _KERNEL */ - -static int -zfs_sa_setup(objset_t *osp, sa_attr_type_t **sa_table) -{ - uint64_t sa_obj = 0; - int error; - - error = zap_lookup(osp, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1, &sa_obj); - if (error != 0 && error != ENOENT) - return (error); - - error = sa_setup(osp, sa_obj, zfs_attr_table, ZPL_END, sa_table); - return (error); -} - -static int -zfs_grab_sa_handle(objset_t *osp, uint64_t obj, sa_handle_t **hdlp, - dmu_buf_t **db, const void *tag) -{ - dmu_object_info_t doi; - int error; - - if ((error = sa_buf_hold(osp, obj, tag, db)) != 0) - return (error); - - dmu_object_info_from_db(*db, &doi); - if ((doi.doi_bonus_type != DMU_OT_SA && - doi.doi_bonus_type != DMU_OT_ZNODE) || - (doi.doi_bonus_type == DMU_OT_ZNODE && - doi.doi_bonus_size < sizeof (znode_phys_t))) { - sa_buf_rele(*db, tag); - return (SET_ERROR(ENOTSUP)); - } - - error = sa_handle_get(osp, obj, NULL, SA_HDL_PRIVATE, hdlp); - if (error != 0) { - sa_buf_rele(*db, tag); - return (error); - } - - return (0); -} - -static void -zfs_release_sa_handle(sa_handle_t *hdl, dmu_buf_t *db, const void *tag) -{ - sa_handle_destroy(hdl); - sa_buf_rele(db, tag); -} - -/* - * Given an object number, return its parent object number and whether - * or not the object is an extended attribute directory. - */ -static int -zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table, - uint64_t *pobjp, int *is_xattrdir) -{ - uint64_t parent; - uint64_t pflags; - uint64_t mode; - uint64_t parent_mode; - sa_bulk_attr_t bulk[3]; - sa_handle_t *sa_hdl; - dmu_buf_t *sa_db; - int count = 0; - int error; - - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_PARENT], NULL, - &parent, sizeof (parent)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_FLAGS], NULL, - &pflags, sizeof (pflags)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, - &mode, sizeof (mode)); - - if ((error = sa_bulk_lookup(hdl, bulk, count)) != 0) - return (error); - - /* - * When a link is removed its parent pointer is not changed and will - * be invalid. There are two cases where a link is removed but the - * file stays around, when it goes to the delete queue and when there - * are additional links. - */ - error = zfs_grab_sa_handle(osp, parent, &sa_hdl, &sa_db, FTAG); - if (error != 0) - return (error); - - error = sa_lookup(sa_hdl, ZPL_MODE, &parent_mode, sizeof (parent_mode)); - zfs_release_sa_handle(sa_hdl, sa_db, FTAG); - if (error != 0) - return (error); - - *is_xattrdir = ((pflags & ZFS_XATTR) != 0) && S_ISDIR(mode); - - /* - * Extended attributes can be applied to files, directories, etc. - * Otherwise the parent must be a directory. - */ - if (!*is_xattrdir && !S_ISDIR(parent_mode)) - return (SET_ERROR(EINVAL)); - - *pobjp = parent; - - return (0); -} - -/* - * Given an object number, return some zpl level statistics - */ -static int -zfs_obj_to_stats_impl(sa_handle_t *hdl, sa_attr_type_t *sa_table, - zfs_stat_t *sb) -{ - sa_bulk_attr_t bulk[4]; - int count = 0; - - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, - &sb->zs_mode, sizeof (sb->zs_mode)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_GEN], NULL, - &sb->zs_gen, sizeof (sb->zs_gen)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_LINKS], NULL, - &sb->zs_links, sizeof (sb->zs_links)); - SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_CTIME], NULL, - &sb->zs_ctime, sizeof (sb->zs_ctime)); - - return (sa_bulk_lookup(hdl, bulk, count)); -} - -static int -zfs_obj_to_path_impl(objset_t *osp, uint64_t obj, sa_handle_t *hdl, - sa_attr_type_t *sa_table, char *buf, int len) -{ - sa_handle_t *sa_hdl; - sa_handle_t *prevhdl = NULL; - dmu_buf_t *prevdb = NULL; - dmu_buf_t *sa_db = NULL; - char *path = buf + len - 1; - int error; - - *path = '\0'; - sa_hdl = hdl; - - uint64_t deleteq_obj; - VERIFY0(zap_lookup(osp, MASTER_NODE_OBJ, - ZFS_UNLINKED_SET, sizeof (uint64_t), 1, &deleteq_obj)); - error = zap_lookup_int(osp, deleteq_obj, obj); - if (error == 0) { - return (ESTALE); - } else if (error != ENOENT) { - return (error); - } - - for (;;) { - uint64_t pobj = 0; - char component[MAXNAMELEN + 2]; - size_t complen; - int is_xattrdir = 0; - - if (prevdb) { - ASSERT(prevhdl != NULL); - zfs_release_sa_handle(prevhdl, prevdb, FTAG); - } - - if ((error = zfs_obj_to_pobj(osp, sa_hdl, sa_table, &pobj, - &is_xattrdir)) != 0) - break; - - if (pobj == obj) { - if (path[0] != '/') - *--path = '/'; - break; - } - - component[0] = '/'; - if (is_xattrdir) { - strcpy(component + 1, ""); - } else { - error = zap_value_search(osp, pobj, obj, - ZFS_DIRENT_OBJ(-1ULL), component + 1); - if (error != 0) - break; - } - - complen = strlen(component); - path -= complen; - ASSERT(path >= buf); - memcpy(path, component, complen); - obj = pobj; - - if (sa_hdl != hdl) { - prevhdl = sa_hdl; - prevdb = sa_db; - } - error = zfs_grab_sa_handle(osp, obj, &sa_hdl, &sa_db, FTAG); - if (error != 0) { - sa_hdl = prevhdl; - sa_db = prevdb; - break; - } - } - - if (sa_hdl != NULL && sa_hdl != hdl) { - ASSERT(sa_db != NULL); - zfs_release_sa_handle(sa_hdl, sa_db, FTAG); - } - - if (error == 0) - (void) memmove(buf, path, buf + len - path); - - return (error); -} - -int -zfs_obj_to_path(objset_t *osp, uint64_t obj, char *buf, int len) -{ - sa_attr_type_t *sa_table; - sa_handle_t *hdl; - dmu_buf_t *db; - int error; - - error = zfs_sa_setup(osp, &sa_table); - if (error != 0) - return (error); - - error = zfs_grab_sa_handle(osp, obj, &hdl, &db, FTAG); - if (error != 0) - return (error); - - error = zfs_obj_to_path_impl(osp, obj, hdl, sa_table, buf, len); - - zfs_release_sa_handle(hdl, db, FTAG); - return (error); -} - -int -zfs_obj_to_stats(objset_t *osp, uint64_t obj, zfs_stat_t *sb, - char *buf, int len) -{ - char *path = buf + len - 1; - sa_attr_type_t *sa_table; - sa_handle_t *hdl; - dmu_buf_t *db; - int error; - - *path = '\0'; - - error = zfs_sa_setup(osp, &sa_table); - if (error != 0) - return (error); - - error = zfs_grab_sa_handle(osp, obj, &hdl, &db, FTAG); - if (error != 0) - return (error); - - error = zfs_obj_to_stats_impl(hdl, sa_table, sb); - if (error != 0) { - zfs_release_sa_handle(hdl, db, FTAG); - return (error); - } - - error = zfs_obj_to_path_impl(osp, obj, hdl, sa_table, buf, len); - - zfs_release_sa_handle(hdl, db, FTAG); - return (error); -} - -/* - * Read a property stored within the master node. - */ -int -zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value) -{ - uint64_t *cached_copy = NULL; - - /* - * Figure out where in the objset_t the cached copy would live, if it - * is available for the requested property. - */ - if (os != NULL) { - switch (prop) { - case ZFS_PROP_VERSION: - cached_copy = &os->os_version; - break; - case ZFS_PROP_NORMALIZE: - cached_copy = &os->os_normalization; - break; - case ZFS_PROP_UTF8ONLY: - cached_copy = &os->os_utf8only; - break; - case ZFS_PROP_CASE: - cached_copy = &os->os_casesensitivity; - break; - default: - break; - } - } - if (cached_copy != NULL && *cached_copy != OBJSET_PROP_UNINITIALIZED) { - *value = *cached_copy; - return (0); - } - - /* - * If the property wasn't cached, look up the file system's value for - * the property. For the version property, we look up a slightly - * different string. - */ - const char *pname; - int error = ENOENT; - if (prop == ZFS_PROP_VERSION) - pname = ZPL_VERSION_STR; - else - pname = zfs_prop_to_name(prop); - - if (os != NULL) { - ASSERT3U(os->os_phys->os_type, ==, DMU_OST_ZFS); - error = zap_lookup(os, MASTER_NODE_OBJ, pname, 8, 1, value); - } - - if (error == ENOENT) { - /* No value set, use the default value */ - switch (prop) { - case ZFS_PROP_VERSION: - *value = ZPL_VERSION; - break; - case ZFS_PROP_NORMALIZE: - case ZFS_PROP_UTF8ONLY: - *value = 0; - break; - case ZFS_PROP_CASE: - *value = ZFS_CASE_SENSITIVE; - break; - case ZFS_PROP_ACLTYPE: - *value = ZFS_ACLTYPE_OFF; - break; - default: - return (error); - } - error = 0; - } - - /* - * If one of the methods for getting the property value above worked, - * copy it into the objset_t's cache. - */ - if (error == 0 && cached_copy != NULL) { - *cached_copy = *value; - } - - return (error); -} -#if defined(_KERNEL) EXPORT_SYMBOL(zfs_create_fs); EXPORT_SYMBOL(zfs_obj_to_path); @@ -2335,4 +1972,3 @@ MODULE_PARM_DESC(zfs_object_mutex_size, "Size of znode hold array"); module_param(zfs_unlink_suspend_progress, int, 0644); MODULE_PARM_DESC(zfs_unlink_suspend_progress, "Set to prevent async unlinks " "(debug - leaks space into the unlinked set)"); -#endif diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c new file mode 100644 index 000000000000..2e28587c8b95 --- /dev/null +++ b/module/zfs/zfs_znode.c @@ -0,0 +1,397 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018 by Delphix. All rights reserved. + * Copyright (c) 2014 Integros [integros.com] + */ + +/* Portions Copyright 2007 Jeremy Teo */ +/* Portions Copyright 2011 Martin Matuska */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "zfs_prop.h" +#include "zfs_comutil.h" + +static int +zfs_sa_setup(objset_t *osp, sa_attr_type_t **sa_table) +{ + uint64_t sa_obj = 0; + int error; + + error = zap_lookup(osp, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1, &sa_obj); + if (error != 0 && error != ENOENT) + return (error); + + error = sa_setup(osp, sa_obj, zfs_attr_table, ZPL_END, sa_table); + return (error); +} + +static int +zfs_grab_sa_handle(objset_t *osp, uint64_t obj, sa_handle_t **hdlp, + dmu_buf_t **db, const void *tag) +{ + dmu_object_info_t doi; + int error; + + if ((error = sa_buf_hold(osp, obj, tag, db)) != 0) + return (error); + + dmu_object_info_from_db(*db, &doi); + if ((doi.doi_bonus_type != DMU_OT_SA && + doi.doi_bonus_type != DMU_OT_ZNODE) || + (doi.doi_bonus_type == DMU_OT_ZNODE && + doi.doi_bonus_size < sizeof (znode_phys_t))) { + sa_buf_rele(*db, tag); + return (SET_ERROR(ENOTSUP)); + } + + error = sa_handle_get(osp, obj, NULL, SA_HDL_PRIVATE, hdlp); + if (error != 0) { + sa_buf_rele(*db, tag); + return (error); + } + + return (0); +} + +static void +zfs_release_sa_handle(sa_handle_t *hdl, dmu_buf_t *db, const void *tag) +{ + sa_handle_destroy(hdl); + sa_buf_rele(db, tag); +} + +/* + * Given an object number, return its parent object number and whether + * or not the object is an extended attribute directory. + */ +int +zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table, + uint64_t *pobjp, int *is_xattrdir) +{ + uint64_t parent; + uint64_t pflags; + uint64_t mode; + uint64_t parent_mode; + sa_bulk_attr_t bulk[3]; + sa_handle_t *sa_hdl; + dmu_buf_t *sa_db; + int count = 0; + int error; + + SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_PARENT], NULL, + &parent, sizeof (parent)); + SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_FLAGS], NULL, + &pflags, sizeof (pflags)); + SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, + &mode, sizeof (mode)); + + if ((error = sa_bulk_lookup(hdl, bulk, count)) != 0) + return (error); + + /* + * When a link is removed its parent pointer is not changed and will + * be invalid. There are two cases where a link is removed but the + * file stays around, when it goes to the delete queue and when there + * are additional links. + */ + error = zfs_grab_sa_handle(osp, parent, &sa_hdl, &sa_db, FTAG); + if (error != 0) + return (error); + + error = sa_lookup(sa_hdl, ZPL_MODE, &parent_mode, sizeof (parent_mode)); + zfs_release_sa_handle(sa_hdl, sa_db, FTAG); + if (error != 0) + return (error); + + *is_xattrdir = ((pflags & ZFS_XATTR) != 0) && S_ISDIR(mode); + + /* + * Extended attributes can be applied to files, directories, etc. + * Otherwise the parent must be a directory. + */ + if (!*is_xattrdir && !S_ISDIR(parent_mode)) + return (SET_ERROR(EINVAL)); + + *pobjp = parent; + + return (0); +} + +/* + * Given an object number, return some zpl level statistics + */ +static int +zfs_obj_to_stats_impl(sa_handle_t *hdl, sa_attr_type_t *sa_table, + zfs_stat_t *sb) +{ + sa_bulk_attr_t bulk[4]; + int count = 0; + + SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, + &sb->zs_mode, sizeof (sb->zs_mode)); + SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_GEN], NULL, + &sb->zs_gen, sizeof (sb->zs_gen)); + SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_LINKS], NULL, + &sb->zs_links, sizeof (sb->zs_links)); + SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_CTIME], NULL, + &sb->zs_ctime, sizeof (sb->zs_ctime)); + + return (sa_bulk_lookup(hdl, bulk, count)); +} + +static int +zfs_obj_to_path_impl(objset_t *osp, uint64_t obj, sa_handle_t *hdl, + sa_attr_type_t *sa_table, char *buf, int len) +{ + sa_handle_t *sa_hdl; + sa_handle_t *prevhdl = NULL; + dmu_buf_t *prevdb = NULL; + dmu_buf_t *sa_db = NULL; + char *path = buf + len - 1; + int error; + + *path = '\0'; + sa_hdl = hdl; + + uint64_t deleteq_obj; + VERIFY0(zap_lookup(osp, MASTER_NODE_OBJ, + ZFS_UNLINKED_SET, sizeof (uint64_t), 1, &deleteq_obj)); + error = zap_lookup_int(osp, deleteq_obj, obj); + if (error == 0) { + return (ESTALE); + } else if (error != ENOENT) { + return (error); + } + + for (;;) { + uint64_t pobj = 0; + char component[MAXNAMELEN + 2]; + size_t complen; + int is_xattrdir = 0; + + if (prevdb) { + ASSERT3P(prevhdl, !=, NULL); + zfs_release_sa_handle(prevhdl, prevdb, FTAG); + } + + if ((error = zfs_obj_to_pobj(osp, sa_hdl, sa_table, &pobj, + &is_xattrdir)) != 0) + break; + + if (pobj == obj) { + if (path[0] != '/') + *--path = '/'; + break; + } + + component[0] = '/'; + if (is_xattrdir) { + strcpy(component + 1, ""); + } else { + error = zap_value_search(osp, pobj, obj, + ZFS_DIRENT_OBJ(-1ULL), component + 1); + if (error != 0) + break; + } + + complen = strlen(component); + path -= complen; + ASSERT3P(path, >=, buf); + memcpy(path, component, complen); + obj = pobj; + + if (sa_hdl != hdl) { + prevhdl = sa_hdl; + prevdb = sa_db; + } + error = zfs_grab_sa_handle(osp, obj, &sa_hdl, &sa_db, FTAG); + if (error != 0) { + sa_hdl = prevhdl; + sa_db = prevdb; + break; + } + } + + if (sa_hdl != NULL && sa_hdl != hdl) { + ASSERT3P(sa_db, !=, NULL); + zfs_release_sa_handle(sa_hdl, sa_db, FTAG); + } + + if (error == 0) + (void) memmove(buf, path, buf + len - path); + + return (error); +} + +int +zfs_obj_to_path(objset_t *osp, uint64_t obj, char *buf, int len) +{ + sa_attr_type_t *sa_table; + sa_handle_t *hdl; + dmu_buf_t *db; + int error; + + error = zfs_sa_setup(osp, &sa_table); + if (error != 0) + return (error); + + error = zfs_grab_sa_handle(osp, obj, &hdl, &db, FTAG); + if (error != 0) + return (error); + + error = zfs_obj_to_path_impl(osp, obj, hdl, sa_table, buf, len); + + zfs_release_sa_handle(hdl, db, FTAG); + return (error); +} + +int +zfs_obj_to_stats(objset_t *osp, uint64_t obj, zfs_stat_t *sb, + char *buf, int len) +{ + char *path = buf + len - 1; + sa_attr_type_t *sa_table; + sa_handle_t *hdl; + dmu_buf_t *db; + int error; + + *path = '\0'; + + error = zfs_sa_setup(osp, &sa_table); + if (error != 0) + return (error); + + error = zfs_grab_sa_handle(osp, obj, &hdl, &db, FTAG); + if (error != 0) + return (error); + + error = zfs_obj_to_stats_impl(hdl, sa_table, sb); + if (error != 0) { + zfs_release_sa_handle(hdl, db, FTAG); + return (error); + } + + error = zfs_obj_to_path_impl(osp, obj, hdl, sa_table, buf, len); + + zfs_release_sa_handle(hdl, db, FTAG); + return (error); +} + +/* + * Read a property stored within the master node. + */ +int +zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value) +{ + uint64_t *cached_copy = NULL; + + /* + * Figure out where in the objset_t the cached copy would live, if it + * is available for the requested property. + */ + if (os != NULL) { + switch (prop) { + case ZFS_PROP_VERSION: + cached_copy = &os->os_version; + break; + case ZFS_PROP_NORMALIZE: + cached_copy = &os->os_normalization; + break; + case ZFS_PROP_UTF8ONLY: + cached_copy = &os->os_utf8only; + break; + case ZFS_PROP_CASE: + cached_copy = &os->os_casesensitivity; + break; + default: + break; + } + } + if (cached_copy != NULL && *cached_copy != OBJSET_PROP_UNINITIALIZED) { + *value = *cached_copy; + return (0); + } + + /* + * If the property wasn't cached, look up the file system's value for + * the property. For the version property, we look up a slightly + * different string. + */ + const char *pname; + int error = ENOENT; + if (prop == ZFS_PROP_VERSION) + pname = ZPL_VERSION_STR; + else + pname = zfs_prop_to_name(prop); + + if (os != NULL) { + ASSERT3U(os->os_phys->os_type, ==, DMU_OST_ZFS); + error = zap_lookup(os, MASTER_NODE_OBJ, pname, 8, 1, value); + } + + if (error == ENOENT) { + /* No value set, use the default value */ + switch (prop) { + case ZFS_PROP_VERSION: + *value = ZPL_VERSION; + break; + case ZFS_PROP_NORMALIZE: + case ZFS_PROP_UTF8ONLY: + *value = 0; + break; + case ZFS_PROP_CASE: + *value = ZFS_CASE_SENSITIVE; + break; + case ZFS_PROP_ACLTYPE: +#ifdef __FreeBSD__ + *value = ZFS_ACLTYPE_NFSV4; +#else + *value = ZFS_ACLTYPE_OFF; +#endif + break; + default: + return (error); + } + error = 0; + } + + /* + * If one of the methods for getting the property value above worked, + * copy it into the objset_t's cache. + */ + if (error == 0 && cached_copy != NULL) { + *cached_copy = *value; + } + + return (error); +} From 63f70d3c61ed69df0106296158beb60f51b98ea0 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 10 May 2024 13:54:08 +1000 Subject: [PATCH 200/223] zfs_dbgmsg_print: make FreeBSD and Linux consistent FreeBSD was using fprintf(), which might not be signal-safe. Meanwhile, Linux's locking did not cover the header output. This two quirks are unrelated, but both have the same response: be like the other one. So with this commit, both functions are the same except for the names of their lock and list variables. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16181 --- module/os/freebsd/zfs/zfs_debug.c | 24 ++++++++++++++++++++---- module/os/linux/zfs/zfs_debug.c | 3 ++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/module/os/freebsd/zfs/zfs_debug.c b/module/os/freebsd/zfs/zfs_debug.c index 78d50c6fd8b7..3e832a9104f2 100644 --- a/module/os/freebsd/zfs/zfs_debug.c +++ b/module/os/freebsd/zfs/zfs_debug.c @@ -234,13 +234,29 @@ __dprintf(boolean_t dprint, const char *file, const char *func, void zfs_dbgmsg_print(const char *tag) { - zfs_dbgmsg_t *zdm; + ssize_t ret __attribute__((unused)); - (void) printf("ZFS_DBGMSG(%s):\n", tag); mutex_enter(&zfs_dbgmsgs_lock); - for (zdm = list_head(&zfs_dbgmsgs); zdm; + + /* + * We use write() in this function instead of printf() + * so it is safe to call from a signal handler. + */ + ret = write(STDOUT_FILENO, "ZFS_DBGMSG(", 11); + ret = write(STDOUT_FILENO, tag, strlen(tag)); + ret = write(STDOUT_FILENO, ") START:\n", 9); + + for (zfs_dbgmsg_t zdm = list_head(&zfs_dbgmsgs); zdm != NULL; zdm = list_next(&zfs_dbgmsgs, zdm)) - (void) printf("%s\n", zdm->zdm_msg); + ret = write(STDOUT_FILENO, zdm->zdm_msg, + strlen(zdm->zdm_msg)); + ret = write(STDOUT_FILENO, "\n", 1); + } + + ret = write(STDOUT_FILENO, "ZFS_DBGMSG(", 11); + ret = write(STDOUT_FILENO, tag, strlen(tag)); + ret = write(STDOUT_FILENO, ") END\n", 6); + mutex_exit(&zfs_dbgmsgs_lock); } #endif /* _KERNEL */ diff --git a/module/os/linux/zfs/zfs_debug.c b/module/os/linux/zfs/zfs_debug.c index b090ec684e05..90ee72b55c7a 100644 --- a/module/os/linux/zfs/zfs_debug.c +++ b/module/os/linux/zfs/zfs_debug.c @@ -224,6 +224,8 @@ zfs_dbgmsg_print(const char *tag) { ssize_t ret __attribute__((unused)); + mutex_enter(&zfs_dbgmsgs.pl_lock); + /* * We use write() in this function instead of printf() * so it is safe to call from a signal handler. @@ -232,7 +234,6 @@ zfs_dbgmsg_print(const char *tag) ret = write(STDOUT_FILENO, tag, strlen(tag)); ret = write(STDOUT_FILENO, ") START:\n", 9); - mutex_enter(&zfs_dbgmsgs.pl_lock); for (zfs_dbgmsg_t *zdm = list_head(&zfs_dbgmsgs.pl_list); zdm != NULL; zdm = list_next(&zfs_dbgmsgs.pl_list, zdm)) { ret = write(STDOUT_FILENO, zdm->zdm_msg, From 16266b47a13a2f9796ad3fba567315d66f8850f5 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Fri, 10 May 2024 13:58:26 +1000 Subject: [PATCH 201/223] zdb/ztest: send dbgmsg output to stderr And, make the output fd an arg to zfs_dbgmsg_print(). This is a change in behaviour, but keeps it consistent with where crash traces go, and it's easy to argue this is what we want anyway; this is information about the task, not the actual output of the task. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16181 --- cmd/zdb/zdb.c | 4 ++-- cmd/ztest.c | 4 ++-- include/sys/zfs_debug.h | 2 +- module/os/freebsd/zfs/zfs_debug.c | 25 ++++++++++++------------- module/os/linux/zfs/zfs_debug.c | 19 +++++++++---------- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 52b8fe8ae66e..f7114b7121e7 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -938,8 +938,8 @@ dump_debug_buffer(void) * We use write() instead of printf() so that this function * is safe to call from a signal handler. */ - ret = write(STDOUT_FILENO, "\n", 1); - zfs_dbgmsg_print("zdb"); + ret = write(STDERR_FILENO, "\n", 1); + zfs_dbgmsg_print(STDERR_FILENO, "zdb"); } #define BACKTRACE_SZ 100 diff --git a/cmd/ztest.c b/cmd/ztest.c index 2601b2796875..9b9e2e8a9963 100644 --- a/cmd/ztest.c +++ b/cmd/ztest.c @@ -593,8 +593,8 @@ dump_debug_buffer(void) * We use write() instead of printf() so that this function * is safe to call from a signal handler. */ - ret = write(STDOUT_FILENO, "\n", 1); - zfs_dbgmsg_print("ztest"); + ret = write(STDERR_FILENO, "\n", 1); + zfs_dbgmsg_print(STDERR_FILENO, "ztest"); } #define BACKTRACE_SZ 100 diff --git a/include/sys/zfs_debug.h b/include/sys/zfs_debug.h index a1dfef1d89ff..62fa34cd14e1 100644 --- a/include/sys/zfs_debug.h +++ b/include/sys/zfs_debug.h @@ -103,7 +103,7 @@ extern void zfs_dbgmsg_fini(void); #ifndef _KERNEL extern int dprintf_find_string(const char *string); -extern void zfs_dbgmsg_print(const char *tag); +extern void zfs_dbgmsg_print(int fd, const char *tag); #endif #ifdef __cplusplus diff --git a/module/os/freebsd/zfs/zfs_debug.c b/module/os/freebsd/zfs/zfs_debug.c index 3e832a9104f2..c4cebe102075 100644 --- a/module/os/freebsd/zfs/zfs_debug.c +++ b/module/os/freebsd/zfs/zfs_debug.c @@ -232,30 +232,29 @@ __dprintf(boolean_t dprint, const char *file, const char *func, #else void -zfs_dbgmsg_print(const char *tag) +zfs_dbgmsg_print(int fd, const char *tag) { ssize_t ret __attribute__((unused)); - mutex_enter(&zfs_dbgmsgs_lock); - /* * We use write() in this function instead of printf() * so it is safe to call from a signal handler. */ - ret = write(STDOUT_FILENO, "ZFS_DBGMSG(", 11); - ret = write(STDOUT_FILENO, tag, strlen(tag)); - ret = write(STDOUT_FILENO, ") START:\n", 9); + ret = write(fd, "ZFS_DBGMSG(", 11); + ret = write(fd, tag, strlen(tag)); + ret = write(fd, ") START:\n", 9); + + mutex_enter(&zfs_dbgmsgs_lock); - for (zfs_dbgmsg_t zdm = list_head(&zfs_dbgmsgs); zdm != NULL; + for (zfs_dbgmsg_t *zdm = list_head(&zfs_dbgmsgs); zdm != NULL; zdm = list_next(&zfs_dbgmsgs, zdm)) - ret = write(STDOUT_FILENO, zdm->zdm_msg, - strlen(zdm->zdm_msg)); - ret = write(STDOUT_FILENO, "\n", 1); + ret = write(fd, zdm->zdm_msg, strlen(zdm->zdm_msg)); + ret = write(fd, "\n", 1); } - ret = write(STDOUT_FILENO, "ZFS_DBGMSG(", 11); - ret = write(STDOUT_FILENO, tag, strlen(tag)); - ret = write(STDOUT_FILENO, ") END\n", 6); + ret = write(fd, "ZFS_DBGMSG(", 11); + ret = write(fd, tag, strlen(tag)); + ret = write(fd, ") END\n", 6); mutex_exit(&zfs_dbgmsgs_lock); } diff --git a/module/os/linux/zfs/zfs_debug.c b/module/os/linux/zfs/zfs_debug.c index 90ee72b55c7a..733b4a574bf5 100644 --- a/module/os/linux/zfs/zfs_debug.c +++ b/module/os/linux/zfs/zfs_debug.c @@ -220,7 +220,7 @@ __dprintf(boolean_t dprint, const char *file, const char *func, #else void -zfs_dbgmsg_print(const char *tag) +zfs_dbgmsg_print(int fd, const char *tag) { ssize_t ret __attribute__((unused)); @@ -230,20 +230,19 @@ zfs_dbgmsg_print(const char *tag) * We use write() in this function instead of printf() * so it is safe to call from a signal handler. */ - ret = write(STDOUT_FILENO, "ZFS_DBGMSG(", 11); - ret = write(STDOUT_FILENO, tag, strlen(tag)); - ret = write(STDOUT_FILENO, ") START:\n", 9); + ret = write(fd, "ZFS_DBGMSG(", 11); + ret = write(fd, tag, strlen(tag)); + ret = write(fd, ") START:\n", 9); for (zfs_dbgmsg_t *zdm = list_head(&zfs_dbgmsgs.pl_list); zdm != NULL; zdm = list_next(&zfs_dbgmsgs.pl_list, zdm)) { - ret = write(STDOUT_FILENO, zdm->zdm_msg, - strlen(zdm->zdm_msg)); - ret = write(STDOUT_FILENO, "\n", 1); + ret = write(fd, zdm->zdm_msg, strlen(zdm->zdm_msg)); + ret = write(fd, "\n", 1); } - ret = write(STDOUT_FILENO, "ZFS_DBGMSG(", 11); - ret = write(STDOUT_FILENO, tag, strlen(tag)); - ret = write(STDOUT_FILENO, ") END\n", 6); + ret = write(fd, "ZFS_DBGMSG(", 11); + ret = write(fd, tag, strlen(tag)); + ret = write(fd, ") END\n", 6); mutex_exit(&zfs_dbgmsgs.pl_lock); } From 4982943d253b45d55b9043bdb6ba3a3c1aa59d7b Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 28 Aug 2024 22:28:58 +1000 Subject: [PATCH 202/223] zfs_debug: specific variant for userspace Just nice and simple, with room to grow. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Sponsored-by: https://despairlabs.com/sponsor/ Closes #16492 --- lib/libzpool/Makefile.am | 4 +- lib/libzpool/vdev_label_os.c | 12 +++- lib/libzpool/zfs_debug.c | 106 ++++++++++++++++++++++++++++++ module/os/freebsd/zfs/zfs_debug.c | 38 +---------- module/os/linux/zfs/zfs_debug.c | 40 ----------- 5 files changed, 118 insertions(+), 82 deletions(-) create mode 100644 lib/libzpool/zfs_debug.c diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index a353583eb430..edac1f1b2707 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -17,7 +17,8 @@ dist_libzpool_la_SOURCES = \ %D%/taskq.c \ %D%/util.c \ %D%/vdev_label_os.c \ - %D%/zfs_racct.c + %D%/zfs_racct.c \ + %D%/zfs_debug.c nodist_libzpool_la_SOURCES = \ module/lua/lapi.c \ @@ -46,7 +47,6 @@ nodist_libzpool_la_SOURCES = \ module/lua/lzio.c \ \ module/os/linux/zfs/vdev_file.c \ - module/os/linux/zfs/zfs_debug.c \ module/os/linux/zfs/zio_crypt.c \ \ module/zcommon/cityhash.c \ diff --git a/lib/libzpool/vdev_label_os.c b/lib/libzpool/vdev_label_os.c index 3d965b89a962..c303cba6dc09 100644 --- a/lib/libzpool/vdev_label_os.c +++ b/lib/libzpool/vdev_label_os.c @@ -30,10 +30,16 @@ #include /* - * Check if the reserved boot area is in-use. + * Check if the reserved boot area is in-use. This is called from + * spa_vdev_attach() when adding a device to a raidz vdev, to ensure that the + * reserved area is available as scratch space for raidz expansion. * - * This function always returns 0, as there are no known external uses - * of the reserved area on Linux. + * This function currently always returns 0. On Linux, there are no known + * external uses of the reserved area. On FreeBSD, the reserved boot area is + * used when booting to a ZFS root from an MBR partition. + * + * Currently nothing using libzpool can add a disk to a pool, so this does + * nothing. */ int vdev_check_boot_reserve(spa_t *spa, vdev_t *childvd) diff --git a/lib/libzpool/zfs_debug.c b/lib/libzpool/zfs_debug.c new file mode 100644 index 000000000000..df49a9a33fe8 --- /dev/null +++ b/lib/libzpool/zfs_debug.c @@ -0,0 +1,106 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2024, Rob Norris + */ + +#include + +typedef struct zfs_dbgmsg { + list_node_t zdm_node; + uint64_t zdm_timestamp; + uint_t zdm_size; + char zdm_msg[]; /* variable length allocation */ +} zfs_dbgmsg_t; + +static list_t zfs_dbgmsgs; +static kmutex_t zfs_dbgmsgs_lock; + +int zfs_dbgmsg_enable = B_TRUE; + +void +zfs_dbgmsg_init(void) +{ + list_create(&zfs_dbgmsgs, sizeof (zfs_dbgmsg_t), + offsetof(zfs_dbgmsg_t, zdm_node)); + mutex_init(&zfs_dbgmsgs_lock, NULL, MUTEX_DEFAULT, NULL); +} + +void +zfs_dbgmsg_fini(void) +{ + zfs_dbgmsg_t *zdm; + while ((zdm = list_remove_head(&zfs_dbgmsgs))) + umem_free(zdm, zdm->zdm_size); + mutex_destroy(&zfs_dbgmsgs_lock); +} + +void +__set_error(const char *file, const char *func, int line, int err) +{ + if (zfs_flags & ZFS_DEBUG_SET_ERROR) + __dprintf(B_FALSE, file, func, line, "error %lu", + (ulong_t)err); +} + +void +__zfs_dbgmsg(char *buf) +{ + uint_t size = sizeof (zfs_dbgmsg_t) + strlen(buf) + 1; + zfs_dbgmsg_t *zdm = umem_zalloc(size, KM_SLEEP); + zdm->zdm_size = size; + zdm->zdm_timestamp = gethrestime_sec(); + strcpy(zdm->zdm_msg, buf); + + mutex_enter(&zfs_dbgmsgs_lock); + list_insert_tail(&zfs_dbgmsgs, zdm); + mutex_exit(&zfs_dbgmsgs_lock); +} + +void +zfs_dbgmsg_print(int fd, const char *tag) +{ + ssize_t ret __attribute__((unused)); + + mutex_enter(&zfs_dbgmsgs_lock); + + /* + * We use write() in this function instead of printf() + * so it is safe to call from a signal handler. + */ + ret = write(fd, "ZFS_DBGMSG(", 11); + ret = write(fd, tag, strlen(tag)); + ret = write(fd, ") START:\n", 9); + + for (zfs_dbgmsg_t *zdm = list_head(&zfs_dbgmsgs); zdm != NULL; + zdm = list_next(&zfs_dbgmsgs, zdm)) { + ret = write(fd, zdm->zdm_msg, strlen(zdm->zdm_msg)); + ret = write(fd, "\n", 1); + } + + ret = write(fd, "ZFS_DBGMSG(", 11); + ret = write(fd, tag, strlen(tag)); + ret = write(fd, ") END\n", 6); + + mutex_exit(&zfs_dbgmsgs_lock); +} diff --git a/module/os/freebsd/zfs/zfs_debug.c b/module/os/freebsd/zfs/zfs_debug.c index c4cebe102075..a7ddd3c2f5eb 100644 --- a/module/os/freebsd/zfs/zfs_debug.c +++ b/module/os/freebsd/zfs/zfs_debug.c @@ -140,15 +140,11 @@ zfs_dbgmsg_fini(void) { if (zfs_dbgmsg_kstat) kstat_delete(zfs_dbgmsg_kstat); - /* - * TODO - decide how to make this permanent - */ -#ifdef _KERNEL + mutex_enter(&zfs_dbgmsgs_lock); zfs_dbgmsg_purge(0); mutex_exit(&zfs_dbgmsgs_lock); mutex_destroy(&zfs_dbgmsgs_lock); -#endif } void @@ -184,7 +180,6 @@ __set_error(const char *file, const char *func, int line, int err) __dprintf(B_FALSE, file, func, line, "error %lu", (ulong_t)err); } -#ifdef _KERNEL void __dprintf(boolean_t dprint, const char *file, const char *func, int line, const char *fmt, ...) @@ -229,37 +224,6 @@ __dprintf(boolean_t dprint, const char *file, const char *func, kmem_free(buf, size); } -#else - -void -zfs_dbgmsg_print(int fd, const char *tag) -{ - ssize_t ret __attribute__((unused)); - - /* - * We use write() in this function instead of printf() - * so it is safe to call from a signal handler. - */ - ret = write(fd, "ZFS_DBGMSG(", 11); - ret = write(fd, tag, strlen(tag)); - ret = write(fd, ") START:\n", 9); - - mutex_enter(&zfs_dbgmsgs_lock); - - for (zfs_dbgmsg_t *zdm = list_head(&zfs_dbgmsgs); zdm != NULL; - zdm = list_next(&zfs_dbgmsgs, zdm)) - ret = write(fd, zdm->zdm_msg, strlen(zdm->zdm_msg)); - ret = write(fd, "\n", 1); - } - - ret = write(fd, "ZFS_DBGMSG(", 11); - ret = write(fd, tag, strlen(tag)); - ret = write(fd, ") END\n", 6); - - mutex_exit(&zfs_dbgmsgs_lock); -} -#endif /* _KERNEL */ - ZFS_MODULE_PARAM(zfs, zfs_, dbgmsg_enable, INT, ZMOD_RW, "Enable ZFS debug message log"); diff --git a/module/os/linux/zfs/zfs_debug.c b/module/os/linux/zfs/zfs_debug.c index 733b4a574bf5..92e2d69ee06b 100644 --- a/module/os/linux/zfs/zfs_debug.c +++ b/module/os/linux/zfs/zfs_debug.c @@ -111,12 +111,7 @@ zfs_dbgmsg_fini(void) procfs_list_uninstall(&zfs_dbgmsgs); zfs_dbgmsg_purge(0); - /* - * TODO - decide how to make this permanent - */ -#ifdef _KERNEL procfs_list_destroy(&zfs_dbgmsgs); -#endif } void @@ -148,8 +143,6 @@ __zfs_dbgmsg(char *buf) mutex_exit(&zfs_dbgmsgs.pl_lock); } -#ifdef _KERNEL - void __dprintf(boolean_t dprint, const char *file, const char *func, int line, const char *fmt, ...) @@ -217,38 +210,6 @@ __dprintf(boolean_t dprint, const char *file, const char *func, kmem_free(buf, size); } -#else - -void -zfs_dbgmsg_print(int fd, const char *tag) -{ - ssize_t ret __attribute__((unused)); - - mutex_enter(&zfs_dbgmsgs.pl_lock); - - /* - * We use write() in this function instead of printf() - * so it is safe to call from a signal handler. - */ - ret = write(fd, "ZFS_DBGMSG(", 11); - ret = write(fd, tag, strlen(tag)); - ret = write(fd, ") START:\n", 9); - - for (zfs_dbgmsg_t *zdm = list_head(&zfs_dbgmsgs.pl_list); zdm != NULL; - zdm = list_next(&zfs_dbgmsgs.pl_list, zdm)) { - ret = write(fd, zdm->zdm_msg, strlen(zdm->zdm_msg)); - ret = write(fd, "\n", 1); - } - - ret = write(fd, "ZFS_DBGMSG(", 11); - ret = write(fd, tag, strlen(tag)); - ret = write(fd, ") END\n", 6); - - mutex_exit(&zfs_dbgmsgs.pl_lock); -} -#endif /* _KERNEL */ - -#ifdef _KERNEL module_param(zfs_dbgmsg_enable, int, 0644); MODULE_PARM_DESC(zfs_dbgmsg_enable, "Enable ZFS debug message log"); @@ -256,4 +217,3 @@ MODULE_PARM_DESC(zfs_dbgmsg_enable, "Enable ZFS debug message log"); module_param(zfs_dbgmsg_maxsize, uint, 0644); /* END CSTYLED */ MODULE_PARM_DESC(zfs_dbgmsg_maxsize, "Maximum ZFS debug log size"); -#endif From dbeb5095798653d8f3200980ce75d7426ff27561 Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Wed, 13 Nov 2024 09:58:26 -0800 Subject: [PATCH 203/223] [zfs-2.2.7] Add vdev_check_boot_reserve() to vdev.h Add vdev_check_boot_reserve() to vdev.h for zfs-2.2.7 compatibility. Signed-off-by: Tony Hutter --- include/sys/vdev.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/sys/vdev.h b/include/sys/vdev.h index 03e1f438aaf9..05d18a36cbaa 100644 --- a/include/sys/vdev.h +++ b/include/sys/vdev.h @@ -204,6 +204,7 @@ extern void vdev_label_write(zio_t *zio, vdev_t *vd, int l, abd_t *buf, uint64_t offset, uint64_t size, zio_done_func_t *done, void *priv, int flags); extern int vdev_label_read_bootenv(vdev_t *, nvlist_t *); extern int vdev_label_write_bootenv(vdev_t *, nvlist_t *); +extern int vdev_check_boot_reserve(spa_t *, vdev_t *); typedef enum { VDEV_LABEL_CREATE, /* create/add a new device */ From c31b18b23c166e3edca65f0a1a295dad3ff88f02 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 24 Sep 2024 15:43:48 +1000 Subject: [PATCH 204/223] Linux 6.12: avoid kmem_cache_create redefinition torvalds/linux@b2e7456b5c25 makes kmem_cache_create() a macro, which gets in the way of our our own redefinition, so we undef the macro first for our own clients. This follows what we did for kmem_cache_alloc(), see e951dba48. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16582 --- include/os/linux/spl/sys/kmem_cache.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/os/linux/spl/sys/kmem_cache.h b/include/os/linux/spl/sys/kmem_cache.h index cfdb0ba750f7..71048db4ec5a 100644 --- a/include/os/linux/spl/sys/kmem_cache.h +++ b/include/os/linux/spl/sys/kmem_cache.h @@ -200,6 +200,7 @@ extern uint64_t spl_kmem_cache_entry_size(kmem_cache_t *cache); /* Avoid conflicts with kernel names that might be implemented as macros. */ #undef kmem_cache_alloc +#undef kmem_cache_create #define kmem_cache_create(name, size, align, ctor, dtor, rclm, priv, vmp, fl) \ spl_kmem_cache_create(name, size, align, ctor, dtor, rclm, priv, vmp, fl) From 08192d12eb06a7d799a0e95e8eb91889b50a6b81 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 24 Sep 2024 16:06:14 +1000 Subject: [PATCH 205/223] Linux 6.12: support 3arg dequeue_signal() without task param See torvalds/linux@a2b80ce87a87. It claims the task arg is always `current`, and so it is with us, so this is a safe change to make. The only spanner is that we also support the older pre-5.17 3-arg dequeue_signal() which had different meaning, so we have to check the types to get the right one. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16582 --- config/kernel-kthread.m4 | 37 ++++++++++++++++++++++++++------ module/os/linux/spl/spl-thread.c | 18 +++++++++------- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/config/kernel-kthread.m4 b/config/kernel-kthread.m4 index f5b824d7947a..4d580efead6b 100644 --- a/config/kernel-kthread.m4 +++ b/config/kernel-kthread.m4 @@ -15,7 +15,7 @@ AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT], [ ]) ]) -AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL_4ARG], [ +AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL], [ dnl # dnl # 5.17 API: enum pid_type * as new 4th dequeue_signal() argument, dnl # 5768d8906bc23d512b1a736c1e198aa833a6daa4 ("signal: Requeue signals in the appropriate queue") @@ -23,12 +23,24 @@ AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL_4ARG], [ dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info); dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type); dnl # + dnl # 6.12 API: first arg struct_task* removed + dnl # int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type); + dnl # AC_MSG_CHECKING([whether dequeue_signal() takes 4 arguments]) - ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal], [ + ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_4arg], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_DEQUEUE_SIGNAL_4ARG, 1, [dequeue_signal() takes 4 arguments]) + AC_DEFINE(HAVE_DEQUEUE_SIGNAL_4ARG, 1, + [dequeue_signal() takes 4 arguments]) ], [ AC_MSG_RESULT(no) + AC_MSG_CHECKING([whether dequeue_signal() a task argument]) + ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_3arg_task], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEQUEUE_SIGNAL_3ARG_TASK, 1, + [dequeue_signal() takes a task argument]) + ], [ + AC_MSG_RESULT(no) + ]) ]) ]) @@ -43,8 +55,19 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT], [ ]) ]) -AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL_4ARG], [ - ZFS_LINUX_TEST_SRC([kthread_dequeue_signal], [ +AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL], [ + ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_3arg_task], [ + #include + ], [ + struct task_struct *task = NULL; + sigset_t *mask = NULL; + kernel_siginfo_t *info = NULL; + int error __attribute__ ((unused)); + + error = dequeue_signal(task, mask, info); + ]) + + ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_4arg], [ #include ], [ struct task_struct *task = NULL; @@ -59,10 +82,10 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL_4ARG], [ AC_DEFUN([ZFS_AC_KERNEL_KTHREAD], [ ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT - ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL_4ARG + ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL ]) AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD], [ ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT - ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL_4ARG + ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL ]) diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c index 80acd0201b3b..7f74d44f91ff 100644 --- a/module/os/linux/spl/spl-thread.c +++ b/module/os/linux/spl/spl-thread.c @@ -162,20 +162,22 @@ issig(void) if (!signal_pending(current)) return (0); - struct task_struct *task = current; spl_kernel_siginfo_t __info; sigset_t set; siginitsetinv(&set, 1ULL << (SIGSTOP - 1) | 1ULL << (SIGTSTP - 1)); - sigorsets(&set, &task->blocked, &set); + sigorsets(&set, ¤t->blocked, &set); - spin_lock_irq(&task->sighand->siglock); -#ifdef HAVE_DEQUEUE_SIGNAL_4ARG + spin_lock_irq(¤t->sighand->siglock); +#if defined(HAVE_DEQUEUE_SIGNAL_4ARG) enum pid_type __type; - if (dequeue_signal(task, &set, &__info, &__type) != 0) { + if (dequeue_signal(current, &set, &__info, &__type) != 0) { +#elif defined(HAVE_DEQUEUE_SIGNAL_3ARG_TASK) + if (dequeue_signal(current, &set, &__info) != 0) { #else - if (dequeue_signal(task, &set, &__info) != 0) { + enum pid_type __type; + if (dequeue_signal(&set, &__info, &__type) != 0) { #endif - spin_unlock_irq(&task->sighand->siglock); + spin_unlock_irq(¤t->sighand->siglock); kernel_signal_stop(); /* @@ -188,7 +190,7 @@ issig(void) return (0); } - spin_unlock_irq(&task->sighand->siglock); + spin_unlock_irq(¤t->sighand->siglock); return (1); } From 997831548a7c76f22b70384e5bf5efc054b732d3 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 24 Sep 2024 16:19:18 +1000 Subject: [PATCH 206/223] Linux 6.12: FMODE_UNSIGNED_OFFSET is now FOP_UNSIGNED_OFFSET torvalds/linux@641bb4394f40 asserts that this is a static flag, not intended to be variable per-file, so it moves it to file_operations instead. We just change our check to follow. No configure check is necessary because FOP_UNSIGNED_OFFSET didn't exist before this commit, and FMODE_UNSIGNED_OFFSET flag is removed in the same commit, so there's no chance of a conflict. It's not clear to me that we need this check at all, as we never set this flag on our own files, and I can't see any way that our llseek handler could recieve a file from another filesystem. But, the whole zpl_llseek() has a number of opportunities for pleasing cleanup that are nothing to do with this change, so I'll leave that for a future change. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16582 --- include/os/linux/kernel/linux/vfs_compat.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index 075b9e111b10..b4767d1ece89 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -68,7 +68,11 @@ lseek_execute( loff_t offset, loff_t maxsize) { +#ifdef FMODE_UNSIGNED_OFFSET if (offset < 0 && !(filp->f_mode & FMODE_UNSIGNED_OFFSET)) +#else + if (offset < 0 && !(filp->f_op->fop_flags & FOP_UNSIGNED_OFFSET)) +#endif return (-EINVAL); if (offset > maxsize) From dbc70ec73aae2e33025e2e3ae650762f250361b9 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 24 Sep 2024 16:44:01 +1000 Subject: [PATCH 207/223] Linux 6.12: f_version removed from struct file linux/torvalds@11068e0b64cb removes it, suggesting this was a always there as a helper to handle concurrent seeks, which all filesystems now handle themselves if necessary. Without looking into the mechanism, I can imagine how it might have been used, but we have always set it to zero and never read from it, presumably because we've always tracked per-caller position through the znode anyway. So I don't see how there can be any functional change for us by removing it. I've stayed conservative though and left it in for older kernels, since its clearly not hurting anything there. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16582 --- config/kernel-file.m4 | 31 ++++++++++++++++++++++ config/kernel.m4 | 2 ++ include/os/linux/kernel/linux/vfs_compat.h | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 config/kernel-file.m4 diff --git a/config/kernel-file.m4 b/config/kernel-file.m4 new file mode 100644 index 000000000000..31252544c745 --- /dev/null +++ b/config/kernel-file.m4 @@ -0,0 +1,31 @@ +dnl # +dnl # 6.12 removed f_version from struct file +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_FILE_F_VERSION], [ + ZFS_LINUX_TEST_SRC([file_f_version], [ + #include + + static const struct f __attribute__((unused)) = { + .f_version = 0; + }; + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_FILE_F_VERSION], [ + AC_MSG_CHECKING([whether file->f_version exists]) + ZFS_LINUX_TEST_RESULT([file_f_version], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FILE_F_VERSION, 1, + [file->f_version exists]) + ], [ + AC_MSG_RESULT(no) + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_FILE], [ + ZFS_AC_KERNEL_FILE_F_VERSION +]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_FILE], [ + ZFS_AC_KERNEL_SRC_FILE_F_VERSION +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 465f69b72b36..640dbbaeff7b 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -125,6 +125,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SYNC_BDEV ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING + ZFS_AC_KERNEL_SRC_FILE case "$host_cpu" in powerpc*) ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE @@ -234,6 +235,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_MM_PAGE_SIZE ZFS_AC_KERNEL_MM_PAGE_MAPPING ZFS_AC_KERNEL_1ARG_ASSIGN_STR + ZFS_AC_KERNEL_FILE case "$host_cpu" in powerpc*) ZFS_AC_KERNEL_CPU_HAS_FEATURE diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index b4767d1ece89..3ed456dbf4c8 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -81,7 +81,9 @@ lseek_execute( if (offset != filp->f_pos) { spin_lock(&filp->f_lock); filp->f_pos = offset; +#ifdef HAVE_FILE_F_VERSION filp->f_version = 0; +#endif spin_unlock(&filp->f_lock); } From 01e06ed89d3547c873e704499be86dac8310e26c Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 24 Sep 2024 17:17:00 +1000 Subject: [PATCH 208/223] Linux 6.12: PG_error flag was removed torvalds/linux@09022bc196d2 removes the flag, and the corresponding SetPageError() and ClearPageError() macros, with no replacement offered. Going back through the upstream history, use of this flag has been gradually removed over the last year as part of the long tail of converting everything to folios. Interesting tidbit comments from torvalds/linux@29e9412b250e and torvalds/linux@420e05d0de18 suggest that this flag has not been used meaningfully since page writeback failures started being recorded in errseq_t instead (the whole "fsyncgate" thing, ~2017, around torvalds/linux@8ed1e46aaf1b). Given that, it's possible that since perhaps Linux 4.13 we haven't been getting anything by setting the flag. I don't know if that's true and/or if there's something we should be doing instead, but my gut feel is that its probably fine we only use the page cache as a proxy to allow mmap() to work, rather than backing IO with it. As such, I'm expecting that removing this will do no harm, but I'm leaving it in for older kernels to maintain status quo, and if there is an overall better way, that is left for a future change. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16582 --- config/kernel-mm-page-flags.m4 | 24 +++++++++++++++++++++++ config/kernel.m4 | 2 ++ include/os/linux/kernel/linux/mm_compat.h | 14 +++++++++++++ module/os/linux/zfs/zfs_znode_os.c | 1 + 4 files changed, 41 insertions(+) create mode 100644 config/kernel-mm-page-flags.m4 diff --git a/config/kernel-mm-page-flags.m4 b/config/kernel-mm-page-flags.m4 new file mode 100644 index 000000000000..b1277118305d --- /dev/null +++ b/config/kernel-mm-page-flags.m4 @@ -0,0 +1,24 @@ +AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_FLAG_ERROR], [ + ZFS_LINUX_TEST_SRC([mm_page_flag_error], [ + #include + + static enum pageflags + test_flag __attribute__((unused)) = PG_error; + ]) +]) +AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_FLAG_ERROR], [ + AC_MSG_CHECKING([whether PG_error flag is available]) + ZFS_LINUX_TEST_RESULT([mm_page_flag_error], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_MM_PAGE_FLAG_ERROR, 1, [PG_error flag is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_FLAGS], [ + ZFS_AC_KERNEL_SRC_MM_PAGE_FLAG_ERROR +]) +AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_FLAGS], [ + ZFS_AC_KERNEL_MM_PAGE_FLAG_ERROR +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 640dbbaeff7b..df3bf5293529 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -123,6 +123,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_PROC_HANDLER_CTL_TABLE_CONST ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ ZFS_AC_KERNEL_SRC_SYNC_BDEV + ZFS_AC_KERNEL_SRC_MM_PAGE_FLAGS ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING ZFS_AC_KERNEL_SRC_FILE @@ -232,6 +233,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_PROC_HANDLER_CTL_TABLE_CONST ZFS_AC_KERNEL_COPY_SPLICE_READ ZFS_AC_KERNEL_SYNC_BDEV + ZFS_AC_KERNEL_MM_PAGE_FLAGS ZFS_AC_KERNEL_MM_PAGE_SIZE ZFS_AC_KERNEL_MM_PAGE_MAPPING ZFS_AC_KERNEL_1ARG_ASSIGN_STR diff --git a/include/os/linux/kernel/linux/mm_compat.h b/include/os/linux/kernel/linux/mm_compat.h index 817f6df422de..4cdc0e099994 100644 --- a/include/os/linux/kernel/linux/mm_compat.h +++ b/include/os/linux/kernel/linux/mm_compat.h @@ -40,4 +40,18 @@ #define page_mapping(p) folio_mapping(page_folio(p)) #endif +/* + * 6.12 removed PG_error, SetPageError and ClearPageError, with no direct + * replacement, because page writeback errors are recorded elsewhere. Since we + * only use the page cache to assist with mmap(), never directly backing it + * with IO, it shouldn't be possible for this condition to occur on our pages + * anyway, even if this is the right way to report it. So it should be safe + * to remove, but for avoidance of doubt, we make it a no-op on 6.12 and leave + * it for everything else. + */ +#ifndef HAVE_MM_PAGE_FLAG_ERROR +#define SetPageError(p) do {} while (0) +#define ClearPageError(p) do {} while (0) +#endif + #endif /* _ZFS_MM_COMPAT_H */ diff --git a/module/os/linux/zfs/zfs_znode_os.c b/module/os/linux/zfs/zfs_znode_os.c index e135f9044679..bbaca2f58394 100644 --- a/module/os/linux/zfs/zfs_znode_os.c +++ b/module/os/linux/zfs/zfs_znode_os.c @@ -58,6 +58,7 @@ #include #include #include +#include #include "zfs_prop.h" #include "zfs_comutil.h" From 9e7af55e8804c9ba914681fc74d0da4408ae80b3 Mon Sep 17 00:00:00 2001 From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:30:25 -0400 Subject: [PATCH 209/223] Add custom debug printing for your asserts Being able to print custom debug information on assert trip seems useful. Reviewed-by: Brian Behlendorf Reviewed-by: Paul Dagnelie Signed-off-by: Rich Ercolani Closes #15792 --- include/os/freebsd/spl/sys/debug.h | 149 +++++++++++++++++++++++++--- include/os/linux/spl/sys/debug.h | 152 +++++++++++++++++++++++++---- lib/libspl/include/assert.h | 97 ++++++++++++++++++ module/zfs/arc.c | 5 +- 4 files changed, 372 insertions(+), 31 deletions(-) diff --git a/include/os/freebsd/spl/sys/debug.h b/include/os/freebsd/spl/sys/debug.h index 785fcf62dd16..f041dde34fc8 100644 --- a/include/os/freebsd/spl/sys/debug.h +++ b/include/os/freebsd/spl/sys/debug.h @@ -56,11 +56,33 @@ /* * Common DEBUG functionality. */ +#ifdef __FreeBSD__ +#include +#endif + +#ifndef __printflike +#define __printflike(a, b) __printf(a, b) +#endif + +#ifndef __maybe_unused +#define __maybe_unused __attribute__((unused)) +#endif + +/* + * Without this, we see warnings from objtool during normal Linux builds when + * the kernel is built with CONFIG_STACK_VALIDATION=y: + * + * warning: objtool: tsd_create() falls through to next function __list_add() + * warning: objtool: .text: unexpected end of section + * + * Until the toolchain stops doing this, we must only define this attribute on + * spl_panic() when doing static analysis. + */ #if defined(__COVERITY__) || defined(__clang_analyzer__) __attribute__((__noreturn__)) #endif extern void spl_panic(const char *file, const char *func, int line, - const char *fmt, ...) __attribute__((__noreturn__)); + const char *fmt, ...); extern void spl_dumpstack(void); static inline int @@ -73,8 +95,10 @@ spl_assert(const char *buf, const char *file, const char *func, int line) #ifndef expect #define expect(expr, value) (__builtin_expect((expr), (value))) #endif +#ifndef __linux__ #define likely(expr) expect((expr) != 0, 1) #define unlikely(expr) expect((expr) != 0, 0) +#endif #define PANIC(fmt, a...) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## a) @@ -84,6 +108,12 @@ spl_assert(const char *buf, const char *file, const char *func, int line) spl_assert("VERIFY(" #cond ") failed\n", \ __FILE__, __FUNCTION__, __LINE__)) +#define VERIFYF(cond, str, ...) do { \ + if (unlikely(!cond)) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY(" #cond ") failed " str "\n", __VA_ARGS__);\ + } while (0) + #define VERIFY3B(LEFT, OP, RIGHT) do { \ const boolean_t _verify3_left = (boolean_t)(LEFT); \ const boolean_t _verify3_right = (boolean_t)(RIGHT); \ @@ -123,7 +153,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ - "failed (%p " #OP " %p)\n", \ + "failed (%px " #OP " %px)\n", \ (void *)_verify3_left, \ (void *)_verify3_right); \ } while (0) @@ -142,10 +172,98 @@ spl_assert(const char *buf, const char *file, const char *func, int line) if (unlikely(!(0 == _verify0_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ "VERIFY0P(" #RIGHT ") " \ - "failed (NULL == %p)\n", \ + "failed (NULL == %px)\n", \ (void *)_verify0_right); \ } while (0) +/* + * Note that you should not put any operations you want to always happen + * in the print section for ASSERTs unless you only want them to run on + * debug builds! + * e.g. ASSERT3UF(2, <, 3, "%s", foo(x)), foo(x) won't run on non-debug + * builds. + */ + +#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \ + const boolean_t _verify3_left = (boolean_t)(LEFT); \ + const boolean_t _verify3_right = (boolean_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%d " #OP " %d) " STR "\n", \ + (boolean_t)(_verify3_left), \ + (boolean_t)(_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY3SF(LEFT, OP, RIGHT, STR, ...) do { \ + const int64_t _verify3_left = (int64_t)(LEFT); \ + const int64_t _verify3_right = (int64_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%lld " #OP " %lld) " STR "\n", \ + (long long)(_verify3_left), \ + (long long)(_verify3_right), \ + __VA_ARGS); \ + } while (0) + +#define VERIFY3UF(LEFT, OP, RIGHT, STR, ...) do { \ + const uint64_t _verify3_left = (uint64_t)(LEFT); \ + const uint64_t _verify3_right = (uint64_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%llu " #OP " %llu) " STR "\n", \ + (unsigned long long)(_verify3_left), \ + (unsigned long long)(_verify3_right), \ + __VA_ARGS); \ + } while (0) + +#define VERIFY3PF(LEFT, OP, RIGHT, STR, ...) do { \ + const uintptr_t _verify3_left = (uintptr_t)(LEFT); \ + const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%px " #OP " %px) " STR "\n", \ + (void *) (_verify3_left), \ + (void *) (_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY0PF(RIGHT, STR, ...) do { \ + const uintptr_t _verify3_left = (uintptr_t)(0); \ + const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ + if (unlikely(!(_verify3_left == _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY0(0 == " #RIGHT ") " \ + "failed (0 == %px) " STR "\n", \ + (long long) (_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY0F(RIGHT, STR, ...) do { \ + const int64_t _verify3_left = (int64_t)(0); \ + const int64_t _verify3_right = (int64_t)(RIGHT); \ + if (unlikely(!(_verify3_left == _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY0(0 == " #RIGHT ") " \ + "failed (0 == %lld) " STR "\n", \ + (long long) (_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY_IMPLY(A, B) \ + ((void)(likely((!(A)) || (B)) || \ + spl_assert("(" #A ") implies (" #B ")", \ + __FILE__, __FUNCTION__, __LINE__))) + +#define VERIFY_EQUIV(A, B) \ + ((void)(likely(!!(A) == !!(B)) || \ + spl_assert("(" #A ") is equivalent to (" #B ")", \ + __FILE__, __FUNCTION__, __LINE__))) + /* * Debugging disabled (--disable-debug) */ @@ -162,6 +280,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line) ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) #define ASSERT0(x) ((void) sizeof ((uintptr_t)(x))) #define ASSERT0P(x) ((void) sizeof ((uintptr_t)(x))) +#define ASSERT3BF(x, y, z, str, ...) ASSERT3B(x, y, z) +#define ASSERT3SF(x, y, z, str, ...) ASSERT3S(x, y, z) +#define ASSERT3UF(x, y, z, str, ...) ASSERT3U(x, y, z) +#define ASSERT3PF(x, y, z, str, ...) ASSERT3P(x, y, z) +#define ASSERT0PF(x, str, ...) ASSERT0P(x) +#define ASSERT0F(x, str, ...) ASSERT0(x) +#define ASSERTF(x, str, ...) ASSERT(x) #define IMPLY(A, B) \ ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B))) #define EQUIV(A, B) \ @@ -178,16 +303,16 @@ spl_assert(const char *buf, const char *file, const char *func, int line) #define ASSERT3P VERIFY3P #define ASSERT0 VERIFY0 #define ASSERT0P VERIFY0P +#define ASSERT3BF VERIFY3BF +#define ASSERT3SF VERIFY3SF +#define ASSERT3UF VERIFY3UF +#define ASSERT3PF VERIFY3PF +#define ASSERT0PF VERIFY0PF +#define ASSERT0F VERIFY0F +#define ASSERTF VERIFYF #define ASSERT VERIFY -#define IMPLY(A, B) \ - ((void)(likely((!(A)) || (B)) || \ - spl_assert("(" #A ") implies (" #B ")", \ - __FILE__, __FUNCTION__, __LINE__))) -#define EQUIV(A, B) \ - ((void)(likely(!!(A) == !!(B)) || \ - spl_assert("(" #A ") is equivalent to (" #B ")", \ - __FILE__, __FUNCTION__, __LINE__))) - +#define IMPLY VERIFY_IMPLY +#define EQUIV VERIFY_EQUIV #endif /* NDEBUG */ diff --git a/include/os/linux/spl/sys/debug.h b/include/os/linux/spl/sys/debug.h index 288193ad21c5..f041dde34fc8 100644 --- a/include/os/linux/spl/sys/debug.h +++ b/include/os/linux/spl/sys/debug.h @@ -1,24 +1,29 @@ /* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 + * Copyright (c) 2020 iXsystems, Inc. + * All rights reserved. * - * This file is part of the SPL, Solaris Porting Layer. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . + * $FreeBSD$ */ /* @@ -47,10 +52,17 @@ #ifndef _SPL_DEBUG_H #define _SPL_DEBUG_H + /* * Common DEBUG functionality. */ +#ifdef __FreeBSD__ +#include +#endif + +#ifndef __printflike #define __printflike(a, b) __printf(a, b) +#endif #ifndef __maybe_unused #define __maybe_unused __attribute__((unused)) @@ -80,6 +92,14 @@ spl_assert(const char *buf, const char *file, const char *func, int line) return (0); } +#ifndef expect +#define expect(expr, value) (__builtin_expect((expr), (value))) +#endif +#ifndef __linux__ +#define likely(expr) expect((expr) != 0, 1) +#define unlikely(expr) expect((expr) != 0, 0) +#endif + #define PANIC(fmt, a...) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## a) @@ -88,6 +108,12 @@ spl_assert(const char *buf, const char *file, const char *func, int line) spl_assert("VERIFY(" #cond ") failed\n", \ __FILE__, __FUNCTION__, __LINE__)) +#define VERIFYF(cond, str, ...) do { \ + if (unlikely(!cond)) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY(" #cond ") failed " str "\n", __VA_ARGS__);\ + } while (0) + #define VERIFY3B(LEFT, OP, RIGHT) do { \ const boolean_t _verify3_left = (boolean_t)(LEFT); \ const boolean_t _verify3_right = (boolean_t)(RIGHT); \ @@ -150,6 +176,84 @@ spl_assert(const char *buf, const char *file, const char *func, int line) (void *)_verify0_right); \ } while (0) +/* + * Note that you should not put any operations you want to always happen + * in the print section for ASSERTs unless you only want them to run on + * debug builds! + * e.g. ASSERT3UF(2, <, 3, "%s", foo(x)), foo(x) won't run on non-debug + * builds. + */ + +#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \ + const boolean_t _verify3_left = (boolean_t)(LEFT); \ + const boolean_t _verify3_right = (boolean_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%d " #OP " %d) " STR "\n", \ + (boolean_t)(_verify3_left), \ + (boolean_t)(_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY3SF(LEFT, OP, RIGHT, STR, ...) do { \ + const int64_t _verify3_left = (int64_t)(LEFT); \ + const int64_t _verify3_right = (int64_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%lld " #OP " %lld) " STR "\n", \ + (long long)(_verify3_left), \ + (long long)(_verify3_right), \ + __VA_ARGS); \ + } while (0) + +#define VERIFY3UF(LEFT, OP, RIGHT, STR, ...) do { \ + const uint64_t _verify3_left = (uint64_t)(LEFT); \ + const uint64_t _verify3_right = (uint64_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%llu " #OP " %llu) " STR "\n", \ + (unsigned long long)(_verify3_left), \ + (unsigned long long)(_verify3_right), \ + __VA_ARGS); \ + } while (0) + +#define VERIFY3PF(LEFT, OP, RIGHT, STR, ...) do { \ + const uintptr_t _verify3_left = (uintptr_t)(LEFT); \ + const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%px " #OP " %px) " STR "\n", \ + (void *) (_verify3_left), \ + (void *) (_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY0PF(RIGHT, STR, ...) do { \ + const uintptr_t _verify3_left = (uintptr_t)(0); \ + const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ + if (unlikely(!(_verify3_left == _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY0(0 == " #RIGHT ") " \ + "failed (0 == %px) " STR "\n", \ + (long long) (_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY0F(RIGHT, STR, ...) do { \ + const int64_t _verify3_left = (int64_t)(0); \ + const int64_t _verify3_right = (int64_t)(RIGHT); \ + if (unlikely(!(_verify3_left == _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY0(0 == " #RIGHT ") " \ + "failed (0 == %lld) " STR "\n", \ + (long long) (_verify3_right), \ + __VA_ARGS__); \ + } while (0) + #define VERIFY_IMPLY(A, B) \ ((void)(likely((!(A)) || (B)) || \ spl_assert("(" #A ") implies (" #B ")", \ @@ -176,6 +280,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line) ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) #define ASSERT0(x) ((void) sizeof ((uintptr_t)(x))) #define ASSERT0P(x) ((void) sizeof ((uintptr_t)(x))) +#define ASSERT3BF(x, y, z, str, ...) ASSERT3B(x, y, z) +#define ASSERT3SF(x, y, z, str, ...) ASSERT3S(x, y, z) +#define ASSERT3UF(x, y, z, str, ...) ASSERT3U(x, y, z) +#define ASSERT3PF(x, y, z, str, ...) ASSERT3P(x, y, z) +#define ASSERT0PF(x, str, ...) ASSERT0P(x) +#define ASSERT0F(x, str, ...) ASSERT0(x) +#define ASSERTF(x, str, ...) ASSERT(x) #define IMPLY(A, B) \ ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B))) #define EQUIV(A, B) \ @@ -192,6 +303,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line) #define ASSERT3P VERIFY3P #define ASSERT0 VERIFY0 #define ASSERT0P VERIFY0P +#define ASSERT3BF VERIFY3BF +#define ASSERT3SF VERIFY3SF +#define ASSERT3UF VERIFY3UF +#define ASSERT3PF VERIFY3PF +#define ASSERT0PF VERIFY0PF +#define ASSERT0F VERIFY0F +#define ASSERTF VERIFYF #define ASSERT VERIFY #define IMPLY VERIFY_IMPLY #define EQUIV VERIFY_EQUIV diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h index 57f5719c1ac1..155bbab3020a 100644 --- a/lib/libspl/include/assert.h +++ b/lib/libspl/include/assert.h @@ -70,6 +70,15 @@ libspl_assert(const char *buf, const char *file, const char *func, int line) #define VERIFY(cond) \ (void) ((!(cond)) && \ libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__)) + +#define VERIFYF(cond, STR, ...) \ +do { \ + if (!(cond)) \ + libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ + "%s " STR, #cond, \ + __VA_ARGS__); \ +} while (0) + #define verify(cond) \ (void) ((!(cond)) && \ libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__)) @@ -132,6 +141,79 @@ do { \ (void *)__left); \ } while (0) +/* + * This is just here because cstyle gets upset about #LEFT + * on a newline. + */ + +/* BEGIN CSTYLED */ +#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) \ +do { \ + const boolean_t __left = (boolean_t)(LEFT); \ + const boolean_t __right = (boolean_t)(RIGHT); \ + if (!(__left OP __right)) \ + libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ + "%s %s %s (0x%llx %s 0x%llx) " STR, \ + #LEFT, #OP, #RIGHT, \ + (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ + __VA_ARGS__); \ +} while (0) + +#define VERIFY3SF(LEFT, OP, RIGHT, STR, ...) \ +do { \ + const int64_t __left = (int64_t)(LEFT); \ + const int64_t __right = (int64_t)(RIGHT); \ + if (!(__left OP __right)) \ + libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ + "%s %s %s (0x%llx %s 0x%llx) " STR, \ + #LEFT, #OP, #RIGHT, \ + (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ + __VA_ARGS__); \ +} while (0) + +#define VERIFY3UF(LEFT, OP, RIGHT, STR, ...) \ +do { \ + const uint64_t __left = (uint64_t)(LEFT); \ + const uint64_t __right = (uint64_t)(RIGHT); \ + if (!(__left OP __right)) \ + libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ + "%s %s %s (0x%llx %s 0x%llx) " STR, \ + #LEFT, #OP, #RIGHT, \ + (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ + __VA_ARGS__); \ +} while (0) + +#define VERIFY3PF(LEFT, OP, RIGHT, STR, ...) \ +do { \ + const uintptr_t __left = (uintptr_t)(LEFT); \ + const uintptr_t __right = (uintptr_t)(RIGHT); \ + if (!(__left OP __right)) \ + libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ + "%s %s %s (0x%llx %s 0x%llx) " STR, \ + #LEFT, #OP, #RIGHT, \ + (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ + __VA_ARGS__); \ +} while (0) +/* END CSTYLED */ + +#define VERIFY0F(LEFT, STR, ...) \ +do { \ + const uint64_t __left = (uint64_t)(LEFT); \ + if (!(__left == 0)) \ + libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ + "%s == 0 (0x%llx == 0) " STR, #LEFT, \ + (u_longlong_t)__left, __VA_ARGS__); \ +} while (0) + +#define VERIFY0PF(LEFT, STR, ...) \ +do { \ + const uintptr_t __left = (uintptr_t)(LEFT); \ + if (!(__left == 0)) \ + libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ + "%s == 0 (%p == 0) " STR, #LEFT, \ + (u_longlong_t)__left, __VA_ARGS__); \ +} while (0) + #ifdef assert #undef assert #endif @@ -147,7 +229,15 @@ do { \ ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) #define ASSERT0(x) ((void) sizeof ((uintptr_t)(x))) #define ASSERT0P(x) ((void) sizeof ((uintptr_t)(x))) +#define ASSERT3BF(x, y, z, str, ...) ASSERT3B(x, y, z) +#define ASSERT3SF(x, y, z, str, ...) ASSERT3S(x, y, z) +#define ASSERT3UF(x, y, z, str, ...) ASSERT3U(x, y, z) +#define ASSERT3PF(x, y, z, str, ...) ASSERT3P(x, y, z) +#define ASSERT0P(x) ((void) sizeof ((uintptr_t)(x))) +#define ASSERT0PF(x, str, ...) ASSERT0P(x) +#define ASSERT0F(x, str, ...) ASSERT0(x) #define ASSERT(x) ((void) sizeof ((uintptr_t)(x))) +#define ASSERTF(x, str, ...) ASSERT(x) #define assert(x) ((void) sizeof ((uintptr_t)(x))) #define IMPLY(A, B) \ ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B))) @@ -160,7 +250,14 @@ do { \ #define ASSERT3P VERIFY3P #define ASSERT0 VERIFY0 #define ASSERT0P VERIFY0P +#define ASSERT3BF VERIFY3BF +#define ASSERT3SF VERIFY3SF +#define ASSERT3UF VERIFY3UF +#define ASSERT3PF VERIFY3PF +#define ASSERT0PF VERIFY0PF +#define ASSERT0F VERIFY0F #define ASSERT VERIFY +#define ASSERTF VERIFYF #define assert VERIFY #define IMPLY(A, B) \ ((void)(((!(A)) || (B)) || \ diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 0aef27e10cc3..4013b2d90fd5 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -1960,7 +1960,7 @@ arc_buf_untransform_in_place(arc_buf_t *buf) ASSERT(HDR_ENCRYPTED(hdr)); ASSERT3U(hdr->b_crypt_hdr.b_ot, ==, DMU_OT_DNODE); ASSERT(HDR_EMPTY_OR_LOCKED(hdr)); - ASSERT3P(hdr->b_l1hdr.b_pabd, !=, NULL); + ASSERT3PF(hdr->b_l1hdr.b_pabd, !=, NULL, "hdr %px buf %px", hdr, buf); zio_crypt_copy_dnode_bonus(hdr->b_l1hdr.b_pabd, buf->b_data, arc_buf_size(buf)); @@ -2083,7 +2083,8 @@ arc_buf_fill(arc_buf_t *buf, spa_t *spa, const zbookmark_phys_t *zb, * allocate a new data buffer for the buf. */ if (ARC_BUF_SHARED(buf)) { - ASSERT(ARC_BUF_COMPRESSED(buf)); + ASSERTF(ARC_BUF_COMPRESSED(buf), + "buf %p was uncompressed", buf); /* We need to give the buf its own b_data */ buf->b_flags &= ~ARC_BUF_FLAG_SHARED; From fc60e0c6ea3284cc690fdf918217471da8daa589 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 16 Oct 2024 11:00:40 -0600 Subject: [PATCH 210/223] freebsd: Use compiler.h from FreeBSD's base's linuxkpi The FreeBSD linux/compiler.h in OpenZFS was copied from a very old version of FreeBSD's linuxkpi's linux/compiler.h. There's no need for this duplication. Use FreeBSD's linuxkpi version instead, and provide zfs_fallthrough to augment it (it's all that's needed). Use #pragma once to avoid naming issues for guard variables. Since this is a complete rewrite, use my copyright here (the original code in FreeBSD still credits everybody). This works back at least to FreeBSD 12.4, which is not out of support, and all newer releases. Remove extra copies of macros that were defined elsewhere, but are now properly defined in LinuxKPI so are redundant. Sponsored-by: Netflix Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: Warner Losh Closes #16650 --- include/os/freebsd/linux/compiler.h | 83 +++------------------------- include/os/freebsd/spl/sys/ccompat.h | 9 --- include/os/freebsd/spl/sys/debug.h | 4 -- 3 files changed, 8 insertions(+), 88 deletions(-) diff --git a/include/os/freebsd/linux/compiler.h b/include/os/freebsd/linux/compiler.h index b408b77c746d..24f09c722158 100644 --- a/include/os/freebsd/linux/compiler.h +++ b/include/os/freebsd/linux/compiler.h @@ -1,10 +1,5 @@ /* - * Copyright (c) 2010 Isilon Systems, Inc. - * Copyright (c) 2010 iXsystems, Inc. - * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. - * Copyright (c) 2015 François Tigeot - * All rights reserved. + * Copyright (c) 2024 Warner Losh. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,76 +21,14 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ -#ifndef _LINUX_COMPILER_H_ -#define _LINUX_COMPILER_H_ - -#include - -#define __user -#define __kernel -#define __safe -#define __force -#define __nocast -#define __iomem -#define __chk_user_ptr(x) ((void)0) -#define __chk_io_ptr(x) ((void)0) -#define __builtin_warning(x, y...) (1) -#define __acquires(x) -#define __releases(x) -#define __acquire(x) do { } while (0) -#define __release(x) do { } while (0) -#define __cond_lock(x, c) (c) -#define __bitwise -#define __devinitdata -#define __deprecated -#define __init -#define __initconst -#define __devinit -#define __devexit -#define __exit -#define __rcu -#define __percpu -#define __weak __weak_symbol -#define __malloc -#define ___stringify(...) #__VA_ARGS__ -#define __stringify(...) ___stringify(__VA_ARGS__) -#define __attribute_const__ __attribute__((__const__)) -#undef __always_inline -#define __always_inline inline -#define noinline __noinline -#define ____cacheline_aligned __aligned(CACHE_LINE_SIZE) -#define zfs_fallthrough __attribute__((__fallthrough__)) - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#endif -#define typeof(x) __typeof(x) - -#define uninitialized_var(x) x = x -#define __maybe_unused __unused -#define __always_unused __unused -#define __must_check __result_use_check - -#define __printf(a, b) __printflike(a, b) -#define barrier() __asm__ __volatile__("": : :"memory") -#define ___PASTE(a, b) a##b -#define __PASTE(a, b) ___PASTE(a, b) - -#define ACCESS_ONCE(x) (*(volatile __typeof(x) *)&(x)) - -#define WRITE_ONCE(x, v) do { \ - barrier(); \ - ACCESS_ONCE(x) = (v); \ - barrier(); \ -} while (0) - -#define lockless_dereference(p) READ_ONCE(p) +/* + * FreeBSD's LinuxKPI compiler.h as far back as FreeBSD 12 has what we need, + * except zfs_fallthrough. + */ +#pragma once -#define _AT(T, X) ((T)(X)) +#include -#endif /* _LINUX_COMPILER_H_ */ +#define zfs_fallthrough __attribute__((__fallthrough__)) diff --git a/include/os/freebsd/spl/sys/ccompat.h b/include/os/freebsd/spl/sys/ccompat.h index 48749fb8eea2..07b3515ad964 100644 --- a/include/os/freebsd/spl/sys/ccompat.h +++ b/include/os/freebsd/spl/sys/ccompat.h @@ -70,15 +70,6 @@ hlist_del(struct hlist_node *n) n->next->pprev = n->pprev; } /* BEGIN CSTYLED */ -#define READ_ONCE(x) ({ \ - __typeof(x) __var = ({ \ - barrier(); \ - ACCESS_ONCE(x); \ - }); \ - barrier(); \ - __var; \ -}) - #define HLIST_HEAD_INIT { } #define HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT #define INIT_HLIST_HEAD(head) (head)->first = NULL diff --git a/include/os/freebsd/spl/sys/debug.h b/include/os/freebsd/spl/sys/debug.h index f041dde34fc8..9eb424dd0373 100644 --- a/include/os/freebsd/spl/sys/debug.h +++ b/include/os/freebsd/spl/sys/debug.h @@ -95,10 +95,6 @@ spl_assert(const char *buf, const char *file, const char *func, int line) #ifndef expect #define expect(expr, value) (__builtin_expect((expr), (value))) #endif -#ifndef __linux__ -#define likely(expr) expect((expr) != 0, 1) -#define unlikely(expr) expect((expr) != 0, 0) -#endif #define PANIC(fmt, a...) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## a) From 1ba5b2ef8c238cd3f0a7bd8ed884e5bc08d71aea Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Fri, 17 Nov 2023 14:02:09 -0800 Subject: [PATCH 211/223] freebsd: remove __FBSDID macro use With FreeBSD's switch to git the $FreeBSD$ string is no longer expanded and they have mostly been removed upstream. Stop using __FBSDID and remove the no-longer needed sys/cdefs.h includes. Reviewed-by: Alexander Motin Signed-off-by: Brooks Davis Closes #15527 --- lib/libshare/os/freebsd/nfs.c | 3 --- lib/libspl/os/freebsd/mnttab.c | 3 --- lib/libzfs/os/freebsd/libzfs_zmount.c | 3 --- module/os/freebsd/spl/spl_acl.c | 3 --- module/os/freebsd/spl/spl_atomic.c | 3 --- module/os/freebsd/spl/spl_dtrace.c | 3 --- module/os/freebsd/spl/spl_kmem.c | 3 --- module/os/freebsd/spl/spl_kstat.c | 3 --- module/os/freebsd/spl/spl_misc.c | 3 --- module/os/freebsd/spl/spl_policy.c | 3 --- module/os/freebsd/spl/spl_procfs_list.c | 3 --- module/os/freebsd/spl/spl_sunddi.c | 3 --- module/os/freebsd/spl/spl_sysevent.c | 3 --- module/os/freebsd/spl/spl_taskq.c | 3 --- module/os/freebsd/spl/spl_vfs.c | 3 --- module/os/freebsd/spl/spl_vm.c | 3 --- module/os/freebsd/spl/spl_zlib.c | 3 --- module/os/freebsd/spl/spl_zone.c | 3 --- module/os/freebsd/zfs/crypto_os.c | 3 --- module/os/freebsd/zfs/dmu_os.c | 3 --- module/os/freebsd/zfs/kmod_core.c | 3 --- module/os/freebsd/zfs/sysctl_os.c | 3 --- module/os/freebsd/zfs/zfs_file_os.c | 3 --- module/os/freebsd/zfs/zfs_ioctl_compat.c | 3 --- module/os/freebsd/zfs/zfs_ioctl_os.c | 3 --- 25 files changed, 75 deletions(-) diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c index dbfc86f2a36b..4100912cf91a 100644 --- a/lib/libshare/os/freebsd/nfs.c +++ b/lib/libshare/os/freebsd/nfs.c @@ -26,9 +26,6 @@ * Copyright (c) 2020, 2022 by Delphix. All rights reserved. */ -#include -__FBSDID("$FreeBSD$"); - #include #include diff --git a/lib/libspl/os/freebsd/mnttab.c b/lib/libspl/os/freebsd/mnttab.c index a4673084ad5f..26a4cd992cfb 100644 --- a/lib/libspl/os/freebsd/mnttab.c +++ b/lib/libspl/os/freebsd/mnttab.c @@ -29,9 +29,6 @@ * functions. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/lib/libzfs/os/freebsd/libzfs_zmount.c b/lib/libzfs/os/freebsd/libzfs_zmount.c index 34976f7bbf46..3c50daf471b7 100644 --- a/lib/libzfs/os/freebsd/libzfs_zmount.c +++ b/lib/libzfs/os/freebsd/libzfs_zmount.c @@ -28,9 +28,6 @@ * This file implements Solaris compatible zmount() function. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_acl.c b/module/os/freebsd/spl/spl_acl.c index 4d67cbb183ec..c820d7a6d22d 100644 --- a/module/os/freebsd/spl/spl_acl.c +++ b/module/os/freebsd/spl/spl_acl.c @@ -23,9 +23,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_atomic.c b/module/os/freebsd/spl/spl_atomic.c index 80040fc6a3e3..cdfd37f3e05f 100644 --- a/module/os/freebsd/spl/spl_atomic.c +++ b/module/os/freebsd/spl/spl_atomic.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_dtrace.c b/module/os/freebsd/spl/spl_dtrace.c index 6b2872bcc066..4b9cc65d641e 100644 --- a/module/os/freebsd/spl/spl_dtrace.c +++ b/module/os/freebsd/spl/spl_dtrace.c @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_kmem.c b/module/os/freebsd/spl/spl_kmem.c index c35375b729f8..ceaa2b40beae 100644 --- a/module/os/freebsd/spl/spl_kmem.c +++ b/module/os/freebsd/spl/spl_kmem.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_kstat.c b/module/os/freebsd/spl/spl_kstat.c index 43cd4da02e30..f657ef2a3acb 100644 --- a/module/os/freebsd/spl/spl_kstat.c +++ b/module/os/freebsd/spl/spl_kstat.c @@ -28,9 +28,6 @@ * [2] https://illumos.org/man/9f/kstat_create */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_misc.c b/module/os/freebsd/spl/spl_misc.c index e3653167323b..a5fc996b6550 100644 --- a/module/os/freebsd/spl/spl_misc.c +++ b/module/os/freebsd/spl/spl_misc.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_policy.c b/module/os/freebsd/spl/spl_policy.c index 01551f53f208..42a693b073d1 100644 --- a/module/os/freebsd/spl/spl_policy.c +++ b/module/os/freebsd/spl/spl_policy.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_procfs_list.c b/module/os/freebsd/spl/spl_procfs_list.c index e8448ce00686..77d33ee2e1f3 100644 --- a/module/os/freebsd/spl/spl_procfs_list.c +++ b/module/os/freebsd/spl/spl_procfs_list.c @@ -25,9 +25,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_sunddi.c b/module/os/freebsd/spl/spl_sunddi.c index 2a3c027c9389..4c97c9f12caf 100644 --- a/module/os/freebsd/spl/spl_sunddi.c +++ b/module/os/freebsd/spl/spl_sunddi.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_sysevent.c b/module/os/freebsd/spl/spl_sysevent.c index 4a2d02350f62..dc5ed81057b8 100644 --- a/module/os/freebsd/spl/spl_sysevent.c +++ b/module/os/freebsd/spl/spl_sysevent.c @@ -25,9 +25,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_taskq.c b/module/os/freebsd/spl/spl_taskq.c index 4bf5cc9b8b26..1ca3e017050a 100644 --- a/module/os/freebsd/spl/spl_taskq.c +++ b/module/os/freebsd/spl/spl_taskq.c @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_vfs.c b/module/os/freebsd/spl/spl_vfs.c index d29855eb9437..6af3da138f8d 100644 --- a/module/os/freebsd/spl/spl_vfs.c +++ b/module/os/freebsd/spl/spl_vfs.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_vm.c b/module/os/freebsd/spl/spl_vm.c index 739ddb05e895..e6f019cb9a46 100644 --- a/module/os/freebsd/spl/spl_vm.c +++ b/module/os/freebsd/spl/spl_vm.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_zlib.c b/module/os/freebsd/spl/spl_zlib.c index 42c6d7f9df6c..4a2bb3884caa 100644 --- a/module/os/freebsd/spl/spl_zlib.c +++ b/module/os/freebsd/spl/spl_zlib.c @@ -25,9 +25,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/spl/spl_zone.c b/module/os/freebsd/spl/spl_zone.c index f75d45f9de88..e3896517bd61 100644 --- a/module/os/freebsd/spl/spl_zone.c +++ b/module/os/freebsd/spl/spl_zone.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/zfs/crypto_os.c b/module/os/freebsd/zfs/crypto_os.c index 889a840f8085..4d8493743ef1 100644 --- a/module/os/freebsd/zfs/crypto_os.c +++ b/module/os/freebsd/zfs/crypto_os.c @@ -27,9 +27,6 @@ * Portions of this file are derived from sys/geom/eli/g_eli_hmac.c */ -#include -__FBSDID("$FreeBSD$"); - #include #include diff --git a/module/os/freebsd/zfs/dmu_os.c b/module/os/freebsd/zfs/dmu_os.c index e0ff69290d0c..0a0af102ea82 100644 --- a/module/os/freebsd/zfs/dmu_os.c +++ b/module/os/freebsd/zfs/dmu_os.c @@ -25,9 +25,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index 9fd8fe51cbd9..82ff29a589cd 100644 --- a/module/os/freebsd/zfs/kmod_core.c +++ b/module/os/freebsd/zfs/kmod_core.c @@ -25,9 +25,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/zfs/sysctl_os.c b/module/os/freebsd/zfs/sysctl_os.c index 38ef590702cb..55e133c096c1 100644 --- a/module/os/freebsd/zfs/sysctl_os.c +++ b/module/os/freebsd/zfs/sysctl_os.c @@ -25,9 +25,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/zfs/zfs_file_os.c b/module/os/freebsd/zfs/zfs_file_os.c index b314489378f7..0a91ed47e144 100644 --- a/module/os/freebsd/zfs/zfs_file_os.c +++ b/module/os/freebsd/zfs/zfs_file_os.c @@ -25,9 +25,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/zfs/zfs_ioctl_compat.c b/module/os/freebsd/zfs/zfs_ioctl_compat.c index 3ddffec91e83..4a7beb650a8d 100644 --- a/module/os/freebsd/zfs/zfs_ioctl_compat.c +++ b/module/os/freebsd/zfs/zfs_ioctl_compat.c @@ -25,9 +25,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include diff --git a/module/os/freebsd/zfs/zfs_ioctl_os.c b/module/os/freebsd/zfs/zfs_ioctl_os.c index a88f62aa08a1..928cf25e940f 100644 --- a/module/os/freebsd/zfs/zfs_ioctl_os.c +++ b/module/os/freebsd/zfs/zfs_ioctl_os.c @@ -25,9 +25,6 @@ * */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include From ba4e582a6762e2772c85bcd0ac2fde473f99030f Mon Sep 17 00:00:00 2001 From: Zhenlei Huang Date: Fri, 31 May 2024 00:58:20 +0800 Subject: [PATCH 212/223] FreeBSD: Add const qualifier to members of struct opensolaris_utsname These members have directly references to the global variables exposed by the kernel. They are not going to be changed by this kernel module. Reviewed-by: Brian Behlendorf Signed-off-by: Zhenlei Huang Closes #16210 --- include/os/freebsd/spl/sys/misc.h | 10 +++++----- module/os/freebsd/spl/spl_misc.c | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/os/freebsd/spl/sys/misc.h b/include/os/freebsd/spl/sys/misc.h index 2e4efc60544a..894ccd8bf9b1 100644 --- a/include/os/freebsd/spl/sys/misc.h +++ b/include/os/freebsd/spl/sys/misc.h @@ -45,11 +45,11 @@ #define F_SEEK_HOLE FIOSEEKHOLE struct opensolaris_utsname { - char *sysname; - char *nodename; - char *release; - char version[32]; - char *machine; + const char *sysname; + const char *nodename; + const char *release; + char version[32]; + const char *machine; }; #define task_io_account_read(n) diff --git a/module/os/freebsd/spl/spl_misc.c b/module/os/freebsd/spl/spl_misc.c index a5fc996b6550..2d0821417ad9 100644 --- a/module/os/freebsd/spl/spl_misc.c +++ b/module/os/freebsd/spl/spl_misc.c @@ -37,6 +37,9 @@ #include static struct opensolaris_utsname hw_utsname = { + .sysname = ostype, + .nodename = prison0.pr_hostname, + .release = osrelease, .machine = MACHINE }; @@ -49,10 +52,6 @@ utsname(void) static void opensolaris_utsname_init(void *arg) { - - hw_utsname.sysname = ostype; - hw_utsname.nodename = prison0.pr_hostname; - hw_utsname.release = osrelease; snprintf(hw_utsname.version, sizeof (hw_utsname.version), "%d", osreldate); } From 84ad1d536695e8fde77856f2f38434111ea9574b Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 22 Sep 2024 03:03:54 +1000 Subject: [PATCH 213/223] FreeBSD: restore zfs_znode_update_vfs() I accidentally removed this in c22d56e3e, and didn't notice because it doesn't fail the build, but does fail to load into the kernel because it can't link it. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: George Melikov Signed-off-by: Rob Norris Closes #16554 --- module/os/freebsd/zfs/zfs_znode_os.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/module/os/freebsd/zfs/zfs_znode_os.c b/module/os/freebsd/zfs/zfs_znode_os.c index ca247576a0ab..fea34273baef 100644 --- a/module/os/freebsd/zfs/zfs_znode_os.c +++ b/module/os/freebsd/zfs/zfs_znode_os.c @@ -1779,6 +1779,18 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx) kmem_free(zfsvfs, sizeof (zfsvfs_t)); } +void +zfs_znode_update_vfs(znode_t *zp) +{ + vm_object_t object; + + if ((object = ZTOV(zp)->v_object) == NULL || + zp->z_size == object->un_pager.vnp.vnp_size) + return; + + vnode_pager_setsize(ZTOV(zp), zp->z_size); +} + int zfs_znode_parent_and_name(znode_t *zp, znode_t **dzpp, char *buf) { From 384b53be8e5c52a6c9d8f84fe1b198260e754f0e Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Thu, 1 Aug 2024 15:25:42 -0400 Subject: [PATCH 214/223] FreeBSD: Add missing memory reclamation accounting Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Reviewed-by: Tino Reichardt Reviewed-by: Umer Saleem Reviewed-by: Ameer Hamza Reviewed-by: Tony Hutter --- module/os/freebsd/zfs/arc_os.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/os/freebsd/zfs/arc_os.c b/module/os/freebsd/zfs/arc_os.c index 92696c0bf1ae..94f0a6b9f0be 100644 --- a/module/os/freebsd/zfs/arc_os.c +++ b/module/os/freebsd/zfs/arc_os.c @@ -167,8 +167,12 @@ arc_lowmem(void *arg __unused, int howto __unused) * here from ARC itself and may hold ARC locks and thus risk a deadlock * with ARC reclaim thread. */ - if (curproc == pageproc) + if (curproc == pageproc) { arc_wait_for_eviction(to_free, B_FALSE); + ARCSTAT_BUMP(arcstat_memory_indirect_count); + } else { + ARCSTAT_BUMP(arcstat_memory_direct_count); + } } void From 1f5e1b919febc72894681ac70125740330607224 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 25 Oct 2024 12:03:37 -0400 Subject: [PATCH 215/223] Pack dmu_buf_impl_t by 16 bytes On 64bit FreeBSD this reduces one from 296 to 280 bytes. On small block workloads dbufs may consume gigabytes of ARC, and this saves 5% of it. Reviewed-by: Tino Reichardt Reviewed-by: Brian Atkinson Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16684 --- include/sys/dbuf.h | 53 +++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/include/sys/dbuf.h b/include/sys/dbuf.h index f2a1535c9167..00f7f8ea7f4f 100644 --- a/include/sys/dbuf.h +++ b/include/sys/dbuf.h @@ -256,6 +256,27 @@ typedef struct dmu_buf_impl { */ uint8_t db_level; + /* This block was freed while a read or write was active. */ + uint8_t db_freed_in_flight; + + /* + * Evict user data as soon as the dirty and reference counts are equal. + */ + uint8_t db_user_immediate_evict; + + /* + * dnode_evict_dbufs() or dnode_evict_bonus() tried to evict this dbuf, + * but couldn't due to outstanding references. Evict once the refcount + * drops to 0. + */ + uint8_t db_pending_evict; + + /* Number of TXGs in which this buffer is dirty. */ + uint8_t db_dirtycnt; + + /* The buffer was partially read. More reads may follow. */ + uint8_t db_partial_read; + /* * Protects db_buf's contents if they contain an indirect block or data * block of the meta-dnode. We use this lock to protect the structure of @@ -280,6 +301,9 @@ typedef struct dmu_buf_impl { */ dbuf_states_t db_state; + /* In which dbuf cache this dbuf is, if any. */ + dbuf_cached_state_t db_caching_status; + /* * Refcount accessed by dmu_buf_{hold,rele}. * If nonzero, the buffer can't be destroyed. @@ -296,39 +320,10 @@ typedef struct dmu_buf_impl { /* Link in dbuf_cache or dbuf_metadata_cache */ multilist_node_t db_cache_link; - /* Tells us which dbuf cache this dbuf is in, if any */ - dbuf_cached_state_t db_caching_status; - uint64_t db_hash; - /* Data which is unique to data (leaf) blocks: */ - /* User callback information. */ dmu_buf_user_t *db_user; - - /* - * Evict user data as soon as the dirty and reference - * counts are equal. - */ - uint8_t db_user_immediate_evict; - - /* - * This block was freed while a read or write was - * active. - */ - uint8_t db_freed_in_flight; - - /* - * dnode_evict_dbufs() or dnode_evict_bonus() tried to - * evict this dbuf, but couldn't due to outstanding - * references. Evict once the refcount drops to 0. - */ - uint8_t db_pending_evict; - - uint8_t db_dirtycnt; - - /* The buffer was partially read. More reads may follow. */ - uint8_t db_partial_read; } dmu_buf_impl_t; #define DBUF_HASH_MUTEX(h, idx) \ From 1c7b70bcc08186130d6da87068e3c732f61b41c6 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 11 Nov 2024 20:06:10 -0500 Subject: [PATCH 216/223] ZTS: Avoid embedded blocks in bclone/bclone_prop_sync If we write less than 113 bytes with enabled compression we get embeded block, which then fails check for number of cloned blocks in bclone_test. Reviewed-by: Brian Behlendorf Reviewed-by: Pawel Jakub Dawidek Reviewed-by: Brian Atkinson Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16740 --- .../tests/functional/bclone/bclone_prop_sync.ksh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/zfs-tests/tests/functional/bclone/bclone_prop_sync.ksh b/tests/zfs-tests/tests/functional/bclone/bclone_prop_sync.ksh index f8aa1c875c60..08ed5717b9da 100755 --- a/tests/zfs-tests/tests/functional/bclone/bclone_prop_sync.ksh +++ b/tests/zfs-tests/tests/functional/bclone/bclone_prop_sync.ksh @@ -41,9 +41,11 @@ log_must zfs set compress=zle $TESTDSTFS for prop in "${sync_prop_vals[@]}"; do log_must zfs set sync=$prop $TESTSRCFS + # 15*8=120, which is greater than 113, so we are sure the data won't + # be embedded into BP. # 32767*8=262136, which is larger than a single default recordsize of # 131072. - FILESIZE=$(random_int_between 1 32767) + FILESIZE=$(random_int_between 15 32767) FILESIZE=$((FILESIZE * 8)) bclone_test random $FILESIZE false $TESTSRCDIR $TESTSRCDIR done @@ -52,9 +54,11 @@ for srcprop in "${sync_prop_vals[@]}"; do log_must zfs set sync=$srcprop $TESTSRCFS for dstprop in "${sync_prop_vals[@]}"; do log_must zfs set sync=$dstprop $TESTDSTFS + # 15*8=120, which is greater than 113, so we are sure the data won't + # be embedded into BP. # 32767*8=262136, which is larger than a single default recordsize of # 131072. - FILESIZE=$(random_int_between 1 32767) + FILESIZE=$(random_int_between 15 32767) FILESIZE=$((FILESIZE * 8)) bclone_test random $FILESIZE false $TESTSRCDIR $TESTDSTDIR done From 2bba6e3c5440e179a498c5cf551373008f82b4e7 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 11 Nov 2024 08:39:47 -0500 Subject: [PATCH 217/223] BRT: Don't call brt_pending_remove() on holes/embedded We are doing exactly the same checks around all brt_pending_add(). Reviewed-by: Brian Behlendorf Reviewed-by: Pawel Jakub Dawidek Reviewed-by: Brian Atkinson Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16740 --- module/zfs/dbuf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index 35d0e59ee2cb..4dcc271c9df4 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -2543,8 +2543,11 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx) * We are freeing a block that we cloned in the same * transaction group. */ - brt_pending_remove(dmu_objset_spa(db->db_objset), - &dr->dt.dl.dr_overridden_by, tx); + blkptr_t *bp = &dr->dt.dl.dr_overridden_by; + if (!BP_IS_HOLE(bp) && !BP_IS_EMBEDDED(bp)) { + brt_pending_remove(dmu_objset_spa(db->db_objset), + bp, tx); + } } dnode_t *dn = dr->dr_dnode; From a6e1cd1838080424784517651dfa82e0a46e1506 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 21 Nov 2024 10:56:30 -0500 Subject: [PATCH 218/223] Linux 6.12 compat: META Update the META file to reflect compatibility with the 6.12 kernel. Reviewed-by: Umer Saleem Signed-off-by: Brian Behlendorf Closes #16793 --- META | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META b/META index c52afcfc560a..0d1318574ded 100644 --- a/META +++ b/META @@ -6,5 +6,5 @@ Release: 1 Release-Tags: relext License: CDDL Author: OpenZFS -Linux-Maximum: 6.11 +Linux-Maximum: 6.12 Linux-Minimum: 4.18 From 0f86fcc2a7bb60f2f6bc1b143f52cad5497f818a Mon Sep 17 00:00:00 2001 From: Pavel Snajdr Date: Fri, 22 Nov 2024 00:30:43 +0100 Subject: [PATCH 219/223] Linux: Fix zfs_prune panics by protecting against sb->s_shrink eviction on umount with newer kernels deactivate_locked_super calls shrinker_free and only then sops->kill_sb cb, resulting in UAF on umount when trying to reach for the shrinker functions in zpl_prune_sb of in-umount dataset Reviewed-by: Brian Behlendorf Reviewed-by: Adam Moss Signed-off-by: Pavel Snajdr Closes #16770 --- module/os/linux/zfs/zpl_super.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/module/os/linux/zfs/zpl_super.c b/module/os/linux/zfs/zpl_super.c index 9de3bdcac62c..19a9ab9c7e3f 100644 --- a/module/os/linux/zfs/zpl_super.c +++ b/module/os/linux/zfs/zpl_super.c @@ -369,7 +369,18 @@ zpl_prune_sb(uint64_t nr_to_scan, void *arg) struct super_block *sb = (struct super_block *)arg; int objects = 0; - (void) -zfs_prune(sb, nr_to_scan, &objects); + /* + * deactivate_locked_super calls shrinker_free and only then + * sops->kill_sb cb, resulting in UAF on umount when trying to reach + * for the shrinker functions in zpl_prune_sb of in-umount dataset. + * Increment if s_active is not zero, but don't prune if it is - + * umount could be underway. + */ + if (atomic_inc_not_zero(&sb->s_active)) { + (void) -zfs_prune(sb, nr_to_scan, &objects); + atomic_dec(&sb->s_active); + } + } const struct super_operations zpl_super_operations = { From 02e73c5f454340ddbee9147028a10c4649e3f46a Mon Sep 17 00:00:00 2001 From: Ivan Volosyuk Date: Sat, 30 Nov 2024 14:50:37 +1100 Subject: [PATCH 220/223] Linux: Fix detection of register_sysctl_sz Adjust the m4 function to mimic sentinel we use in spl-proc.c This fixes the detection on kernels compiled with CONFIG_RANDSTRUCT=y Reviewed-by: Brian Behlendorf Reviewed-by: Rob Norris Reviewed-by: Pavel Snajdr Reviewed-by: Alexander Motin Signed-off-by: Ivan Volosyuk Closes: #16620 Closes: #16805 --- config/kernel-register_sysctl_table.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/kernel-register_sysctl_table.m4 b/config/kernel-register_sysctl_table.m4 index 12ffe9d95142..8dc17e2d42f9 100644 --- a/config/kernel-register_sysctl_table.m4 +++ b/config/kernel-register_sysctl_table.m4 @@ -36,7 +36,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_SZ], [ ZFS_LINUX_TEST_SRC([has_register_sysctl_sz], [ #include ],[ - struct ctl_table test_table[] __attribute__((unused)) = {0}; + struct ctl_table test_table[] __attribute__((unused)) = {{}}; register_sysctl_sz("", test_table, 0); ]) ]) From 299da6ace3c06393dff505ed277ead8de276a419 Mon Sep 17 00:00:00 2001 From: shodanshok Date: Wed, 4 Dec 2024 11:36:10 +0100 Subject: [PATCH 221/223] Fix race in libzfs_run_process_impl When replacing a disk, a child process is forked to run a script called zfs_prepare_disk (which can be useful for disk firmware update or health check). The parent than calls waitpid and checks the child error/status code. However, the _reap_children thread (created from zed_exec_process to manage zedlets) also waits for all children with the same PGID and can stole the signal, causing the replace operation to be aborted. As waitpid returns -1, the parent incorrectly assume that the child process had an error or was killed. This, in turn, leaves the newly added disk in REMOVED or UNAVAIL status rather than completing the replace process. This patch changes the PGID of the child process execuing the prepare script, shielding it from the _reap_children thread. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Tony Hutter Signed-off-by: Gionatan Danti Closes #16801 --- lib/libzfs/libzfs_util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 1db79fb170e4..89fea053d598 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -926,6 +926,7 @@ libzfs_run_process_impl(const char *path, char *argv[], char *env[], int flags, pid = fork(); if (pid == 0) { /* Child process */ + setpgid(0, 0); devnull_fd = open("/dev/null", O_WRONLY | O_CLOEXEC); if (devnull_fd < 0) From 0bd8481aa751d7be7ea90ed47a4c8c208f066c03 Mon Sep 17 00:00:00 2001 From: Charles Hedrick Date: Wed, 4 Dec 2024 17:01:57 -0500 Subject: [PATCH 222/223] add get_name implementation for exports. (#16833) This fixes a serious performance problem with NFS handling of large directories, as the new get_name code is much more efficient than the default zfs_readdir. This is actually part of 20232ecfaa34177bef6c08f2f1a55b8c8bd20da4 in 2.3. But I've taken only the minimum code to implement get_name, and not the rest of the long name changes. Signed-off-by: Charles Hedrick Co-authored-by: Charles L. Hedrick Reviewed-by: Alexander Motin Reviewed by: Brian Behlendorf Reviewed by: Brian Behlendorf Reviewed-by: Tony Hutter --- include/os/linux/zfs/sys/zfs_vnops_os.h | 1 + module/os/linux/zfs/zfs_vnops_os.c | 42 +++++++++++++++++++++++++ module/os/linux/zfs/zpl_export.c | 32 +++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/include/os/linux/zfs/sys/zfs_vnops_os.h b/include/os/linux/zfs/sys/zfs_vnops_os.h index f34eb153f546..db33eda57705 100644 --- a/include/os/linux/zfs/sys/zfs_vnops_os.h +++ b/include/os/linux/zfs/sys/zfs_vnops_os.h @@ -44,6 +44,7 @@ extern int zfs_write_simple(znode_t *zp, const void *data, size_t len, loff_t pos, size_t *resid); extern int zfs_lookup(znode_t *dzp, char *nm, znode_t **zpp, int flags, cred_t *cr, int *direntflags, pathname_t *realpnp); +extern int zfs_get_name(znode_t *dzp, char *name, znode_t *zp); extern int zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl, int mode, znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp, zidmap_t *mnt_ns); diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c index 97de89767d93..c26d232b0021 100644 --- a/module/os/linux/zfs/zfs_vnops_os.c +++ b/module/os/linux/zfs/zfs_vnops_os.c @@ -526,6 +526,48 @@ zfs_lookup(znode_t *zdp, char *nm, znode_t **zpp, int flags, cred_t *cr, return (error); } +/* + * Perform a linear search in directory for the name of specific inode. + * Note we don't pass in the buffer size of name because it's hardcoded to + * NAME_MAX+1(256) in Linux. + * + * IN: dzp - znode of directory to search. + * zp - znode of the target + * + * OUT: name - dentry name of the target + * + * RETURN: 0 on success, error code on failure. + */ +int +zfs_get_name(znode_t *dzp, char *name, znode_t *zp) +{ + zfsvfs_t *zfsvfs = ZTOZSB(dzp); + int error = 0; + + if ((error = zfs_enter_verify_zp(zfsvfs, dzp, FTAG)) != 0) + return (error); + + if ((error = zfs_verify_zp(zp)) != 0) { + zfs_exit(zfsvfs, FTAG); + return (error); + } + + /* ctldir should have got their name in zfs_vget */ + if (dzp->z_is_ctldir || zp->z_is_ctldir) { + zfs_exit(zfsvfs, FTAG); + return (ENOENT); + } + + /* buffer len is hardcoded to 256 in Linux kernel */ + error = zap_value_search(zfsvfs->z_os, dzp->z_id, zp->z_id, + ZFS_DIRENT_OBJ(-1ULL), name); + + zfs_exit(zfsvfs, FTAG); + return (error); +} + + + /* * Attempt to create a new entry in a directory. If the entry * already exists, truncate the file if permissible, else return diff --git a/module/os/linux/zfs/zpl_export.c b/module/os/linux/zfs/zpl_export.c index b6b9e2754055..2d749d9c9376 100644 --- a/module/os/linux/zfs/zpl_export.c +++ b/module/os/linux/zfs/zpl_export.c @@ -24,6 +24,7 @@ */ +#include #include #include #include @@ -102,6 +103,36 @@ zpl_fh_to_dentry(struct super_block *sb, struct fid *fh, return (d_obtain_alias(ip)); } +/* + * In case the filesystem contains name longer than 255, we need to override + * the default get_name so we don't get buffer overflow. Unfortunately, since + * the buffer size is hardcoded in Linux, we will get ESTALE error in this + * case. + */ +static int +zpl_get_name(struct dentry *parent, char *name, struct dentry *child) +{ + cred_t *cr = CRED(); + fstrans_cookie_t cookie; + struct inode *dir = parent->d_inode; + struct inode *ip = child->d_inode; + int error; + + if (!dir || !S_ISDIR(dir->i_mode)) + return (-ENOTDIR); + + crhold(cr); + cookie = spl_fstrans_mark(); + spl_inode_lock_shared(dir); + error = -zfs_get_name(ITOZ(dir), name, ITOZ(ip)); + spl_inode_unlock_shared(dir); + spl_fstrans_unmark(cookie); + crfree(cr); + + return (error); +} + + static struct dentry * zpl_get_parent(struct dentry *child) { @@ -146,6 +177,7 @@ zpl_commit_metadata(struct inode *inode) const struct export_operations zpl_export_operations = { .encode_fh = zpl_encode_fh, .fh_to_dentry = zpl_fh_to_dentry, + .get_name = zpl_get_name, .get_parent = zpl_get_parent, .commit_metadata = zpl_commit_metadata, }; From e269af1b3c7b1b1c000d05f147a2f75e5e72e0ca Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Mon, 4 Nov 2024 11:15:18 -0800 Subject: [PATCH 223/223] Tag zfs-2.2.7 META file and changelog updated. Signed-off-by: Tony Hutter --- META | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META b/META index 0d1318574ded..0e852d300e8f 100644 --- a/META +++ b/META @@ -1,7 +1,7 @@ Meta: 1 Name: zfs Branch: 1.0 -Version: 2.2.6 +Version: 2.2.7 Release: 1 Release-Tags: relext License: CDDL