Skip to content

Commit

Permalink
Merge branch 'zfs_master_03.04.2015' into zfs_master_20.03.2015_2129+…
Browse files Browse the repository at this point in the history
…3115_WIP_clean

sync against latest upstream master from April 3rd to benefit from the
changes from openzfs#3225
  • Loading branch information
kernelOfTruth committed Apr 4, 2015
2 parents 2130841 + 40d06e3 commit 8f2267a
Show file tree
Hide file tree
Showing 35 changed files with 345 additions and 124 deletions.
2 changes: 1 addition & 1 deletion cmd/mount_zfs/mount_zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ parse_dataset(char *dataset)
if (fd < 0)
goto out;

error = zpool_read_label(fd, &config);
error = zpool_read_label(fd, &config, NULL);
(void) close(fd);
if (error)
goto out;
Expand Down
4 changes: 3 additions & 1 deletion cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,9 @@ snprintf_blkptr_compact(char *blkbuf, size_t buflen, const blkptr_t *bp)

if (BP_IS_HOLE(bp)) {
(void) snprintf(blkbuf + strlen(blkbuf),
buflen - strlen(blkbuf), "B=%llu",
buflen - strlen(blkbuf),
"%llxL B=%llu",
(u_longlong_t)BP_GET_LSIZE(bp),
(u_longlong_t)bp->blk_birth);
} else {
(void) snprintf(blkbuf + strlen(blkbuf),
Expand Down
14 changes: 0 additions & 14 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5641,7 +5641,6 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
char mountpoint[ZFS_MAXPROPLEN];
char shareopts[ZFS_MAXPROPLEN];
char smbshareopts[ZFS_MAXPROPLEN];
char overlay[ZFS_MAXPROPLEN];
const char *cmdname = op == OP_SHARE ? "share" : "mount";
struct mnttab mnt;
uint64_t zoned, canmount;
Expand Down Expand Up @@ -5748,19 +5747,6 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
return (0);
}

/*
* Overlay mounts are disabled by default but may be enabled
* via the 'overlay' property or the 'zfs mount -O' option.
*/
if (!(flags & MS_OVERLAY)) {
if (zfs_prop_get(zhp, ZFS_PROP_OVERLAY, overlay,
sizeof (overlay), NULL, NULL, 0, B_FALSE) == 0) {
if (strcmp(overlay, "on") == 0) {
flags |= MS_OVERLAY;
}
}
}

/*
* At this point, we have verified that the mountpoint and/or
* shareopts are appropriate for auto management. If the
Expand Down
2 changes: 1 addition & 1 deletion cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ is_spare(nvlist_t *config, const char *path)
if (zpool_in_use(g_zfs, fd, &state, &name, &inuse) != 0 ||
!inuse ||
state != POOL_STATE_SPARE ||
zpool_read_label(fd, &label) != 0) {
zpool_read_label(fd, &label, NULL) != 0) {
free(name);
(void) close(fd);
return (B_FALSE);
Expand Down
2 changes: 1 addition & 1 deletion config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ AC_DEFUN([ZFS_AC_RPM], [
RPM_SPEC_DIR="rpm/generic"
AC_ARG_WITH([spec],
AS_HELP_STRING([--with-spec=SPEC],
[Spec files 'generic|fedora']),
[Spec files 'generic|redhat']),
[RPM_SPEC_DIR="rpm/$withval"])
AC_MSG_CHECKING([whether spec files are available])
Expand Down
8 changes: 4 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ AC_CONFIG_FILES([
scripts/zpool-config/Makefile
scripts/common.sh
rpm/Makefile
rpm/fedora/Makefile
rpm/fedora/zfs.spec
rpm/fedora/zfs-kmod.spec
rpm/fedora/zfs-dkms.spec
rpm/redhat/Makefile
rpm/redhat/zfs.spec
rpm/redhat/zfs-kmod.spec
rpm/redhat/zfs-dkms.spec
rpm/generic/Makefile
rpm/generic/zfs.spec
rpm/generic/zfs-kmod.spec
Expand Down
3 changes: 3 additions & 0 deletions dracut/90zfs/mount-zfs.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then
ZPOOL_FORCE="-f"
fi

# Delay until all required block devices are present.
udevadm settle

case "$root" in
zfs:*)
# We have ZFS modules loaded, so we're able to import pools now.
Expand Down
2 changes: 1 addition & 1 deletion include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **,
/*
* Label manipulation.
*/
extern int zpool_read_label(int, nvlist_t **);
extern int zpool_read_label(int, nvlist_t **, int *);
extern int zpool_clear_label(int);

/*
Expand Down
13 changes: 7 additions & 6 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,13 @@ _NOTE(CONSTCOND) } while (0)
if (bp == NULL) { \
len += func(buf + len, size - len, "<NULL>"); \
} else if (BP_IS_HOLE(bp)) { \
len += func(buf + len, size - len, "<hole>"); \
if (bp->blk_birth > 0) { \
len += func(buf + len, size - len, \
" birth=%lluL", \
(u_longlong_t)bp->blk_birth); \
} \
len += func(buf + len, size - len, \
"HOLE [L%llu %s] " \
"size=%llxL birth=%lluL", \
(u_longlong_t)BP_GET_LEVEL(bp), \
type, \
(u_longlong_t)BP_GET_LSIZE(bp), \
(u_longlong_t)bp->blk_birth); \
} else if (BP_IS_EMBEDDED(bp)) { \
len = func(buf + len, size - len, \
"EMBEDDED [L%llu %s] et=%u %s " \
Expand Down
18 changes: 9 additions & 9 deletions include/sys/trace_zrlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@ DECLARE_EVENT_CLASS(zfs_zrlock_class,
TP_PROTO(zrlock_t *zrl, uint32_t n),
TP_ARGS(zrl, n),
TP_STRUCT__entry(
__field(int32_t, zr_refcount)
__field(int32_t, refcount)
#ifdef ZFS_DEBUG
__field(pid_t, zr_owner_pid)
__field(const char *, zr_caller)
__field(pid_t, owner_pid)
__field(const char *, caller)
#endif
__field(uint32_t, n)
),
TP_fast_assign(
__entry->zr_refcount = zrl->zr_refcount;
__entry->refcount = zrl->zr_refcount;
#ifdef ZFS_DEBUG
__entry->zr_owner_pid = zrl->zr_owner->pid;
__entry->zr_caller = zrl->zr_caller;
__entry->owner_pid = zrl->zr_owner ? zrl->zr_owner->pid : 0;
__entry->caller = zrl->zr_caller;
#endif
__entry->n = n;
__entry->n = n;
),
#ifdef ZFS_DEBUG
TP_printk("zrl { refcount %d owner_pid %d caller %s } n %u",
__entry->zr_refcount, __entry->zr_owner_pid, __entry->zr_caller,
__entry->refcount, __entry->owner_pid, __entry->caller,
__entry->n)
#else
TP_printk("zrl { refcount %d } n %u",
__entry->zr_refcount, __entry->n)
__entry->refcount, __entry->n)
#endif
);

Expand Down
1 change: 0 additions & 1 deletion include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ typedef struct kmutex {
} kmutex_t;

#define MUTEX_DEFAULT 0
#define MUTEX_FSTRANS MUTEX_DEFAULT
#define MUTEX_HELD(m) ((m)->m_owner == curthread)
#define MUTEX_NOT_HELD(m) (!MUTEX_HELD(m))

Expand Down
2 changes: 1 addition & 1 deletion include/sys/zfs_vfsops.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ typedef struct zfs_sb {
uint64_t z_replay_eof; /* New end of file - replay only */
sa_attr_type_t *z_attr_table; /* SA attr mapping->id */
#define ZFS_OBJ_MTX_SZ 256
kmutex_t z_hold_mtx[ZFS_OBJ_MTX_SZ]; /* znode hold locks */
kmutex_t *z_hold_mtx; /* znode hold locks */
} zfs_sb_t;

