Skip to content

Commit

Permalink
Merge branch 'upstream-0.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
lundman committed Aug 26, 2013
2 parents 59a624e + 2ea3f3b commit 9703561
Show file tree
Hide file tree
Showing 42 changed files with 1,183 additions and 532 deletions.
2 changes: 1 addition & 1 deletion META
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Meta: 1
Name: zfs
Branch: 1.0
Version: 0.6.1
Version: 0.6.2
Release: 1
Release-Tags: relext
License: CDDL
Expand Down
30 changes: 12 additions & 18 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "zfs_iter.h"
#include "zfs_util.h"
#include "zfs_comutil.h"
#include "libzfs_impl.h"

libzfs_handle_t *g_zfs;

Expand Down Expand Up @@ -2288,10 +2289,8 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
if (!cb->cb_sid2posix) {
e = directory_name_from_sid(NULL, sid, &name,
&classes);
if (e != NULL) {
if (e != NULL)
directory_error_free(e);
return (1);
}
if (name == NULL)
name = sid;
}
Expand Down Expand Up @@ -2543,7 +2542,7 @@ zfs_do_userspace(int argc, char **argv)
boolean_t prtnum = B_FALSE;
boolean_t parsable = B_FALSE;
boolean_t sid2posix = B_FALSE;
int error = 0;
int ret = 0;
int c;
zfs_sort_column_t *sortcol = NULL;
int types = USTYPE_PSX_USR | USTYPE_SMB_USR;
Expand Down Expand Up @@ -2688,18 +2687,19 @@ zfs_do_userspace(int argc, char **argv)
!(types & (USTYPE_PSX_GRP | USTYPE_SMB_GRP))))
continue;
cb.cb_prop = p;
error = zfs_userspace(zhp, p, userspace_cb, &cb);
if (error)
break;
if ((ret = zfs_userspace(zhp, p, userspace_cb, &cb)) != 0)
return (ret);
}

/* Sort the list */
if ((node = uu_avl_first(avl_tree)) == NULL)
return (0);

us_populated = B_TRUE;

listpool = uu_list_pool_create("tmplist", sizeof (us_node_t),
offsetof(us_node_t, usn_listnode), NULL, UU_DEFAULT);
list = uu_list_create(listpool, NULL, UU_DEFAULT);

node = uu_avl_first(avl_tree);
uu_list_node_init(node, &node->usn_listnode, listpool);

while (node != NULL) {
Expand Down Expand Up @@ -2740,7 +2740,7 @@ zfs_do_userspace(int argc, char **argv)
uu_avl_destroy(avl_tree);
uu_avl_pool_destroy(avl_pool);

return (error);
return (ret);
}

/*
Expand Down Expand Up @@ -6342,12 +6342,6 @@ main(int argc, char **argv)

opterr = 0;

if ((mnttab_file = fopen(MNTTAB, "r")) == NULL) {
(void) fprintf(stderr, gettext("internal error: unable to "
"open %s\n"), MNTTAB);
return (1);
}

/*
* Make sure the user has specified some command.
*/
Expand Down Expand Up @@ -6386,6 +6380,8 @@ main(int argc, char **argv)
if ((g_zfs = libzfs_init()) == NULL)
return (1);

mnttab_file = g_zfs->libzfs_mnttab;

zpool_set_history_str("zfs", argc, argv, history_str);
verify(zpool_stage_history(g_zfs, history_str) == 0);

Expand All @@ -6410,8 +6406,6 @@ main(int argc, char **argv)
}
libzfs_fini(g_zfs);

(void) fclose(mnttab_file);

/*
* The 'ZFS_ABORT' environment variable causes us to dump core on exit
* for the purposes of running ::findleaks.
Expand Down
4 changes: 4 additions & 0 deletions cmd/zinject/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ parse_pathname(const char *inpath, char *dataset, char *relpath,
return (-1);
}

#ifdef HAVE_SETMNTENT
if ((fp = setmntent(MNTTAB, "r")) == NULL) {
#else
if ((fp = fopen(MNTTAB, "r")) == NULL) {
#endif
(void) fprintf(stderr, "cannot open /etc/mtab\n");
return (-1);
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ get_usage(zpool_help_t idx) {
case HELP_LABELCLEAR:
return (gettext("\tlabelclear [-f] <vdev>\n"));
case HELP_LIST:
return (gettext("\tlist [-H] [-o property[,...]] "
return (gettext("\tlist [-Hv] [-o property[,...]] "
"[-T d|u] [pool] ... [interval [count]]\n"));
case HELP_OFFLINE:
return (gettext("\toffline [-t] <pool> <device> ...\n"));
Expand Down Expand Up @@ -3060,7 +3060,7 @@ int
zpool_do_list(int argc, char **argv)
{
int c;
int ret;
int ret = 0;
list_cbdata_t cb = { 0 };
static char default_props[] =
"name,size,allocated,free,capacity,dedupratio,"
Expand Down
160 changes: 156 additions & 4 deletions cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
#include <libintl.h>
#include <libnvpair.h>
#include <limits.h>
//#include <scsi/scsi.h>
//#include <scsi/sg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
Expand All @@ -83,6 +85,7 @@
#endif /* HAVE_LIBBLKID */

