diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-05-16 12:25:49 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-05-16 12:25:49 +0000 |
commit | 20bbbc2871a3fc191b4c28e03bf213a0e83166f4 (patch) | |
tree | 64de367725cd9de026683bffc4f62fba14da9631 | |
parent | c5bf6dbcaf952d0108897703c878c1c0eb4be27f (diff) | |
parent | ade42b557a6e29c3d17a61b1535d99af10e379be (diff) | |
download | illumos-joyent-20bbbc2871a3fc191b4c28e03bf213a0e83166f4.tar.gz |
[illumos-gate merge]
commit ade42b557a6e29c3d17a61b1535d99af10e379be
8064 need a static DTrace probe in VN_HOLD
commit fe4627ef755b7c263f91a0e6f07cdca5d7083501
8149 deadlock between datalink deletion and kstat read
commit 4286ffae246c5943dbdc0d830e5e117c900d6baa
7444 fs/xattr.c should be more transparent (zfs_acl_test)
commit faf269d301b574ab95145509e30b86f2caad6578
8221 libndmp: misleading-indentation
commit 3bf67e00acfe087698262c7f308007f5dfb49f91
8222 libdscfg: misleading-indentation
commit 3cf7d3e96c394bb30710bd264c0bb61f4646639f
8215 print: misleading-indentation
Conflicts:
usr/src/uts/common/io/dls/dls_mgmt.c
usr/src/uts/common/fs/tmpfs/tmp_vnops.c
usr/src/test/os-tests/tests/Makefile
usr/src/test/os-tests/runfiles/default.run
usr/src/pkg/manifests/system-test-ostest.mf
48 files changed, 692 insertions, 628 deletions
diff --git a/usr/src/lib/libdscfg/common/cfg.c b/usr/src/lib/libdscfg/common/cfg.c index 72355963e0..17f668744a 100644 --- a/usr/src/lib/libdscfg/common/cfg.c +++ b/usr/src/lib/libdscfg/common/cfg.c @@ -107,21 +107,21 @@ dump_status(cfp_t *cfp, char *str) { printf("called from %s\n", str); printf(gettext("Header info:\n" - "\tmagic: %x\tstate: %x\n"), - cfp->cf_head->h_magic, cfp->cf_head->h_state); + "\tmagic: %x\tstate: %x\n"), + cfp->cf_head->h_magic, cfp->cf_head->h_state); printf(gettext("Parser section:\n" - "Start: %x\tsize: %d\toffset: %d\n"), - cfp->cf_mapped, cfp->cf_head->h_parsesize, - cfp->cf_head->h_parseoff); + "Start: %x\tsize: %d\toffset: %d\n"), + cfp->cf_mapped, cfp->cf_head->h_parsesize, + cfp->cf_head->h_parseoff); printf(gettext("Config section:\n" - "Start: %x\tsize:%d\tacsize: %d\n"), - cfp->cf_head->h_cparse, cfp->cf_head->h_csize, - cfp->cf_head->h_acsize); + "Start: %x\tsize:%d\tacsize: %d\n"), + cfp->cf_head->h_cparse, cfp->cf_head->h_csize, + cfp->cf_head->h_acsize); printf("\n\tccopy1: %x\tccopy2: %x\n", - cfp->cf_head->h_ccopy1, cfp->cf_head->h_ccopy2); + cfp->cf_head->h_ccopy1, cfp->cf_head->h_ccopy2); printf(gettext("Sequence:\n" - "\tseq1: %d\t\tseq2: %d\n"), - cfp->cf_head->h_seq1, cfp->cf_head->h_seq2); + "\tseq1: %d\t\tseq2: %d\n"), + cfp->cf_head->h_seq1, cfp->cf_head->h_seq2); } #endif /* DEBUG */ @@ -247,7 +247,7 @@ cfg_get_parser_offset(const char *section) /* Handle failure */ cfg_perror_str = dgettext("cfg", - "cfg_get_parser_offset: section not found"); + "cfg_get_parser_offset: section not found"); cfg_severity = CFG_EFATAL; errno = ESRCH; return (-1); @@ -503,19 +503,18 @@ cfg_get_cstring(CFGFILE *cfg, const char *key, void *value, int value_len) if (*p == '-') { strcpy(value, ""); return (0); - } - else + } else { if (strlen(p) > value_len) { errno = E2BIG; cfg_perror_str = - dgettext("cfg", - strerror(errno)); + dgettext("cfg", + strerror(errno)); cfg_severity = - CFG_ENONFATAL; + CFG_ENONFATAL; return (-1); } - - strncpy(value, p, value_len); + } + strncpy(value, p, value_len); return (pos); } @@ -546,7 +545,8 @@ cfg_get_cstring(CFGFILE *cfg, const char *key, void *value, int value_len) */ int cfg_find_cstring(CFGFILE *cfg, const char *target, - const char *section, int numflds, ...) { + const char *section, int numflds, ...) +{ char **list = NULL; va_list ap; @@ -770,7 +770,7 @@ cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len) if (cfp->cf_head->h_state & CFG_HDR_INVALID) { if (!cfg_read(cfp)) { cfg_perror_str = - dgettext("cfg", CFG_RDFAILED); + dgettext("cfg", CFG_RDFAILED); cfg_severity = CFG_EFATAL; return (-1); } @@ -783,7 +783,7 @@ cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len) break; } if (cfg_filter_node(cfg, &chead[0], tmpbuf, - section)) + section)) numfound++; if (numfound == setnum) @@ -808,8 +808,9 @@ cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len) if (value == NULL) { /* Remove entry completely */ - if ((rc = ((*cfp->cf_pp->remcf) - (cfp, table_index, relnum - secnum))) < 0) + rc = (*cfp->cf_pp->remcf)(cfp, table_index, + relnum - secnum); + if (rc < 0) return (rc); return (0); } @@ -840,8 +841,8 @@ cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len) cfg_insert_node(cfg, &chead[0], buf, section); } - (*cfp->cf_pp->replacecf) - (cfp, bufp, table_index, relnum - secnum); + (*cfp->cf_pp->replacecf)(cfp, bufp, table_index, + relnum - secnum); return (TRUE); } @@ -863,7 +864,7 @@ cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len) if (cfp->cf_head->h_state & CFG_HDR_INVALID) { if (!cfg_read(cfp)) { cfg_perror_str = - dgettext("cfg", CFG_RDFAILED); + dgettext("cfg", CFG_RDFAILED); cfg_severity = CFG_EFATAL; return (-1); } @@ -876,7 +877,7 @@ cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len) break; } if (cfg_filter_node(cfg, &chead[0], buf, - section)) + section)) numfound++; if (numfound == setnum) @@ -922,8 +923,8 @@ cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len) newbuf, section); } - (*cfp->cf_pp->replacecf) - (cfp, newbuf, table_index, relnum - secnum); + (*cfp->cf_pp->replacecf)(cfp, newbuf, table_index, + relnum - secnum); return (TRUE); } @@ -1428,9 +1429,10 @@ cfg_del_option(CFGFILE *cfg, int section, const char *basekey, char *tag) if (strncmp(buf, &encode_buf[1], enclen) == 0) { p = strchr(buf, ';'); if (p && (*(p + 1) != '\0')) { - rc = cfg_put_cstring(cfg, basekey, p + 1, strlen(p + 1)); + rc = cfg_put_cstring(cfg, basekey, p + 1, + strlen(p + 1)); } else { - rc = cfg_put_cstring(cfg, basekey, "-", 1); + rc = cfg_put_cstring(cfg, basekey, "-", 1); } /* severity & perror_str are set by cfg_put_cstring */ return (rc); @@ -1559,7 +1561,7 @@ cfg_read(cfp_t *cfp) if (cfp->cf_head->h_magic != CFG_NEW_MAGIC) { #ifdef DEBUG_LIB (void) fprintf(stderr, "cfg_read: wrong MAGIC number %x\n", - cfp->cf_head->h_magic); + cfp->cf_head->h_magic); #endif return (FALSE); } @@ -1569,8 +1571,8 @@ cfg_read(cfp_t *cfp) #ifdef DEBUG_CFGLIST (void) fprintf(stderr, "reading parser\n"); #endif - rc = (*cfp->cf_pp->read) - (cfp, (char *)cfp->cf_mapped, CFG_DEFAULT_PARSE_SIZE); + rc = (*cfp->cf_pp->read)(cfp, (char *)cfp->cf_mapped, + CFG_DEFAULT_PARSE_SIZE); if (rc < sizeof (*hd)) { #ifdef DEBUG (void) fprintf(stderr, "cfg: read parse config failed\n"); @@ -1583,8 +1585,8 @@ cfg_read(cfp_t *cfp) #ifdef DEBUG_CFGLIST (void) fprintf(stderr, "reading copy1 readsize = %d\n", readsize); #endif - rc = (*cfp->cf_pp->read) - (cfp, (char *)cfp->cf_head->h_ccopy1, readsize); + rc = (*cfp->cf_pp->read)(cfp, (char *)cfp->cf_head->h_ccopy1, + readsize); if (rc < 0) { /* don't fail just return */ #ifdef DEBUG @@ -1594,7 +1596,7 @@ cfg_read(cfp_t *cfp) } if ((*cfp->cf_pp->seek) - (cfp, CFG_DEFAULT_SSIZE - rc, SEEK_CUR) < 0) { + (cfp, CFG_DEFAULT_SSIZE - rc, SEEK_CUR) < 0) { #ifdef DEBUG (void) fprintf(stderr, "cfg: seek (SEEK_CUR) failed\n"); #endif @@ -1605,8 +1607,8 @@ cfg_read(cfp_t *cfp) (void) fprintf(stderr, "reading copy2 readsize = %d\n", readsize); #endif - rc = (*cfp->cf_pp->read) - (cfp, (char *)cfp->cf_head->h_ccopy2, readsize); + rc = (*cfp->cf_pp->read)(cfp, (char *)cfp->cf_head->h_ccopy2, + readsize); if (rc < 0) { /* don't fail just return */ #ifdef DEBUG @@ -1617,7 +1619,7 @@ cfg_read(cfp_t *cfp) /* read the sizes of the lists from disk */ if ((*cfp->cf_pp->seek) - (cfp, CFG_DEFAULT_SSIZE - rc, SEEK_CUR) < 0) { + (cfp, CFG_DEFAULT_SSIZE - rc, SEEK_CUR) < 0) { #ifdef DEBUG (void) fprintf(stderr, "cfg: seek (SEEK_CUR) failed\n"); #endif @@ -1627,8 +1629,8 @@ cfg_read(cfp_t *cfp) #ifdef DEBUG_CFGLIST (void) fprintf(stderr, "reading sizes\n"); #endif - rc = (*cfp->cf_pp->read) - (cfp, (int *)cfp->cf_head->h_sizes1, CFG_DEFAULT_PSIZE); + rc = (*cfp->cf_pp->read)(cfp, (int *)cfp->cf_head->h_sizes1, + CFG_DEFAULT_PSIZE); if (rc < 0) { #ifdef DEBUG (void) fprintf(stderr, "cfg: read h_sizes1 failed\n"); @@ -1636,8 +1638,8 @@ cfg_read(cfp_t *cfp) return (FALSE); } - rc = (*cfp->cf_pp->read) - (cfp, (int *)cfp->cf_head->h_sizes2, CFG_DEFAULT_PSIZE); + rc = (*cfp->cf_pp->read)(cfp, (int *)cfp->cf_head->h_sizes2, + CFG_DEFAULT_PSIZE); if (rc < 0) { #ifdef DEBUG (void) fprintf(stderr, "cfg: read h_sizes2 failed\n"); @@ -1718,7 +1720,7 @@ cfg_lock(CFGFILE *cfg, CFGLOCK mode) cfg->cf[1].cf_lock = cfg->cf[0].cf_lock = cfg->cf[0].cf_fd; if (!((cfg->cf[0].cf_flag & CFG_RDONLY) && - (mode == CFG_RDLOCK))) { + (mode == CFG_RDLOCK))) { struct flock lk = {0}; lk.l_type = (mode == CFG_RDLOCK ? F_RDLCK : F_WRLCK); @@ -1739,7 +1741,7 @@ cfg_lock(CFGFILE *cfg, CFGLOCK mode) if ((rc = cfg_hdrcmp(cfp)) == 0) { #ifdef DEBUG_HDR (void) fprintf(stderr, - "cfg header match, skipping re-read\n"); + "cfg header match, skipping re-read\n"); #endif cfp->cf_head->h_state |= CFG_HDR_RDLOCK; if (mode == CFG_WRLOCK) @@ -1800,28 +1802,28 @@ cfg_lock(CFGFILE *cfg, CFGLOCK mode) if (cfp->cf_head->h_seq1 >= cfp->cf_head->h_seq2) { #ifdef DEBUG_LIB (void) fprintf(stderr, - "cfg_lock: WRLOCK copying 1 to 2\n"); + "cfg_lock: WRLOCK copying 1 to 2\n"); #endif memcpy(cfp->cf_head->h_ccopy2, - cfp->cf_head->h_ccopy1, - cfp->cf_head->h_csize); + cfp->cf_head->h_ccopy1, + cfp->cf_head->h_csize); memcpy(cfp->cf_head->h_sizes2, - cfp->cf_head->h_sizes1, - CFG_DEFAULT_PSIZE); + cfp->cf_head->h_sizes1, + CFG_DEFAULT_PSIZE); cfp->cf_head->h_cparse = cfp->cf_head->h_ccopy2; cfp->cf_head->h_sizes = cfp->cf_head->h_sizes2; } else { #ifdef DEBUG_LIB (void) fprintf(stderr, - "cfg_lock: WRLOCK copying 2 to 1\n"); + "cfg_lock: WRLOCK copying 2 to 1\n"); #endif memcpy(cfp->cf_head->h_ccopy1, - cfp->cf_head->h_ccopy2, - cfp->cf_head->h_csize); + cfp->cf_head->h_ccopy2, + cfp->cf_head->h_csize); memcpy(cfp->cf_head->h_sizes1, - cfp->cf_head->h_sizes2, - CFG_DEFAULT_PSIZE); + cfp->cf_head->h_sizes2, + CFG_DEFAULT_PSIZE); cfp->cf_head->h_cparse = cfp->cf_head->h_ccopy1; cfp->cf_head->h_sizes = cfp->cf_head->h_sizes1; @@ -1909,33 +1911,34 @@ cfg_rdlock(CFGFILE *cfg) /* Determine number of files open */ for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) { - if (!cfp->cf_fd) continue; + if (!cfp->cf_fd) + continue; if (cfp->cf_head == NULL) { #ifdef DEBUG_LIB - (void) fprintf(stderr, "cfg_rdlock: cf_head == NULL\n"); + (void) fprintf(stderr, "cfg_rdlock: cf_head == NULL\n"); #endif - /* - * 6335583, if header == NULL, - * we can't call cfg_read to fill the header again - * since it will change the lock state to - * CFG_HDR_WRLOCK and dscfg will be the processer - * that hold the lock, - * just returning a FALSE if the case, - * then retrieve the lock state from flock structure. - */ - rc = FALSE; - break; + /* + * 6335583, if header == NULL, + * we can't call cfg_read to fill the header again + * since it will change the lock state to + * CFG_HDR_WRLOCK and dscfg will be the processer + * that hold the lock, + * just returning a FALSE if the case, + * then retrieve the lock state from flock structure. + */ + rc = FALSE; + break; } else { #ifdef DEBUG_LIB - (void) fprintf(stderr, "cfg_rdlock: cf_head != NULL\n"); + (void) fprintf(stderr, "cfg_rdlock: cf_head != NULL\n"); #endif - if ((cfp->cf_head->h_state & CFG_HDR_RDLOCK) - == CFG_HDR_RDLOCK) - rc = TRUE; - else { - rc = FALSE; - break; - } + if ((cfp->cf_head->h_state & CFG_HDR_RDLOCK) + == CFG_HDR_RDLOCK) { + rc = TRUE; + } else { + rc = FALSE; + break; + } } } @@ -1962,27 +1965,28 @@ cfg_wrlock(CFGFILE *cfg) /* Determine number of files open */ for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) { - if (!cfp->cf_fd) continue; + if (!cfp->cf_fd) + continue; if (cfp->cf_head == NULL) { #ifdef DEBUG_LIB - (void) fprintf(stderr, "cfg wrlock: cf_head == NULL\n"); + (void) fprintf(stderr, "cfg wrlock: cf_head == NULL\n"); #endif - /* - * 6335583, see comments on cfg_rdlock - */ - rc = FALSE; - break; + /* + * 6335583, see comments on cfg_rdlock + */ + rc = FALSE; + break; } else { #ifdef DEBUG_LIB - (void) fprintf(stderr, "cfg wrlock: cf_head != NULL\n"); + (void) fprintf(stderr, "cfg wrlock: cf_head != NULL\n"); #endif - if ((cfp->cf_head->h_state & CFG_HDR_WRLOCK) - == CFG_HDR_WRLOCK) - rc = TRUE; - else { - rc = FALSE; - break; - } + if ((cfp->cf_head->h_state & CFG_HDR_WRLOCK) + == CFG_HDR_WRLOCK) { + rc = TRUE; + } else { + rc = FALSE; + break; + } } } @@ -2023,15 +2027,15 @@ cfg_get_lock(CFGFILE *cfg, CFGLOCK *lock, pid_t *pid) } } else { if (cfg_wrlock(cfg)) { - *lock = CFG_WRLOCK; - *pid = getpid(); - return (TRUE); + *lock = CFG_WRLOCK; + *pid = getpid(); + return (TRUE); } if (cfg_rdlock(cfg)) { - *lock = CFG_RDLOCK; - *pid = getpid(); - return (TRUE); + *lock = CFG_RDLOCK; + *pid = getpid(); + return (TRUE); } } /* Lock is always based on local file pointer */ @@ -2091,7 +2095,8 @@ cfg_commit(CFGFILE *cfg) /* Determine number of files open */ for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) { - if (!cfp->cf_fd) continue; + if (!cfp->cf_fd) + continue; /* * lets put everything back into one char * @@ -2100,18 +2105,18 @@ cfg_commit(CFGFILE *cfg) if ((*cfp->cf_pp->seek)(cfp, 0, SEEK_SET) < 0) { #ifdef DEBUG_LIB - (void) fprintf(stderr, "cfg: seek header failed\n"); + (void) fprintf(stderr, "cfg: seek header failed\n"); #endif return (FALSE); } cfp->cf_head->h_size = cfp->cf_head->h_parsesize - + cfp->cf_head->h_csize + cfp->cf_head->h_psize; + + cfp->cf_head->h_csize + cfp->cf_head->h_psize; cfp->cf_head->h_stamp = time(&tloc); /* seeking into database */ - if ((*cfp->cf_pp->seek) - (cfp, sizeof (cfgheader_t), SEEK_CUR) < 0) + if ((*cfp->cf_pp->seek)(cfp, sizeof (cfgheader_t), + SEEK_CUR) < 0) return (FALSE); if (cfp->cf_head->h_ccopy1 == cfp->cf_head->h_cparse) { @@ -2130,24 +2135,23 @@ cfg_commit(CFGFILE *cfg) #ifdef DEBUG_LIB dump_status(cfp, "cfg_commit"); #endif - rc = (*cfp->cf_pp->write) - (cfp, cfp->cf_mapped, CFG_DEFAULT_PARSE_SIZE); + rc = (*cfp->cf_pp->write)(cfp, cfp->cf_mapped, + CFG_DEFAULT_PARSE_SIZE); #ifdef DEBUG if (rc < 0) { (void) fprintf(stderr, - "parse commit: rc %d h_parsesize %d\n", - rc, cfp->cf_head->h_parsesize); + "parse commit: rc %d h_parsesize %d\n", + rc, cfp->cf_head->h_parsesize); } #endif if (section == 1) { - rc = (*cfp->cf_pp->write) - (cfp, cfp->cf_head->h_ccopy1, - cfp->cf_head->h_csize); + rc = (*cfp->cf_pp->write) (cfp, cfp->cf_head->h_ccopy1, + cfp->cf_head->h_csize); #ifdef DEBUG if (rc < 0) { (void) fprintf(stderr, - "csection commit 1: rc %d h_csize %d\n", - rc, cfp->cf_head->h_csize); + "csection commit 1: rc %d h_csize %d\n", + rc, cfp->cf_head->h_csize); } #endif if ((*cfp->cf_pp->seek) @@ -2161,26 +2165,26 @@ cfg_commit(CFGFILE *cfg) for (wrsize = 0; *ip; ip += *ip + 1) wrsize += *ip + 1; - rc = (*cfp->cf_pp->write)(cfp, - cfp->cf_head->h_sizes1, wrsize * sizeof (int)); + rc = (*cfp->cf_pp->write)(cfp, cfp->cf_head->h_sizes1, + wrsize * sizeof (int)); #ifdef DEBUG if (rc < 0) { (void) fprintf(stderr, - "cfg: write list sizes1 failed rc\n"); + "cfg: write list sizes1 failed rc\n"); } #endif } else { - if ((*cfp->cf_pp->seek)(cfp, - CFG_DEFAULT_SSIZE, SEEK_CUR) < 0) + if ((*cfp->cf_pp->seek)(cfp, CFG_DEFAULT_SSIZE, + SEEK_CUR) < 0) return (FALSE); - rc = (*cfp->cf_pp->write)(cfp, - cfp->cf_head->h_ccopy2, cfp->cf_head->h_csize); + rc = (*cfp->cf_pp->write)(cfp, cfp->cf_head->h_ccopy2, + cfp->cf_head->h_csize); #ifdef DEBUG if (rc < 0) { (void) fprintf(stderr, - "csection commit 2: rc %d h_csize %d\n", - rc, cfp->cf_head->h_csize); + "csection commit 2: rc %d h_csize %d\n", + rc, cfp->cf_head->h_csize); } #endif if ((*cfp->cf_pp->seek) @@ -2196,11 +2200,11 @@ cfg_commit(CFGFILE *cfg) wrsize += *ip + 1; rc = (*cfp->cf_pp->write)(cfp, cfp->cf_head->h_sizes2, - wrsize * sizeof (int)); + wrsize * sizeof (int)); #ifdef DEBUG if (rc < 0) { (void) fprintf(stderr, - "cfg: write list sizes2 failed\n"); + "cfg: write list sizes2 failed\n"); } #endif @@ -2215,13 +2219,13 @@ cfg_commit(CFGFILE *cfg) return (FALSE); cfp->cf_head->h_size = cfp->cf_head->h_parsesize + - cfp->cf_head->h_csize + cfp->cf_head->h_psize; + cfp->cf_head->h_csize + cfp->cf_head->h_psize; - rc = (*cfp->cf_pp->write) - (cfp, cfp->cf_head, sizeof (cfgheader_t)); + rc = (*cfp->cf_pp->write)(cfp, cfp->cf_head, + sizeof (cfgheader_t)); if (rc < 0) { cfg_perror_str = dgettext("cfg", - "cfg_commit: header write failed"); + "cfg_commit: header write failed"); cfg_severity = CFG_EFATAL; return (FALSE); } @@ -2492,7 +2496,7 @@ cfg_read_parser_config(cfp_t *cfp) p = thead[n].fld; if (p == NULL) { q = thead[n].fld = calloc(1, - sizeof (struct lookup)); + sizeof (struct lookup)); } else { for (q = thead[n].fld; q; q = q->l_next) p = q; @@ -2539,7 +2543,7 @@ cfg_read_parser_config(cfp_t *cfp) (void) fprintf(stderr, "alloced %d cfg lists \n", n + 1); #endif for (cfp->cf_head->h_ncfgs = n + 1; - i < min(cfp->cf_head->h_ncfgs, MAX_CFG); i++) { + i < min(cfp->cf_head->h_ncfgs, MAX_CFG); i++) { cfp->cf_head->h_cfgs[i].l_name = '\0'; cfp->cf_head->h_cfgs[i].l_name = strdup(chead[i].tag.l_word); @@ -2922,7 +2926,7 @@ cfg_open(char *name) cfg_severity = 0; if ((cfg = (CFGFILE *)calloc(1, sizeof (*cfg))) == NULL) { cfg_perror_str = dgettext("cfg", - "cfg_open: malloc failed"); + "cfg_open: malloc failed"); cfg_severity = CFG_EFATAL; return (NULL); } @@ -2933,9 +2937,8 @@ cfg_open(char *name) (void) fprintf(stderr, "cfg_open: Using non-standard name\n"); #endif cfp->cf_name = name; - cfp->cf_pp = (strstr(cfp->cf_name, "/rdsk/") == NULL) - ? cfg_block_io_provider() - : cfg_raw_io_provider(); + cfp->cf_pp = (strstr(cfp->cf_name, "/rdsk/") == NULL) ? + cfg_block_io_provider() : cfg_raw_io_provider(); } else { cfp->cf_name = cfg_location(NULL, CFG_LOC_GET_LOCAL, NULL); cfp->cf_pp = cfg_block_io_provider(); @@ -2946,7 +2949,7 @@ cfg_open(char *name) if (cfg_iscluster() > 0) { cfp = &cfg->cf[1]; cfp->cf_name = - cfg_location(NULL, CFG_LOC_GET_CLUSTER, NULL); + cfg_location(NULL, CFG_LOC_GET_CLUSTER, NULL); if (cfp->cf_name) { cfp->cf_pp = cfg_raw_io_provider(); } @@ -2986,7 +2989,7 @@ cfg_open(char *name) */ if (magic == CFG_NEW_MAGIC) { needed = FBA_NUM(FBA_SIZE(1) - 1 + - (sizeof (struct cfgheader) + CFG_CONFIG_SIZE)); + (sizeof (struct cfgheader) + CFG_CONFIG_SIZE)); } else { needed = 0; } @@ -3002,7 +3005,7 @@ cfg_open(char *name) cfp->cf_mapped = (char *)malloc(CFG_DEFAULT_PARSE_SIZE); if (cfp->cf_mapped == NULL) { cfg_perror_str = dgettext("cfg", - "cfg_open: malloc failed"); + "cfg_open: malloc failed"); cfg_severity = CFG_EFATAL; break; } @@ -3033,7 +3036,8 @@ cfg_open(char *name) } void -cfg_invalidate_hsizes(int fd, const char *loc) { +cfg_invalidate_hsizes(int fd, const char *loc) +{ int offset; int rc = -1; int hdrsz; @@ -3165,7 +3169,7 @@ cfg_get_section(CFGFILE *cfg, char ***list, const char *section) buf = (char **)malloc(cfl->l_nentry * sizeof (char *)); else buf = (char **)realloc(buf, (cfl->l_nentry + count) * - sizeof (char *)); + sizeof (char *)); if (buf == NULL) { errno = ENOMEM; return (-1); @@ -3261,7 +3265,7 @@ cfg_is_cfg(CFGFILE *cfg) return (1); cfg_perror_str = dgettext("cfg", - "configuration not initialized, bad magic"); + "configuration not initialized, bad magic"); cfg_severity = CFG_EFATAL; return (0); @@ -3329,7 +3333,7 @@ compare(const void* a, const void *b) */ int cfg_get_srtdsec(CFGFILE *cfg, char ***list, const char *section, - const char *field) + const char *field) { cfglist_t *cfl; cfp_t *cfp; @@ -3375,7 +3379,7 @@ cfg_get_srtdsec(CFGFILE *cfg, char ***list, const char *section, buf = (char **)malloc(cfl->l_nentry * sizeof (char *)); else buf = (char **)realloc(buf, (cfl->l_nentry + count) * - sizeof (char *)); + sizeof (char *)); if (buf == NULL) { errno = ENOMEM; cfg_perror_str = dgettext("cfg", "cfg_get_srtdsec: " @@ -3402,7 +3406,7 @@ cfg_get_srtdsec(CFGFILE *cfg, char ***list, const char *section, tmplst = (char *)malloc(cfl->l_nentry * CFG_MAX_BUF); else tmplst = (char *)realloc(tmplst, - (cfl->l_nentry + count) * CFG_MAX_BUF); + (cfl->l_nentry + count) * CFG_MAX_BUF); if (tmplst == NULL) { cfg_perror_str = dgettext("cfg", "cfg_get_srtdsec: " "malloc failed"); diff --git a/usr/src/lib/libndmp/common/libndmp_prop.c b/usr/src/lib/libndmp/common/libndmp_prop.c index 27564c5bf5..024a3801ff 100644 --- a/usr/src/lib/libndmp/common/libndmp_prop.c +++ b/usr/src/lib/libndmp/common/libndmp_prop.c @@ -316,9 +316,10 @@ ndmp_smf_create_service_pgroup(ndmp_scfhandle_t *handle, const char *pgroup) */ if (handle->scf_pg == NULL) { if ((handle->scf_pg = - scf_pg_create(handle->scf_handle)) == NULL) + scf_pg_create(handle->scf_handle)) == NULL) { ndmp_errno = ENDMP_SMF_INTERNAL; return (-1); + } } /* diff --git a/usr/src/lib/print/libpapi-common/common/attribute.c b/usr/src/lib/print/libpapi-common/common/attribute.c index 76268c7591..8e90d4e9e0 100644 --- a/usr/src/lib/print/libpapi-common/common/attribute.c +++ b/usr/src/lib/print/libpapi-common/common/attribute.c @@ -27,8 +27,6 @@ * */ -/* $Id: attribute.c 157 2006-04-26 15:07:55Z ktou $ */ - /*LINTLIBRARY*/ #include <stdio.h> @@ -50,7 +48,7 @@ static void papiAttributeFree(papi_attribute_t *attribute); static void papiAttributeValueFree(papi_attribute_value_type_t type, - papi_attribute_value_t *value) + papi_attribute_value_t *value) { if (value != NULL) { switch (type) { @@ -78,7 +76,7 @@ papiAttributeValueFree(papi_attribute_value_type_t type, static void papiAttributeValuesFree(papi_attribute_value_type_t type, - papi_attribute_value_t **values) + papi_attribute_value_t **values) { if (values != NULL) { int i; @@ -94,12 +92,11 @@ static void papiAttributeFree(papi_attribute_t *attribute) { if (attribute != NULL) { - if (attribute->name != NULL) - free(attribute->name); + free(attribute->name); if (attribute->values != NULL) papiAttributeValuesFree(attribute->type, - attribute->values); - free(attribute); + attribute->values); + free(attribute); } } @@ -127,22 +124,19 @@ collection_dup(papi_attribute_t **collection) int i; for (i = 0; ((collection[i] != NULL) && (status == PAPI_OK)); - i++) { + i++) { papi_attribute_t *a = collection[i]; status = papiAttributeListAddValue(&result, - PAPI_ATTR_APPEND, a->name, a->type, - NULL); + PAPI_ATTR_APPEND, a->name, a->type, NULL); if ((status == PAPI_OK) && (a->values != NULL)) { int j; for (j = 0; ((a->values[j] != NULL) && - (status == PAPI_OK)); j++) + (status == PAPI_OK)); j++) status = papiAttributeListAddValue( - &result, - PAPI_ATTR_APPEND, - a->name, a->type, - a->values[j]); + &result, PAPI_ATTR_APPEND, + a->name, a->type, a->values[j]); } } if (status != PAPI_OK) { @@ -156,7 +150,7 @@ collection_dup(papi_attribute_t **collection) static papi_attribute_value_t * papiAttributeValueDup(papi_attribute_value_type_t type, - papi_attribute_value_t *v) + papi_attribute_value_t *v) { papi_attribute_value_t *result = NULL; @@ -217,8 +211,8 @@ papiAttributeAlloc(char *name, papi_attribute_value_type_t type) static papi_status_t papiAttributeListAppendValue(papi_attribute_value_t ***values, - papi_attribute_value_type_t type, - papi_attribute_value_t *value) + papi_attribute_value_type_t type, + papi_attribute_value_t *value) { if (values == NULL) @@ -238,8 +232,8 @@ papiAttributeListAppendValue(papi_attribute_value_t ***values, papi_status_t papiAttributeListAddValue(papi_attribute_t ***list, int flgs, - char *name, papi_attribute_value_type_t type, - papi_attribute_value_t *value) + char *name, papi_attribute_value_type_t type, + papi_attribute_value_t *value) { papi_status_t result; int flags = flgs; @@ -298,7 +292,7 @@ papiAttributeListAddValue(papi_attribute_t ***list, int flgs, papi_status_t papiAttributeListAddString(papi_attribute_t ***list, int flags, - char *name, char *string) + char *name, char *string) { papi_attribute_value_t v; @@ -308,7 +302,7 @@ papiAttributeListAddString(papi_attribute_t ***list, int flags, papi_status_t papiAttributeListAddInteger(papi_attribute_t ***list, int flags, - char *name, int integer) + char *name, int integer) { papi_attribute_value_t v; @@ -318,7 +312,7 @@ papiAttributeListAddInteger(papi_attribute_t ***list, int flags, papi_status_t papiAttributeListAddBoolean(papi_attribute_t ***list, int flags, - char *name, char boolean) + char *name, char boolean) { papi_attribute_value_t v; @@ -328,7 +322,7 @@ papiAttributeListAddBoolean(papi_attribute_t ***list, int flags, papi_status_t papiAttributeListAddRange(papi_attribute_t ***list, int flags, - char *name, int lower, int upper) + char *name, int lower, int upper) { papi_attribute_value_t v; @@ -339,8 +333,7 @@ papiAttributeListAddRange(papi_attribute_t ***list, int flags, papi_status_t papiAttributeListAddResolution(papi_attribute_t ***list, int flags, - char *name, int xres, int yres, - papi_resolution_unit_t units) + char *name, int xres, int yres, papi_resolution_unit_t units) { papi_attribute_value_t v; @@ -348,40 +341,40 @@ papiAttributeListAddResolution(papi_attribute_t ***list, int flags, v.resolution.yres = yres; v.resolution.units = units; return (papiAttributeListAddValue(list, flags, name, - PAPI_RESOLUTION, &v)); + PAPI_RESOLUTION, &v)); } papi_status_t papiAttributeListAddDatetime(papi_attribute_t ***list, int flags, - char *name, time_t datetime) + char *name, time_t datetime) { papi_attribute_value_t v; v.datetime = datetime; return (papiAttributeListAddValue(list, flags, name, - PAPI_DATETIME, &v)); + PAPI_DATETIME, &v)); } papi_status_t papiAttributeListAddCollection(papi_attribute_t ***list, int flags, - char *name, papi_attribute_t **collection) + char *name, papi_attribute_t **collection) { papi_attribute_value_t v; v.collection = (papi_attribute_t **)collection; return (papiAttributeListAddValue(list, flags, name, - PAPI_COLLECTION, &v)); + PAPI_COLLECTION, &v)); } papi_status_t papiAttributeListAddMetadata(papi_attribute_t ***list, int flags, - char *name, papi_metadata_t metadata) + char *name, papi_metadata_t metadata) { papi_attribute_value_t v; v.metadata = metadata; return (papiAttributeListAddValue(list, flags, name, - PAPI_METADATA, &v)); + PAPI_METADATA, &v)); } papi_status_t @@ -435,8 +428,8 @@ papiAttributeListGetNext(papi_attribute_t **list, void **iter) papi_status_t papiAttributeListGetValue(papi_attribute_t **list, void **iter, - char *name, papi_attribute_value_type_t type, - papi_attribute_value_t **value) + char *name, papi_attribute_value_type_t type, + papi_attribute_value_t **value) { papi_attribute_value_t **tmp; void *fodder = NULL; @@ -475,7 +468,7 @@ papiAttributeListGetValue(papi_attribute_t **list, void **iter, papi_status_t papiAttributeListGetString(papi_attribute_t **list, void **iter, - char *name, char **vptr) + char *name, char **vptr) { papi_status_t status; papi_attribute_value_t *value = NULL; @@ -484,7 +477,7 @@ papiAttributeListGetString(papi_attribute_t **list, void **iter, return (PAPI_BAD_ARGUMENT); status = papiAttributeListGetValue(list, iter, name, - PAPI_STRING, &value); + PAPI_STRING, &value); if (status == PAPI_OK) *vptr = value->string; @@ -493,7 +486,7 @@ papiAttributeListGetString(papi_attribute_t **list, void **iter, papi_status_t papiAttributeListGetInteger(papi_attribute_t **list, void **iter, - char *name, int *vptr) + char *name, int *vptr) { papi_status_t status; papi_attribute_value_t *value = NULL; @@ -502,7 +495,7 @@ papiAttributeListGetInteger(papi_attribute_t **list, void **iter, return (PAPI_BAD_ARGUMENT); status = papiAttributeListGetValue(list, iter, name, - PAPI_INTEGER, &value); + PAPI_INTEGER, &value); if (status == PAPI_OK) *vptr = value->integer; @@ -511,7 +504,7 @@ papiAttributeListGetInteger(papi_attribute_t **list, void **iter, papi_status_t papiAttributeListGetBoolean(papi_attribute_t **list, void **iter, - char *name, char *vptr) + char *name, char *vptr) { papi_status_t status; papi_attribute_value_t *value = NULL; @@ -520,7 +513,7 @@ papiAttributeListGetBoolean(papi_attribute_t **list, void **iter, return (PAPI_BAD_ARGUMENT); status = papiAttributeListGetValue(list, iter, name, - PAPI_BOOLEAN, &value); + PAPI_BOOLEAN, &value); if (status == PAPI_OK) *vptr = value->boolean; @@ -529,7 +522,7 @@ papiAttributeListGetBoolean(papi_attribute_t **list, void **iter, papi_status_t papiAttributeListGetRange(papi_attribute_t **list, void **iter, - char *name, int *min, int *max) + char *name, int *min, int *max) { papi_status_t status; papi_attribute_value_t *value = NULL; @@ -538,7 +531,7 @@ papiAttributeListGetRange(papi_attribute_t **list, void **iter, return (PAPI_BAD_ARGUMENT); status = papiAttributeListGetValue(list, iter, name, - PAPI_RANGE, &value); + PAPI_RANGE, &value); if (status == PAPI_OK) { *min = value->range.lower; *max = value->range.upper; @@ -549,8 +542,7 @@ papiAttributeListGetRange(papi_attribute_t **list, void **iter, papi_status_t papiAttributeListGetResolution(papi_attribute_t **list, void **iter, - char *name, int *x, int *y, - papi_resolution_unit_t *units) + char *name, int *x, int *y, papi_resolution_unit_t *units) { papi_status_t status; papi_attribute_value_t *value = NULL; @@ -559,7 +551,7 @@ papiAttributeListGetResolution(papi_attribute_t **list, void **iter, return (PAPI_BAD_ARGUMENT); status = papiAttributeListGetValue(list, iter, name, - PAPI_RESOLUTION, &value); + PAPI_RESOLUTION, &value); if (status == PAPI_OK) { *x = value->resolution.xres; *y = value->resolution.yres; @@ -571,7 +563,7 @@ papiAttributeListGetResolution(papi_attribute_t **list, void **iter, papi_status_t papiAttributeListGetDatetime(papi_attribute_t **list, void **iter, - char *name, time_t *dt) + char *name, time_t *dt) { papi_status_t status; papi_attribute_value_t *value = NULL; @@ -580,7 +572,7 @@ papiAttributeListGetDatetime(papi_attribute_t **list, void **iter, return (PAPI_BAD_ARGUMENT); status = papiAttributeListGetValue(list, iter, name, - PAPI_DATETIME, &value); + PAPI_DATETIME, &value); if (status == PAPI_OK) { *dt = value->datetime; } @@ -590,7 +582,7 @@ papiAttributeListGetDatetime(papi_attribute_t **list, void **iter, papi_status_t papiAttributeListGetCollection(papi_attribute_t **list, void **iter, - char *name, papi_attribute_t ***collection) + char *name, papi_attribute_t ***collection) { papi_status_t status; papi_attribute_value_t *value = NULL; @@ -599,7 +591,7 @@ papiAttributeListGetCollection(papi_attribute_t **list, void **iter, return (PAPI_BAD_ARGUMENT); status = papiAttributeListGetValue(list, iter, name, - PAPI_COLLECTION, &value); + PAPI_COLLECTION, &value); if (status == PAPI_OK) { *collection = value->collection; } @@ -609,7 +601,7 @@ papiAttributeListGetCollection(papi_attribute_t **list, void **iter, papi_status_t papiAttributeListGetMetadata(papi_attribute_t **list, void **iter, - char *name, papi_metadata_t *vptr) + char *name, papi_metadata_t *vptr) { papi_status_t status; papi_attribute_value_t *value = NULL; @@ -618,7 +610,7 @@ papiAttributeListGetMetadata(papi_attribute_t **list, void **iter, return (PAPI_BAD_ARGUMENT); status = papiAttributeListGetValue(list, iter, name, - PAPI_METADATA, &value); + PAPI_METADATA, &value); if (status == PAPI_OK) *vptr = value->metadata; @@ -649,7 +641,7 @@ _process_value(char *string, char ***parts) int compiled; regex_t re; } types[] = { - { PAPI_BOOLEAN, 1, "^(true|false|yes|no)$", 0 }, + { PAPI_BOOLEAN, 1, "^(true|false|yes|no)$", 0 }, { PAPI_COLLECTION, 1, "^\\{(.+)\\}$", 0 }, /* PAPI_DATETIME is unsupported, too much like an integer */ { PAPI_INTEGER, 1, "^([+-]{0,1}[[:digit:]]+)$", 0 }, @@ -665,14 +657,14 @@ _process_value(char *string, char ***parts) if (types[i].compiled == 0) { (void) regcomp(&(types[i].re), types[i].expression, - REG_EXTENDED|REG_ICASE); + REG_EXTENDED|REG_ICASE); types[i].compiled = 1; } if (regexec(&(types[i].re), string, (size_t)types[i].vals, - matches, 0) == REG_NOMATCH) + matches, 0) == REG_NOMATCH) continue; - for (j = 0 ; j < types[i].vals; j++) + for (j = 0; j < types[i].vals; j++) list_append(parts, regvalue(matches[j], string)); return (types[i].type); } @@ -683,12 +675,12 @@ _process_value(char *string, char ***parts) static void _add_attribute_value(papi_attribute_value_t ***list, - papi_attribute_value_type_t type, - papi_attribute_value_type_t dtype, char **parts) + papi_attribute_value_type_t type, + papi_attribute_value_type_t dtype, char **parts) { papi_attribute_value_t *value = calloc(1, sizeof (*value)); - switch(type) { + switch (type) { case PAPI_STRING: value->string = strdup(parts[0]); list_append(list, value); @@ -751,7 +743,7 @@ _add_attribute_value(papi_attribute_value_t ***list, static papi_status_t _papiAttributeFromStrings(papi_attribute_t ***list, int flags, - char *key, char **values) + char *key, char **values) { int i; papi_status_t result = PAPI_OK; @@ -760,7 +752,7 @@ _papiAttributeFromStrings(papi_attribute_t ***list, int flags, /* these are specified in the papi spec as ranges */ char *ranges[] = { "copies-supported", "job-impressions-supported", "job-k-octets-supported", - "job-media-sheets-supported", "page-ranges", + "job-media-sheets-supported", "page-ranges", NULL }; if ((attr == NULL) || ((attr->name = strdup(key)) == NULL)) @@ -842,8 +834,8 @@ _parse_attribute_list(papi_attribute_t ***list, int flags, char *string) } else { /* value */ while ((*ptr != '\0') && - (*ptr != ',') && - (isspace(*ptr) == 0)) + (*ptr != ',') && + (isspace(*ptr) == 0)) ptr++; } if (*ptr == ',') @@ -870,14 +862,13 @@ _parse_attribute_list(papi_attribute_t ***list, int flags, char *string) } papi_status_t -papiAttributeListFromString(papi_attribute_t ***attrs, - int flags, char *string) +papiAttributeListFromString(papi_attribute_t ***attrs, int flags, char *string) { papi_status_t result = PAPI_OK; if ((attrs != NULL) && (string != NULL) && ((flags & ~(PAPI_ATTR_APPEND+PAPI_ATTR_REPLACE+PAPI_ATTR_EXCL)) - == 0)) { + == 0)) { result = _parse_attribute_list(attrs, flags, string); } else { result = PAPI_BAD_ARGUMENT; @@ -888,7 +879,7 @@ papiAttributeListFromString(papi_attribute_t ***attrs, static papi_status_t papiAttributeToString(papi_attribute_t *attribute, char *delim, - char *buffer, size_t buflen) + char *buffer, size_t buflen) { papi_attribute_value_t **values = attribute->values; int rc, i; @@ -918,25 +909,25 @@ papiAttributeToString(papi_attribute_t *attribute, char *delim, char string[24]; snprintf(string, sizeof (string), "%d", - values[i]->integer); + values[i]->integer); rc = strlcat(buffer, string, buflen); } break; case PAPI_BOOLEAN: if (values[1] != NULL) - rc = strlcat(buffer, (values[i]->boolean ? - "true" : "false"), buflen); + rc = strlcat(buffer, values[i]->boolean ? + "true" : "false", buflen); break; case PAPI_RANGE: { char string[24]; if (values[i]->range.lower == values[i]->range.upper) snprintf(string, sizeof (string), "%d", - values[i]->range.lower); + values[i]->range.lower); else snprintf(string, sizeof (string), "%d-%d", - values[i]->range.lower, - values[i]->range.upper); + values[i]->range.lower, + values[i]->range.upper); rc = strlcat(buffer, string, buflen); } break; @@ -944,10 +935,10 @@ papiAttributeToString(papi_attribute_t *attribute, char *delim, char string[24]; snprintf(string, sizeof (string), "%dx%ddp%c", - values[i]->resolution.xres, - values[i]->resolution.yres, - (values[i]->resolution.units == PAPI_RES_PER_CM - ? 'c' : 'i')); + values[i]->resolution.xres, + values[i]->resolution.yres, + values[i]->resolution.units == PAPI_RES_PER_CM ? + 'c' : 'i'); rc = strlcat(buffer, string, buflen); } break; @@ -965,7 +956,7 @@ papiAttributeToString(papi_attribute_t *attribute, char *delim, char *string = alloca(buflen); papiAttributeListToString(values[i]->collection, - delim, string, buflen); + delim, string, buflen); rc = strlcat(buffer, string, buflen); } break; @@ -973,7 +964,7 @@ papiAttributeToString(papi_attribute_t *attribute, char *delim, char string[32]; snprintf(string, sizeof (string), "unknown-type-0x%x", - attribute->type); + attribute->type); rc = strlcat(buffer, string, buflen); } } @@ -990,7 +981,7 @@ papiAttributeToString(papi_attribute_t *attribute, char *delim, papi_status_t papiAttributeListToString(papi_attribute_t **attrs, - char *delim, char *buffer, size_t buflen) + char *delim, char *buffer, size_t buflen) { papi_status_t status = PAPI_OK; int i; @@ -1036,12 +1027,10 @@ copy_attribute(papi_attribute_t ***list, papi_attribute_t *attribute) return (PAPI_BAD_ARGUMENT); for (status = papiAttributeListAddValue(list, PAPI_ATTR_EXCL, - attribute->name, attribute->type, - attribute->values[i]); - ((status == PAPI_OK) && (attribute->values[i] != NULL)); - status = papiAttributeListAddValue(list, PAPI_ATTR_APPEND, - attribute->name, attribute->type, - attribute->values[i])) + attribute->name, attribute->type, attribute->values[i]); + ((status == PAPI_OK) && (attribute->values[i] != NULL)); + status = papiAttributeListAddValue(list, PAPI_ATTR_APPEND, + attribute->name, attribute->type, attribute->values[i])) i++; return (status); @@ -1061,7 +1050,7 @@ copy_attributes(papi_attribute_t ***result, papi_attribute_t **attributes) void split_and_copy_attributes(char **list, papi_attribute_t **attributes, - papi_attribute_t ***in, papi_attribute_t ***out) + papi_attribute_t ***in, papi_attribute_t ***out) { int i; @@ -1077,7 +1066,7 @@ split_and_copy_attributes(char **list, papi_attribute_t **attributes, void papiAttributeListPrint(FILE *fp, papi_attribute_t **attributes, - char *prefix_fmt, ...) + char *prefix_fmt, ...) { char *prefix = NULL; char *buffer = NULL; @@ -1101,7 +1090,7 @@ papiAttributeListPrint(FILE *fp, papi_attribute_t **attributes, if (attributes) { size = 0; while (papiAttributeListToString(attributes, prefix, buffer, - size) != PAPI_OK) { + size) != PAPI_OK) { size += 1024; mem = realloc(buffer, size); if (!mem) goto error; @@ -1112,7 +1101,7 @@ papiAttributeListPrint(FILE *fp, papi_attribute_t **attributes, fprintf(fp, "%s%s\n", prefix, buffer ? buffer : ""); fflush(fp); - error: +error: free(newfmt); free(prefix); free(buffer); diff --git a/usr/src/pkg/manifests/system-test-ostest.mf b/usr/src/pkg/manifests/system-test-ostest.mf index 64daf4a64f..3741e1c920 100644 --- a/usr/src/pkg/manifests/system-test-ostest.mf +++ b/usr/src/pkg/manifests/system-test-ostest.mf @@ -10,7 +10,7 @@ # # -# Copyright (c) 2012 by Delphix. All rights reserved. +# Copyright (c) 2012, 2016 by Delphix. All rights reserved. # Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved. # Copyright 2016, Joyent, Inc. # @@ -29,6 +29,7 @@ dir path=opt/os-tests/tests/file-locking dir path=opt/os-tests/tests/sdevfs dir path=opt/os-tests/tests/secflags dir path=opt/os-tests/tests/sigqueue +dir path=opt/os-tests/tests/stress file path=opt/os-tests/README mode=0444 file path=opt/os-tests/bin/ostest mode=0555 file path=opt/os-tests/runfiles/default.run mode=0444 @@ -60,6 +61,7 @@ file path=opt/os-tests/tests/file-locking/runtests.32 mode=0555 file path=opt/os-tests/tests/file-locking/runtests.64 mode=0555 file path=opt/os-tests/tests/file-locking/acquire-lock.32 mode=0555 file path=opt/os-tests/tests/file-locking/acquire-lock.64 mode=0555 +file path=opt/os-tests/tests/stress/dladm-kstat mode=0555 license cr_Sun license=cr_Sun license lic_CDDL license=lic_CDDL depend fmri=system/test/testrunner type=require diff --git a/usr/src/test/os-tests/runfiles/default.run b/usr/src/test/os-tests/runfiles/default.run index db212b8113..0c231b3e11 100644 --- a/usr/src/test/os-tests/runfiles/default.run +++ b/usr/src/test/os-tests/runfiles/default.run @@ -56,6 +56,10 @@ tests = ['timer_limit'] user = root tests = ['tmpfs_badmount', 'tmpfs_enospc'] +[/opt/os-tests/tests/stress] +user = root +tests = ['dladm-kstat'] + [/opt/os-tests/tests/file-locking] tests = ['runtests.32', 'runtests.64'] diff --git a/usr/src/test/os-tests/tests/Makefile b/usr/src/test/os-tests/tests/Makefile index c0391d45bd..3a15589376 100644 --- a/usr/src/test/os-tests/tests/Makefile +++ b/usr/src/test/os-tests/tests/Makefile @@ -10,11 +10,12 @@ # # -# Copyright (c) 2012 by Delphix. All rights reserved. +# Copyright (c) 2012, 2016 by Delphix. All rights reserved. # Copyright 2016 Joyent, Inc. # -SUBDIRS = poll secflags sigqueue spoof-ras sdevfs timer tmpfs file-locking +SUBDIRS = poll secflags sigqueue spoof-ras sdevfs stress timer tmpfs \ + file-locking PROGS = \ OS-6097 diff --git a/usr/src/test/os-tests/tests/stress/Makefile b/usr/src/test/os-tests/tests/stress/Makefile new file mode 100644 index 0000000000..7aed99b982 --- /dev/null +++ b/usr/src/test/os-tests/tests/stress/Makefile @@ -0,0 +1,42 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2016 by Delphix. All rights reserved. +# + +include $(SRC)/cmd/Makefile.cmd +include $(SRC)/test/Makefile.com + +PROG = dladm-kstat + +ROOTOPTPKG = $(ROOT)/opt/os-tests +TESTDIR = $(ROOTOPTPKG)/tests/stress + +CMDS = $(PROG:%=$(TESTDIR)/%) +$(CMDS) := FILEMODE = 0555 + +all: $(PROG) + +install: all $(CMDS) + +clobber: clean + +clean: + -$(RM) $(PROG) + +$(CMDS): $(TESTDIR) $(PROG) + +$(TESTDIR): + $(INS.dir) + +$(TESTDIR)/%: % + $(INS.file) diff --git a/usr/src/test/os-tests/tests/stress/dladm-kstat.sh b/usr/src/test/os-tests/tests/stress/dladm-kstat.sh new file mode 100755 index 0000000000..f0ab886d9f --- /dev/null +++ b/usr/src/test/os-tests/tests/stress/dladm-kstat.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2016 by Delphix. All rights reserved. +# + +# +# This test attempts to stress the interaction between threads adding +# and deleting datalinks, and those reading kstats associated with +# those datalinks. +# + +RUNFILE=$(mktemp) +linkname1=laverne0 +linkname2=shirley0 +duration=20 # seconds + +# +# Delete any potential datalinks left behind by the etherstub function. +# +function cleanup +{ + rm -f $RUNFILE +} + +function etherstub +{ + while [[ -e $RUNFILE ]]; do + dladm create-etherstub -t $linkname1 + dladm rename-link $linkname1 $linkname2 + dladm delete-etherstub -t $linkname2 + done +} + +function readkstat +{ + local linkname=$1 + while [[ -e $RUNFILE ]]; do + kstat link:0:$linkname &>/dev/null + done +} + +trap "cleanup; exit" SIGHUP SIGINT SIGTERM + +etherstub & +readkstat $linkname1 & +readkstat $linkname1 & +readkstat $linkname2 & +readkstat $linkname2 & + +sleep $duration +cleanup + +wait + +exit 0 diff --git a/usr/src/uts/common/avs/ns/sdbc/sd_bio.c b/usr/src/uts/common/avs/ns/sdbc/sd_bio.c index 46bb16ddc7..a82a19f6f7 100644 --- a/usr/src/uts/common/avs/ns/sdbc/sd_bio.c +++ b/usr/src/uts/common/avs/ns/sdbc/sd_bio.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ #include <sys/types.h> #include <sys/param.h> @@ -180,9 +183,9 @@ _sdbc_iobuf_load(void) void _sdbc_iobuf_unload(void) { - /* Undo our VN_HOLD hack, by putting ref count back to normal state */ mutex_enter(&kvp.v_lock); - kvp.v_count = 0; + ASSERT(kvp.v_count == 1); + VN_RELE_LOCKED(&kvp); mutex_exit(&kvp.v_lock); mutex_destroy(&sdbc_bio_mutex); @@ -706,7 +709,7 @@ _sd_pack_pages(struct buf *bp, struct buf *list, sd_addr_t *addr, */ static void _sd_pack_pages_nopageio(struct buf *bp, struct buf *list, sd_addr_t *addr, - nsc_off_t offset, nsc_size_t size) + nsc_off_t offset, nsc_size_t size) { uintptr_t start_addr; #ifdef _SD_BIO_STATS @@ -924,7 +927,7 @@ sd_add_mem(struct buf *bp, char *buf, nsc_size_t len) */ int sd_start_io(struct buf *bp, strategy_fn_t strategy, sdbc_ea_fn_t fn, - blind_t arg) + blind_t arg) { int err; iob_hook_t *hook = (iob_hook_t *)bp->b_private; diff --git a/usr/src/uts/common/fs/autofs/auto_vfsops.c b/usr/src/uts/common/fs/autofs/auto_vfsops.c index f8c6169d47..9b95ef5269 100644 --- a/usr/src/uts/common/fs/autofs/auto_vfsops.c +++ b/usr/src/uts/common/fs/autofs/auto_vfsops.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011 Bayard G. Bell. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ #include <sys/param.h> @@ -196,8 +197,10 @@ autofs_zone_destructor(zoneid_t zoneid, void *arg) * make this 0 to placate auto_freefnnode(). */ vp = fntovn(fngp->fng_rootfnnodep); + mutex_enter(&vp->v_lock); ASSERT(vp->v_count == 1); - vp->v_count--; + VN_RELE_LOCKED(vp); + mutex_exit(&vp->v_lock); auto_freefnnode(fngp->fng_rootfnnodep); mutex_destroy(&fngp->fng_unmount_threads_lock); kmem_free(fngp, sizeof (*fngp)); diff --git a/usr/src/uts/common/fs/autofs/auto_vnops.c b/usr/src/uts/common/fs/autofs/auto_vnops.c index 25eede67fd..086e264b7f 100644 --- a/usr/src/uts/common/fs/autofs/auto_vnops.c +++ b/usr/src/uts/common/fs/autofs/auto_vnops.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ #include <sys/param.h> @@ -1316,7 +1317,8 @@ auto_inactive(vnode_t *vp, cred_t *cred, caller_context_t *ct) rw_enter(&dfnp->fn_rwlock, RW_WRITER); mutex_enter(&vp->v_lock); ASSERT(vp->v_count > 0); - count = --vp->v_count; + VN_RELE_LOCKED(vp); + count = vp->v_count; mutex_exit(&vp->v_lock); if (count == 0) { /* diff --git a/usr/src/uts/common/fs/dcfs/dc_vnops.c b/usr/src/uts/common/fs/dcfs/dc_vnops.c index bd0edcbcd4..bed5c280f6 100644 --- a/usr/src/uts/common/fs/dcfs/dc_vnops.c +++ b/usr/src/uts/common/fs/dcfs/dc_vnops.c @@ -21,6 +21,7 @@ */ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -261,7 +262,7 @@ dc_close(struct vnode *vp, int flag, int count, offset_t off, /*ARGSUSED*/ static int dc_read(struct vnode *vp, struct uio *uiop, int ioflag, struct cred *cr, - struct caller_context *ct) + struct caller_context *ct) { struct dcnode *dp = VTODC(vp); size_t rdsize = MAX(MAXBSIZE, dp->dc_hdr->ch_blksize); @@ -355,7 +356,8 @@ dc_inactive(struct vnode *vp, cred_t *cr, caller_context_t *ctp) mutex_enter(&dctable_lock); mutex_enter(&vp->v_lock); ASSERT(vp->v_count >= 1); - if (--vp->v_count != 0) { + VN_RELE_LOCKED(vp); + if (vp->v_count != 0) { /* * Somebody accessed the dcnode before we got a chance to * remove it. They will remove it when they do a vn_rele. diff --git a/usr/src/uts/common/fs/dev/sdev_subr.c b/usr/src/uts/common/fs/dev/sdev_subr.c index 511432453f..42a3874b95 100644 --- a/usr/src/uts/common/fs/dev/sdev_subr.c +++ b/usr/src/uts/common/fs/dev/sdev_subr.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2016 Joyent, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* @@ -2677,8 +2678,8 @@ checkforroot: } int -sdev_modctl_readdir(const char *dir, char ***dirlistp, - int *npathsp, int *npathsp_alloc, int checking_empty) +sdev_modctl_readdir(const char *dir, char ***dirlistp, int *npathsp, + int *npathsp_alloc, int checking_empty) { char **pathlist = NULL; char **newlist = NULL; @@ -2959,12 +2960,12 @@ devname_inactive_func(struct vnode *vp, struct cred *cred, } VERIFY(dv->sdev_nlink == 1); decr_link(dv); - --vp->v_count; + VN_RELE_LOCKED(vp); rw_exit(&dv->sdev_contents); mutex_exit(&vp->v_lock); sdev_nodedestroy(dv, 0); } else { - --vp->v_count; + VN_RELE_LOCKED(vp); rw_exit(&dv->sdev_contents); mutex_exit(&vp->v_lock); } diff --git a/usr/src/uts/common/fs/dev/sdev_vfsops.c b/usr/src/uts/common/fs/dev/sdev_vfsops.c index 8de16926cd..8c5f7d9841 100644 --- a/usr/src/uts/common/fs/dev/sdev_vfsops.c +++ b/usr/src/uts/common/fs/dev/sdev_vfsops.c @@ -22,6 +22,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2015 Joyent, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* @@ -512,7 +513,7 @@ sdev_find_mntinfo(char *mntpt) mntinfo = sdev_mntinfo; while (mntinfo) { if (strcmp(mntpt, mntinfo->sdev_root->sdev_name) == 0) { - SDEVTOV(mntinfo->sdev_root)->v_count++; + VN_HOLD(SDEVTOV(mntinfo->sdev_root)); break; } mntinfo = mntinfo->sdev_next; @@ -524,8 +525,12 @@ sdev_find_mntinfo(char *mntpt) void sdev_mntinfo_rele(struct sdev_data *mntinfo) { + vnode_t *vp = SDEVTOV(mntinfo->sdev_root); + mutex_enter(&sdev_lock); - SDEVTOV(mntinfo->sdev_root)->v_count--; + mutex_enter(&vp->v_lock); + VN_RELE_LOCKED(vp); + mutex_exit(&vp->v_lock); mutex_exit(&sdev_lock); } diff --git a/usr/src/uts/common/fs/devfs/devfs_vnops.c b/usr/src/uts/common/fs/devfs/devfs_vnops.c index 0c5114066b..1ab460d071 100644 --- a/usr/src/uts/common/fs/devfs/devfs_vnops.c +++ b/usr/src/uts/common/fs/devfs/devfs_vnops.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* @@ -105,7 +106,7 @@ devfs_close(struct vnode *vp, int flag, int count, /*ARGSUSED*/ static int devfs_read(struct vnode *vp, struct uio *uiop, int ioflag, struct cred *cred, - struct caller_context *ct) + struct caller_context *ct) { dcmn_err2(("devfs_read %s\n", VTODV(vp)->dv_name)); ASSERT(vp->v_type == VDIR); @@ -120,7 +121,7 @@ devfs_read(struct vnode *vp, struct uio *uiop, int ioflag, struct cred *cred, /*ARGSUSED*/ static int devfs_write(struct vnode *vp, struct uio *uiop, int ioflag, struct cred *cred, - struct caller_context *ct) + struct caller_context *ct) { dcmn_err2(("devfs_write %s\n", VTODV(vp)->dv_name)); ASSERT(vp->v_type == VDIR); @@ -1053,7 +1054,7 @@ devfs_inactive(struct vnode *vp, struct cred *cred, caller_context_t *ct) dcmn_err2(("devfs_inactive: %s\n", dv->dv_name)); mutex_enter(&vp->v_lock); ASSERT(vp->v_count >= 1); - --vp->v_count; + VN_RELE_LOCKED(vp); destroy = (DV_STALE(dv) && vp->v_count == 0); mutex_exit(&vp->v_lock); diff --git a/usr/src/uts/common/fs/dnlc.c b/usr/src/uts/common/fs/dnlc.c index c949117da6..8708cb9fa4 100644 --- a/usr/src/uts/common/fs/dnlc.c +++ b/usr/src/uts/common/fs/dnlc.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -76,8 +77,9 @@ #define VN_HOLD_CALLER VN_HOLD #define VN_HOLD_DNLC(vp) { \ mutex_enter(&(vp)->v_lock); \ - if ((vp)->v_count_dnlc == 0) \ - (vp)->v_count++; \ + if ((vp)->v_count_dnlc == 0) { \ + VN_HOLD_LOCKED(vp); \ + } \ (vp)->v_count_dnlc++; \ mutex_exit(&(vp)->v_lock); \ } @@ -404,11 +406,16 @@ dnlc_init() dc_head.dch_prev = (dircache_t *)&dc_head; /* - * Initialise the reference count of the negative cache vnode to 1 - * so that it never goes away (VOP_INACTIVE isn't called on it). + * Put a hold on the negative cache vnode so that it never goes away + * (VOP_INACTIVE isn't called on it). The mutex_enter() isn't necessary + * for correctness, but VN_HOLD_LOCKED() asserts that it's held, so + * we oblige. */ - negative_cache_vnode.v_count = 1; + mutex_enter(&negative_cache_vnode.v_lock); + negative_cache_vnode.v_count = 0; + VN_HOLD_LOCKED(&negative_cache_vnode); negative_cache_vnode.v_count_dnlc = 0; + mutex_exit(&negative_cache_vnode.v_lock); /* * Initialise kstats - both the old compatability raw kind and diff --git a/usr/src/uts/common/fs/doorfs/door_vnops.c b/usr/src/uts/common/fs/doorfs/door_vnops.c index b50465f9c8..c18699dc79 100644 --- a/usr/src/uts/common/fs/doorfs/door_vnops.c +++ b/usr/src/uts/common/fs/doorfs/door_vnops.c @@ -22,8 +22,9 @@ * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ #include <sys/types.h> #include <sys/vnode.h> @@ -100,14 +101,8 @@ door_open(struct vnode **vpp, int flag, struct cred *cr, caller_context_t *ct) /* ARGSUSED */ static int -door_close( - struct vnode *vp, - int flag, - int count, - offset_t offset, - struct cred *cr, - caller_context_t *ct -) +door_close(struct vnode *vp, int flag, int count, offset_t offset, + struct cred *cr, caller_context_t *ct) { door_node_t *dp = VTOD(vp); @@ -146,7 +141,7 @@ door_close( /* ARGSUSED */ static int door_getattr(struct vnode *vp, struct vattr *vap, int flags, struct cred *cr, - caller_context_t *ct) + caller_context_t *ct) { static timestruc_t tzero = {0, 0}; extern dev_t doordev; @@ -185,7 +180,7 @@ door_inactive(struct vnode *vp, struct cred *cr, caller_context_t *ct) */ ASSERT(vp->v_count == 1); if (dp->door_bound_threads > 0) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); return; } @@ -229,7 +224,7 @@ door_unbind_thread(door_node_t *dp) ASSERT(dp->door_bound_threads > 0); if (--dp->door_bound_threads == 0 && vp->v_count == 0) { /* set up for inactive handling */ - vp->v_count++; + VN_HOLD_LOCKED(vp); do_inactive = 1; } mutex_exit(&vp->v_lock); @@ -241,7 +236,7 @@ door_unbind_thread(door_node_t *dp) /* ARGSUSED */ static int door_access(struct vnode *vp, int mode, int flags, struct cred *cr, - caller_context_t *ct) + caller_context_t *ct) { return (0); } diff --git a/usr/src/uts/common/fs/fd/fdops.c b/usr/src/uts/common/fs/fd/fdops.c index a8c03455f3..6ef5a0bd12 100644 --- a/usr/src/uts/common/fs/fd/fdops.c +++ b/usr/src/uts/common/fs/fd/fdops.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -92,7 +93,7 @@ fdopen(vnode_t **vpp, int mode, cred_t *cr, caller_context_t *ct) /* ARGSUSED */ static int fdclose(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr, - caller_context_t *ct) + caller_context_t *ct) { return (0); } @@ -162,7 +163,7 @@ fdread(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct) /* ARGSUSED */ static int fdgetattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr, - caller_context_t *ct) + caller_context_t *ct) { vfs_t *vfsp = vp->v_vfsp; timestruc_t now; @@ -201,9 +202,9 @@ fdaccess(vnode_t *vp, int mode, int flags, cred_t *cr, caller_context_t *ct) /* ARGSUSED */ static int -fdlookup(vnode_t *dp, char *comp, vnode_t **vpp, pathname_t *pnp, - int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct, - int *direntflags, pathname_t *realpnp) +fdlookup(vnode_t *dp, char *comp, vnode_t **vpp, pathname_t *pnp, int flags, + vnode_t *rdir, cred_t *cr, caller_context_t *ct, int *direntflags, + pathname_t *realpnp) { if (comp[0] == 0 || strcmp(comp, ".") == 0 || strcmp(comp, "..") == 0) { VN_HOLD(dp); @@ -215,9 +216,9 @@ fdlookup(vnode_t *dp, char *comp, vnode_t **vpp, pathname_t *pnp, /* ARGSUSED */ static int -fdcreate(vnode_t *dvp, char *comp, vattr_t *vap, enum vcexcl excl, - int mode, vnode_t **vpp, cred_t *cr, int flag, caller_context_t *ct, - vsecattr_t *vsecp) +fdcreate(vnode_t *dvp, char *comp, vattr_t *vap, enum vcexcl excl, int mode, + vnode_t **vpp, cred_t *cr, int flag, caller_context_t *ct, + vsecattr_t *vsecp) { return (fdget(dvp, comp, vpp)); } @@ -225,7 +226,7 @@ fdcreate(vnode_t *dvp, char *comp, vattr_t *vap, enum vcexcl excl, /* ARGSUSED */ static int fdreaddir(vnode_t *vp, uio_t *uiop, cred_t *cr, int *eofp, caller_context_t *ct, - int flags) + int flags) { /* bp holds one dirent structure */ u_offset_t bp[DIRENT64_RECLEN(FDNSIZE) / sizeof (u_offset_t)]; @@ -306,7 +307,8 @@ fdinactive(vnode_t *vp, cred_t *cr, caller_context_t *ct) { mutex_enter(&vp->v_lock); ASSERT(vp->v_count >= 1); - if (--vp->v_count != 0) { + VN_RELE_LOCKED(vp); + if (vp->v_count != 0) { mutex_exit(&vp->v_lock); return; } diff --git a/usr/src/uts/common/fs/fifofs/fifovnops.c b/usr/src/uts/common/fs/fifofs/fifovnops.c index 61edfab76c..ef8d76e8e8 100644 --- a/usr/src/uts/common/fs/fifofs/fifovnops.c +++ b/usr/src/uts/common/fs/fifofs/fifovnops.c @@ -29,6 +29,7 @@ /* * Copyright 2015, Joyent, Inc. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* @@ -435,7 +436,7 @@ done: /*ARGSUSED*/ int fifo_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *crp, - caller_context_t *ct) + caller_context_t *ct) { fifonode_t *fnp = VTOF(vp); fifonode_t *fn_dest = fnp->fn_dest; @@ -656,7 +657,7 @@ fifo_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *crp, static int fifo_read(struct vnode *vp, struct uio *uiop, int ioflag, struct cred *crp, - caller_context_t *ct) + caller_context_t *ct) { fifonode_t *fnp = VTOF(vp); fifonode_t *fn_dest; @@ -842,7 +843,7 @@ done: /*ARGSUSED*/ static int fifo_write(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *crp, - caller_context_t *ct) + caller_context_t *ct) { struct fifonode *fnp, *fn_dest; fifolock_t *fn_lock; @@ -1112,8 +1113,8 @@ epipe: /*ARGSUSED6*/ static int -fifo_ioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, - cred_t *cr, int *rvalp, caller_context_t *ct) +fifo_ioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr, + int *rvalp, caller_context_t *ct) { /* * Just a quick check @@ -1127,8 +1128,8 @@ fifo_ioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, } static int -fifo_fastioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, - cred_t *cr, int *rvalp) +fifo_fastioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr, + int *rvalp) { fifonode_t *fnp = VTOF(vp); fifonode_t *fn_dest; @@ -1385,8 +1386,8 @@ stream_mode: * FIFO is in STREAMS mode; STREAMS framework does most of the work. */ static int -fifo_strioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, - cred_t *cr, int *rvalp) +fifo_strioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr, + int *rvalp) { fifonode_t *fnp = VTOF(vp); int error; @@ -1441,7 +1442,7 @@ fifo_strioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, */ int fifo_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *crp, - caller_context_t *ct) + caller_context_t *ct) { int error = 0; fifonode_t *fnp = VTOF(vp); @@ -1517,12 +1518,8 @@ fifo_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *crp, * Otherwise, set the time and return 0. */ int -fifo_setattr( - vnode_t *vp, - vattr_t *vap, - int flags, - cred_t *crp, - caller_context_t *ctp) +fifo_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *crp, + caller_context_t *ctp) { fifonode_t *fnp = VTOF(vp); int error = 0; @@ -1622,7 +1619,8 @@ fifo_inactive(vnode_t *vp, cred_t *crp, caller_context_t *ct) mutex_enter(&ftable_lock); mutex_enter(&vp->v_lock); ASSERT(vp->v_count >= 1); - if (--vp->v_count != 0) { + VN_RELE_LOCKED(vp); + if (vp->v_count != 0) { /* * Somebody accessed the fifo before we got a chance to * remove it. They will remove it when they do a vn_rele. @@ -1760,7 +1758,7 @@ fifo_realvp(vnode_t *vp, vnode_t **vpp, caller_context_t *ct) /* ARGSUSED */ int fifo_poll(vnode_t *vp, short events, int anyyet, short *reventsp, - pollhead_t **phpp, caller_context_t *ct) + pollhead_t **phpp, caller_context_t *ct) { fifonode_t *fnp, *fn_dest; fifolock_t *fn_lock; @@ -1873,7 +1871,7 @@ stream_mode: /* ARGSUSED */ int fifo_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr, - caller_context_t *ct) + caller_context_t *ct) { ulong_t val; int error = 0; @@ -1947,7 +1945,7 @@ fifo_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr, */ int fifo_setsecattr(struct vnode *vp, vsecattr_t *vsap, int flag, struct cred *crp, - caller_context_t *ct) + caller_context_t *ct) { int error; @@ -1972,7 +1970,7 @@ fifo_setsecattr(struct vnode *vp, vsecattr_t *vsap, int flag, struct cred *crp, */ int fifo_getsecattr(struct vnode *vp, vsecattr_t *vsap, int flag, struct cred *crp, - caller_context_t *ct) + caller_context_t *ct) { if (VTOF(vp)->fn_realvp) return (VOP_GETSECATTR(VTOF(vp)->fn_realvp, vsap, flag, diff --git a/usr/src/uts/common/fs/gfs.c b/usr/src/uts/common/fs/gfs.c index 4d24df60f7..c863e186cf 100644 --- a/usr/src/uts/common/fs/gfs.c +++ b/usr/src/uts/common/fs/gfs.c @@ -23,8 +23,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ #include <sys/types.h> #include <sys/cmn_err.h> @@ -671,7 +672,7 @@ found: } vn_free(vp); } else { - vp->v_count--; + VN_RELE_LOCKED(vp); data = NULL; mutex_exit(&vp->v_lock); if (vp->v_flag & V_XATTRDIR) { diff --git a/usr/src/uts/common/fs/hsfs/hsfs_vnops.c b/usr/src/uts/common/fs/hsfs/hsfs_vnops.c index c928a839d1..09792a3ac6 100644 --- a/usr/src/uts/common/fs/hsfs/hsfs_vnops.c +++ b/usr/src/uts/common/fs/hsfs/hsfs_vnops.c @@ -23,6 +23,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* @@ -157,10 +158,7 @@ int hsched_invoke_strategy(struct hsfs *fsp); /* ARGSUSED */ static int -hsfs_fsync(vnode_t *cp, - int syncflag, - cred_t *cred, - caller_context_t *ct) +hsfs_fsync(vnode_t *cp, int syncflag, cred_t *cred, caller_context_t *ct) { return (0); } @@ -168,11 +166,8 @@ hsfs_fsync(vnode_t *cp, /*ARGSUSED*/ static int -hsfs_read(struct vnode *vp, - struct uio *uiop, - int ioflag, - struct cred *cred, - struct caller_context *ct) +hsfs_read(struct vnode *vp, struct uio *uiop, int ioflag, struct cred *cred, + struct caller_context *ct) { caddr_t base; offset_t diff; @@ -301,12 +296,8 @@ hsfs_read(struct vnode *vp, /*ARGSUSED2*/ static int -hsfs_getattr( - struct vnode *vp, - struct vattr *vap, - int flags, - struct cred *cred, - caller_context_t *ct) +hsfs_getattr(struct vnode *vp, struct vattr *vap, int flags, struct cred *cred, + caller_context_t *ct) { struct hsnode *hp; struct vfs *vfsp; @@ -349,10 +340,8 @@ hsfs_getattr( /*ARGSUSED*/ static int -hsfs_readlink(struct vnode *vp, - struct uio *uiop, - struct cred *cred, - caller_context_t *ct) +hsfs_readlink(struct vnode *vp, struct uio *uiop, struct cred *cred, + caller_context_t *ct) { struct hsnode *hp; @@ -371,9 +360,7 @@ hsfs_readlink(struct vnode *vp, /*ARGSUSED*/ static void -hsfs_inactive(struct vnode *vp, - struct cred *cred, - caller_context_t *ct) +hsfs_inactive(struct vnode *vp, struct cred *cred, caller_context_t *ct) { struct hsnode *hp; struct hsfs *fsp; @@ -397,14 +384,13 @@ hsfs_inactive(struct vnode *vp, /*NOTREACHED*/ } - if (vp->v_count > 1 || (hp->hs_flags & HREF) == 0) { - vp->v_count--; /* release hold from vn_rele */ + VN_RELE_LOCKED(vp); + if (vp->v_count > 0 || (hp->hs_flags & HREF) == 0) { mutex_exit(&vp->v_lock); mutex_exit(&hp->hs_contents_lock); rw_exit(&fsp->hsfs_hash_lock); return; } - vp->v_count--; /* release hold from vn_rele */ if (vp->v_count == 0) { /* * Free the hsnode. @@ -432,17 +418,9 @@ hsfs_inactive(struct vnode *vp, /*ARGSUSED*/ static int -hsfs_lookup( - struct vnode *dvp, - char *nm, - struct vnode **vpp, - struct pathname *pnp, - int flags, - struct vnode *rdir, - struct cred *cred, - caller_context_t *ct, - int *direntflags, - pathname_t *realpnp) +hsfs_lookup(struct vnode *dvp, char *nm, struct vnode **vpp, + struct pathname *pnp, int flags, struct vnode *rdir, struct cred *cred, + caller_context_t *ct, int *direntflags, pathname_t *realpnp) { int error; int namelen = (int)strlen(nm); @@ -470,13 +448,8 @@ hsfs_lookup( /*ARGSUSED*/ static int -hsfs_readdir( - struct vnode *vp, - struct uio *uiop, - struct cred *cred, - int *eofp, - caller_context_t *ct, - int flags) +hsfs_readdir(struct vnode *vp, struct uio *uiop, struct cred *cred, int *eofp, + caller_context_t *ct, int flags) { struct hsnode *dhp; struct hsfs *fsp; @@ -676,23 +649,15 @@ hsfs_fid(struct vnode *vp, struct fid *fidp, caller_context_t *ct) /*ARGSUSED*/ static int -hsfs_open(struct vnode **vpp, - int flag, - struct cred *cred, - caller_context_t *ct) +hsfs_open(struct vnode **vpp, int flag, struct cred *cred, caller_context_t *ct) { return (0); } /*ARGSUSED*/ static int -hsfs_close( - struct vnode *vp, - int flag, - int count, - offset_t offset, - struct cred *cred, - caller_context_t *ct) +hsfs_close(struct vnode *vp, int flag, int count, offset_t offset, + struct cred *cred, caller_context_t *ct) { (void) cleanlocks(vp, ttoproc(curthread)->p_pid, 0); cleanshares(vp, ttoproc(curthread)->p_pid); @@ -701,11 +666,8 @@ hsfs_close( /*ARGSUSED2*/ static int -hsfs_access(struct vnode *vp, - int mode, - int flags, - cred_t *cred, - caller_context_t *ct) +hsfs_access(struct vnode *vp, int mode, int flags, cred_t *cred, + caller_context_t *ct) { return (hs_access(vp, (mode_t)mode, cred)); } @@ -794,17 +756,9 @@ hsfs_ra_task(void *arg) */ /*ARGSUSED*/ static int -hsfs_getpage_ra( - struct vnode *vp, - u_offset_t off, - struct seg *seg, - caddr_t addr, - struct hsnode *hp, - struct hsfs *fsp, - int xarsiz, - offset_t bof, - int chunk_lbn_count, - int chunk_data_bytes) +hsfs_getpage_ra(struct vnode *vp, u_offset_t off, struct seg *seg, + caddr_t addr, struct hsnode *hp, struct hsfs *fsp, int xarsiz, + offset_t bof, int chunk_lbn_count, int chunk_data_bytes) { struct buf *bufs; caddr_t *vas; @@ -1082,17 +1036,9 @@ hsfs_getpage_ra( */ /*ARGSUSED*/ static int -hsfs_getapage( - struct vnode *vp, - u_offset_t off, - size_t len, - uint_t *protp, - struct page *pl[], - size_t plsz, - struct seg *seg, - caddr_t addr, - enum seg_rw rw, - struct cred *cred) +hsfs_getapage(struct vnode *vp, u_offset_t off, size_t len, uint_t *protp, + struct page *pl[], size_t plsz, struct seg *seg, caddr_t addr, + enum seg_rw rw, struct cred *cred) { struct hsnode *hp; struct hsfs *fsp; @@ -1563,18 +1509,9 @@ again: /*ARGSUSED*/ static int -hsfs_getpage( - struct vnode *vp, - offset_t off, - size_t len, - uint_t *protp, - struct page *pl[], - size_t plsz, - struct seg *seg, - caddr_t addr, - enum seg_rw rw, - struct cred *cred, - caller_context_t *ct) +hsfs_getpage(struct vnode *vp, offset_t off, size_t len, uint_t *protp, + struct page *pl[], size_t plsz, struct seg *seg, caddr_t addr, + enum seg_rw rw, struct cred *cred, caller_context_t *ct) { uint_t filsiz; struct hsfs *fsp; @@ -1665,13 +1602,8 @@ hsfs_getpage( */ /*ARGSUSED*/ int -hsfs_putapage( - vnode_t *vp, - page_t *pp, - u_offset_t *offp, - size_t *lenp, - int flags, - cred_t *cr) +hsfs_putapage(vnode_t *vp, page_t *pp, u_offset_t *offp, size_t *lenp, + int flags, cred_t *cr) { /* should never happen - just destroy it */ cmn_err(CE_NOTE, "hsfs_putapage: dirty HSFS page"); @@ -1694,13 +1626,8 @@ hsfs_putapage( */ /*ARGSUSED*/ static int -hsfs_putpage( - struct vnode *vp, - offset_t off, - size_t len, - int flags, - struct cred *cr, - caller_context_t *ct) +hsfs_putpage(struct vnode *vp, offset_t off, size_t len, int flags, + struct cred *cr, caller_context_t *ct) { int error = 0; @@ -1771,17 +1698,9 @@ hsfs_putpage( /*ARGSUSED*/ static int -hsfs_map( - struct vnode *vp, - offset_t off, - struct as *as, - caddr_t *addrp, - size_t len, - uchar_t prot, - uchar_t maxprot, - uint_t flags, - struct cred *cred, - caller_context_t *ct) +hsfs_map(struct vnode *vp, offset_t off, struct as *as, caddr_t *addrp, + size_t len, uchar_t prot, uchar_t maxprot, uint_t flags, struct cred *cred, + caller_context_t *ct) { struct segvn_crargs vn_a; int error; @@ -1833,17 +1752,9 @@ hsfs_map( /* ARGSUSED */ static int -hsfs_addmap( - struct vnode *vp, - offset_t off, - struct as *as, - caddr_t addr, - size_t len, - uchar_t prot, - uchar_t maxprot, - uint_t flags, - struct cred *cr, - caller_context_t *ct) +hsfs_addmap(struct vnode *vp, offset_t off, struct as *as, caddr_t addr, + size_t len, uchar_t prot, uchar_t maxprot, uint_t flags, struct cred *cr, + caller_context_t *ct) { struct hsnode *hp; @@ -1859,17 +1770,9 @@ hsfs_addmap( /*ARGSUSED*/ static int -hsfs_delmap( - struct vnode *vp, - offset_t off, - struct as *as, - caddr_t addr, - size_t len, - uint_t prot, - uint_t maxprot, - uint_t flags, - struct cred *cr, - caller_context_t *ct) +hsfs_delmap(struct vnode *vp, offset_t off, struct as *as, caddr_t addr, + size_t len, uint_t prot, uint_t maxprot, uint_t flags, struct cred *cr, + caller_context_t *ct) { struct hsnode *hp; @@ -1886,26 +1789,17 @@ hsfs_delmap( /* ARGSUSED */ static int -hsfs_seek( - struct vnode *vp, - offset_t ooff, - offset_t *noffp, - caller_context_t *ct) +hsfs_seek(struct vnode *vp, offset_t ooff, offset_t *noffp, + caller_context_t *ct) { return ((*noffp < 0 || *noffp > MAXOFFSET_T) ? EINVAL : 0); } /* ARGSUSED */ static int -hsfs_frlock( - struct vnode *vp, - int cmd, - struct flock64 *bfp, - int flag, - offset_t offset, - struct flk_callback *flk_cbp, - cred_t *cr, - caller_context_t *ct) +hsfs_frlock(struct vnode *vp, int cmd, struct flock64 *bfp, int flag, + offset_t offset, struct flk_callback *flk_cbp, cred_t *cr, + caller_context_t *ct) { struct hsnode *hp = VTOH(vp); @@ -2391,11 +2285,8 @@ hsched_enqueue_io(struct hsfs *fsp, struct hio *hsio, int ra) /* ARGSUSED */ static int -hsfs_pathconf(struct vnode *vp, - int cmd, - ulong_t *valp, - struct cred *cr, - caller_context_t *ct) +hsfs_pathconf(struct vnode *vp, int cmd, ulong_t *valp, struct cred *cr, + caller_context_t *ct) { struct hsfs *fsp; diff --git a/usr/src/uts/common/fs/lofs/lofs_subr.c b/usr/src/uts/common/fs/lofs/lofs_subr.c index 433a76d789..3f9cd6e5de 100644 --- a/usr/src/uts/common/fs/lofs/lofs_subr.c +++ b/usr/src/uts/common/fs/lofs/lofs_subr.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ /* * The idea behind composition-based stacked filesystems is to add a @@ -656,7 +659,7 @@ freelonode(lnode_t *lp) mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; /* release our hold from vn_rele */ + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); TABLE_LOCK_EXIT(lp->lo_vp, li); return; @@ -759,10 +762,8 @@ static int lofsdebug; #ifdef LODEBUG /*VARARGS2*/ -lo_dprint(level, str, a1, a2, a3, a4, a5, a6, a7, a8, a9) - int level; - char *str; - int a1, a2, a3, a4, a5, a6, a7, a8, a9; +lo_dprint(int level, char *str, int a1, int a2, int a3, int a4, int a5, int a6, + int a7, int a8, int a9) { if (lofsdebug == level || (lofsdebug > 10 && (lofsdebug - 10) >= level)) diff --git a/usr/src/uts/common/fs/namefs/namevfs.c b/usr/src/uts/common/fs/namefs/namevfs.c index 13e620d410..6498fea2b8 100644 --- a/usr/src/uts/common/fs/namefs/namevfs.c +++ b/usr/src/uts/common/fs/namefs/namevfs.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -581,7 +582,8 @@ nm_unmount(vfs_t *vfsp, int flag, cred_t *crp) nameremove(nodep); thisvp = NMTOV(nodep); mutex_enter(&thisvp->v_lock); - if (thisvp->v_count-- == 1) { + VN_RELE_LOCKED(thisvp); + if (thisvp->v_count == 0) { fp = nodep->nm_filep; mutex_exit(&thisvp->v_lock); vn_invalid(thisvp); diff --git a/usr/src/uts/common/fs/namefs/namevno.c b/usr/src/uts/common/fs/namefs/namevno.c index 56c732e0fe..7e545cb4f0 100644 --- a/usr/src/uts/common/fs/namefs/namevno.c +++ b/usr/src/uts/common/fs/namefs/namevno.c @@ -24,7 +24,7 @@ /* * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016 by Delphix. All rights reserved. + * Copyright (c) 2016, 2017 by Delphix. All rights reserved. */ /* @@ -162,7 +162,7 @@ gotit: */ static int nm_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *crp, - caller_context_t *ct) + caller_context_t *ct) { struct namenode *nodep = VTONM(vp); int error = 0; @@ -191,21 +191,21 @@ nm_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *crp, static int nm_read(vnode_t *vp, struct uio *uiop, int ioflag, cred_t *crp, - caller_context_t *ct) + caller_context_t *ct) { return (VOP_READ(VTONM(vp)->nm_filevp, uiop, ioflag, crp, ct)); } static int nm_write(vnode_t *vp, struct uio *uiop, int ioflag, cred_t *crp, - caller_context_t *ct) + caller_context_t *ct) { return (VOP_WRITE(VTONM(vp)->nm_filevp, uiop, ioflag, crp, ct)); } static int nm_ioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr, int *rvalp, - caller_context_t *ct) + caller_context_t *ct) { return (VOP_IOCTL(VTONM(vp)->nm_filevp, cmd, arg, mode, cr, rvalp, ct)); } @@ -217,7 +217,7 @@ nm_ioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, cred_t *cr, int *rvalp, /* ARGSUSED */ static int nm_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *crp, - caller_context_t *ct) + caller_context_t *ct) { struct namenode *nodep = VTONM(vp); struct vattr va; @@ -261,12 +261,8 @@ nm_access_unlocked(void *vnp, int mode, cred_t *crp) */ /* ARGSUSED */ static int -nm_setattr( - vnode_t *vp, - vattr_t *vap, - int flags, - cred_t *crp, - caller_context_t *ctp) +nm_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *crp, + caller_context_t *ctp) { struct namenode *nodep = VTONM(vp); struct vattr *nmvap = &nodep->nm_vattr; @@ -334,8 +330,7 @@ out: */ /* ARGSUSED */ static int -nm_access(vnode_t *vp, int mode, int flags, cred_t *crp, - caller_context_t *ct) +nm_access(vnode_t *vp, int mode, int flags, cred_t *crp, caller_context_t *ct) { struct namenode *nodep = VTONM(vp); int error; @@ -356,9 +351,9 @@ nm_access(vnode_t *vp, int mode, int flags, cred_t *crp, */ /*ARGSUSED*/ static int -nm_create(vnode_t *dvp, char *name, vattr_t *vap, enum vcexcl excl, - int mode, vnode_t **vpp, cred_t *cr, int flag, - caller_context_t *ct, vsecattr_t *vsecp) +nm_create(vnode_t *dvp, char *name, vattr_t *vap, enum vcexcl excl, int mode, + vnode_t **vpp, cred_t *cr, int flag, caller_context_t *ct, + vsecattr_t *vsecp) { int error; @@ -378,7 +373,7 @@ nm_create(vnode_t *dvp, char *name, vattr_t *vap, enum vcexcl excl, /*ARGSUSED*/ static int nm_link(vnode_t *tdvp, vnode_t *vp, char *tnm, cred_t *crp, - caller_context_t *ct, int flags) + caller_context_t *ct, int flags) { return (EXDEV); } @@ -399,7 +394,8 @@ nm_inactive(vnode_t *vp, cred_t *crp, caller_context_t *ct) mutex_enter(&vp->v_lock); ASSERT(vp->v_count >= 1); - if (--vp->v_count != 0) { + VN_RELE_LOCKED(vp); + if (vp->v_count != 0) { mutex_exit(&vp->v_lock); return; } @@ -457,7 +453,7 @@ nm_realvp(vnode_t *vp, vnode_t **vpp, caller_context_t *ct) static int nm_poll(vnode_t *vp, short events, int anyyet, short *reventsp, - pollhead_t **phpp, caller_context_t *ct) + pollhead_t **phpp, caller_context_t *ct) { return (VOP_POLL(VTONM(vp)->nm_filevp, events, anyyet, reventsp, phpp, ct)); diff --git a/usr/src/uts/common/fs/nfs/nfs4_client.c b/usr/src/uts/common/fs/nfs/nfs4_client.c index 5438038105..65ccce1c05 100644 --- a/usr/src/uts/common/fs/nfs/nfs4_client.c +++ b/usr/src/uts/common/fs/nfs/nfs4_client.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* @@ -3198,10 +3199,15 @@ nfs4_clnt_init(void) nfs4_mi_destroy); /* - * Initialise the reference count of the notsupp xattr cache vnode to 1 - * so that it never goes away (VOP_INACTIVE isn't called on it). + * Initialize the reference count of the notsupp xattr cache vnode to 1 + * so that it never goes away (VOP_INACTIVE isn't called on it). The + * mutex_enter() isn't necessary for correctness, but VN_HOLD_LOCK() + * asserts that it's held, so we oblige. */ - nfs4_xattr_notsupp_vnode.v_count = 1; + mutex_enter(&nfs4_xattr_notsupp_vnode.v_lock); + nfs4_xattr_notsupp_vnode.v_count = 0; + VN_HOLD_LOCKED(&nfs4_xattr_notsupp_vnode); + mutex_exit(&nfs4_xattr_notsupp_vnode.v_lock); } void diff --git a/usr/src/uts/common/fs/nfs/nfs4_rnode.c b/usr/src/uts/common/fs/nfs/nfs4_rnode.c index 5d3254e478..14abf17329 100644 --- a/usr/src/uts/common/fs/nfs/nfs4_rnode.c +++ b/usr/src/uts/common/fs/nfs/nfs4_rnode.c @@ -30,6 +30,7 @@ /* * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ #include <sys/param.h> @@ -603,7 +604,7 @@ start: rw_enter(&rp->r_hashq->r_lock, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&rp->r_hashq->r_lock); rw_enter(&rhtp->r_lock, RW_READER); @@ -618,7 +619,7 @@ start: mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_enter(&rhtp->r_lock, RW_READER); goto start; @@ -785,7 +786,7 @@ rp4_addfree(rnode4_t *rp, cred_t *cr) rw_enter(&rp->r_hashq->r_lock, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&rp->r_hashq->r_lock); return; @@ -827,7 +828,7 @@ rp4_addfree(rnode4_t *rp, cred_t *cr) */ mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); return; } @@ -850,7 +851,7 @@ again: mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&rp->r_hashq->r_lock); return; @@ -1552,7 +1553,7 @@ nfs4_rnode_reclaim(void) rw_enter(&rp->r_hashq->r_lock, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&rp->r_hashq->r_lock); mutex_enter(&rp4freelist_lock); diff --git a/usr/src/uts/common/fs/nfs/nfs4_shadow.c b/usr/src/uts/common/fs/nfs/nfs4_shadow.c index 18d3fbff58..1675199469 100644 --- a/usr/src/uts/common/fs/nfs/nfs4_shadow.c +++ b/usr/src/uts/common/fs/nfs/nfs4_shadow.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ #include <sys/systm.h> @@ -303,7 +306,7 @@ sv_inactive(vnode_t *vp) mutex_enter(&vp->v_lock); /* check if someone slipped in while locks were dropped */ if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); mutex_exit(&rp->r_svlock); return; diff --git a/usr/src/uts/common/fs/nfs/nfs_subr.c b/usr/src/uts/common/fs/nfs/nfs_subr.c index 96844660f4..cda666c27e 100644 --- a/usr/src/uts/common/fs/nfs/nfs_subr.c +++ b/usr/src/uts/common/fs/nfs/nfs_subr.c @@ -25,7 +25,7 @@ /* * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2016 by Delphix. All rights reserved. + * Copyright (c) 2016, 2017 by Delphix. All rights reserved. */ #include <sys/param.h> @@ -2490,7 +2490,7 @@ start: rw_enter(&rp->r_hashq->r_lock, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&rp->r_hashq->r_lock); rw_enter(&rhtp->r_lock, RW_READER); @@ -2505,7 +2505,7 @@ start: mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_enter(&rhtp->r_lock, RW_READER); goto start; @@ -2698,7 +2698,7 @@ rp_addfree(rnode_t *rp, cred_t *cr) rw_enter(&rp->r_hashq->r_lock, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&rp->r_hashq->r_lock); return; @@ -2731,7 +2731,7 @@ rp_addfree(rnode_t *rp, cred_t *cr) */ mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); return; } @@ -2753,7 +2753,7 @@ rp_addfree(rnode_t *rp, cred_t *cr) mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&rp->r_hashq->r_lock); return; @@ -4081,7 +4081,7 @@ nfs_rnode_reclaim(void) rw_enter(&rp->r_hashq->r_lock, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&rp->r_hashq->r_lock); mutex_enter(&rpfreelist_lock); diff --git a/usr/src/uts/common/fs/pcfs/pc_node.c b/usr/src/uts/common/fs/pcfs/pc_node.c index fb304f35fe..84a29f4430 100644 --- a/usr/src/uts/common/fs/pcfs/pc_node.c +++ b/usr/src/uts/common/fs/pcfs/pc_node.c @@ -22,6 +22,9 @@ * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ #include <sys/param.h> #include <sys/t_lock.h> @@ -259,7 +262,7 @@ retry: } ASSERT(!vn_has_cached_data(vp)); - vp->v_count--; /* release our hold from vn_rele */ + VN_RELE_LOCKED(vp); if (vp->v_count > 0) { /* Is this check still needed? */ PC_DPRINTF1(3, "pc_rele: pcp=0x%p HELD AGAIN!\n", (void *)pcp); mutex_exit(&vp->v_lock); diff --git a/usr/src/uts/common/fs/pcfs/pc_vnops.c b/usr/src/uts/common/fs/pcfs/pc_vnops.c index ae72cada7a..b307fe11d7 100644 --- a/usr/src/uts/common/fs/pcfs/pc_vnops.c +++ b/usr/src/uts/common/fs/pcfs/pc_vnops.c @@ -27,6 +27,7 @@ /* * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ #include <sys/param.h> @@ -948,7 +949,7 @@ pcfs_inactive( mutex_enter(&vp->v_lock); ASSERT(vp->v_count >= 1); if (vp->v_count > 1) { - vp->v_count--; /* release our hold from vn_rele */ + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); pc_unlockfs(fsp); return; diff --git a/usr/src/uts/common/fs/proc/prvnops.c b/usr/src/uts/common/fs/proc/prvnops.c index 93a3d68ea5..462d62dcd7 100644 --- a/usr/src/uts/common/fs/proc/prvnops.c +++ b/usr/src/uts/common/fs/proc/prvnops.c @@ -22,6 +22,7 @@ /* * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Joyent, Inc. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -5813,7 +5814,7 @@ prinactive(vnode_t *vp, cred_t *cr, caller_context_t *ct) mutex_enter(&vp->v_lock); if (type == PR_PROCDIR || vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); if (p != NULL) mutex_exit(&p->p_lock); diff --git a/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_subr2.c b/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_subr2.c index 025bc0b3ec..2d7cf7f75a 100644 --- a/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_subr2.c +++ b/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_subr2.c @@ -25,6 +25,9 @@ * Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. * All rights reserved. */ +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ /* * Node hash implementation initially borrowed from NFS (nfs_subr.c) @@ -354,7 +357,7 @@ start: rw_enter(&tmp_mi->smi_hash_lk, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&tmp_mi->smi_hash_lk); /* start over */ @@ -370,7 +373,7 @@ start: mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_enter(&mi->smi_hash_lk, RW_READER); goto start; @@ -533,7 +536,7 @@ smbfs_addfree(smbnode_t *np) rw_enter(&mi->smi_hash_lk, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&mi->smi_hash_lk); return; @@ -570,7 +573,7 @@ smbfs_addfree(smbnode_t *np) */ mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); return; } @@ -592,7 +595,7 @@ smbfs_addfree(smbnode_t *np) mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&mi->smi_hash_lk); return; @@ -1137,7 +1140,7 @@ smbfs_node_reclaim(void) rw_enter(&mi->smi_hash_lk, RW_WRITER); mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&mi->smi_hash_lk); mutex_enter(&smbfreelist_lock); diff --git a/usr/src/uts/common/fs/sockfs/sockcommon_vnops.c b/usr/src/uts/common/fs/sockfs/sockcommon_vnops.c index ffcecfa7c1..d49bdbcc6d 100644 --- a/usr/src/uts/common/fs/sockfs/sockcommon_vnops.c +++ b/usr/src/uts/common/fs/sockfs/sockcommon_vnops.c @@ -23,6 +23,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ #include <sys/types.h> #include <sys/t_lock.h> @@ -434,10 +437,8 @@ socket_vop_inactive(struct vnode *vp, struct cred *cr, caller_context_t *ct) if (vp->v_count < 1) cmn_err(CE_PANIC, "socket_inactive: Bad v_count"); - /* - * Drop the temporary hold by vn_rele now - */ - if (--vp->v_count != 0) { + VN_RELE_LOCKED(vp); + if (vp->v_count != 0) { mutex_exit(&vp->v_lock); return; } diff --git a/usr/src/uts/common/fs/specfs/specvnops.c b/usr/src/uts/common/fs/specfs/specvnops.c index 5cbbd2e1d3..e6f732c04b 100644 --- a/usr/src/uts/common/fs/specfs/specvnops.c +++ b/usr/src/uts/common/fs/specfs/specvnops.c @@ -22,6 +22,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -1581,10 +1582,8 @@ spec_inactive(struct vnode *vp, struct cred *cr, caller_context_t *ct) mutex_enter(&stable_lock); mutex_enter(&vp->v_lock); - /* - * Drop the temporary hold by vn_rele now - */ - if (--vp->v_count != 0) { + VN_RELE_LOCKED(vp); + if (vp->v_count != 0) { mutex_exit(&vp->v_lock); mutex_exit(&stable_lock); return; diff --git a/usr/src/uts/common/fs/tmpfs/tmp_vnops.c b/usr/src/uts/common/fs/tmpfs/tmp_vnops.c index 747d280915..a356f22750 100644 --- a/usr/src/uts/common/fs/tmpfs/tmp_vnops.c +++ b/usr/src/uts/common/fs/tmpfs/tmp_vnops.c @@ -28,6 +28,7 @@ * Copyright 2016 Joyent, Inc. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright 2016 RackTop Systems. + * Copyright (c) 2017 by Delphix. All rights reserved. */ #include <sys/types.h> @@ -1720,9 +1721,9 @@ top: * don't decrement in this case. */ if (vp->v_count > 1) - vp->v_count--; + VN_RELE_LOCKED(vp); } else { - vp->v_count--; + VN_RELE_LOCKED(vp); } mutex_exit(&vp->v_lock); mutex_exit(&tp->tn_tlock); diff --git a/usr/src/uts/common/fs/udfs/udf_inode.c b/usr/src/uts/common/fs/udfs/udf_inode.c index 749e5a922f..1004b90d17 100644 --- a/usr/src/uts/common/fs/udfs/udf_inode.c +++ b/usr/src/uts/common/fs/udfs/udf_inode.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ #include <sys/types.h> @@ -158,8 +159,8 @@ ud_search_icache(struct vfs *vfsp, uint16_t prn, uint32_t ploc) /* ARGSUSED */ int -ud_iget(struct vfs *vfsp, uint16_t prn, uint32_t ploc, - struct ud_inode **ipp, struct buf *pbp, struct cred *cred) +ud_iget(struct vfs *vfsp, uint16_t prn, uint32_t ploc, struct ud_inode **ipp, + struct buf *pbp, struct cred *cred) { int32_t hno, nomem = 0, icb_tag_flags; union ihead *ih; @@ -476,7 +477,7 @@ error_ret: * It remains in the cache. Put it back on the freelist. */ mutex_enter(&vp->v_lock); - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); ip->i_icb_lbano = 0; @@ -962,7 +963,7 @@ ud_iinactive(struct ud_inode *ip, struct cred *cr) return; } if ((vp->v_count > 1) || ((ip->i_flag & IREF) == 0)) { - vp->v_count--; /* release our hold from vn_rele */ + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&ip->i_contents); return; @@ -1029,7 +1030,7 @@ ud_iinactive(struct ud_inode *ip, struct cred *cr) */ mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&ip->i_contents); return; @@ -1064,7 +1065,7 @@ tryagain: if (vn_has_cached_data(vp)) { mutex_exit(&ud_nino_lock); mutex_enter(&vp->v_lock); - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); mutex_enter(&ip->i_tlock); mutex_enter(&udf_ifree_lock); @@ -1084,7 +1085,7 @@ tryagain: if (vn_has_cached_data(vp)) { cmn_err(CE_WARN, "ud_iinactive: v_pages not NULL\n"); } - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); mutex_enter(&ip->i_tlock); @@ -2036,15 +2037,13 @@ ud_idrop(struct ud_inode *ip) ud_printf("ud_idrop\n"); mutex_enter(&vp->v_lock); - if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); + if (vp->v_count > 0) { mutex_exit(&vp->v_lock); return; } - vp->v_count = 0; mutex_exit(&vp->v_lock); - /* * if inode is invalid or there is no page associated with * this inode, put the inode in the front of the free list diff --git a/usr/src/uts/common/fs/ufs/ufs_inode.c b/usr/src/uts/common/fs/ufs/ufs_inode.c index ef09f7d32c..05f23a6d29 100644 --- a/usr/src/uts/common/fs/ufs/ufs_inode.c +++ b/usr/src/uts/common/fs/ufs/ufs_inode.c @@ -20,7 +20,7 @@ */ /* * Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016 by Delphix. All rights reserved. + * Copyright (c) 2016, 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -702,7 +702,7 @@ ufs_iinactive(struct inode *ip) mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; /* release our hold from vn_rele */ + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&ip->i_contents); return; @@ -745,7 +745,7 @@ ufs_iinactive(struct inode *ip) */ if (ULOCKFS_IS_NOIDEL(ITOUL(ip))) { mutex_enter(&vp->v_lock); - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&ip->i_contents); return; @@ -786,7 +786,7 @@ ufs_iinactive(struct inode *ip) */ mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; /* release our hold from vn_rele */ + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); rw_exit(&ip->i_contents); return; @@ -1616,7 +1616,7 @@ ufs_rmidle(struct inode *ip) */ int ufs_scan_inodes(int rwtry, int (*func)(struct inode *, void *), void *arg, - struct ufsvfs *ufsvfsp) + struct ufsvfs *ufsvfsp) { struct inode *ip; /* current inode */ struct inode *lip = NULL; /* last/previous inode */ diff --git a/usr/src/uts/common/fs/ufs/ufs_thread.c b/usr/src/uts/common/fs/ufs/ufs_thread.c index 9ea1d8c980..3cd9fdeb0b 100644 --- a/usr/src/uts/common/fs/ufs/ufs_thread.c +++ b/usr/src/uts/common/fs/ufs/ufs_thread.c @@ -27,6 +27,10 @@ /* All Rights Reserved */ /* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ + +/* * Portions of this source code were derived from Berkeley 4.3 BSD * under license from the Regents of the University of California. */ @@ -52,7 +56,7 @@ #include <sys/sysmacros.h> #include <vm/pvn.h> -extern pri_t minclsyspri; +extern pri_t minclsyspri; extern int hash2ints(); extern struct kmem_cache *inode_cache; /* cache of free inodes */ extern int ufs_idle_waiters; @@ -679,17 +683,18 @@ ufs_idle_free(struct inode *ip) /* * It must be guaranteed that v_count >= 2, otherwise * something must be wrong with this vnode already. - * That is why we use v_count-- instead of VN_RELE(). + * That is why we use VN_RELE_LOCKED() instead of VN_RELE(). * Acquire the vnode lock in case another thread is in * VN_RELE(). */ mutex_enter(&vp->v_lock); - if (vp->v_count < 2) + if (vp->v_count < 2) { cmn_err(CE_PANIC, "ufs_idle_free: vnode ref count is less than 2"); + } - vp->v_count--; + VN_RELE_LOCKED(vp); vn_has_data = (vp->v_type != VCHR && vn_has_cached_data(vp)); vn_modified = (ip->i_flag & (IMOD|IMODACC|IACC|ICHG|IUPD|IATTCHG)); diff --git a/usr/src/uts/common/fs/vnode.c b/usr/src/uts/common/fs/vnode.c index d2562caa58..8ff9905af3 100644 --- a/usr/src/uts/common/fs/vnode.c +++ b/usr/src/uts/common/fs/vnode.c @@ -23,6 +23,7 @@ * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2017 Joyent, Inc. * Copyright 2016 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2011, 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -847,7 +848,7 @@ vn_rele(vnode_t *vp) VOP_INACTIVE(vp, CRED(), NULL); return; } - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); } @@ -868,15 +869,15 @@ vn_rele_dnlc(vnode_t *vp) VOP_INACTIVE(vp, CRED(), NULL); return; } - vp->v_count--; + VN_RELE_LOCKED(vp); } mutex_exit(&vp->v_lock); } /* * Like vn_rele() except that it clears v_stream under v_lock. - * This is used by sockfs when it dismantels the association between - * the sockfs node and the vnode in the underlaying file system. + * This is used by sockfs when it dismantles the association between + * the sockfs node and the vnode in the underlying file system. * v_lock has to be held to prevent a thread coming through the lookupname * path from accessing a stream head that is going away. */ @@ -891,7 +892,7 @@ vn_rele_stream(vnode_t *vp) VOP_INACTIVE(vp, CRED(), NULL); return; } - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); } @@ -922,7 +923,7 @@ vn_rele_async(vnode_t *vp, taskq_t *taskq) vp, TQ_SLEEP) != NULL); return; } - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); } diff --git a/usr/src/uts/common/fs/xattr.c b/usr/src/uts/common/fs/xattr.c index 3f5e4078db..7373aaddbe 100644 --- a/usr/src/uts/common/fs/xattr.c +++ b/usr/src/uts/common/fs/xattr.c @@ -1174,16 +1174,25 @@ xattr_dir_access(vnode_t *vp, int mode, int flags, cred_t *cr, return (EACCES); } - /* - * If there is a real xattr directory, check access there; - * otherwise just return success. - */ error = xattr_dir_realdir(vp, &realvp, LOOKUP_XATTR, cr, ct); - if (error == 0) { - error = VOP_ACCESS(realvp, mode, flags, cr, ct); - } else { - error = 0; + if ((error == ENOENT || error == EINVAL)) { + /* + * These errors mean there's no "real" xattr dir. + * The GFS xattr dir always allows access. + */ + return (0); } + if (error != 0) { + /* + * The "real" xattr dir was not accessible. + */ + return (error); + } + /* + * We got the "real" xattr dir. + * Pass through the access call. + */ + error = VOP_ACCESS(realvp, mode, flags, cr, ct); return (error); } diff --git a/usr/src/uts/common/fs/zfs/zfs_ctldir.c b/usr/src/uts/common/fs/zfs/zfs_ctldir.c index ec9cd27225..f72a1a064a 100644 --- a/usr/src/uts/common/fs/zfs/zfs_ctldir.c +++ b/usr/src/uts/common/fs/zfs/zfs_ctldir.c @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2017 by Delphix. All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. */ @@ -1210,7 +1210,7 @@ zfsctl_snapshot_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct) mutex_enter(&vp->v_lock); if (vp->v_count > 1) { - vp->v_count--; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); mutex_exit(&sdp->sd_lock); VN_RELE(dvp); diff --git a/usr/src/uts/common/fs/zfs/zfs_vnops.c b/usr/src/uts/common/fs/zfs/zfs_vnops.c index 9e55c30f79..efe36b7f10 100644 --- a/usr/src/uts/common/fs/zfs/zfs_vnops.c +++ b/usr/src/uts/common/fs/zfs/zfs_vnops.c @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2017 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Joyent, Inc. * Copyright 2017 Nexenta Systems, Inc. @@ -1821,7 +1821,7 @@ top: ASSERT0(error); } mutex_enter(&vp->v_lock); - vp->v_count--; + VN_RELE_LOCKED(vp); ASSERT0(vp->v_count); mutex_exit(&vp->v_lock); mutex_exit(&zp->z_lock); @@ -4414,7 +4414,7 @@ zfs_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct) mutex_enter(&zp->z_lock); mutex_enter(&vp->v_lock); ASSERT(vp->v_count == 1); - vp->v_count = 0; + VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); mutex_exit(&zp->z_lock); rw_exit(&zfsvfs->z_teardown_inactive_lock); diff --git a/usr/src/uts/common/fs/zfs/zfs_znode.c b/usr/src/uts/common/fs/zfs/zfs_znode.c index ccc9be21b5..b76d86fca2 100644 --- a/usr/src/uts/common/fs/zfs/zfs_znode.c +++ b/usr/src/uts/common/fs/zfs/zfs_znode.c @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2012, 2017 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -1293,7 +1293,7 @@ zfs_zinactive(znode_t *zp) mutex_enter(&zp->z_lock); mutex_enter(&vp->v_lock); - vp->v_count--; + VN_RELE_LOCKED(vp); if (vp->v_count > 0 || vn_has_cached_data(vp)) { /* * If the hold count is greater than zero, somebody has diff --git a/usr/src/uts/common/io/dls/dls_mgmt.c b/usr/src/uts/common/io/dls/dls_mgmt.c index 31d7565bff..8213f78e8a 100644 --- a/usr/src/uts/common/io/dls/dls_mgmt.c +++ b/usr/src/uts/common/io/dls/dls_mgmt.c @@ -23,6 +23,9 @@ * Use is subject to license terms. * Copyright 2016 Joyent, Inc. */ +/* + * Copyright (c) 2016 by Delphix. All rights reserved. + */ /* * Datalink management routines. @@ -80,9 +83,9 @@ boolean_t devnet_need_rebuild; /* Upcall door handle */ static door_handle_t dls_mgmt_dh = NULL; +/* dls_devnet_t dd_flags */ #define DD_CONDEMNED 0x1 -#define DD_KSTAT_CHANGING 0x2 -#define DD_IMPLICIT_IPTUN 0x4 /* Implicitly-created ip*.*tun* tunnel */ +#define DD_IMPLICIT_IPTUN 0x2 /* Implicitly-created ip*.*tun* tunnel */ /* * This structure is used to keep the <linkid, macname> mapping. @@ -731,27 +734,20 @@ dls_devnet_rele_link(dls_dl_handle_t dlh, dls_link_t *dlp) static int dls_devnet_stat_update(kstat_t *ksp, int rw) { - dls_devnet_t *ddp = ksp->ks_private; + datalink_id_t linkid = (datalink_id_t)(uintptr_t)ksp->ks_private; + dls_devnet_t *ddp; dls_link_t *dlp; int err; - /* - * Check the link is being renamed or if the link is going away - * before incrementing dd_tref which in turn prevents the link - * from being renamed or deleted until we finish. - */ - mutex_enter(&ddp->dd_mutex); - if (ddp->dd_flags & (DD_CONDEMNED | DD_KSTAT_CHANGING)) { - mutex_exit(&ddp->dd_mutex); - return (ENOENT); + if ((err = dls_devnet_hold_tmp(linkid, &ddp)) != 0) { + return (err); } - ddp->dd_tref++; - mutex_exit(&ddp->dd_mutex); /* * If a device detach happens at this time, it will block in - * dls_devnet_unset since the dd_tref has been bumped up above. So the - * access to 'dlp' is safe even though we don't hold the mac perimeter. + * dls_devnet_unset since the dd_tref has been bumped in + * dls_devnet_hold_tmp(). So the access to 'dlp' is safe even though + * we don't hold the mac perimeter. */ if (mod_hash_find(i_dls_link_hash, (mod_hash_key_t)ddp->dd_mac, (mod_hash_val_t *)&dlp) != 0) { @@ -784,8 +780,9 @@ dls_devnet_stat_create(dls_devnet_t *ddp, zoneid_t zoneid, zoneid_t newzoneid) nm = ddp->dd_linkname; } - if (dls_stat_create("link", 0, nm, zoneid, - dls_devnet_stat_update, ddp, &ksp, newzoneid) == 0) { + if (dls_stat_create("link", 0, ddp->dd_linkname, zoneid, + dls_devnet_stat_update, (void *)(uintptr_t)ddp->dd_linkid, + &ksp, newzoneid) == 0) { ASSERT(ksp != NULL); if (zoneid == ddp->dd_owner_zid) { ASSERT(ddp->dd_ksp == NULL); @@ -1140,7 +1137,7 @@ dls_devnet_hold_common(datalink_id_t linkid, dls_devnet_t **ddpp, if (dls_mgmt_get_phydev(linkid, &phydev) == 0) (void) softmac_hold_device(phydev, &ddh); - rw_enter(&i_dls_devnet_lock, RW_WRITER); + rw_enter(&i_dls_devnet_lock, RW_READER); if ((err = mod_hash_find(i_dls_devnet_id_hash, (mod_hash_key_t)(uintptr_t)linkid, (mod_hash_val_t *)&ddp)) != 0) { ASSERT(err == MH_ERR_NOTFOUND); @@ -1221,7 +1218,7 @@ dls_devnet_hold_by_dev(dev_t dev, dls_dl_handle_t *ddhp) if (DLS_MINOR2INST(getminor(dev)) <= DLS_MAX_PPA) (void) softmac_hold_device(dev, &ddh); - rw_enter(&i_dls_devnet_lock, RW_WRITER); + rw_enter(&i_dls_devnet_lock, RW_READER); if ((err = mod_hash_find(i_dls_devnet_hash, (mod_hash_key_t)name, (mod_hash_val_t *)&ddp)) != 0) { ASSERT(err == MH_ERR_NOTFOUND); @@ -1430,7 +1427,6 @@ dls_devnet_rename(datalink_id_t id1, datalink_id_t id2, const char *link, mac_perim_handle_t mph = NULL; mac_handle_t mh; mod_hash_val_t val; - boolean_t clear_dd_flag = B_FALSE; /* * In the second case, id2 must be a REMOVED physical link. @@ -1466,14 +1462,6 @@ dls_devnet_rename(datalink_id_t id1, datalink_id_t id2, const char *link, goto done; } - /* - * Return EBUSY if any applications have this link open, if any thread - * is currently accessing the link kstats, or if the link is on-loan - * to a non-global zone. Then set the DD_KSTAT_CHANGING flag to - * prevent any access to the kstats while we delete and recreate - * kstats below. However, we skip this check if we're renaming the - * vnic as part of bringing it up for a zone. - */ mutex_enter(&ddp->dd_mutex); if (!zoneinit) { if (ddp->dd_ref > 1) { @@ -1482,9 +1470,6 @@ dls_devnet_rename(datalink_id_t id1, datalink_id_t id2, const char *link, goto done; } } - - ddp->dd_flags |= DD_KSTAT_CHANGING; - clear_dd_flag = B_TRUE; mutex_exit(&ddp->dd_mutex); if (id2 == DATALINK_INVALID_LINKID) { @@ -1566,23 +1551,11 @@ dls_devnet_rename(datalink_id_t id1, datalink_id_t id2, const char *link, mutex_exit(&ddp->dd_mutex); done: - /* - * Change the name of the kstat based on the new link name. - * We can't hold the i_dls_devnet_lock across calls to the kstat - * subsystem. Instead the DD_KSTAT_CHANGING flag set above in this - * function prevents any access to the dd_ksp while we delete and - * recreate it below. - */ rw_exit(&i_dls_devnet_lock); + if (err == 0) dls_devnet_stat_rename(ddp, zoneinit); - if (clear_dd_flag) { - mutex_enter(&ddp->dd_mutex); - ddp->dd_flags &= ~DD_KSTAT_CHANGING; - mutex_exit(&ddp->dd_mutex); - } - if (mph != NULL) mac_perim_exit(mph); softmac_rele_device(ddh); diff --git a/usr/src/uts/common/os/contract.c b/usr/src/uts/common/os/contract.c index 9ea08f5535..1a3502a710 100644 --- a/usr/src/uts/common/os/contract.c +++ b/usr/src/uts/common/os/contract.c @@ -23,6 +23,9 @@ * Use is subject to license terms. * Copyright 2016 Joyent, Inc. */ +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ /* * Contracts @@ -895,7 +898,7 @@ contract_vnode_clear(contract_t *ct, contract_vnode_t *ctv) list_remove(&ct->ct_vnodes, ctv); result = 1; } else { - vp->v_count--; + VN_RELE_LOCKED(vp); result = 0; } mutex_exit(&vp->v_lock); diff --git a/usr/src/uts/common/os/driver.c b/usr/src/uts/common/os/driver.c index fa992e5e45..c6ef9ee367 100644 --- a/usr/src/uts/common/os/driver.c +++ b/usr/src/uts/common/os/driver.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ #include <sys/types.h> #include <sys/t_lock.h> @@ -363,7 +366,7 @@ dev_lclose(dev_t dev, int flag, int otype, struct cred *cred) mutex_enter(&cvp->v_lock); switch (cvp->v_count) { default: - cvp->v_count--; + VN_RELE_LOCKED(cvp); break; case 0: @@ -570,7 +573,7 @@ cdev_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, struct cred *cred, int cdev_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len, - size_t *maplen, uint_t mode) + size_t *maplen, uint_t mode) { struct cb_ops *cb; @@ -586,7 +589,7 @@ cdev_mmap(int (*mapfunc)(dev_t, off_t, int), dev_t dev, off_t off, int prot) int cdev_segmap(dev_t dev, off_t off, struct as *as, caddr_t *addrp, off_t len, - uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp) + uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp) { struct cb_ops *cb; @@ -597,7 +600,7 @@ cdev_segmap(dev_t dev, off_t off, struct as *as, caddr_t *addrp, off_t len, int cdev_poll(dev_t dev, short events, int anyyet, short *reventsp, - struct pollhead **pollhdrp) + struct pollhead **pollhdrp) { struct cb_ops *cb; diff --git a/usr/src/uts/common/sys/fs/sdev_impl.h b/usr/src/uts/common/sys/fs/sdev_impl.h index 5fbef16470..d1c5f674f1 100644 --- a/usr/src/uts/common/sys/fs/sdev_impl.h +++ b/usr/src/uts/common/sys/fs/sdev_impl.h @@ -21,7 +21,7 @@ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015, 2016 Joyent, Inc. All rights reserved. - * Copyright (c) 2014 by Delphix. All rights reserved. + * Copyright (c) 2014, 2017 by Delphix. All rights reserved. */ #ifndef _SYS_SDEV_IMPL_H @@ -237,9 +237,10 @@ typedef enum { #define SDEV_HOLD(dv) VN_HOLD(SDEVTOV(dv)) #define SDEV_RELE(dv) VN_RELE(SDEVTOV(dv)) #define SDEV_SIMPLE_RELE(dv) { \ - mutex_enter(&SDEVTOV(dv)->v_lock); \ - SDEVTOV(dv)->v_count--; \ - mutex_exit(&SDEVTOV(dv)->v_lock); \ + struct vnode *vp = SDEVTOV(dv); \ + mutex_enter(&vp->v_lock); \ + VN_RELE_LOCKED(vp); \ + mutex_exit(&vp->v_lock); \ } #define SDEV_ACL_FLAVOR(vp) (VFSTOSDEVFS(vp->v_vfsp)->sdev_acl_flavor) diff --git a/usr/src/uts/common/sys/vnode.h b/usr/src/uts/common/sys/vnode.h index 3ce834ae13..5926c366eb 100644 --- a/usr/src/uts/common/sys/vnode.h +++ b/usr/src/uts/common/sys/vnode.h @@ -22,6 +22,7 @@ /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Joyent, Inc. + * Copyright (c) 2011, 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -53,6 +54,7 @@ #include <sys/list.h> #ifdef _KERNEL #include <sys/buf.h> +#include <sys/sdt.h> #endif /* _KERNEL */ #ifdef __cplusplus @@ -1416,10 +1418,32 @@ extern char *vn_vpath_empty; */ extern uint_t pvn_vmodsort_supported; -#define VN_HOLD(vp) { \ - mutex_enter(&(vp)->v_lock); \ - (vp)->v_count++; \ - mutex_exit(&(vp)->v_lock); \ +/* + * All changes to v_count should be done through VN_HOLD() or VN_RELE(), or + * one of their variants. This makes it possible to ensure proper locking, + * and to guarantee that all modifications are accompanied by a firing of + * the vn-hold or vn-rele SDT DTrace probe. + * + * Example DTrace command for tracing vnode references using these probes: + * + * dtrace -q -n 'sdt:::vn-hold,sdt:::vn-rele + * { + * this->vp = (vnode_t *)arg0; + * printf("%s %s(%p[%s]) %d\n", execname, probename, this->vp, + * this->vp->v_path == NULL ? "NULL" : stringof(this->vp->v_path), + * this->vp->v_count) + * }' + */ +#define VN_HOLD_LOCKED(vp) { \ + ASSERT(mutex_owned(&(vp)->v_lock)); \ + (vp)->v_count++; \ + DTRACE_PROBE1(vn__hold, vnode_t *, vp); \ +} + +#define VN_HOLD(vp) { \ + mutex_enter(&(vp)->v_lock); \ + VN_HOLD_LOCKED(vp); \ + mutex_exit(&(vp)->v_lock); \ } #define VN_RELE(vp) { \ @@ -1430,6 +1454,13 @@ extern uint_t pvn_vmodsort_supported; vn_rele_async(vp, taskq); \ } +#define VN_RELE_LOCKED(vp) { \ + ASSERT(mutex_owned(&(vp)->v_lock)); \ + ASSERT((vp)->v_count >= 1); \ + (vp)->v_count--; \ + DTRACE_PROBE1(vn__rele, vnode_t *, vp); \ +} + #define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \ (vp)->v_vfsp = (vfsp); \ (vp)->v_type = (type); \ |