int main(int argc, char **argv) { prog_name = argv[0]; decode_arguments(argc, argv); switch (operation) { /* calls to libdlm; pass a command to dlm-kernel */ case OP_JOIN: do_join(lsname); break; case OP_LEAVE: do_leave(lsname); break; case OP_JOINLEAVE: do_join(lsname); do_leave(lsname); break; /* calls to libdlmcontrol; pass a command/query to dlm_controld */ case OP_LIST: do_list(lsname); break; case OP_DUMP: do_dump(); break; case OP_LOG_PLOCK: do_log_plock(); break; case OP_PLOCKS: do_plocks(lsname); break; case OP_DEADLOCK_CHECK: do_deadlock_check(lsname); break; /* calls to read debugfs; query info from dlm-kernel */ case OP_LOCKDUMP: do_lockdump(lsname); break; case OP_LOCKDEBUG: do_lockdebug(lsname); break; } return 0; }
int main(int argc, char *argv[]) { prog_name = basename(argv[0]); decode_arguments(argc, argv); switch (operation) { case OP_JOIN: do_join(argc, argv); break; case OP_LEAVE: do_leave(); break; case OP_DUMP: do_dump(); break; case OP_LIST: do_list(); break; } return EXIT_FAILURE; }
int main(int argc, char **argv) { decode_arguments(argc, argv); switch (operation) { case OP_LEAVE: do_leave(fsname); break; case OP_LIST: do_list(fsname); break; case OP_DUMP: do_dump(); break; case OP_PLOCKS: do_plocks(fsname); break; } return 0; }
int main(int argc, char *argv[]) { struct gfs2_sbd sbd, *sdp = &sbd; int rindex_fd; int error = EXIT_SUCCESS; int devflags = (test ? O_RDONLY : O_RDWR) | O_CLOEXEC; setlocale(LC_ALL, ""); textdomain("gfs2-utils"); srandom(time(NULL) ^ getpid()); memset(sdp, 0, sizeof(struct gfs2_sbd)); sdp->bsize = GFS2_DEFAULT_BSIZE; sdp->rgsize = -1; sdp->jsize = GFS2_DEFAULT_JSIZE; sdp->qcsize = GFS2_DEFAULT_QCSIZE; sdp->md.journals = 1; decode_arguments(argc, argv, sdp); for(; (argc - optind) > 0; optind++) { struct metafs mfs = {0}; struct mntent *mnt; unsigned rgcount; unsigned old_rg_count; lgfs2_rgrps_t rgs; error = lgfs2_open_mnt(argv[optind], O_RDONLY|O_CLOEXEC, &sdp->path_fd, devflags, &sdp->device_fd, &mnt); if (error != 0) { fprintf(stderr, _("Error looking up mount '%s': %s\n"), argv[optind], strerror(errno)); exit(EXIT_FAILURE); } if (mnt == NULL) { fprintf(stderr, _("%s: not a mounted gfs2 file system\n"), argv[optind]); continue; } if (lgfs2_get_dev_info(sdp->device_fd, &sdp->dinfo) < 0) { perror(mnt->mnt_fsname); exit(EXIT_FAILURE); } sdp->sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE; sdp->bsize = sdp->sd_sb.sb_bsize; if (compute_constants(sdp)) { log_crit("%s\n", _("Failed to compute file system constants")); exit(EXIT_FAILURE); } if (read_sb(sdp) < 0) { fprintf(stderr, _("Error reading superblock.\n")); exit(EXIT_FAILURE); } if (sdp->gfs1) { fprintf(stderr, _("cannot grow gfs1 filesystem\n")); exit(EXIT_FAILURE); } fix_device_geometry(sdp); mfs.context = copy_context_opt(mnt); if (mount_gfs2_meta(&mfs, mnt->mnt_dir, (print_level > MSG_NOTICE))) { perror(_("Failed to mount GFS2 meta file system")); exit(EXIT_FAILURE); } rindex_fd = open_rindex(mfs.path, (test ? O_RDONLY : O_RDWR)); if (rindex_fd < 0) { cleanup_metafs(&mfs); exit(EXIT_FAILURE); } /* Get master dinode */ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr); if (sdp->master_dir == NULL) { perror(_("Could not read master directory")); exit(EXIT_FAILURE); } rgs = rgrps_init(sdp); if (rgs == NULL) { perror(_("Could not initialise resource groups")); error = -1; goto out; } /* Fetch the rindex from disk. We aren't using gfs2 here, */ /* which means that the bitmaps will most likely be cached */ /* and therefore out of date. It shouldn't matter because */ /* we're only going to write out new RG information after */ /* the existing RGs, and only write to the index at EOF. */ log_info(_("Gathering resource group information for %s\n"), argv[optind]); old_rg_count = lgfs2_rindex_read_fd(rindex_fd, rgs); if (old_rg_count == 0) { perror(_("Failed to scan existing resource groups")); error = -EXIT_FAILURE; goto out; } if (metafs_interrupted) goto out; fssize = lgfs2_rgrp_align_addr(rgs, filesystem_size(rgs) + 1); /* We're done with the old rgs now that we have the fssize and rg count */ lgfs2_rgrps_free(&rgs); /* Now lets set up the new ones with alignment and all */ rgs = rgrps_init(sdp); if (rgs == NULL) { perror(_("Could not initialise new resource groups")); error = -1; goto out; } fsgrowth = (sdp->device.length - fssize); rgcount = lgfs2_rgrps_plan(rgs, fsgrowth, ((GFS2_MAX_RGSIZE << 20) / sdp->bsize)); if (rgcount == 0) { log_err( _("The calculated resource group size is too small.\n")); log_err( _("%s has not grown.\n"), argv[optind]); error = -1; goto out; } print_info(sdp, mnt->mnt_fsname, mnt->mnt_dir); rgcount = initialize_new_portion(sdp, rgs); if (rgcount == 0 || metafs_interrupted) goto out; fsync(sdp->device_fd); fix_rindex(rindex_fd, rgs, old_rg_count, rgcount); out: lgfs2_rgrps_free(&rgs); close(rindex_fd); cleanup_metafs(&mfs); close(sdp->device_fd); if (metafs_interrupted) break; } close(sdp->path_fd); sync(); if (metafs_interrupted) { log_notice( _("gfs2_grow interrupted.\n")); exit(1); } log_notice( _("gfs2_grow complete.\n")); return error; }
int main(int argc, char *argv[]) { uint32_t major, minor, patch; struct lk *lk; int i, rv, maxi = 0, quit = 0; srandom(time(NULL)); decode_arguments(argc, argv); if (maxn < maxr) { printf("number of resources must be >= number of locks\n"); return -1; } if (maxn % maxr) { printf("number of locks must be multiple of number of resources\n"); return -1; } printf("maxn = %d\n", maxn); printf("maxr = %d\n", maxr); printf("locks per resource = %d\n", maxn / maxr); signal(SIGTERM, sigterm_handler); client_init(); locks = malloc(maxn * sizeof(struct lk)); if (!locks) { printf("no mem for %d locks\n", maxn); return 0; } memset(locks, 0, sizeof(*locks)); lk = locks; for (i = 0; i < maxn; i++) { lk->id = i; lk->grmode = -1; lk->rqmode = -1; lk++; } rv = dlm_kernel_version(&major, &minor, &patch); if (rv < 0) { printf("can't detect dlm in kernel %d\n", errno); return -1; } printf("dlm kernel version: %u.%u.%u\n", major, minor, patch); dlm_library_version(&major, &minor, &patch); printf("dlm library version: %u.%u.%u\n", major, minor, patch); if (openclose_ls) { printf("dlm_open_lockspace...\n"); dh = dlm_open_lockspace("test"); if (!dh) { printf("dlm_open_lockspace error %lu %d\n", (unsigned long)dh, errno); return -ENOTCONN; } } else { printf("dlm_new_lockspace...\n"); dh = dlm_new_lockspace("test", 0600, timewarn ? DLM_LSFL_TIMEWARN : 0); if (!dh) { printf("dlm_new_lockspace error %lu %d\n", (unsigned long)dh, errno); return -ENOTCONN; } } rv = dlm_ls_get_fd(dh); if (rv < 0) { printf("dlm_ls_get_fd error %d %d\n", rv, errno); dlm_release_lockspace("test", dh, 1); return rv; } libdlm_fd = rv; client_add(libdlm_fd, &maxi); if (opt_cmd) { process_command(&quit); goto out; } client_add(STDIN_FILENO, &maxi); printf("Type EXIT to finish, help for usage\n"); while (1) { rv = poll(pollfd, maxi + 1, -1); if (rv < 0 && errno == EINTR) continue; if (rv < 0) printf("poll error %d errno %d\n", rv, errno); for (i = 0; i <= maxi; i++) { if (client[i].fd < 0) continue; if (pollfd[i].revents & POLLIN) { if (pollfd[i].fd == libdlm_fd) process_libdlm(); else if (pollfd[i].fd == STDIN_FILENO) process_command(&quit); } if (pollfd[i].revents & (POLLHUP | POLLERR | POLLNVAL)) client_dead(i); } if (quit && all_unlocks_done()) break; } out: if (openclose_ls) { printf("dlm_close_lockspace\n"); rv = dlm_close_lockspace(dh); if (rv < 0) printf("dlm_close_lockspace error %d %d\n", rv, errno); } else { printf("dlm_release_lockspace\n"); rv = dlm_release_lockspace("test", dh, 1); if (rv < 0) printf("dlm_release_lockspace error %d %d\n", rv, errno); } return 0; }