#include "zpool_util.h"
#include <sys/zfs_context.h>

/*
* For any given vdev specification, we can have multiple errors. The
Expand All @@ -92,6 +95,142 @@
boolean_t error_seen;
boolean_t is_force;

typedef struct vdev_disk_db_entry
{
char id[24];
int sector_size;
} vdev_disk_db_entry_t;

/*
* Database of block devices that lie about physical sector sizes. The
* identification string must be precisely 24 characters to avoid false
* negatives
*/
static vdev_disk_db_entry_t vdev_disk_database[] = {
{"ATA Corsair Force 3 ", 8192},
{"ATA INTEL SSDSA2CT04", 8192},
{"ATA INTEL SSDSA2CW16", 8192},
{"ATA INTEL SSDSC2CT18", 8192},
{"ATA INTEL SSDSC2CW12", 8192},
{"ATA KINGSTON SH100S3", 8192},
{"ATA M4-CT064M4SSD2 ", 8192},
{"ATA M4-CT128M4SSD2 ", 8192},
{"ATA M4-CT256M4SSD2 ", 8192},
{"ATA M4-CT512M4SSD2 ", 8192},
{"ATA OCZ-AGILITY2 ", 8192},
{"ATA OCZ-VERTEX2 3.5 ", 8192},
{"ATA OCZ-VERTEX3 ", 8192},
{"ATA OCZ-VERTEX3 LT ", 8192},
{"ATA OCZ-VERTEX3 MI ", 8192},
{"ATA SAMSUNG SSD 830 ", 8192},
{"ATA Samsung SSD 840 ", 8192},
{"ATA INTEL SSDSA2M040", 4096},
{"ATA INTEL SSDSA2M080", 4096},
{"ATA INTEL SSDSA2M160", 4096},
/* Imported from Open Solaris*/
{"ATA MARVELL SD88SA02", 4096},
/* Advanced format Hard drives */
{"ATA Hitachi HDS5C303", 4096},
{"ATA SAMSUNG HD204UI ", 4096},
{"ATA ST2000DL004 HD20", 4096},
{"ATA WDC WD10EARS-00M", 4096},
{"ATA WDC WD10EARS-00S", 4096},
{"ATA WDC WD10EARS-00Z", 4096},
{"ATA WDC WD15EARS-00M", 4096},
{"ATA WDC WD15EARS-00S", 4096},
{"ATA WDC WD15EARS-00Z", 4096},
{"ATA WDC WD20EARS-00M", 4096},
{"ATA WDC WD20EARS-00S", 4096},
{"ATA WDC WD20EARS-00Z", 4096},
/* Virtual disks: Assume zvols with default volblocksize */
#if 0
{"ATA QEMU HARDDISK ", 8192},
{"IET VIRTUAL-DISK ", 8192},
{"OI COMSTAR ", 8192},
#endif
};

static const int vdev_disk_database_size =
sizeof (vdev_disk_database) / sizeof (vdev_disk_database[0]);

#define INQ_REPLY_LEN 96
#define INQ_CMD_LEN 6

#ifdef __LINUX__
static boolean_t
check_sector_size_database(char *path, int *sector_size)
{
unsigned char inq_buff[INQ_REPLY_LEN];
unsigned char sense_buffer[32];
unsigned char inq_cmd_blk[INQ_CMD_LEN] =
{INQUIRY, 0, 0, 0, INQ_REPLY_LEN, 0};
sg_io_hdr_t io_hdr;
int error;
int fd;
int i;

/* Prepare INQUIRY command */
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
io_hdr.interface_id = 'S';
io_hdr.cmd_len = sizeof(inq_cmd_blk);
io_hdr.mx_sb_len = sizeof(sense_buffer);
io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
io_hdr.dxfer_len = INQ_REPLY_LEN;
io_hdr.dxferp = inq_buff;
io_hdr.cmdp = inq_cmd_blk;
io_hdr.sbp = sense_buffer;
io_hdr.timeout = 10; /* 10 milliseconds is ample time */

if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0)
return (B_FALSE);

