summaryrefslogtreecommitdiff
path: root/usr/src/lib/libbsm/common/devalloc.c
diff options
context:
space:
mode:
authoraj <none@none>2007-06-21 10:39:47 -0700
committeraj <none@none>2007-06-21 10:39:47 -0700
commit10ddde3aee60d88fa580028fcf7642a87e80a2c6 (patch)
treed7d477bfb38c88169915ac216139ad9f3a669179 /usr/src/lib/libbsm/common/devalloc.c
parentf9aa3e1e897e74b50458e34d6c88abb9a7a08aed (diff)
downloadillumos-gate-10ddde3aee60d88fa580028fcf7642a87e80a2c6.tar.gz
6535551 TX DA GUI behaves incorrectly if multiple rapid updates to TX DA database are done
6542809 TX: add_allocatable/remove_allocatable don't play well with other instances of themselves 6545689 device_clean scripts should be able to return a "CANCEL" return code 6549055 TX: deallocate(1), list_devices(1) should allow operation on classes of devices
Diffstat (limited to 'usr/src/lib/libbsm/common/devalloc.c')
-rw-r--r--usr/src/lib/libbsm/common/devalloc.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/usr/src/lib/libbsm/common/devalloc.c b/usr/src/lib/libbsm/common/devalloc.c
index 08db0f0325..e39b57fa23 100644
--- a/usr/src/lib/libbsm/common/devalloc.c
+++ b/usr/src/lib/libbsm/common/devalloc.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -849,6 +849,11 @@ int
_da_lock_devdb(char *rootdir)
{
int lockfd = -1;
+ int ret;
+ int count = 0;
+ int retry = 10;
+ int retry_sleep;
+ uint_t seed;
char *lockfile;
char path[MAXPATHLEN];
int size = sizeof (path);
@@ -873,14 +878,27 @@ _da_lock_devdb(char *rootdir)
(void) close(lockfd);
return (-1);
}
- if (lockf(lockfd, F_TLOCK, 0) == -1) {
- /* cannot set lock */
- (void) close(lockfd);
- return (-1);
+ errno = 0;
+ while (retry > 0) {
+ count++;
+ seed = (uint_t)gethrtime();
+ ret = lockf(lockfd, F_TLOCK, 0);
+ if (ret == 0) {
+ (void) utime(lockfile, NULL);
+ return (lockfd);
+ }
+ if ((errno != EACCES) && (errno != EAGAIN)) {
+ /* cannot set lock */
+ (void) close(lockfd);
+ return (-1);
+ }
+ retry--;
+ retry_sleep = rand_r(&seed)/((RAND_MAX + 2)/3) + count;
+ (void) sleep(retry_sleep);
+ errno = 0;
}
- (void) utime(lockfile, NULL);
- return (lockfd);
+ return (-1);
}
/*
@@ -1160,10 +1178,10 @@ da_update_device(da_args *dargs)
int tafd = -1, tmfd = -1;
int lockfd = -1;
char *rootdir = NULL;
- char *apathp = NULL, *mpathp = NULL, *dapathp = NULL,
- *dmpathp = NULL;
- char apath[MAXPATHLEN], mpath[MAXPATHLEN],
- dapath[MAXPATHLEN], dmpath[MAXPATHLEN];
+ char *apathp = NULL, *mpathp = NULL;
+ char *dapathp = NULL, *dmpathp = NULL;
+ char apath[MAXPATHLEN], mpath[MAXPATHLEN];
+ char dapath[MAXPATHLEN], dmpath[MAXPATHLEN];
FILE *tafp = NULL, *tmfp = NULL, *dafp = NULL;
struct stat dastat;
devinfo_t *devinfo;
@@ -1620,12 +1638,11 @@ da_remove_list(devlist_t *dlist, char *link, int type, char *devname, int size)
if (plen == 0) {
slen =
snprintf(current->devinfo.devlist,
- nlen, "%s", lname);
+ nlen, "%s", lname);
} else {
slen =
snprintf(current->devinfo.devlist +
- plen, nlen - plen, " %s",
- lname);
+ plen, nlen - plen, " %s", lname);
}
plen = plen + slen + 1;
}