2008-11-20 23:01:55 +03:00
|
|
|
/*
|
|
|
|
* 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
|
2022-07-12 00:16:13 +03:00
|
|
|
* or https://opensource.org/licenses/CDDL-1.0.
|
2008-11-20 23:01:55 +03:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
/*
|
2010-08-27 01:24:34 +04:00
|
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
2019-06-10 21:48:42 +03:00
|
|
|
* Copyright (c) 2015, 2018 by Delphix. All rights reserved.
|
2023-03-10 22:59:53 +03:00
|
|
|
* Copyright (c) 2022 by Pawel Jakub Dawidek
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
|
2010-08-26 22:45:02 +04:00
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/sysmacros.h>
|
|
|
|
#include <sys/cmn_err.h>
|
|
|
|
#include <sys/kmem.h>
|
|
|
|
#include <sys/thread.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/vfs.h>
|
|
|
|
#include <sys/zfs_znode.h>
|
|
|
|
#include <sys/zfs_dir.h>
|
|
|
|
#include <sys/zil.h>
|
|
|
|
#include <sys/zil_impl.h>
|
|
|
|
#include <sys/byteorder.h>
|
|
|
|
#include <sys/policy.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/acl.h>
|
|
|
|
#include <sys/dmu.h>
|
2019-08-16 02:36:24 +03:00
|
|
|
#include <sys/dbuf.h>
|
2008-11-20 23:01:55 +03:00
|
|
|
#include <sys/spa.h>
|
|
|
|
#include <sys/zfs_fuid.h>
|
2009-01-16 00:59:39 +03:00
|
|
|
#include <sys/dsl_dataset.h>
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
/*
|
2009-01-16 00:59:39 +03:00
|
|
|
* These zfs_log_* functions must be called within a dmu tx, in one
|
|
|
|
* of 2 contexts depending on zilog->z_replay:
|
|
|
|
*
|
|
|
|
* Non replay mode
|
|
|
|
* ---------------
|
|
|
|
* We need to record the transaction so that if it is committed to
|
|
|
|
* the Intent Log then it can be replayed. An intent log transaction
|
|
|
|
* structure (itx_t) is allocated and all the information necessary to
|
|
|
|
* possibly replay the transaction is saved in it. The itx is then assigned
|
|
|
|
* a sequence number and inserted in the in-memory list anchored in the zilog.
|
|
|
|
*
|
|
|
|
* Replay mode
|
|
|
|
* -----------
|
|
|
|
* We need to mark the intent log record as replayed in the log header.
|
|
|
|
* This is done in the same transaction as the replay so that they
|
|
|
|
* commit atomically.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
zfs_log_create_txtype(zil_create_t type, vsecattr_t *vsecp, vattr_t *vap)
|
|
|
|
{
|
2011-03-01 23:24:09 +03:00
|
|
|
int isxvattr = (vap->va_mask & ATTR_XVATTR);
|
2008-11-20 23:01:55 +03:00
|
|
|
switch (type) {
|
|
|
|
case Z_FILE:
|
|
|
|
if (vsecp == NULL && !isxvattr)
|
|
|
|
return (TX_CREATE);
|
|
|
|
if (vsecp && isxvattr)
|
|
|
|
return (TX_CREATE_ACL_ATTR);
|
|
|
|
if (vsecp)
|
|
|
|
return (TX_CREATE_ACL);
|
|
|
|
else
|
|
|
|
return (TX_CREATE_ATTR);
|
|
|
|
case Z_DIR:
|
|
|
|
if (vsecp == NULL && !isxvattr)
|
|
|
|
return (TX_MKDIR);
|
|
|
|
if (vsecp && isxvattr)
|
|
|
|
return (TX_MKDIR_ACL_ATTR);
|
|
|
|
if (vsecp)
|
|
|
|
return (TX_MKDIR_ACL);
|
|
|
|
else
|
|
|
|
return (TX_MKDIR_ATTR);
|
|
|
|
case Z_XATTRDIR:
|
|
|
|
return (TX_MKXATTR);
|
|
|
|
}
|
|
|
|
ASSERT(0);
|
|
|
|
return (TX_MAX_TYPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* build up the log data necessary for logging xvattr_t
|
|
|
|
* First lr_attr_t is initialized. following the lr_attr_t
|
|
|
|
* is the mapsize and attribute bitmap copied from the xvattr_t.
|
|
|
|
* Following the bitmap and bitmapsize two 64 bit words are reserved
|
|
|
|
* for the create time which may be set. Following the create time
|
|
|
|
* records a single 64 bit integer which has the bits to set on
|
|
|
|
* replay for the xvattr.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
zfs_log_xvattr(lr_attr_t *lrattr, xvattr_t *xvap)
|
|
|
|
{
|
2022-06-21 01:36:38 +03:00
|
|
|
xoptattr_t *xoap;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
xoap = xva_getxoptattr(xvap);
|
|
|
|
ASSERT(xoap);
|
|
|
|
|
|
|
|
lrattr->lr_attr_masksize = xvap->xva_mapsize;
|
2022-06-21 01:36:38 +03:00
|
|
|
uint32_t *bitmap = &lrattr->lr_attr_bitmap;
|
|
|
|
for (int i = 0; i != xvap->xva_mapsize; i++, bitmap++)
|
2008-11-20 23:01:55 +03:00
|
|
|
*bitmap = xvap->xva_reqattrmap[i];
|
|
|
|
|
2022-06-21 01:36:38 +03:00
|
|
|
lr_attr_end_t *end = (lr_attr_end_t *)bitmap;
|
|
|
|
end->lr_attr_attrs = 0;
|
|
|
|
end->lr_attr_crtime[0] = 0;
|
|
|
|
end->lr_attr_crtime[1] = 0;
|
|
|
|
memset(end->lr_attr_scanstamp, 0, AV_SCANSTAMP_SZ);
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_READONLY))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_readonly == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_READONLY;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_HIDDEN))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_hidden == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_HIDDEN;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_SYSTEM))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_system == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_SYSTEM;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_ARCHIVE))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_archive == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_ARCHIVE;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_IMMUTABLE))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_immutable == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_IMMUTABLE;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_NOUNLINK))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_nounlink == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_NOUNLINK;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_APPENDONLY))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_appendonly == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_APPENDONLY;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_OPAQUE))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_opaque == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_APPENDONLY;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_NODUMP))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_nodump == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_NODUMP;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_AV_QUARANTINED))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_av_quarantined == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_AV_QUARANTINED;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_AV_MODIFIED))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_av_modified == 0) ? 0 :
|
2008-11-20 23:01:55 +03:00
|
|
|
XAT0_AV_MODIFIED;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_CREATETIME))
|
2022-06-21 01:36:38 +03:00
|
|
|
ZFS_TIME_ENCODE(&xoap->xoa_createtime, end->lr_attr_crtime);
|
2018-02-14 01:54:54 +03:00
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_AV_SCANSTAMP)) {
|
|
|
|
ASSERT(!XVA_ISSET_REQ(xvap, XAT_PROJID));
|
|
|
|
|
2022-06-21 01:36:38 +03:00
|
|
|
memcpy(end->lr_attr_scanstamp, xoap->xoa_av_scanstamp,
|
|
|
|
AV_SCANSTAMP_SZ);
|
2018-02-14 01:54:54 +03:00
|
|
|
} else if (XVA_ISSET_REQ(xvap, XAT_PROJID)) {
|
|
|
|
/*
|
|
|
|
* XAT_PROJID and XAT_AV_SCANSTAMP will never be valid
|
|
|
|
* at the same time, so we can share the same space.
|
|
|
|
*/
|
2022-06-21 01:36:38 +03:00
|
|
|
memcpy(end->lr_attr_scanstamp, &xoap->xoa_projid,
|
|
|
|
sizeof (uint64_t));
|
2018-02-14 01:54:54 +03:00
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_REPARSE))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_reparse == 0) ? 0 :
|
2010-05-29 00:45:14 +04:00
|
|
|
XAT0_REPARSE;
|
2010-08-27 01:24:34 +04:00
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_OFFLINE))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_offline == 0) ? 0 :
|
2010-08-27 01:24:34 +04:00
|
|
|
XAT0_OFFLINE;
|
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_SPARSE))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_sparse == 0) ? 0 :
|
2010-08-27 01:24:34 +04:00
|
|
|
XAT0_SPARSE;
|
2018-02-14 01:54:54 +03:00
|
|
|
if (XVA_ISSET_REQ(xvap, XAT_PROJINHERIT))
|
2022-06-21 01:36:38 +03:00
|
|
|
end->lr_attr_attrs |= (xoap->xoa_projinherit == 0) ? 0 :
|
2018-02-14 01:54:54 +03:00
|
|
|
XAT0_PROJINHERIT;
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
zfs_log_fuid_ids(zfs_fuid_info_t *fuidp, void *start)
|
|
|
|
{
|
|
|
|
zfs_fuid_t *zfuid;
|
|
|
|
uint64_t *fuidloc = start;
|
|
|
|
|
|
|
|
/* First copy in the ACE FUIDs */
|
|
|
|
for (zfuid = list_head(&fuidp->z_fuids); zfuid;
|
|
|
|
zfuid = list_next(&fuidp->z_fuids, zfuid)) {
|
|
|
|
*fuidloc++ = zfuid->z_logfuid;
|
|
|
|
}
|
|
|
|
return (fuidloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
zfs_log_fuid_domains(zfs_fuid_info_t *fuidp, void *start)
|
|
|
|
{
|
|
|
|
zfs_fuid_domain_t *zdomain;
|
|
|
|
|
|
|
|
/* now copy in the domain info, if any */
|
|
|
|
if (fuidp->z_domain_str_sz != 0) {
|
|
|
|
for (zdomain = list_head(&fuidp->z_domains); zdomain;
|
|
|
|
zdomain = list_next(&fuidp->z_domains, zdomain)) {
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy(start, zdomain->z_domain,
|
2008-11-20 23:01:55 +03:00
|
|
|
strlen(zdomain->z_domain) + 1);
|
|
|
|
start = (caddr_t)start +
|
|
|
|
strlen(zdomain->z_domain) + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (start);
|
|
|
|
}
|
|
|
|
|
2016-10-13 03:30:46 +03:00
|
|
|
/*
|
|
|
|
* If zp is an xattr node, check whether the xattr owner is unlinked.
|
|
|
|
* We don't want to log anything if the owner is unlinked.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
zfs_xattr_owner_unlinked(znode_t *zp)
|
|
|
|
{
|
|
|
|
int unlinked = 0;
|
|
|
|
znode_t *dzp;
|
2020-02-29 01:53:18 +03:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
znode_t *tzp = zp;
|
2019-12-11 22:53:57 +03:00
|
|
|
|
2019-12-16 20:49:05 +03:00
|
|
|
/*
|
|
|
|
* zrele drops the vnode lock which violates the VOP locking contract
|
|
|
|
* on FreeBSD. See comment at the top of zfs_replay.c for more detail.
|
|
|
|
*/
|
2020-02-29 01:53:18 +03:00
|
|
|
/*
|
|
|
|
* if zp is XATTR node, keep walking up via z_xattr_parent until we
|
|
|
|
* get the owner
|
|
|
|
*/
|
|
|
|
while (tzp->z_pflags & ZFS_XATTR) {
|
|
|
|
ASSERT3U(zp->z_xattr_parent, !=, 0);
|
|
|
|
if (zfs_zget(ZTOZSB(tzp), tzp->z_xattr_parent, &dzp) != 0) {
|
|
|
|
unlinked = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tzp != zp)
|
|
|
|
zrele(tzp);
|
|
|
|
tzp = dzp;
|
|
|
|
unlinked = tzp->z_unlinked;
|
|
|
|
}
|
|
|
|
if (tzp != zp)
|
|
|
|
zrele(tzp);
|
|
|
|
#else
|
2019-12-11 22:53:57 +03:00
|
|
|
zhold(zp);
|
2016-10-13 03:30:46 +03:00
|
|
|
/*
|
|
|
|
* if zp is XATTR node, keep walking up via z_xattr_parent until we
|
|
|
|
* get the owner
|
|
|
|
*/
|
|
|
|
while (zp->z_pflags & ZFS_XATTR) {
|
|
|
|
ASSERT3U(zp->z_xattr_parent, !=, 0);
|
|
|
|
if (zfs_zget(ZTOZSB(zp), zp->z_xattr_parent, &dzp) != 0) {
|
|
|
|
unlinked = 1;
|
|
|
|
break;
|
|
|
|
}
|
2020-02-29 01:53:18 +03:00
|
|
|
|
2019-12-11 22:53:57 +03:00
|
|
|
zrele(zp);
|
2016-10-13 03:30:46 +03:00
|
|
|
zp = dzp;
|
|
|
|
unlinked = zp->z_unlinked;
|
|
|
|
}
|
2019-12-11 22:53:57 +03:00
|
|
|
zrele(zp);
|
2019-12-16 20:49:05 +03:00
|
|
|
#endif
|
2016-10-13 03:30:46 +03:00
|
|
|
return (unlinked);
|
|
|
|
}
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
/*
|
2013-06-11 21:12:34 +04:00
|
|
|
* Handles TX_CREATE, TX_CREATE_ATTR, TX_MKDIR, TX_MKDIR_ATTR and
|
|
|
|
* TK_MKXATTR transactions.
|
2008-11-20 23:01:55 +03:00
|
|
|
*
|
|
|
|
* TX_CREATE and TX_MKDIR are standard creates, but they may have FUID
|
|
|
|
* domain information appended prior to the name. In this case the
|
|
|
|
* uid/gid in the log record will be a log centric FUID.
|
|
|
|
*
|
|
|
|
* TX_CREATE_ACL_ATTR and TX_MKDIR_ACL_ATTR handle special creates that
|
|
|
|
* may contain attributes, ACL and optional fuid information.
|
|
|
|
*
|
|
|
|
* TX_CREATE_ACL and TX_MKDIR_ACL handle special creates that specify
|
|
|
|
* and ACL and normal users/groups in the ACEs.
|
|
|
|
*
|
|
|
|
* There may be an optional xvattr attribute information similar
|
|
|
|
* to zfs_log_setattr.
|
|
|
|
*
|
|
|
|
* Also, after the file name "domain" strings may be appended.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
2020-10-03 03:44:10 +03:00
|
|
|
znode_t *dzp, znode_t *zp, const char *name, vsecattr_t *vsecp,
|
2008-11-20 23:01:55 +03:00
|
|
|
zfs_fuid_info_t *fuidp, vattr_t *vap)
|
|
|
|
{
|
|
|
|
itx_t *itx;
|
|
|
|
lr_create_t *lr;
|
|
|
|
lr_acl_create_t *lracl;
|
2011-03-01 23:24:09 +03:00
|
|
|
size_t aclsize = 0;
|
2008-11-20 23:01:55 +03:00
|
|
|
size_t xvatsize = 0;
|
|
|
|
size_t txsize;
|
2013-02-11 10:21:05 +04:00
|
|
|
xvattr_t *xvap = (xvattr_t *)vap;
|
2008-11-20 23:01:55 +03:00
|
|
|
void *end;
|
|
|
|
size_t lrsize;
|
|
|
|
size_t namesize = strlen(name) + 1;
|
|
|
|
size_t fuidsz = 0;
|
|
|
|
|
2016-10-13 03:30:46 +03:00
|
|
|
if (zil_replaying(zilog, tx) || zfs_xattr_owner_unlinked(dzp))
|
2008-11-20 23:01:55 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have FUIDs present then add in space for
|
|
|
|
* domains and ACE fuid's if any.
|
|
|
|
*/
|
|
|
|
if (fuidp) {
|
|
|
|
fuidsz += fuidp->z_domain_str_sz;
|
|
|
|
fuidsz += fuidp->z_fuid_cnt * sizeof (uint64_t);
|
|
|
|
}
|
|
|
|
|
2011-03-01 23:24:09 +03:00
|
|
|
if (vap->va_mask & ATTR_XVATTR)
|
2008-11-20 23:01:55 +03:00
|
|
|
xvatsize = ZIL_XVAT_SIZE(xvap->xva_mapsize);
|
|
|
|
|
|
|
|
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);
|
|
|
|
} 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);
|
|
|
|
|
|
|
|
lr = (lr_create_t *)&itx->itx_lr;
|
|
|
|
lr->lr_doid = dzp->z_id;
|
|
|
|
lr->lr_foid = zp->z_id;
|
Implement large_dnode pool feature
Justification
-------------
This feature adds support for variable length dnodes. Our motivation is
to eliminate the overhead associated with using spill blocks. Spill
blocks are used to store system attribute data (i.e. file metadata) that
does not fit in the dnode's bonus buffer. By allowing a larger bonus
buffer area the use of a spill block can be avoided. Spill blocks
potentially incur an additional read I/O for every dnode in a dnode
block. As a worst case example, reading 32 dnodes from a 16k dnode block
and all of the spill blocks could issue 33 separate reads. Now suppose
those dnodes have size 1024 and therefore don't need spill blocks. Then
the worst case number of blocks read is reduced to from 33 to two--one
per dnode block. In practice spill blocks may tend to be co-located on
disk with the dnode blocks so the reduction in I/O would not be this
drastic. In a badly fragmented pool, however, the improvement could be
significant.
ZFS-on-Linux systems that make heavy use of extended attributes would
benefit from this feature. In particular, ZFS-on-Linux supports the
xattr=sa dataset property which allows file extended attribute data
to be stored in the dnode bonus buffer as an alternative to the
traditional directory-based format. Workloads such as SELinux and the
Lustre distributed filesystem often store enough xattr data to force
spill bocks when xattr=sa is in effect. Large dnodes may therefore
provide a performance benefit to such systems.
Other use cases that may benefit from this feature include files with
large ACLs and symbolic links with long target names. Furthermore,
this feature may be desirable on other platforms in case future
applications or features are developed that could make use of a
larger bonus buffer area.
Implementation
--------------
The size of a dnode may be a multiple of 512 bytes up to the size of
a dnode block (currently 16384 bytes). A dn_extra_slots field was
added to the current on-disk dnode_phys_t structure to describe the
size of the physical dnode on disk. The 8 bits for this field were
taken from the zero filled dn_pad2 field. The field represents how
many "extra" dnode_phys_t slots a dnode consumes in its dnode block.
This convention results in a value of 0 for 512 byte dnodes which
preserves on-disk format compatibility with older software.
Similarly, the in-memory dnode_t structure has a new dn_num_slots field
to represent the total number of dnode_phys_t slots consumed on disk.
Thus dn->dn_num_slots is 1 greater than the corresponding
dnp->dn_extra_slots. This difference in convention was adopted
because, unlike on-disk structures, backward compatibility is not a
concern for in-memory objects, so we used a more natural way to
represent size for a dnode_t.
The default size for newly created dnodes is determined by the value of
a new "dnodesize" dataset property. By default the property is set to
"legacy" which is compatible with older software. Setting the property
to "auto" will allow the filesystem to choose the most suitable dnode
size. Currently this just sets the default dnode size to 1k, but future
code improvements could dynamically choose a size based on observed
workload patterns. Dnodes of varying sizes can coexist within the same
dataset and even within the same dnode block. For example, to enable
automatically-sized dnodes, run
# zfs set dnodesize=auto tank/fish
The user can also specify literal values for the dnodesize property.
These are currently limited to powers of two from 1k to 16k. The
power-of-2 limitation is only for simplicity of the user interface.
Internally the implementation can handle any multiple of 512 up to 16k,
and consumers of the DMU API can specify any legal dnode value.
The size of a new dnode is determined at object allocation time and
stored as a new field in the znode in-memory structure. New DMU
interfaces are added to allow the consumer to specify the dnode size
that a newly allocated object should use. Existing interfaces are
unchanged to avoid having to update every call site and to preserve
compatibility with external consumers such as Lustre. The new
interfaces names are given below. The versions of these functions that
don't take a dnodesize parameter now just call the _dnsize() versions
with a dnodesize of 0, which means use the legacy dnode size.
New DMU interfaces:
dmu_object_alloc_dnsize()
dmu_object_claim_dnsize()
dmu_object_reclaim_dnsize()
New ZAP interfaces:
zap_create_dnsize()
zap_create_norm_dnsize()
zap_create_flags_dnsize()
zap_create_claim_norm_dnsize()
zap_create_link_dnsize()
The constant DN_MAX_BONUSLEN is renamed to DN_OLD_MAX_BONUSLEN. The
spa_maxdnodesize() function should be used to determine the maximum
bonus length for a pool.
These are a few noteworthy changes to key functions:
* The prototype for dnode_hold_impl() now takes a "slots" parameter.
When the DNODE_MUST_BE_FREE flag is set, this parameter is used to
ensure the hole at the specified object offset is large enough to
hold the dnode being created. The slots parameter is also used
to ensure a dnode does not span multiple dnode blocks. In both of
these cases, if a failure occurs, ENOSPC is returned. Keep in mind,
these failure cases are only possible when using DNODE_MUST_BE_FREE.
If the DNODE_MUST_BE_ALLOCATED flag is set, "slots" must be 0.
dnode_hold_impl() will check if the requested dnode is already
consumed as an extra dnode slot by an large dnode, in which case
it returns ENOENT.
* The function dmu_object_alloc() advances to the next dnode block
if dnode_hold_impl() returns an error for a requested object.
This is because the beginning of the next dnode block is the only
location it can safely assume to either be a hole or a valid
starting point for a dnode.
* dnode_next_offset_level() and other functions that iterate
through dnode blocks may no longer use a simple array indexing
scheme. These now use the current dnode's dn_num_slots field to
advance to the next dnode in the block. This is to ensure we
properly skip the current dnode's bonus area and don't interpret it
as a valid dnode.
zdb
---
The zdb command was updated to display a dnode's size under the
"dnsize" column when the object is dumped.
For ZIL create log records, zdb will now display the slot count for
the object.
ztest
-----
Ztest chooses a random dnodesize for every newly created object. The
random distribution is more heavily weighted toward small dnodes to
better simulate real-world datasets.
Unused bonus buffer space is filled with non-zero values computed from
the object number, dataset id, offset, and generation number. This
helps ensure that the dnode traversal code properly skips the interior
regions of large dnodes, and that these interior regions are not
overwritten by data belonging to other dnodes. A new test visits each
object in a dataset. It verifies that the actual dnode size matches what
was stored in the ztest block tag when it was created. It also verifies
that the unused bonus buffer space is filled with the expected data
patterns.
ZFS Test Suite
--------------
Added six new large dnode-specific tests, and integrated the dnodesize
property into existing tests for zfs allow and send/recv.
Send/Receive
------------
ZFS send streams for datasets containing large dnodes cannot be received
on pools that don't support the large_dnode feature. A send stream with
large dnodes sets a DMU_BACKUP_FEATURE_LARGE_DNODE flag which will be
unrecognized by an incompatible receiving pool so that the zfs receive
will fail gracefully.
While not implemented here, it may be possible to generate a
backward-compatible send stream from a dataset containing large
dnodes. The implementation may be tricky, however, because the send
object record for a large dnode would need to be resized to a 512
byte dnode, possibly kicking in a spill block in the process. This
means we would need to construct a new SA layout and possibly
register it in the SA layout object. The SA layout is normally just
sent as an ordinary object record. But if we are constructing new
layouts while generating the send stream we'd have to build the SA
layout object dynamically and send it at the end of the stream.
For sending and receiving between pools that do support large dnodes,
the drr_object send record type is extended with a new field to store
the dnode slot count. This field was repurposed from unused padding
in the structure.
ZIL Replay
----------
The dnode slot count is stored in the uppermost 8 bits of the lr_foid
field. The bits were unused as the object id is currently capped at
48 bits.
Resizing Dnodes
---------------
It should be possible to resize a dnode when it is dirtied if the
current dnodesize dataset property differs from the dnode's size, but
this functionality is not currently implemented. Clearly a dnode can
only grow if there are sufficient contiguous unused slots in the
dnode block, but it should always be possible to shrink a dnode.
Growing dnodes may be useful to reduce fragmentation in a pool with
many spill blocks in use. Shrinking dnodes may be useful to allow
sending a dataset to a pool that doesn't support the large_dnode
feature.
Feature Reference Counting
--------------------------
The reference count for the large_dnode pool feature tracks the
number of datasets that have ever contained a dnode of size larger
than 512 bytes. The first time a large dnode is created in a dataset
the dataset is converted to an extensible dataset. This is a one-way
operation and the only way to decrement the feature count is to
destroy the dataset, even if the dataset no longer contains any large
dnodes. The complexity of reference counting on a per-dnode basis was
too high, so we chose to track it on a per-dataset basis similarly to
the large_block feature.
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3542
2016-03-17 04:25:34 +03:00
|
|
|
/* Store dnode slot count in 8 bits above object id. */
|
|
|
|
LR_FOID_SET_SLOTS(lr->lr_foid, zp->z_dnodesize >> DNODE_SHIFT);
|
2010-05-29 00:45:14 +04:00
|
|
|
lr->lr_mode = zp->z_mode;
|
2019-10-02 19:15:12 +03:00
|
|
|
if (!IS_EPHEMERAL(KUID_TO_SUID(ZTOUID(zp)))) {
|
|
|
|
lr->lr_uid = (uint64_t)KUID_TO_SUID(ZTOUID(zp));
|
2008-11-20 23:01:55 +03:00
|
|
|
} else {
|
|
|
|
lr->lr_uid = fuidp->z_fuid_owner;
|
|
|
|
}
|
2019-10-02 19:15:12 +03:00
|
|
|
if (!IS_EPHEMERAL(KGID_TO_SGID(ZTOGID(zp)))) {
|
|
|
|
lr->lr_gid = (uint64_t)KGID_TO_SGID(ZTOGID(zp));
|
2008-11-20 23:01:55 +03:00
|
|
|
} else {
|
|
|
|
lr->lr_gid = fuidp->z_fuid_group;
|
|
|
|
}
|
2011-02-08 22:33:08 +03:00
|
|
|
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
|
2010-05-29 00:45:14 +04:00
|
|
|
sizeof (uint64_t));
|
2011-02-08 22:33:08 +03:00
|
|
|
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)),
|
2010-05-29 00:45:14 +04:00
|
|
|
lr->lr_crtime, sizeof (uint64_t) * 2);
|
|
|
|
|
2011-02-08 22:33:08 +03:00
|
|
|
if (sa_lookup(zp->z_sa_hdl, SA_ZPL_RDEV(ZTOZSB(zp)), &lr->lr_rdev,
|
2010-05-29 00:45:14 +04:00
|
|
|
sizeof (lr->lr_rdev)) != 0)
|
|
|
|
lr->lr_rdev = 0;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in xvattr info if any
|
|
|
|
*/
|
2011-03-01 23:24:09 +03:00
|
|
|
if (vap->va_mask & ATTR_XVATTR) {
|
2008-11-20 23:01:55 +03:00
|
|
|
zfs_log_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), xvap);
|
|
|
|
end = (caddr_t)lr + lrsize + xvatsize;
|
|
|
|
} else {
|
|
|
|
end = (caddr_t)lr + lrsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now fill in any ACL info */
|
|
|
|
|
|
|
|
if (vsecp) {
|
|
|
|
lracl = (lr_acl_create_t *)&itx->itx_lr;
|
|
|
|
lracl->lr_aclcnt = vsecp->vsa_aclcnt;
|
|
|
|
lracl->lr_acl_bytes = aclsize;
|
|
|
|
lracl->lr_domcnt = fuidp ? fuidp->z_domain_cnt : 0;
|
|
|
|
lracl->lr_fuidcnt = fuidp ? fuidp->z_fuid_cnt : 0;
|
|
|
|
if (vsecp->vsa_aclflags & VSA_ACE_ACLFLAGS)
|
|
|
|
lracl->lr_acl_flags = (uint64_t)vsecp->vsa_aclflags;
|
|
|
|
else
|
|
|
|
lracl->lr_acl_flags = 0;
|
|
|
|
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy(end, vsecp->vsa_aclentp, aclsize);
|
2008-11-20 23:01:55 +03:00
|
|
|
end = (caddr_t)end + ZIL_ACE_LENGTH(aclsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* drop in FUID info */
|
|
|
|
if (fuidp) {
|
|
|
|
end = zfs_log_fuid_ids(fuidp, end);
|
|
|
|
end = zfs_log_fuid_domains(fuidp, end);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Now place file name in log record
|
|
|
|
*/
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy(end, name, namesize);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-06-11 21:12:34 +04:00
|
|
|
* Handles both TX_REMOVE and TX_RMDIR transactions.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
2020-10-03 03:44:10 +03:00
|
|
|
znode_t *dzp, const char *name, uint64_t foid, boolean_t unlinked)
|
2008-11-20 23:01:55 +03:00
|
|
|
{
|
|
|
|
itx_t *itx;
|
|
|
|
lr_remove_t *lr;
|
|
|
|
size_t namesize = strlen(name) + 1;
|
|
|
|
|
2016-10-13 03:30:46 +03:00
|
|
|
if (zil_replaying(zilog, tx) || zfs_xattr_owner_unlinked(dzp))
|
2008-11-20 23:01:55 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
|
|
|
|
lr = (lr_remove_t *)&itx->itx_lr;
|
|
|
|
lr->lr_doid = dzp->z_id;
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy(lr + 1, name, namesize);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2010-08-27 01:24:34 +04:00
|
|
|
itx->itx_oid = foid;
|
|
|
|
|
2019-08-14 06:21:27 +03:00
|
|
|
/*
|
|
|
|
* Object ids can be re-instantiated in the next txg so
|
|
|
|
* remove any async transactions to avoid future leaks.
|
|
|
|
* This can happen if a fsync occurs on the re-instantiated
|
|
|
|
* object for a WR_INDIRECT or WR_NEED_COPY write, which gets
|
|
|
|
* the new file data and flushes a write record for the old object.
|
|
|
|
*/
|
|
|
|
if (unlinked) {
|
|
|
|
ASSERT((txtype & ~TX_CI) == TX_REMOVE);
|
|
|
|
zil_remove_async(zilog, foid);
|
|
|
|
}
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-06-11 21:12:34 +04:00
|
|
|
* Handles TX_LINK transactions.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
2020-10-03 03:44:10 +03:00
|
|
|
znode_t *dzp, znode_t *zp, const char *name)
|
2008-11-20 23:01:55 +03:00
|
|
|
{
|
|
|
|
itx_t *itx;
|
|
|
|
lr_link_t *lr;
|
|
|
|
size_t namesize = strlen(name) + 1;
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
if (zil_replaying(zilog, tx))
|
2008-11-20 23:01:55 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
|
|
|
|
lr = (lr_link_t *)&itx->itx_lr;
|
|
|
|
lr->lr_doid = dzp->z_id;
|
|
|
|
lr->lr_link_obj = zp->z_id;
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy(lr + 1, name, namesize);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-06-11 21:12:34 +04:00
|
|
|
* Handles TX_SYMLINK transactions.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
2020-10-03 03:44:10 +03:00
|
|
|
znode_t *dzp, znode_t *zp, const char *name, const char *link)
|
2008-11-20 23:01:55 +03:00
|
|
|
{
|
|
|
|
itx_t *itx;
|
|
|
|
lr_create_t *lr;
|
|
|
|
size_t namesize = strlen(name) + 1;
|
|
|
|
size_t linksize = strlen(link) + 1;
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
if (zil_replaying(zilog, tx))
|
2008-11-20 23:01:55 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
itx = zil_itx_create(txtype, sizeof (*lr) + namesize + linksize);
|
|
|
|
lr = (lr_create_t *)&itx->itx_lr;
|
|
|
|
lr->lr_doid = dzp->z_id;
|
|
|
|
lr->lr_foid = zp->z_id;
|
2019-10-02 19:15:12 +03:00
|
|
|
lr->lr_uid = KUID_TO_SUID(ZTOUID(zp));
|
|
|
|
lr->lr_gid = KGID_TO_SGID(ZTOGID(zp));
|
2010-05-29 00:45:14 +04:00
|
|
|
lr->lr_mode = zp->z_mode;
|
2011-02-08 22:16:06 +03:00
|
|
|
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
|
2010-05-29 00:45:14 +04:00
|
|
|
sizeof (uint64_t));
|
2011-02-08 22:16:06 +03:00
|
|
|
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)),
|
2010-05-29 00:45:14 +04:00
|
|
|
lr->lr_crtime, sizeof (uint64_t) * 2);
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy((char *)(lr + 1), name, namesize);
|
|
|
|
memcpy((char *)(lr + 1) + namesize, link, linksize);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
2019-06-22 03:35:11 +03:00
|
|
|
static void
|
|
|
|
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;
|
|
|
|
size_t snamesize = strlen(sname) + 1;
|
|
|
|
size_t dnamesize = strlen(dname) + 1;
|
|
|
|
|
|
|
|
if (zil_replaying(zilog, tx))
|
|
|
|
return;
|
|
|
|
|
|
|
|
itx = zil_itx_create(txtype, sizeof (*lr) + snamesize + dnamesize);
|
|
|
|
lr = (lr_rename_t *)&itx->itx_lr;
|
|
|
|
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);
|
|
|
|
itx->itx_oid = szp->z_id;
|
|
|
|
|
|
|
|
zil_itx_assign(zilog, itx, tx);
|
|
|
|
}
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
/*
|
2013-06-11 21:12:34 +04:00
|
|
|
* Handles TX_RENAME transactions.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
void
|
2020-10-03 03:44:10 +03:00
|
|
|
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)
|
2019-06-22 03:35:11 +03:00
|
|
|
{
|
|
|
|
txtype |= TX_RENAME;
|
|
|
|
do_zfs_log_rename(zilog, tx, txtype, sdzp, sname, tdzp, dname, szp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handles TX_RENAME_EXCHANGE transactions.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_rename_exchange(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)
|
|
|
|
{
|
|
|
|
txtype |= TX_RENAME_EXCHANGE;
|
|
|
|
do_zfs_log_rename(zilog, tx, txtype, sdzp, sname, tdzp, dname, szp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handles TX_RENAME_WHITEOUT transactions.
|
|
|
|
*
|
|
|
|
* Unfortunately we cannot reuse do_zfs_log_rename because we we need to call
|
|
|
|
* zfs_mknode() on replay which requires stashing bits as with TX_CREATE.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_rename_whiteout(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, znode_t *wzp)
|
2008-11-20 23:01:55 +03:00
|
|
|
{
|
|
|
|
itx_t *itx;
|
2019-06-22 03:35:11 +03:00
|
|
|
lr_rename_whiteout_t *lr;
|
2008-11-20 23:01:55 +03:00
|
|
|
size_t snamesize = strlen(sname) + 1;
|
|
|
|
size_t dnamesize = strlen(dname) + 1;
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
if (zil_replaying(zilog, tx))
|
2008-11-20 23:01:55 +03:00
|
|
|
return;
|
|
|
|
|
2019-06-22 03:35:11 +03:00
|
|
|
txtype |= TX_RENAME_WHITEOUT;
|
2008-11-20 23:01:55 +03:00
|
|
|
itx = zil_itx_create(txtype, sizeof (*lr) + snamesize + dnamesize);
|
2019-06-22 03:35:11 +03:00
|
|
|
lr = (lr_rename_whiteout_t *)&itx->itx_lr;
|
|
|
|
lr->lr_rename.lr_sdoid = sdzp->z_id;
|
|
|
|
lr->lr_rename.lr_tdoid = tdzp->z_id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RENAME_WHITEOUT will create an entry at the source znode, so we need
|
|
|
|
* to store the same data that the equivalent call to zfs_log_create()
|
|
|
|
* would.
|
|
|
|
*/
|
|
|
|
lr->lr_wfoid = wzp->z_id;
|
|
|
|
LR_FOID_SET_SLOTS(lr->lr_wfoid, wzp->z_dnodesize >> DNODE_SHIFT);
|
|
|
|
(void) sa_lookup(wzp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(wzp)), &lr->lr_wgen,
|
|
|
|
sizeof (uint64_t));
|
|
|
|
(void) sa_lookup(wzp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(wzp)),
|
|
|
|
lr->lr_wcrtime, sizeof (uint64_t) * 2);
|
|
|
|
lr->lr_wmode = wzp->z_mode;
|
|
|
|
lr->lr_wuid = (uint64_t)KUID_TO_SUID(ZTOUID(wzp));
|
|
|
|
lr->lr_wgid = (uint64_t)KGID_TO_SGID(ZTOGID(wzp));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This rdev will always be makdevice(0, 0) but because the ZIL log and
|
|
|
|
* replay code needs to be platform independent (and there is no
|
|
|
|
* platform independent makdev()) we need to copy the one created
|
|
|
|
* during the rename operation.
|
|
|
|
*/
|
|
|
|
(void) sa_lookup(wzp->z_sa_hdl, SA_ZPL_RDEV(ZTOZSB(wzp)), &lr->lr_wrdev,
|
|
|
|
sizeof (lr->lr_wrdev));
|
|
|
|
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy((char *)(lr + 1), sname, snamesize);
|
|
|
|
memcpy((char *)(lr + 1) + snamesize, dname, dnamesize);
|
2010-08-27 01:24:34 +04:00
|
|
|
itx->itx_oid = szp->z_id;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
Only commit the ZIL once in zpl_writepages() (msync() case).
Currently, using msync() results in the following code path:
sys_msync -> zpl_fsync -> filemap_write_and_wait_range -> zpl_writepages -> write_cache_pages -> zpl_putpage
In such a code path, zil_commit() is called as part of zpl_putpage().
This means that for each page, the write is handed to the DMU, the ZIL
is committed, and only then do we move on to the next page. As one might
imagine, this results in atrocious performance where there is a large
number of pages to write: instead of committing a batch of N writes,
we do N commits containing one page each. In some extreme cases this
can result in msync() being ~700 times slower than it should be, as well
as very inefficient use of ZIL resources.
This patch fixes this issue by making sure that the requested writes
are batched and then committed only once. Unfortunately, the
implementation is somewhat non-trivial because there is no way to run
write_cache_pages in SYNC mode (so that we get all pages) without
making it wait on the writeback tag for each page.
The solution implemented here is composed of two parts:
- I added a new callback system to the ZIL, which allows the caller to
be notified when its ITX gets written to stable storage. One nice
thing is that the callback is called not only in zil_commit() but
in zil_sync() as well, which means that the caller doesn't have to
care whether the write ended up in the ZIL or the DMU: it will get
notified as soon as it's safe, period. This is an improvement over
dmu_tx_callback_register() that was used previously, which only
supports DMU writes. The rationale for this change is to allow
zpl_putpage() to be notified when a ZIL commit is completed without
having to block on zil_commit() itself.
- zpl_writepages() now calls write_cache_pages in non-SYNC mode, which
will prevent (1) write_cache_pages from blocking, and (2) zpl_putpage
from issuing ZIL commits. zpl_writepages() will issue the commit
itself instead of relying on zpl_putpage() to do it, thus nicely
batching the writes. Note, however, that we still have to call
write_cache_pages() again in SYNC mode because there is an edge case
documented in the implementation of write_cache_pages() whereas it
will not give us all dirty pages when running in non-SYNC mode. Thus
we need to run it at least once in SYNC mode to make sure we honor
persistency guarantees. This only happens when the pages are
modified at the same time msync() is running, which should be rare.
In most cases there won't be any additional pages and this second
call will do nothing.
Note that this change also fixes a bug related to #907 whereas calling
msync() on pages that were already handed over to the DMU in a previous
writepages() call would make msync() block until the next TXG sync
instead of returning as soon as the ZIL commit is complete. The new
callback system fixes that problem.
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1849
Closes #907
2013-11-10 19:00:11 +04:00
|
|
|
* zfs_log_write() handles TX_WRITE transactions. The specified callback is
|
|
|
|
* called as soon as the write is on stable storage (be it via a DMU sync or a
|
|
|
|
* ZIL commit).
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
Cleanup: 64-bit kernel module parameters should use fixed width types
Various module parameters such as `zfs_arc_max` were originally
`uint64_t` on OpenSolaris/Illumos, but were changed to `unsigned long`
for Linux compatibility because Linux's kernel default module parameter
implementation did not support 64-bit types on 32-bit platforms. This
caused problems when porting OpenZFS to Windows because its LLP64 memory
model made `unsigned long` a 32-bit type on 64-bit, which created the
undesireable situation that parameters that should accept 64-bit values
could not on 64-bit Windows.
Upon inspection, it turns out that the Linux kernel module parameter
interface is extensible, such that we are allowed to define our own
types. Rather than maintaining the original type change via hacks to to
continue shrinking module parameters on 32-bit Linux, we implement
support for 64-bit module parameters on Linux.
After doing a review of all 64-bit kernel parameters (found via the man
page and also proposed changes by Andrew Innes), the kernel module
parameters fell into a few groups:
Parameters that were originally 64-bit on Illumos:
* dbuf_cache_max_bytes
* dbuf_metadata_cache_max_bytes
* l2arc_feed_min_ms
* l2arc_feed_secs
* l2arc_headroom
* l2arc_headroom_boost
* l2arc_write_boost
* l2arc_write_max
* metaslab_aliquot
* metaslab_force_ganging
* zfetch_array_rd_sz
* zfs_arc_max
* zfs_arc_meta_limit
* zfs_arc_meta_min
* zfs_arc_min
* zfs_async_block_max_blocks
* zfs_condense_max_obsolete_bytes
* zfs_condense_min_mapping_bytes
* zfs_deadman_checktime_ms
* zfs_deadman_synctime_ms
* zfs_initialize_chunk_size
* zfs_initialize_value
* zfs_lua_max_instrlimit
* zfs_lua_max_memlimit
* zil_slog_bulk
Parameters that were originally 32-bit on Illumos:
* zfs_per_txg_dirty_frees_percent
Parameters that were originally `ssize_t` on Illumos:
* zfs_immediate_write_sz
Note that `ssize_t` is `int32_t` on 32-bit and `int64_t` on 64-bit. It
has been upgraded to 64-bit.
Parameters that were `long`/`unsigned long` because of Linux/FreeBSD
influence:
* l2arc_rebuild_blocks_min_l2size
* zfs_key_max_salt_uses
* zfs_max_log_walking
* zfs_max_logsm_summary_length
* zfs_metaslab_max_size_cache_sec
* zfs_min_metaslabs_to_flush
* zfs_multihost_interval
* zfs_unflushed_log_block_max
* zfs_unflushed_log_block_min
* zfs_unflushed_log_block_pct
* zfs_unflushed_max_mem_amt
* zfs_unflushed_max_mem_ppm
New parameters that do not exist in Illumos:
* l2arc_trim_ahead
* vdev_file_logical_ashift
* vdev_file_physical_ashift
* zfs_arc_dnode_limit
* zfs_arc_dnode_limit_percent
* zfs_arc_dnode_reduce_percent
* zfs_arc_meta_limit_percent
* zfs_arc_sys_free
* zfs_deadman_ziotime_ms
* zfs_delete_blocks
* zfs_history_output_max
* zfs_livelist_max_entries
* zfs_max_async_dedup_frees
* zfs_max_nvlist_src_size
* zfs_rebuild_max_segment
* zfs_rebuild_vdev_limit
* zfs_unflushed_log_txg_max
* zfs_vdev_max_auto_ashift
* zfs_vdev_min_auto_ashift
* zfs_vnops_read_chunk_size
* zvol_max_discard_blocks
Rather than clutter the lists with commentary, the module parameters
that need comments are repeated below.
A few parameters were defined in Linux/FreeBSD specific code, where the
use of ulong/long is not an issue for portability, so we leave them
alone:
* zfs_delete_blocks
* zfs_key_max_salt_uses
* zvol_max_discard_blocks
The documentation for a few parameters was found to be incorrect:
* zfs_deadman_checktime_ms - incorrectly documented as int
* zfs_delete_blocks - not documented as Linux only
* zfs_history_output_max - incorrectly documented as int
* zfs_vnops_read_chunk_size - incorrectly documented as long
* zvol_max_discard_blocks - incorrectly documented as ulong
The documentation for these has been fixed, alongside the changes to
document the switch to fixed width types.
In addition, several kernel module parameters were percentages or held
ashift values, so being 64-bit never made sense for them. They have been
downgraded to 32-bit:
* vdev_file_logical_ashift
* vdev_file_physical_ashift
* zfs_arc_dnode_limit_percent
* zfs_arc_dnode_reduce_percent
* zfs_arc_meta_limit_percent
* zfs_per_txg_dirty_frees_percent
* zfs_unflushed_log_block_pct
* zfs_vdev_max_auto_ashift
* zfs_vdev_min_auto_ashift
Of special note are `zfs_vdev_max_auto_ashift` and
`zfs_vdev_min_auto_ashift`, which were already defined as `uint64_t`,
and passed to the kernel as `ulong`. This is inherently buggy on big
endian 32-bit Linux, since the values would not be written to the
correct locations. 32-bit FreeBSD was unaffected because its sysctl code
correctly treated this as a `uint64_t`.
Lastly, a code comment suggests that `zfs_arc_sys_free` is
Linux-specific, but there is nothing to indicate to me that it is
Linux-specific. Nothing was done about that.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Original-patch-by: Andrew Innes <andrew.c12@gmail.com>
Original-patch-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13984
Closes #14004
2022-10-03 22:06:54 +03:00
|
|
|
static int64_t zfs_immediate_write_sz = 32768;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
|
2023-10-31 00:51:56 +03:00
|
|
|
znode_t *zp, offset_t off, ssize_t resid, boolean_t commit,
|
Adding Direct IO Support
Adding O_DIRECT support to ZFS to bypass the ARC for writes/reads.
O_DIRECT support in ZFS will always ensure there is coherency between
buffered and O_DIRECT IO requests. This ensures that all IO requests,
whether buffered or direct, will see the same file contents at all
times. Just as in other FS's , O_DIRECT does not imply O_SYNC. While
data is written directly to VDEV disks, metadata will not be synced
until the associated TXG is synced.
For both O_DIRECT read and write request the offset and request sizes,
at a minimum, must be PAGE_SIZE aligned. In the event they are not,
then EINVAL is returned unless the direct property is set to always (see
below).
For O_DIRECT writes:
The request also must be block aligned (recordsize) or the write
request will take the normal (buffered) write path. In the event that
request is block aligned and a cached copy of the buffer in the ARC,
then it will be discarded from the ARC forcing all further reads to
retrieve the data from disk.
For O_DIRECT reads:
The only alignment restrictions are PAGE_SIZE alignment. In the event
that the requested data is in buffered (in the ARC) it will just be
copied from the ARC into the user buffer.
For both O_DIRECT writes and reads the O_DIRECT flag will be ignored in
the event that file contents are mmap'ed. In this case, all requests
that are at least PAGE_SIZE aligned will just fall back to the buffered
paths. If the request however is not PAGE_SIZE aligned, EINVAL will
be returned as always regardless if the file's contents are mmap'ed.
Since O_DIRECT writes go through the normal ZIO pipeline, the
following operations are supported just as with normal buffered writes:
Checksum
Compression
Encryption
Erasure Coding
There is one caveat for the data integrity of O_DIRECT writes that is
distinct for each of the OS's supported by ZFS.
FreeBSD - FreeBSD is able to place user pages under write protection so
any data in the user buffers and written directly down to the
VDEV disks is guaranteed to not change. There is no concern
with data integrity and O_DIRECT writes.
Linux - Linux is not able to place anonymous user pages under write
protection. Because of this, if the user decides to manipulate
the page contents while the write operation is occurring, data
integrity can not be guaranteed. However, there is a module
parameter `zfs_vdev_direct_write_verify` that controls the
if a O_DIRECT writes that can occur to a top-level VDEV before
a checksum verify is run before the contents of the I/O buffer
are committed to disk. In the event of a checksum verification
failure the write will return EIO. The number of O_DIRECT write
checksum verification errors can be observed by doing
`zpool status -d`, which will list all verification errors that
have occurred on a top-level VDEV. Along with `zpool status`, a
ZED event will be issues as `dio_verify` when a checksum
verification error occurs.
ZVOLs and dedup is not currently supported with Direct I/O.
A new dataset property `direct` has been added with the following 3
allowable values:
disabled - Accepts O_DIRECT flag, but silently ignores it and treats
the request as a buffered IO request.
standard - Follows the alignment restrictions outlined above for
write/read IO requests when the O_DIRECT flag is used.
always - Treats every write/read IO request as though it passed
O_DIRECT and will do O_DIRECT if the alignment restrictions
are met otherwise will redirect through the ARC. This
property will not allow a request to fail.
There is also a module parameter zfs_dio_enabled that can be used to
force all reads and writes through the ARC. By setting this module
parameter to 0, it mimics as if the direct dataset property is set to
disabled.
Reviewed-by: Brian Behlendorf <behlendorf@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Co-authored-by: Mark Maybee <mark.maybee@delphix.com>
Co-authored-by: Matt Macy <mmacy@FreeBSD.org>
Co-authored-by: Brian Behlendorf <behlendorf@llnl.gov>
Closes #10018
2024-09-14 23:47:59 +03:00
|
|
|
boolean_t o_direct, zil_callback_t callback, void *callback_data)
|
2008-11-20 23:01:55 +03:00
|
|
|
{
|
2019-08-16 02:36:24 +03:00
|
|
|
dmu_buf_impl_t *db = (dmu_buf_impl_t *)sa_get_db(zp->z_sa_hdl);
|
OpenZFS 7578 - Fix/improve some aspects of ZIL writing
- After some ZIL changes 6 years ago zil_slog_limit got partially broken
due to zl_itx_list_sz not updated when async itx'es upgraded to sync.
Actually because of other changes about that time zl_itx_list_sz is not
really required to implement the functionality, so this patch removes
some unneeded broken code and variables.
- Original idea of zil_slog_limit was to reduce chance of SLOG abuse by
single heavy logger, that increased latency for other (more latency critical)
loggers, by pushing heavy log out into the main pool instead of SLOG. Beside
huge latency increase for heavy writers, this implementation caused double
write of all data, since the log records were explicitly prepared for SLOG.
Since we now have I/O scheduler, I've found it can be much more efficient
to reduce priority of heavy logger SLOG writes from ZIO_PRIORITY_SYNC_WRITE
to ZIO_PRIORITY_ASYNC_WRITE, while still leave them on SLOG.
- Existing ZIL implementation had problem with space efficiency when it
has to write large chunks of data into log blocks of limited size. In some
cases efficiency stopped to almost as low as 50%. In case of ZIL stored on
spinning rust, that also reduced log write speed in half, since head had to
uselessly fly over allocated but not written areas. This change improves
the situation by offloading problematic operations from z*_log_write() to
zil_lwb_commit(), which knows real situation of log blocks allocation and
can split large requests into pieces much more efficiently. Also as side
effect it removes one of two data copy operations done by ZIL code WR_COPIED
case.
- While there, untangle and unify code of z*_log_write() functions.
Also zfs_log_write() alike to zvol_log_write() can now handle writes crossing
block boundary, that may also improve efficiency if ZPL is made to do that.
Sponsored by: iXsystems, Inc.
Authored by: Alexander Motin <mav@FreeBSD.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7578
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/aeb13ac
Closes #6191
2017-06-09 19:15:37 +03:00
|
|
|
uint32_t blocksize = zp->z_blksz;
|
2008-11-20 23:01:55 +03:00
|
|
|
itx_wr_state_t write_state;
|
2021-03-20 08:53:31 +03:00
|
|
|
uint64_t gen = 0;
|
2021-07-20 18:40:24 +03:00
|
|
|
ssize_t size = resid;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2016-10-13 03:30:46 +03:00
|
|
|
if (zil_replaying(zilog, tx) || zp->z_unlinked ||
|
|
|
|
zfs_xattr_owner_unlinked(zp)) {
|
Only commit the ZIL once in zpl_writepages() (msync() case).
Currently, using msync() results in the following code path:
sys_msync -> zpl_fsync -> filemap_write_and_wait_range -> zpl_writepages -> write_cache_pages -> zpl_putpage
In such a code path, zil_commit() is called as part of zpl_putpage().
This means that for each page, the write is handed to the DMU, the ZIL
is committed, and only then do we move on to the next page. As one might
imagine, this results in atrocious performance where there is a large
number of pages to write: instead of committing a batch of N writes,
we do N commits containing one page each. In some extreme cases this
can result in msync() being ~700 times slower than it should be, as well
as very inefficient use of ZIL resources.
This patch fixes this issue by making sure that the requested writes
are batched and then committed only once. Unfortunately, the
implementation is somewhat non-trivial because there is no way to run
write_cache_pages in SYNC mode (so that we get all pages) without
making it wait on the writeback tag for each page.
The solution implemented here is composed of two parts:
- I added a new callback system to the ZIL, which allows the caller to
be notified when its ITX gets written to stable storage. One nice
thing is that the callback is called not only in zil_commit() but
in zil_sync() as well, which means that the caller doesn't have to
care whether the write ended up in the ZIL or the DMU: it will get
notified as soon as it's safe, period. This is an improvement over
dmu_tx_callback_register() that was used previously, which only
supports DMU writes. The rationale for this change is to allow
zpl_putpage() to be notified when a ZIL commit is completed without
having to block on zil_commit() itself.
- zpl_writepages() now calls write_cache_pages in non-SYNC mode, which
will prevent (1) write_cache_pages from blocking, and (2) zpl_putpage
from issuing ZIL commits. zpl_writepages() will issue the commit
itself instead of relying on zpl_putpage() to do it, thus nicely
batching the writes. Note, however, that we still have to call
write_cache_pages() again in SYNC mode because there is an edge case
documented in the implementation of write_cache_pages() whereas it
will not give us all dirty pages when running in non-SYNC mode. Thus
we need to run it at least once in SYNC mode to make sure we honor
persistency guarantees. This only happens when the pages are
modified at the same time msync() is running, which should be rare.
In most cases there won't be any additional pages and this second
call will do nothing.
Note that this change also fixes a bug related to #907 whereas calling
msync() on pages that were already handed over to the DMU in a previous
writepages() call would make msync() block until the next TXG sync
instead of returning as soon as the ZIL commit is complete. The new
callback system fixes that problem.
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1849
Closes #907
2013-11-10 19:00:11 +04:00
|
|
|
if (callback != NULL)
|
|
|
|
callback(callback_data);
|
2008-11-20 23:01:55 +03:00
|
|
|
return;
|
Only commit the ZIL once in zpl_writepages() (msync() case).
Currently, using msync() results in the following code path:
sys_msync -> zpl_fsync -> filemap_write_and_wait_range -> zpl_writepages -> write_cache_pages -> zpl_putpage
In such a code path, zil_commit() is called as part of zpl_putpage().
This means that for each page, the write is handed to the DMU, the ZIL
is committed, and only then do we move on to the next page. As one might
imagine, this results in atrocious performance where there is a large
number of pages to write: instead of committing a batch of N writes,
we do N commits containing one page each. In some extreme cases this
can result in msync() being ~700 times slower than it should be, as well
as very inefficient use of ZIL resources.
This patch fixes this issue by making sure that the requested writes
are batched and then committed only once. Unfortunately, the
implementation is somewhat non-trivial because there is no way to run
write_cache_pages in SYNC mode (so that we get all pages) without
making it wait on the writeback tag for each page.
The solution implemented here is composed of two parts:
- I added a new callback system to the ZIL, which allows the caller to
be notified when its ITX gets written to stable storage. One nice
thing is that the callback is called not only in zil_commit() but
in zil_sync() as well, which means that the caller doesn't have to
care whether the write ended up in the ZIL or the DMU: it will get
notified as soon as it's safe, period. This is an improvement over
dmu_tx_callback_register() that was used previously, which only
supports DMU writes. The rationale for this change is to allow
zpl_putpage() to be notified when a ZIL commit is completed without
having to block on zil_commit() itself.
- zpl_writepages() now calls write_cache_pages in non-SYNC mode, which
will prevent (1) write_cache_pages from blocking, and (2) zpl_putpage
from issuing ZIL commits. zpl_writepages() will issue the commit
itself instead of relying on zpl_putpage() to do it, thus nicely
batching the writes. Note, however, that we still have to call
write_cache_pages() again in SYNC mode because there is an edge case
documented in the implementation of write_cache_pages() whereas it
will not give us all dirty pages when running in non-SYNC mode. Thus
we need to run it at least once in SYNC mode to make sure we honor
persistency guarantees. This only happens when the pages are
modified at the same time msync() is running, which should be rare.
In most cases there won't be any additional pages and this second
call will do nothing.
Note that this change also fixes a bug related to #907 whereas calling
msync() on pages that were already handed over to the DMU in a previous
writepages() call would make msync() block until the next TXG sync
instead of returning as soon as the ZIL commit is complete. The new
callback system fixes that problem.
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1849
Closes #907
2013-11-10 19:00:11 +04:00
|
|
|
}
|
2008-11-20 23:01:55 +03:00
|
|
|
|
Adding Direct IO Support
Adding O_DIRECT support to ZFS to bypass the ARC for writes/reads.
O_DIRECT support in ZFS will always ensure there is coherency between
buffered and O_DIRECT IO requests. This ensures that all IO requests,
whether buffered or direct, will see the same file contents at all
times. Just as in other FS's , O_DIRECT does not imply O_SYNC. While
data is written directly to VDEV disks, metadata will not be synced
until the associated TXG is synced.
For both O_DIRECT read and write request the offset and request sizes,
at a minimum, must be PAGE_SIZE aligned. In the event they are not,
then EINVAL is returned unless the direct property is set to always (see
below).
For O_DIRECT writes:
The request also must be block aligned (recordsize) or the write
request will take the normal (buffered) write path. In the event that
request is block aligned and a cached copy of the buffer in the ARC,
then it will be discarded from the ARC forcing all further reads to
retrieve the data from disk.
For O_DIRECT reads:
The only alignment restrictions are PAGE_SIZE alignment. In the event
that the requested data is in buffered (in the ARC) it will just be
copied from the ARC into the user buffer.
For both O_DIRECT writes and reads the O_DIRECT flag will be ignored in
the event that file contents are mmap'ed. In this case, all requests
that are at least PAGE_SIZE aligned will just fall back to the buffered
paths. If the request however is not PAGE_SIZE aligned, EINVAL will
be returned as always regardless if the file's contents are mmap'ed.
Since O_DIRECT writes go through the normal ZIO pipeline, the
following operations are supported just as with normal buffered writes:
Checksum
Compression
Encryption
Erasure Coding
There is one caveat for the data integrity of O_DIRECT writes that is
distinct for each of the OS's supported by ZFS.
FreeBSD - FreeBSD is able to place user pages under write protection so
any data in the user buffers and written directly down to the
VDEV disks is guaranteed to not change. There is no concern
with data integrity and O_DIRECT writes.
Linux - Linux is not able to place anonymous user pages under write
protection. Because of this, if the user decides to manipulate
the page contents while the write operation is occurring, data
integrity can not be guaranteed. However, there is a module
parameter `zfs_vdev_direct_write_verify` that controls the
if a O_DIRECT writes that can occur to a top-level VDEV before
a checksum verify is run before the contents of the I/O buffer
are committed to disk. In the event of a checksum verification
failure the write will return EIO. The number of O_DIRECT write
checksum verification errors can be observed by doing
`zpool status -d`, which will list all verification errors that
have occurred on a top-level VDEV. Along with `zpool status`, a
ZED event will be issues as `dio_verify` when a checksum
verification error occurs.
ZVOLs and dedup is not currently supported with Direct I/O.
A new dataset property `direct` has been added with the following 3
allowable values:
disabled - Accepts O_DIRECT flag, but silently ignores it and treats
the request as a buffered IO request.
standard - Follows the alignment restrictions outlined above for
write/read IO requests when the O_DIRECT flag is used.
always - Treats every write/read IO request as though it passed
O_DIRECT and will do O_DIRECT if the alignment restrictions
are met otherwise will redirect through the ARC. This
property will not allow a request to fail.
There is also a module parameter zfs_dio_enabled that can be used to
force all reads and writes through the ARC. By setting this module
parameter to 0, it mimics as if the direct dataset property is set to
disabled.
Reviewed-by: Brian Behlendorf <behlendorf@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Co-authored-by: Mark Maybee <mark.maybee@delphix.com>
Co-authored-by: Matt Macy <mmacy@FreeBSD.org>
Co-authored-by: Brian Behlendorf <behlendorf@llnl.gov>
Closes #10018
2024-09-14 23:47:59 +03:00
|
|
|
if (zilog->zl_logbias == ZFS_LOGBIAS_THROUGHPUT || o_direct)
|
OpenZFS 7578 - Fix/improve some aspects of ZIL writing
- After some ZIL changes 6 years ago zil_slog_limit got partially broken
due to zl_itx_list_sz not updated when async itx'es upgraded to sync.
Actually because of other changes about that time zl_itx_list_sz is not
really required to implement the functionality, so this patch removes
some unneeded broken code and variables.
- Original idea of zil_slog_limit was to reduce chance of SLOG abuse by
single heavy logger, that increased latency for other (more latency critical)
loggers, by pushing heavy log out into the main pool instead of SLOG. Beside
huge latency increase for heavy writers, this implementation caused double
write of all data, since the log records were explicitly prepared for SLOG.
Since we now have I/O scheduler, I've found it can be much more efficient
to reduce priority of heavy logger SLOG writes from ZIO_PRIORITY_SYNC_WRITE
to ZIO_PRIORITY_ASYNC_WRITE, while still leave them on SLOG.
- Existing ZIL implementation had problem with space efficiency when it
has to write large chunks of data into log blocks of limited size. In some
cases efficiency stopped to almost as low as 50%. In case of ZIL stored on
spinning rust, that also reduced log write speed in half, since head had to
uselessly fly over allocated but not written areas. This change improves
the situation by offloading problematic operations from z*_log_write() to
zil_lwb_commit(), which knows real situation of log blocks allocation and
can split large requests into pieces much more efficiently. Also as side
effect it removes one of two data copy operations done by ZIL code WR_COPIED
case.
- While there, untangle and unify code of z*_log_write() functions.
Also zfs_log_write() alike to zvol_log_write() can now handle writes crossing
block boundary, that may also improve efficiency if ZPL is made to do that.
Sponsored by: iXsystems, Inc.
Authored by: Alexander Motin <mav@FreeBSD.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7578
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/aeb13ac
Closes #6191
2017-06-09 19:15:37 +03:00
|
|
|
write_state = WR_INDIRECT;
|
|
|
|
else if (!spa_has_slogs(zilog->zl_spa) &&
|
|
|
|
resid >= zfs_immediate_write_sz)
|
2008-11-20 23:01:55 +03:00
|
|
|
write_state = WR_INDIRECT;
|
2023-10-31 00:51:56 +03:00
|
|
|
else if (commit)
|
2008-11-20 23:01:55 +03:00
|
|
|
write_state = WR_COPIED;
|
|
|
|
else
|
|
|
|
write_state = WR_NEED_COPY;
|
|
|
|
|
2021-03-20 08:53:31 +03:00
|
|
|
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &gen,
|
|
|
|
sizeof (gen));
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
while (resid) {
|
|
|
|
itx_t *itx;
|
|
|
|
lr_write_t *lr;
|
OpenZFS 7578 - Fix/improve some aspects of ZIL writing
- After some ZIL changes 6 years ago zil_slog_limit got partially broken
due to zl_itx_list_sz not updated when async itx'es upgraded to sync.
Actually because of other changes about that time zl_itx_list_sz is not
really required to implement the functionality, so this patch removes
some unneeded broken code and variables.
- Original idea of zil_slog_limit was to reduce chance of SLOG abuse by
single heavy logger, that increased latency for other (more latency critical)
loggers, by pushing heavy log out into the main pool instead of SLOG. Beside
huge latency increase for heavy writers, this implementation caused double
write of all data, since the log records were explicitly prepared for SLOG.
Since we now have I/O scheduler, I've found it can be much more efficient
to reduce priority of heavy logger SLOG writes from ZIO_PRIORITY_SYNC_WRITE
to ZIO_PRIORITY_ASYNC_WRITE, while still leave them on SLOG.
- Existing ZIL implementation had problem with space efficiency when it
has to write large chunks of data into log blocks of limited size. In some
cases efficiency stopped to almost as low as 50%. In case of ZIL stored on
spinning rust, that also reduced log write speed in half, since head had to
uselessly fly over allocated but not written areas. This change improves
the situation by offloading problematic operations from z*_log_write() to
zil_lwb_commit(), which knows real situation of log blocks allocation and
can split large requests into pieces much more efficiently. Also as side
effect it removes one of two data copy operations done by ZIL code WR_COPIED
case.
- While there, untangle and unify code of z*_log_write() functions.
Also zfs_log_write() alike to zvol_log_write() can now handle writes crossing
block boundary, that may also improve efficiency if ZPL is made to do that.
Sponsored by: iXsystems, Inc.
Authored by: Alexander Motin <mav@FreeBSD.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7578
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/aeb13ac
Closes #6191
2017-06-09 19:15:37 +03:00
|
|
|
itx_wr_state_t wr_state = write_state;
|
|
|
|
ssize_t len = resid;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2019-06-10 21:48:42 +03:00
|
|
|
/*
|
|
|
|
* A WR_COPIED record must fit entirely in one log block.
|
|
|
|
* Large writes can use WR_NEED_COPY, which the ZIL will
|
|
|
|
* split into multiple records across several log blocks
|
|
|
|
* if necessary.
|
|
|
|
*/
|
|
|
|
if (wr_state == WR_COPIED &&
|
|
|
|
resid > zil_max_copied_data(zilog))
|
OpenZFS 7578 - Fix/improve some aspects of ZIL writing
- After some ZIL changes 6 years ago zil_slog_limit got partially broken
due to zl_itx_list_sz not updated when async itx'es upgraded to sync.
Actually because of other changes about that time zl_itx_list_sz is not
really required to implement the functionality, so this patch removes
some unneeded broken code and variables.
- Original idea of zil_slog_limit was to reduce chance of SLOG abuse by
single heavy logger, that increased latency for other (more latency critical)
loggers, by pushing heavy log out into the main pool instead of SLOG. Beside
huge latency increase for heavy writers, this implementation caused double
write of all data, since the log records were explicitly prepared for SLOG.
Since we now have I/O scheduler, I've found it can be much more efficient
to reduce priority of heavy logger SLOG writes from ZIO_PRIORITY_SYNC_WRITE
to ZIO_PRIORITY_ASYNC_WRITE, while still leave them on SLOG.
- Existing ZIL implementation had problem with space efficiency when it
has to write large chunks of data into log blocks of limited size. In some
cases efficiency stopped to almost as low as 50%. In case of ZIL stored on
spinning rust, that also reduced log write speed in half, since head had to
uselessly fly over allocated but not written areas. This change improves
the situation by offloading problematic operations from z*_log_write() to
zil_lwb_commit(), which knows real situation of log blocks allocation and
can split large requests into pieces much more efficiently. Also as side
effect it removes one of two data copy operations done by ZIL code WR_COPIED
case.
- While there, untangle and unify code of z*_log_write() functions.
Also zfs_log_write() alike to zvol_log_write() can now handle writes crossing
block boundary, that may also improve efficiency if ZPL is made to do that.
Sponsored by: iXsystems, Inc.
Authored by: Alexander Motin <mav@FreeBSD.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7578
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/aeb13ac
Closes #6191
2017-06-09 19:15:37 +03:00
|
|
|
wr_state = WR_NEED_COPY;
|
|
|
|
else if (wr_state == WR_INDIRECT)
|
|
|
|
len = MIN(blocksize - P2PHASE(off, blocksize), resid);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
itx = zil_itx_create(txtype, sizeof (*lr) +
|
OpenZFS 7578 - Fix/improve some aspects of ZIL writing
- After some ZIL changes 6 years ago zil_slog_limit got partially broken
due to zl_itx_list_sz not updated when async itx'es upgraded to sync.
Actually because of other changes about that time zl_itx_list_sz is not
really required to implement the functionality, so this patch removes
some unneeded broken code and variables.
- Original idea of zil_slog_limit was to reduce chance of SLOG abuse by
single heavy logger, that increased latency for other (more latency critical)
loggers, by pushing heavy log out into the main pool instead of SLOG. Beside
huge latency increase for heavy writers, this implementation caused double
write of all data, since the log records were explicitly prepared for SLOG.
Since we now have I/O scheduler, I've found it can be much more efficient
to reduce priority of heavy logger SLOG writes from ZIO_PRIORITY_SYNC_WRITE
to ZIO_PRIORITY_ASYNC_WRITE, while still leave them on SLOG.
- Existing ZIL implementation had problem with space efficiency when it
has to write large chunks of data into log blocks of limited size. In some
cases efficiency stopped to almost as low as 50%. In case of ZIL stored on
spinning rust, that also reduced log write speed in half, since head had to
uselessly fly over allocated but not written areas. This change improves
the situation by offloading problematic operations from z*_log_write() to
zil_lwb_commit(), which knows real situation of log blocks allocation and
can split large requests into pieces much more efficiently. Also as side
effect it removes one of two data copy operations done by ZIL code WR_COPIED
case.
- While there, untangle and unify code of z*_log_write() functions.
Also zfs_log_write() alike to zvol_log_write() can now handle writes crossing
block boundary, that may also improve efficiency if ZPL is made to do that.
Sponsored by: iXsystems, Inc.
Authored by: Alexander Motin <mav@FreeBSD.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7578
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/aeb13ac
Closes #6191
2017-06-09 19:15:37 +03:00
|
|
|
(wr_state == WR_COPIED ? len : 0));
|
2008-11-20 23:01:55 +03:00
|
|
|
lr = (lr_write_t *)&itx->itx_lr;
|
2019-08-16 02:36:24 +03:00
|
|
|
|
2020-09-25 23:06:34 +03:00
|
|
|
/*
|
|
|
|
* For WR_COPIED records, copy the data into the lr_write_t.
|
|
|
|
*/
|
|
|
|
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);
|
2024-07-22 04:04:38 +03:00
|
|
|
DB_DNODE_EXIT(db);
|
2020-09-25 23:06:34 +03:00
|
|
|
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;
|
|
|
|
}
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
OpenZFS 7578 - Fix/improve some aspects of ZIL writing
- After some ZIL changes 6 years ago zil_slog_limit got partially broken
due to zl_itx_list_sz not updated when async itx'es upgraded to sync.
Actually because of other changes about that time zl_itx_list_sz is not
really required to implement the functionality, so this patch removes
some unneeded broken code and variables.
- Original idea of zil_slog_limit was to reduce chance of SLOG abuse by
single heavy logger, that increased latency for other (more latency critical)
loggers, by pushing heavy log out into the main pool instead of SLOG. Beside
huge latency increase for heavy writers, this implementation caused double
write of all data, since the log records were explicitly prepared for SLOG.
Since we now have I/O scheduler, I've found it can be much more efficient
to reduce priority of heavy logger SLOG writes from ZIO_PRIORITY_SYNC_WRITE
to ZIO_PRIORITY_ASYNC_WRITE, while still leave them on SLOG.
- Existing ZIL implementation had problem with space efficiency when it
has to write large chunks of data into log blocks of limited size. In some
cases efficiency stopped to almost as low as 50%. In case of ZIL stored on
spinning rust, that also reduced log write speed in half, since head had to
uselessly fly over allocated but not written areas. This change improves
the situation by offloading problematic operations from z*_log_write() to
zil_lwb_commit(), which knows real situation of log blocks allocation and
can split large requests into pieces much more efficiently. Also as side
effect it removes one of two data copy operations done by ZIL code WR_COPIED
case.
- While there, untangle and unify code of z*_log_write() functions.
Also zfs_log_write() alike to zvol_log_write() can now handle writes crossing
block boundary, that may also improve efficiency if ZPL is made to do that.
Sponsored by: iXsystems, Inc.
Authored by: Alexander Motin <mav@FreeBSD.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7578
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/aeb13ac
Closes #6191
2017-06-09 19:15:37 +03:00
|
|
|
itx->itx_wr_state = wr_state;
|
2008-11-20 23:01:55 +03:00
|
|
|
lr->lr_foid = zp->z_id;
|
|
|
|
lr->lr_offset = off;
|
|
|
|
lr->lr_length = len;
|
|
|
|
lr->lr_blkoff = 0;
|
|
|
|
BP_ZERO(&lr->lr_blkptr);
|
|
|
|
|
2011-02-08 22:16:06 +03:00
|
|
|
itx->itx_private = ZTOZSB(zp);
|
2023-10-31 00:51:56 +03:00
|
|
|
itx->itx_sync = (zp->z_sync_cnt != 0);
|
2021-03-20 08:53:31 +03:00
|
|
|
itx->itx_gen = gen;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
Only commit the ZIL once in zpl_writepages() (msync() case).
Currently, using msync() results in the following code path:
sys_msync -> zpl_fsync -> filemap_write_and_wait_range -> zpl_writepages -> write_cache_pages -> zpl_putpage
In such a code path, zil_commit() is called as part of zpl_putpage().
This means that for each page, the write is handed to the DMU, the ZIL
is committed, and only then do we move on to the next page. As one might
imagine, this results in atrocious performance where there is a large
number of pages to write: instead of committing a batch of N writes,
we do N commits containing one page each. In some extreme cases this
can result in msync() being ~700 times slower than it should be, as well
as very inefficient use of ZIL resources.
This patch fixes this issue by making sure that the requested writes
are batched and then committed only once. Unfortunately, the
implementation is somewhat non-trivial because there is no way to run
write_cache_pages in SYNC mode (so that we get all pages) without
making it wait on the writeback tag for each page.
The solution implemented here is composed of two parts:
- I added a new callback system to the ZIL, which allows the caller to
be notified when its ITX gets written to stable storage. One nice
thing is that the callback is called not only in zil_commit() but
in zil_sync() as well, which means that the caller doesn't have to
care whether the write ended up in the ZIL or the DMU: it will get
notified as soon as it's safe, period. This is an improvement over
dmu_tx_callback_register() that was used previously, which only
supports DMU writes. The rationale for this change is to allow
zpl_putpage() to be notified when a ZIL commit is completed without
having to block on zil_commit() itself.
- zpl_writepages() now calls write_cache_pages in non-SYNC mode, which
will prevent (1) write_cache_pages from blocking, and (2) zpl_putpage
from issuing ZIL commits. zpl_writepages() will issue the commit
itself instead of relying on zpl_putpage() to do it, thus nicely
batching the writes. Note, however, that we still have to call
write_cache_pages() again in SYNC mode because there is an edge case
documented in the implementation of write_cache_pages() whereas it
will not give us all dirty pages when running in non-SYNC mode. Thus
we need to run it at least once in SYNC mode to make sure we honor
persistency guarantees. This only happens when the pages are
modified at the same time msync() is running, which should be rare.
In most cases there won't be any additional pages and this second
call will do nothing.
Note that this change also fixes a bug related to #907 whereas calling
msync() on pages that were already handed over to the DMU in a previous
writepages() call would make msync() block until the next TXG sync
instead of returning as soon as the ZIL commit is complete. The new
callback system fixes that problem.
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1849
Closes #907
2013-11-10 19:00:11 +04:00
|
|
|
itx->itx_callback = callback;
|
|
|
|
itx->itx_callback_data = callback_data;
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
off += len;
|
|
|
|
resid -= len;
|
|
|
|
}
|
2021-07-20 18:40:24 +03:00
|
|
|
|
|
|
|
if (write_state == WR_COPIED || write_state == WR_NEED_COPY) {
|
|
|
|
dsl_pool_wrlog_count(zilog->zl_dmu_pool, size, tx->tx_txg);
|
|
|
|
}
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-06-11 21:12:34 +04:00
|
|
|
* Handles TX_TRUNCATE transactions.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_truncate(zilog_t *zilog, dmu_tx_t *tx, int txtype,
|
2017-01-12 20:42:11 +03:00
|
|
|
znode_t *zp, uint64_t off, uint64_t len)
|
2008-11-20 23:01:55 +03:00
|
|
|
{
|
|
|
|
itx_t *itx;
|
|
|
|
lr_truncate_t *lr;
|
|
|
|
|
2016-10-13 03:30:46 +03:00
|
|
|
if (zil_replaying(zilog, tx) || zp->z_unlinked ||
|
|
|
|
zfs_xattr_owner_unlinked(zp))
|
2008-11-20 23:01:55 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
itx = zil_itx_create(txtype, sizeof (*lr));
|
|
|
|
lr = (lr_truncate_t *)&itx->itx_lr;
|
|
|
|
lr->lr_foid = zp->z_id;
|
|
|
|
lr->lr_offset = off;
|
|
|
|
lr->lr_length = len;
|
|
|
|
|
|
|
|
itx->itx_sync = (zp->z_sync_cnt != 0);
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-06-11 21:12:34 +04:00
|
|
|
* Handles TX_SETATTR transactions.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
void
|
2011-03-01 23:24:09 +03:00
|
|
|
zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
|
|
|
|
znode_t *zp, vattr_t *vap, uint_t mask_applied, zfs_fuid_info_t *fuidp)
|
2008-11-20 23:01:55 +03:00
|
|
|
{
|
|
|
|
itx_t *itx;
|
|
|
|
lr_setattr_t *lr;
|
|
|
|
xvattr_t *xvap = (xvattr_t *)vap;
|
|
|
|
size_t recsize = sizeof (lr_setattr_t);
|
|
|
|
void *start;
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
if (zil_replaying(zilog, tx) || zp->z_unlinked)
|
2008-11-20 23:01:55 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If XVATTR set, then log record size needs to allow
|
|
|
|
* for lr_attr_t + xvattr mask, mapsize and create time
|
|
|
|
* plus actual attribute values
|
|
|
|
*/
|
2011-03-01 23:24:09 +03:00
|
|
|
if (vap->va_mask & ATTR_XVATTR)
|
2008-11-20 23:01:55 +03:00
|
|
|
recsize = sizeof (*lr) + ZIL_XVAT_SIZE(xvap->xva_mapsize);
|
|
|
|
|
|
|
|
if (fuidp)
|
|
|
|
recsize += fuidp->z_domain_str_sz;
|
|
|
|
|
|
|
|
itx = zil_itx_create(txtype, recsize);
|
|
|
|
lr = (lr_setattr_t *)&itx->itx_lr;
|
|
|
|
lr->lr_foid = zp->z_id;
|
|
|
|
lr->lr_mask = (uint64_t)mask_applied;
|
2011-03-01 23:24:09 +03:00
|
|
|
lr->lr_mode = (uint64_t)vap->va_mode;
|
|
|
|
if ((mask_applied & ATTR_UID) && IS_EPHEMERAL(vap->va_uid))
|
2008-11-20 23:01:55 +03:00
|
|
|
lr->lr_uid = fuidp->z_fuid_owner;
|
|
|
|
else
|
2011-03-01 23:24:09 +03:00
|
|
|
lr->lr_uid = (uint64_t)vap->va_uid;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2011-03-01 23:24:09 +03:00
|
|
|
if ((mask_applied & ATTR_GID) && IS_EPHEMERAL(vap->va_gid))
|
2008-11-20 23:01:55 +03:00
|
|
|
lr->lr_gid = fuidp->z_fuid_group;
|
|
|
|
else
|
2011-03-01 23:24:09 +03:00
|
|
|
lr->lr_gid = (uint64_t)vap->va_gid;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2011-03-01 23:24:09 +03:00
|
|
|
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);
|
2008-11-20 23:01:55 +03:00
|
|
|
start = (lr_setattr_t *)(lr + 1);
|
2011-03-01 23:24:09 +03:00
|
|
|
if (vap->va_mask & ATTR_XVATTR) {
|
2008-11-20 23:01:55 +03:00
|
|
|
zfs_log_xvattr((lr_attr_t *)start, xvap);
|
|
|
|
start = (caddr_t)start + ZIL_XVAT_SIZE(xvap->xva_mapsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now stick on domain information if any on end
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (fuidp)
|
|
|
|
(void) zfs_log_fuid_domains(fuidp, start);
|
|
|
|
|
|
|
|
itx->itx_sync = (zp->z_sync_cnt != 0);
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
log xattr=sa create/remove/update to ZIL
As such, there are no specific synchronous semantics defined for
the xattrs. But for xattr=on, it does log to ZIL and zil_commit() is
done, if sync=always is set on dataset. This provides sync semantics
for xattr=on with sync=always set on dataset.
For the xattr=sa implementation, it doesn't log to ZIL, so, even with
sync=always, xattrs are not guaranteed to be synced before xattr call
returns to caller. So, xattr can be lost if system crash happens, before
txg carrying xattr transaction is synced.
This change adds xattr=sa logging to ZIL on xattr create/remove/update
and xattrs are synced to ZIL (zil_commit() done) for sync=always.
This makes xattr=sa behavior similar to xattr=on.
Implementation notes:
The actual logging is fairly straight-forward and does not warrant
additional explanation.
However, it has been 14 years since we last added new TX types
to the ZIL [1], hence this is the first time we do it after the
introduction of zpool features. Therefore, here is an overview of the
feature activation and deactivation workflow:
1. The feature must be enabled. Otherwise, we don't log the new
record type. This ensures compatibility with older software.
2. The feature is activated per-dataset, since the ZIL is per-dataset.
3. If the feature is enabled and dataset is not for zvol, any append to
the ZIL chain will activate the feature for the dataset. Likewise
for starting a new ZIL chain.
4. A dataset that doesn't have a ZIL chain has the feature deactivated.
We ensure (3) by activating on the first zil_commit() after the feature
was enabled. Since activating the features requires waiting for txg
sync, the first zil_commit() after enabling the feature will be slower
than usual. The downside is that this is really a conservative
approximation: even if we never append a 'TX_SETSAXATTR' to the ZIL
chain, we pay the penalty for feature activation. The upside is that the
user is in control of when we pay the penalty, i.e., upon enabling the
feature.
We ensure (4) by hooking into zil_sync(), where ZIL destroy actually
happens.
One more piece on feature activation, since it's spread across
multiple functions:
zil_commit()
zil_process_commit_list()
if lwb == NULL // first zil_commit since zil_open
zil_create()
if no log block pointer in ZIL header:
if feature enabled and not active:
// CASE 1
enable, COALESCE txg wait with dmu_tx that allocated the
log block
else // log block was allocated earlier than this zil_open
if feature enabled and not active:
// CASE 2
enable, EXPLICIT txg wait
else // already have an in-DRAM LWB
if feature enabled and not active:
// this happens when we enable the feature after zil_create
// CASE 3
enable, EXPLICIT txg wait
[1] https://github.com/illumos/illumos-gate/commit/da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Christian Schwarz <christian.schwarz@nutanix.com>
Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #8768
Closes #9078
2022-02-23 00:06:43 +03:00
|
|
|
/*
|
|
|
|
* Handles TX_SETSAXATTR transactions.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_setsaxattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
|
|
|
|
znode_t *zp, const char *name, const void *value, size_t size)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
return;
|
|
|
|
|
|
|
|
namelen = strlen(name) + 1;
|
|
|
|
recsize += (namelen + size);
|
|
|
|
itx = zil_itx_create(txtype, recsize);
|
|
|
|
lr = (lr_setsaxattr_t *)&itx->itx_lr;
|
|
|
|
lr->lr_foid = zp->z_id;
|
|
|
|
xattrstart = (char *)(lr + 1);
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy(xattrstart, name, namelen);
|
log xattr=sa create/remove/update to ZIL
As such, there are no specific synchronous semantics defined for
the xattrs. But for xattr=on, it does log to ZIL and zil_commit() is
done, if sync=always is set on dataset. This provides sync semantics
for xattr=on with sync=always set on dataset.
For the xattr=sa implementation, it doesn't log to ZIL, so, even with
sync=always, xattrs are not guaranteed to be synced before xattr call
returns to caller. So, xattr can be lost if system crash happens, before
txg carrying xattr transaction is synced.
This change adds xattr=sa logging to ZIL on xattr create/remove/update
and xattrs are synced to ZIL (zil_commit() done) for sync=always.
This makes xattr=sa behavior similar to xattr=on.
Implementation notes:
The actual logging is fairly straight-forward and does not warrant
additional explanation.
However, it has been 14 years since we last added new TX types
to the ZIL [1], hence this is the first time we do it after the
introduction of zpool features. Therefore, here is an overview of the
feature activation and deactivation workflow:
1. The feature must be enabled. Otherwise, we don't log the new
record type. This ensures compatibility with older software.
2. The feature is activated per-dataset, since the ZIL is per-dataset.
3. If the feature is enabled and dataset is not for zvol, any append to
the ZIL chain will activate the feature for the dataset. Likewise
for starting a new ZIL chain.
4. A dataset that doesn't have a ZIL chain has the feature deactivated.
We ensure (3) by activating on the first zil_commit() after the feature
was enabled. Since activating the features requires waiting for txg
sync, the first zil_commit() after enabling the feature will be slower
than usual. The downside is that this is really a conservative
approximation: even if we never append a 'TX_SETSAXATTR' to the ZIL
chain, we pay the penalty for feature activation. The upside is that the
user is in control of when we pay the penalty, i.e., upon enabling the
feature.
We ensure (4) by hooking into zil_sync(), where ZIL destroy actually
happens.
One more piece on feature activation, since it's spread across
multiple functions:
zil_commit()
zil_process_commit_list()
if lwb == NULL // first zil_commit since zil_open
zil_create()
if no log block pointer in ZIL header:
if feature enabled and not active:
// CASE 1
enable, COALESCE txg wait with dmu_tx that allocated the
log block
else // log block was allocated earlier than this zil_open
if feature enabled and not active:
// CASE 2
enable, EXPLICIT txg wait
else // already have an in-DRAM LWB
if feature enabled and not active:
// this happens when we enable the feature after zil_create
// CASE 3
enable, EXPLICIT txg wait
[1] https://github.com/illumos/illumos-gate/commit/da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Christian Schwarz <christian.schwarz@nutanix.com>
Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #8768
Closes #9078
2022-02-23 00:06:43 +03:00
|
|
|
if (value != NULL) {
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy((char *)xattrstart + namelen, value, size);
|
log xattr=sa create/remove/update to ZIL
As such, there are no specific synchronous semantics defined for
the xattrs. But for xattr=on, it does log to ZIL and zil_commit() is
done, if sync=always is set on dataset. This provides sync semantics
for xattr=on with sync=always set on dataset.
For the xattr=sa implementation, it doesn't log to ZIL, so, even with
sync=always, xattrs are not guaranteed to be synced before xattr call
returns to caller. So, xattr can be lost if system crash happens, before
txg carrying xattr transaction is synced.
This change adds xattr=sa logging to ZIL on xattr create/remove/update
and xattrs are synced to ZIL (zil_commit() done) for sync=always.
This makes xattr=sa behavior similar to xattr=on.
Implementation notes:
The actual logging is fairly straight-forward and does not warrant
additional explanation.
However, it has been 14 years since we last added new TX types
to the ZIL [1], hence this is the first time we do it after the
introduction of zpool features. Therefore, here is an overview of the
feature activation and deactivation workflow:
1. The feature must be enabled. Otherwise, we don't log the new
record type. This ensures compatibility with older software.
2. The feature is activated per-dataset, since the ZIL is per-dataset.
3. If the feature is enabled and dataset is not for zvol, any append to
the ZIL chain will activate the feature for the dataset. Likewise
for starting a new ZIL chain.
4. A dataset that doesn't have a ZIL chain has the feature deactivated.
We ensure (3) by activating on the first zil_commit() after the feature
was enabled. Since activating the features requires waiting for txg
sync, the first zil_commit() after enabling the feature will be slower
than usual. The downside is that this is really a conservative
approximation: even if we never append a 'TX_SETSAXATTR' to the ZIL
chain, we pay the penalty for feature activation. The upside is that the
user is in control of when we pay the penalty, i.e., upon enabling the
feature.
We ensure (4) by hooking into zil_sync(), where ZIL destroy actually
happens.
One more piece on feature activation, since it's spread across
multiple functions:
zil_commit()
zil_process_commit_list()
if lwb == NULL // first zil_commit since zil_open
zil_create()
if no log block pointer in ZIL header:
if feature enabled and not active:
// CASE 1
enable, COALESCE txg wait with dmu_tx that allocated the
log block
else // log block was allocated earlier than this zil_open
if feature enabled and not active:
// CASE 2
enable, EXPLICIT txg wait
else // already have an in-DRAM LWB
if feature enabled and not active:
// this happens when we enable the feature after zil_create
// CASE 3
enable, EXPLICIT txg wait
[1] https://github.com/illumos/illumos-gate/commit/da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Christian Schwarz <christian.schwarz@nutanix.com>
Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #8768
Closes #9078
2022-02-23 00:06:43 +03:00
|
|
|
lr->lr_size = size;
|
|
|
|
} else {
|
|
|
|
lr->lr_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
itx->itx_sync = (zp->z_sync_cnt != 0);
|
|
|
|
zil_itx_assign(zilog, itx, tx);
|
|
|
|
}
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
/*
|
2013-06-11 21:12:34 +04:00
|
|
|
* Handles TX_ACL transactions.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_acl(zilog_t *zilog, dmu_tx_t *tx, znode_t *zp,
|
|
|
|
vsecattr_t *vsecp, zfs_fuid_info_t *fuidp)
|
|
|
|
{
|
|
|
|
itx_t *itx;
|
|
|
|
lr_acl_v0_t *lrv0;
|
|
|
|
lr_acl_t *lr;
|
|
|
|
int txtype;
|
|
|
|
int lrsize;
|
|
|
|
size_t txsize;
|
|
|
|
size_t aclbytes = vsecp->vsa_aclentsz;
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
if (zil_replaying(zilog, tx) || zp->z_unlinked)
|
2008-12-03 23:09:06 +03:00
|
|
|
return;
|
|
|
|
|
2011-02-08 22:16:06 +03:00
|
|
|
txtype = (ZTOZSB(zp)->z_version < ZPL_VERSION_FUID) ?
|
2008-11-20 23:01:55 +03:00
|
|
|
TX_ACL_V0 : TX_ACL;
|
|
|
|
|
|
|
|
if (txtype == TX_ACL)
|
|
|
|
lrsize = sizeof (*lr);
|
|
|
|
else
|
|
|
|
lrsize = sizeof (*lrv0);
|
|
|
|
|
|
|
|
txsize = lrsize +
|
|
|
|
((txtype == TX_ACL) ? ZIL_ACE_LENGTH(aclbytes) : aclbytes) +
|
|
|
|
(fuidp ? fuidp->z_domain_str_sz : 0) +
|
2008-12-03 23:09:06 +03:00
|
|
|
sizeof (uint64_t) * (fuidp ? fuidp->z_fuid_cnt : 0);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
itx = zil_itx_create(txtype, txsize);
|
|
|
|
|
|
|
|
lr = (lr_acl_t *)&itx->itx_lr;
|
|
|
|
lr->lr_foid = zp->z_id;
|
|
|
|
if (txtype == TX_ACL) {
|
|
|
|
lr->lr_acl_bytes = aclbytes;
|
|
|
|
lr->lr_domcnt = fuidp ? fuidp->z_domain_cnt : 0;
|
|
|
|
lr->lr_fuidcnt = fuidp ? fuidp->z_fuid_cnt : 0;
|
|
|
|
if (vsecp->vsa_mask & VSA_ACE_ACLFLAGS)
|
|
|
|
lr->lr_acl_flags = (uint64_t)vsecp->vsa_aclflags;
|
|
|
|
else
|
|
|
|
lr->lr_acl_flags = 0;
|
|
|
|
}
|
|
|
|
lr->lr_aclcnt = (uint64_t)vsecp->vsa_aclcnt;
|
|
|
|
|
|
|
|
if (txtype == TX_ACL_V0) {
|
|
|
|
lrv0 = (lr_acl_v0_t *)lr;
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy(lrv0 + 1, vsecp->vsa_aclentp, aclbytes);
|
2008-11-20 23:01:55 +03:00
|
|
|
} else {
|
|
|
|
void *start = (ace_t *)(lr + 1);
|
|
|
|
|
2022-02-25 16:26:54 +03:00
|
|
|
memcpy(start, vsecp->vsa_aclentp, aclbytes);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
start = (caddr_t)start + ZIL_ACE_LENGTH(aclbytes);
|
|
|
|
|
|
|
|
if (fuidp) {
|
|
|
|
start = zfs_log_fuid_ids(fuidp, start);
|
|
|
|
(void) zfs_log_fuid_domains(fuidp, start);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
itx->itx_sync = (zp->z_sync_cnt != 0);
|
2010-08-27 01:24:34 +04:00
|
|
|
zil_itx_assign(zilog, itx, tx);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
2012-10-08 22:02:20 +04:00
|
|
|
|
2023-03-10 22:59:53 +03:00
|
|
|
/*
|
|
|
|
* Handles TX_CLONE_RANGE transactions.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
zfs_log_clone_range(zilog_t *zilog, dmu_tx_t *tx, int txtype, znode_t *zp,
|
|
|
|
uint64_t off, uint64_t len, uint64_t blksz, const blkptr_t *bps,
|
|
|
|
size_t nbps)
|
|
|
|
{
|
|
|
|
itx_t *itx;
|
|
|
|
lr_clone_range_t *lr;
|
|
|
|
uint64_t partlen, max_log_data;
|
2024-05-09 17:39:57 +03:00
|
|
|
size_t partnbps;
|
2023-03-10 22:59:53 +03:00
|
|
|
|
2023-04-18 02:42:09 +03:00
|
|
|
if (zil_replaying(zilog, tx) || zp->z_unlinked)
|
2023-03-10 22:59:53 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
max_log_data = zil_max_log_data(zilog, sizeof (lr_clone_range_t));
|
|
|
|
|
|
|
|
while (nbps > 0) {
|
|
|
|
partnbps = MIN(nbps, max_log_data / sizeof (bps[0]));
|
2024-05-09 17:39:57 +03:00
|
|
|
partlen = partnbps * blksz;
|
|
|
|
ASSERT3U(partlen, <, len + blksz);
|
2023-03-10 22:59:53 +03:00
|
|
|
partlen = MIN(partlen, len);
|
|
|
|
|
|
|
|
itx = zil_itx_create(txtype,
|
|
|
|
sizeof (*lr) + sizeof (bps[0]) * partnbps);
|
|
|
|
lr = (lr_clone_range_t *)&itx->itx_lr;
|
|
|
|
lr->lr_foid = zp->z_id;
|
|
|
|
lr->lr_offset = off;
|
|
|
|
lr->lr_length = partlen;
|
|
|
|
lr->lr_blksz = blksz;
|
|
|
|
lr->lr_nbps = partnbps;
|
|
|
|
memcpy(lr->lr_bps, bps, sizeof (bps[0]) * partnbps);
|
|
|
|
|
|
|
|
itx->itx_sync = (zp->z_sync_cnt != 0);
|
|
|
|
|
|
|
|
zil_itx_assign(zilog, itx, tx);
|
|
|
|
|
|
|
|
bps += partnbps;
|
|
|
|
ASSERT3U(nbps, >=, partnbps);
|
|
|
|
nbps -= partnbps;
|
|
|
|
off += partlen;
|
|
|
|
ASSERT3U(len, >=, partlen);
|
|
|
|
len -= partlen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Cleanup: 64-bit kernel module parameters should use fixed width types
Various module parameters such as `zfs_arc_max` were originally
`uint64_t` on OpenSolaris/Illumos, but were changed to `unsigned long`
for Linux compatibility because Linux's kernel default module parameter
implementation did not support 64-bit types on 32-bit platforms. This
caused problems when porting OpenZFS to Windows because its LLP64 memory
model made `unsigned long` a 32-bit type on 64-bit, which created the
undesireable situation that parameters that should accept 64-bit values
could not on 64-bit Windows.
Upon inspection, it turns out that the Linux kernel module parameter
interface is extensible, such that we are allowed to define our own
types. Rather than maintaining the original type change via hacks to to
continue shrinking module parameters on 32-bit Linux, we implement
support for 64-bit module parameters on Linux.
After doing a review of all 64-bit kernel parameters (found via the man
page and also proposed changes by Andrew Innes), the kernel module
parameters fell into a few groups:
Parameters that were originally 64-bit on Illumos:
* dbuf_cache_max_bytes
* dbuf_metadata_cache_max_bytes
* l2arc_feed_min_ms
* l2arc_feed_secs
* l2arc_headroom
* l2arc_headroom_boost
* l2arc_write_boost
* l2arc_write_max
* metaslab_aliquot
* metaslab_force_ganging
* zfetch_array_rd_sz
* zfs_arc_max
* zfs_arc_meta_limit
* zfs_arc_meta_min
* zfs_arc_min
* zfs_async_block_max_blocks
* zfs_condense_max_obsolete_bytes
* zfs_condense_min_mapping_bytes
* zfs_deadman_checktime_ms
* zfs_deadman_synctime_ms
* zfs_initialize_chunk_size
* zfs_initialize_value
* zfs_lua_max_instrlimit
* zfs_lua_max_memlimit
* zil_slog_bulk
Parameters that were originally 32-bit on Illumos:
* zfs_per_txg_dirty_frees_percent
Parameters that were originally `ssize_t` on Illumos:
* zfs_immediate_write_sz
Note that `ssize_t` is `int32_t` on 32-bit and `int64_t` on 64-bit. It
has been upgraded to 64-bit.
Parameters that were `long`/`unsigned long` because of Linux/FreeBSD
influence:
* l2arc_rebuild_blocks_min_l2size
* zfs_key_max_salt_uses
* zfs_max_log_walking
* zfs_max_logsm_summary_length
* zfs_metaslab_max_size_cache_sec
* zfs_min_metaslabs_to_flush
* zfs_multihost_interval
* zfs_unflushed_log_block_max
* zfs_unflushed_log_block_min
* zfs_unflushed_log_block_pct
* zfs_unflushed_max_mem_amt
* zfs_unflushed_max_mem_ppm
New parameters that do not exist in Illumos:
* l2arc_trim_ahead
* vdev_file_logical_ashift
* vdev_file_physical_ashift
* zfs_arc_dnode_limit
* zfs_arc_dnode_limit_percent
* zfs_arc_dnode_reduce_percent
* zfs_arc_meta_limit_percent
* zfs_arc_sys_free
* zfs_deadman_ziotime_ms
* zfs_delete_blocks
* zfs_history_output_max
* zfs_livelist_max_entries
* zfs_max_async_dedup_frees
* zfs_max_nvlist_src_size
* zfs_rebuild_max_segment
* zfs_rebuild_vdev_limit
* zfs_unflushed_log_txg_max
* zfs_vdev_max_auto_ashift
* zfs_vdev_min_auto_ashift
* zfs_vnops_read_chunk_size
* zvol_max_discard_blocks
Rather than clutter the lists with commentary, the module parameters
that need comments are repeated below.
A few parameters were defined in Linux/FreeBSD specific code, where the
use of ulong/long is not an issue for portability, so we leave them
alone:
* zfs_delete_blocks
* zfs_key_max_salt_uses
* zvol_max_discard_blocks
The documentation for a few parameters was found to be incorrect:
* zfs_deadman_checktime_ms - incorrectly documented as int
* zfs_delete_blocks - not documented as Linux only
* zfs_history_output_max - incorrectly documented as int
* zfs_vnops_read_chunk_size - incorrectly documented as long
* zvol_max_discard_blocks - incorrectly documented as ulong
The documentation for these has been fixed, alongside the changes to
document the switch to fixed width types.
In addition, several kernel module parameters were percentages or held
ashift values, so being 64-bit never made sense for them. They have been
downgraded to 32-bit:
* vdev_file_logical_ashift
* vdev_file_physical_ashift
* zfs_arc_dnode_limit_percent
* zfs_arc_dnode_reduce_percent
* zfs_arc_meta_limit_percent
* zfs_per_txg_dirty_frees_percent
* zfs_unflushed_log_block_pct
* zfs_vdev_max_auto_ashift
* zfs_vdev_min_auto_ashift
Of special note are `zfs_vdev_max_auto_ashift` and
`zfs_vdev_min_auto_ashift`, which were already defined as `uint64_t`,
and passed to the kernel as `ulong`. This is inherently buggy on big
endian 32-bit Linux, since the values would not be written to the
correct locations. 32-bit FreeBSD was unaffected because its sysctl code
correctly treated this as a `uint64_t`.
Lastly, a code comment suggests that `zfs_arc_sys_free` is
Linux-specific, but there is nothing to indicate to me that it is
Linux-specific. Nothing was done about that.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Original-patch-by: Andrew Innes <andrew.c12@gmail.com>
Original-patch-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13984
Closes #14004
2022-10-03 22:06:54 +03:00
|
|
|
ZFS_MODULE_PARAM(zfs, zfs_, immediate_write_sz, S64, ZMOD_RW,
|
2019-09-06 00:49:49 +03:00
|
|
|
"Largest data block to write to zil");
|