error = ioctl(fd, SG_IO, (unsigned long) &io_hdr);

(void) close(fd);

if (error < 0)
return (B_FALSE);

if ((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK)
return (B_FALSE);

for (i = 0; i < vdev_disk_database_size; i++) {
if (memcmp(inq_buff + 8, vdev_disk_database[i].id, 24))
continue;

*sector_size = vdev_disk_database[i].sector_size;
return (B_TRUE);
}

return (B_FALSE);
}
#endif


#ifdef __APPLE__
// FIXME
static boolean_t
check_sector_size_database(char *path, int *sector_size)
{
char diskname[256] = {0};
int i, error = 0;

if (error < 0)
return (B_FALSE);

for (i = 0; i < vdev_disk_database_size; i++) {
if (memcmp(diskname, vdev_disk_database[i].id, 24))
continue;

*sector_size = vdev_disk_database[i].sector_size;
return (B_TRUE);
}

return (B_FALSE);
}
#endif


/*PRINTFLIKE1*/
static void
vdev_error(const char *fmt, ...)
Expand Down Expand Up @@ -460,6 +599,7 @@ make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log)
nvlist_t *vdev = NULL;
char *type = NULL;
boolean_t wholedisk = B_FALSE;
uint64_t ashift = 0;
int err;

/*
Expand Down Expand Up @@ -545,19 +685,31 @@ make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log)
verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK,
(uint64_t)wholedisk) == 0);

/*
* Override defaults if custom properties are provided.
*/
if (props != NULL) {
uint64_t ashift = 0;
char *value = NULL;

if (nvlist_lookup_string(props,
zpool_prop_to_name(ZPOOL_PROP_ASHIFT), &value) == 0)
zfs_nicestrtonum(NULL, value, &ashift);
}

/*
* If the device is known to incorrectly report its physical sector
* size explicitly provide the known correct value.
*/
if (ashift == 0) {
int sector_size;

if (ashift > 0)
verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_ASHIFT,
ashift) == 0);
if (check_sector_size_database(path, &sector_size) == B_TRUE)
ashift = highbit(sector_size) - 1;
}

if (ashift > 0)
nvlist_add_uint64(vdev, ZPOOL_CONFIG_ASHIFT, ashift);

return (vdev);
}

Expand Down
39 changes: 39 additions & 0 deletions config/kernel-shrink.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,45 @@ AC_DEFUN([ZFS_AC_KERNEL_SHRINK], [
])
])

dnl #
dnl # 3.3 API change
dnl # The super_block structure was changed to use an hlist_node instead
dnl # of a list_head for the .s_instance linkage.
dnl #
dnl # This was done in part to resolve a race in the iterate_supers_type()
dnl # function which was introduced in Linux 3.0 kernel. The iterator
dnl # was supposed to provide a safe way to call an arbitrary function on
dnl # all super blocks of a specific type. Unfortunately, because a
dnl # list_head was used it was possible for iterate_supers_type() to
dnl # get stuck spinning a super block which was just deactivated.
dnl #
dnl # This can occur because when the list head is removed from the
dnl # fs_supers list it is reinitialized to point to itself. If the
dnl # iterate_supers_type() function happened to be processing the
dnl # removed list_head it will get stuck spinning on that list_head.
dnl #
dnl # To resolve the issue for existing 3.0 - 3.2 kernels we detect when
dnl # a list_head is used. Then to prevent the spinning from occurring
dnl # the .next pointer is set to the fs_supers list_head which ensures
dnl # the iterate_supers_type() function will always terminate.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD], [
AC_MSG_CHECKING([whether super_block has s_instances list_head])
ZFS_LINUX_TRY_COMPILE([
#include <linux/fs.h>
],[
struct super_block sb __attribute__ ((unused));
INIT_LIST_HEAD(&sb.s_instances);
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_S_INSTANCES_LIST_HEAD, 1,
[struct super_block has s_instances list_head])
],[
AC_MSG_RESULT(no)
])
])

AC_DEFUN([ZFS_AC_KERNEL_NR_CACHED_OBJECTS], [
AC_MSG_CHECKING([whether sops->nr_cached_objects() exists])
ZFS_LINUX_TRY_COMPILE([
Expand Down
Loading

0 comments on commit 9703561

Please sign in to comment.