X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Flfs.c;h=3c412518b72985ea81d20d55a0fec070b211231c;hp=3923ea0f44ed45de993c1b03e5fef9c225e9dc26;hb=31e7f22cdc7c77ac7b48ba6a258ca9611063320a;hpb=43f96aa9cc3cec66d9b9e0a03e5fc23e094525e7 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 3923ea0..3c41251 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -353,41 +353,6 @@ command_t cmdlist[] = { { 0, 0, 0, NULL } }; -/* Generate a random id for the grouplock */ -static int random_group_id(int *gid) -{ - int fd; - int rc; - size_t sz = sizeof(*gid); - - fd = open("/dev/urandom", O_RDONLY); - if (fd < 0) { - rc = -errno; - fprintf(stderr, "cannot open /dev/urandom: %s\n", - strerror(-rc)); - goto out; - } - -retry: - rc = read(fd, gid, sz); - if (rc < sz) { - rc = -errno; - fprintf(stderr, "cannot read %zu bytes from /dev/urandom: %s\n", - sz, strerror(-rc)); - goto out; - } - - /* gids must be non-zero */ - if (*gid == 0) - goto retry; - -out: - if (fd >= 0) - close(fd); - - return rc; -} - #define MIGRATION_BLOCKS 1 static int lfs_migrate(char *name, __u64 migration_flags, @@ -433,15 +398,6 @@ static int lfs_migrate(char *name, __u64 migration_flags, goto free; } - if (migration_flags & MIGRATION_BLOCKS) { - rc = random_group_id(&gid); - if (rc < 0) { - fprintf(stderr, "%s: cannot get random group ID: %s\n", - name, strerror(-rc)); - goto free; - } - } - /* search for file directory pathname */ if (strlen(name) > sizeof(parent)-1) { rc = -E2BIG; @@ -526,6 +482,9 @@ static int lfs_migrate(char *name, __u64 migration_flags, goto error; } + do + gid = random(); + while (gid == 0); if (migration_flags & MIGRATION_BLOCKS) { /* take group lock to limit concurent access * this will be no more needed when exclusive access will @@ -4070,6 +4029,10 @@ int main(int argc, char **argv) { int rc; + /* Ensure that liblustreapi constructor has run */ + if (!liblustreapi_initialized) + fprintf(stderr, "liblustreapi was not properly initialized\n"); + setlinebuf(stdout); Parser_init("lfs > ", cmdlist);