#define ZFS_SUPER_MAGIC 0x2fc12fc1
Expand Down
74 changes: 58 additions & 16 deletions lib/libzfs/libzfs_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef struct name_entry {
char *ne_name;
uint64_t ne_guid;
uint64_t ne_order;
uint64_t ne_num_labels;
struct name_entry *ne_next;
} name_entry_t;

Expand Down Expand Up @@ -173,8 +174,23 @@ fix_paths(nvlist_t *nv, name_entry_t *names)
break;
}

if (best == NULL || ne->ne_order < best->ne_order)
if (best == NULL) {
best = ne;
continue;
}

/* Prefer paths with move vdev labels. */
if (ne->ne_num_labels > best->ne_num_labels) {
best = ne;
continue;
}

/* Prefer paths earlier in the search order. */
if (best->ne_num_labels == best->ne_num_labels &&
ne->ne_order < best->ne_order) {
best = ne;
continue;
}
}
}

Expand All @@ -200,7 +216,7 @@ fix_paths(nvlist_t *nv, name_entry_t *names)
*/
static int
add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path,
int order, nvlist_t *config)
int order, int num_labels, nvlist_t *config)
{
uint64_t pool_guid, vdev_guid, top_guid, txg, state;
pool_entry_t *pe;
Expand All @@ -226,6 +242,7 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path,
}
ne->ne_guid = vdev_guid;
ne->ne_order = order;
ne->ne_num_labels = num_labels;
ne->ne_next = pl->names;
pl->names = ne;
return (0);
Expand Down Expand Up @@ -328,6 +345,7 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path,

ne->ne_guid = vdev_guid;
ne->ne_order = order;
ne->ne_num_labels = num_labels;
ne->ne_next = pl->names;
pl->names = ne;

Expand Down Expand Up @@ -843,15 +861,17 @@ label_offset(uint64_t size, int l)

/*
* Given a file descriptor, read the label information and return an nvlist
* describing the configuration, if there is one.
* describing the configuration, if there is one. The number of valid
* labels found will be returned in num_labels when non-NULL.
*/
int
zpool_read_label(int fd, nvlist_t **config)
zpool_read_label(int fd, nvlist_t **config, int *num_labels)
{
struct stat64 statbuf;
int l;
int l, count = 0;
vdev_label_t *label;
uint64_t state, txg, size;
nvlist_t *expected_config = NULL;
uint64_t expected_guid = 0, size;

*config = NULL;

Expand All @@ -863,6 +883,8 @@ zpool_read_label(int fd, nvlist_t **config)
return (-1);

for (l = 0; l < VDEV_LABELS; l++) {
uint64_t state, guid, txg;

if (pread64(fd, label, sizeof (vdev_label_t),
label_offset(size, l)) != sizeof (vdev_label_t))
continue;
Expand All @@ -871,6 +893,12 @@ zpool_read_label(int fd, nvlist_t **config)
sizeof (label->vl_vdev_phys.vp_nvlist), config, 0) != 0)
continue;

if (nvlist_lookup_uint64(*config, ZPOOL_CONFIG_GUID,
&guid) != 0 || guid == 0) {
nvlist_free(*config);
continue;
}

if (nvlist_lookup_uint64(*config, ZPOOL_CONFIG_POOL_STATE,
&state) != 0 || state > POOL_STATE_L2CACHE) {
nvlist_free(*config);
Expand All @@ -884,12 +912,24 @@ zpool_read_label(int fd, nvlist_t **config)
continue;
}

free(label);
return (0);
if (expected_guid) {
if (expected_guid == guid)
count++;

nvlist_free(*config);
} else {
expected_config = *config;
expected_guid = guid;
count++;
}
}

if (num_labels != NULL)
*num_labels = count;

free(label);
*config = NULL;
*config = expected_config;

return (0);
}

Expand Down Expand Up @@ -937,7 +977,7 @@ zpool_find_import_blkid(libzfs_handle_t *hdl, pool_list_t *pools)
blkid_dev dev;
const char *devname;
nvlist_t *config;
int fd, err;
int fd, err, num_labels;

err = blkid_get_cache(&cache, NULL);
if (err != 0) {
Expand Down Expand Up @@ -972,7 +1012,7 @@ zpool_find_import_blkid(libzfs_handle_t *hdl, pool_list_t *pools)
if ((fd = open64(devname, O_RDONLY)) < 0)
continue;

err = zpool_read_label(fd, &config);
err = zpool_read_label(fd, &config, &num_labels);
(void) close(fd);

if (err != 0) {
Expand All @@ -981,7 +1021,8 @@ zpool_find_import_blkid(libzfs_handle_t *hdl, pool_list_t *pools)
}

if (config != NULL) {
err = add_config(hdl, pools, devname, 0, config);
err = add_config(hdl, pools, devname, 0,
num_labels, config);
if (err != 0)
goto err_blkid3;
}
Expand Down Expand Up @@ -1017,7 +1058,7 @@ zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE] = {
static nvlist_t *
zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
{
int i, dirs = iarg->paths;
int i, num_labels, dirs = iarg->paths;
DIR *dirp = NULL;
struct dirent64 *dp;
char path[MAXPATHLEN];
Expand Down Expand Up @@ -1143,7 +1184,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
if ((fd = openat64(dfd, name, O_RDONLY)) < 0)
continue;

if ((zpool_read_label(fd, &config)) != 0) {
if ((zpool_read_label(fd, &config, &num_labels))) {
(void) close(fd);
(void) no_memory(hdl);
goto error;
Expand Down Expand Up @@ -1177,7 +1218,8 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
}
/* use the non-raw path for the config */
(void) strlcpy(end, name, pathleft);
if (add_config(hdl, &pools, path, i+1, config))
if (add_config(hdl, &pools, path, i+1,
num_labels, config))
goto error;
}
}
Expand Down Expand Up @@ -1461,7 +1503,7 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr,

*inuse = B_FALSE;

if (zpool_read_label(fd, &config) != 0) {
if (zpool_read_label(fd, &config, NULL) != 0) {
(void) no_memory(hdl);
return (-1);
}
Expand Down
14 changes: 14 additions & 0 deletions lib/libzfs/libzfs_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
struct stat buf;
char mountpoint[ZFS_MAXPROPLEN];
char mntopts[MNT_LINE_MAX];
char overlay[ZFS_MAXPROPLEN];
libzfs_handle_t *hdl = zhp->zfs_hdl;
int remount = 0, rc;

Expand Down Expand Up @@ -441,6 +442,19 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
}
}

/*
* Overlay mounts are disabled by default but may be enabled
* via the 'overlay' property or the 'zfs mount -O' option.
*/
if (!(flags & MS_OVERLAY)) {
if (zfs_prop_get(zhp, ZFS_PROP_OVERLAY, overlay,
sizeof (overlay), NULL, NULL, 0, B_FALSE) == 0) {
if (strcmp(overlay, "on") == 0) {
flags |= MS_OVERLAY;
}
}
}

/*
* Determine if the mountpoint is empty. If so, refuse to perform the
* mount. We don't perform this check if 'remount' is
Expand Down
Loading

0 comments on commit 8f2267a

Please sign in to comment.