static inline int lfs_mirror_write(int argc, char **argv);
static inline int lfs_mirror_copy(int argc, char **argv);
static int lfs_pcc_attach(int argc, char **argv);
+static int lfs_pcc_attach_fid(int argc, char **argv);
static int lfs_pcc_detach(int argc, char **argv);
static int lfs_pcc_detach_fid(int argc, char **argv);
static int lfs_pcc_state(int argc, char **argv);
.pc_help = "Attach given files to the Persistent Client Cache.\n"
"usage: lfs pcc attach <--id|-i NUM> <file> ...\n"
"\t-i: archive id for RW-PCC\n" },
+ { .pc_name = "attach_fid", .pc_func = lfs_pcc_attach_fid,
+ .pc_help = "Attach given files into PCC by FID(s).\n"
+ "usage: lfs pcc attach_id <--id|-i NUM> <--mnt|-m mnt> "
+ "<fid> ...\n"
+ "\t-i: archive id for RW-PCC\n"
+ "\t-m: Lustre mount point\n" },
{ .pc_name = "state", .pc_func = lfs_pcc_state,
.pc_help = "Display the PCC state for given files.\n"
"usage: lfs pcc state <file> ...\n" },
{"pcc", lfs_pcc, pcc_cmdlist,
"lfs commands used to interact with PCC features:\n"
"lfs pcc attach - attach given files to Persistent Client Cache\n"
+ "lfs pcc attach_fid - attach given files into PCC by FID(s)\n"
"lfs pcc state - display the PCC state for given files\n"
"lfs pcc detach - detach given files from Persistent Client Cache\n"
"lfs pcc detach_fid - detach given files from PCC by FID(s)\n"},
static char obd_statfs_state2char(int s)
{
- /* Not an error state, do not print here */
- if (s == OS_STATE_NONROT)
- return '\0';
/* Unknown name */
if (s > ARRAY_SIZE(obd_statfs_state_names)/sizeof(char) ||
obd_statfs_state_names[s] == 0)
printf(" ");
for (i = 0, state = stat->os_state; state != 0; i++) {
uint32_t mask = 1 << i;
- if (!(state & mask))
+ if (!(state & mask) || mask == OS_STATE_NONROT)
continue;
printf("%c", obd_statfs_state2char(mask));
state &= ~mask;
"%s %s: warning: '--index' deprecated, use '--mdt-index' instead\n",
progname, argv[0]);
#endif
- lsa.lsa_pattern = LLAPI_LAYOUT_OVERSTRIPING;
lsa.lsa_nr_tgts = parse_targets(mdts,
sizeof(mdts) / sizeof(__u32),
lsa.lsa_nr_tgts, optarg, NULL);
progname, argv[0], optarg);
return CMD_HELP;
}
- lsa.lsa_pattern = 0;
lsa.lsa_tgts = mdts;
if (lsa.lsa_stripe_off == LLAPI_LAYOUT_DEFAULT)
return rc;
}
-static int lfs_pcc_detach(int argc, char **argv)
+static int lfs_pcc_attach_fid(int argc, char **argv)
{
+ struct option long_opts[] = {
+ { .val = 'i', .name = "id", .has_arg = required_argument },
+ { .val = 'm', .name = "mnt", .has_arg = required_argument },
+ { .name = NULL } };
+ char short_opts[] = "i:m:";
+ int c;
int rc = 0;
- const char *path;
- char fullpath[PATH_MAX];
+ __u32 archive_id = 0;
+ char *end;
+ const char *mntpath = NULL;
+ const char *fidstr;
+ enum lu_pcc_type type = LU_PCC_READWRITE;
- optind = 1;
+ optind = 0;
+ while ((c = getopt_long(argc, argv, short_opts,
+ long_opts, NULL)) != -1) {
+ switch (c) {
+ case 'i':
+ archive_id = strtoul(optarg, &end, 0);
+ if (*end != '\0') {
+ fprintf(stderr, "error: %s: bad archive ID "
+ "'%s'\n", argv[0], optarg);
+ return CMD_HELP;
+ }
+ break;
+ case 'm':
+ mntpath = optarg;
+ break;
+ case '?':
+ return CMD_HELP;
+ default:
+ fprintf(stderr, "%s: option '%s' unrecognized\n",
+ argv[0], argv[optind - 1]);
+ return CMD_HELP;
+ }
+ }
- if (argc <= 1) {
- fprintf(stderr, "%s: must specify one or more file names\n",
+ if (archive_id == 0) {
+ fprintf(stderr, "%s: must specify an archive ID\n", argv[0]);
+ return CMD_HELP;
+ }
+
+ if (mntpath == NULL) {
+ fprintf(stderr, "%s: must specify Lustre mount point\n",
argv[0]);
return CMD_HELP;
}
+ if (argc <= optind) {
+ fprintf(stderr, "%s: must specify one or more fids\n", argv[0]);
+ return CMD_HELP;
+ }
+
+ while (optind < argc) {
+ int rc2;
+
+ fidstr = argv[optind++];
+
+ rc2 = llapi_pcc_attach_fid_str(mntpath, fidstr,
+ archive_id, type);
+ if (rc2 < 0) {
+ fprintf(stderr, "%s: cannot attach '%s' on '%s' to PCC "
+ "with archive ID '%u': %s\n", argv[0],
+ fidstr, mntpath, archive_id, strerror(rc2));
+ }
+ if (rc == 0 && rc2 < 0)
+ rc = rc2;
+ }
+ return rc;
+}
+
+static int lfs_pcc_detach(int argc, char **argv)
+{
+ struct option long_opts[] = {
+ { .val = 'k', .name = "keep", .has_arg = no_argument },
+ { .name = NULL } };
+ char short_opts[] = "k";
+ int c;
+ int rc = 0;
+ const char *path;
+ char fullpath[PATH_MAX];
+ __u32 detach_opt = PCC_DETACH_OPT_UNCACHE;
+
+ optind = 0;
+ while ((c = getopt_long(argc, argv, short_opts,
+ long_opts, NULL)) != -1) {
+ switch (c) {
+ case 'k':
+ detach_opt = PCC_DETACH_OPT_NONE;
+ break;
+ case '?':
+ return CMD_HELP;
+ default:
+ fprintf(stderr, "%s: option '%s' unrecognized\n",
+ argv[0], argv[optind - 1]);
+ return CMD_HELP;
+ }
+ }
+
while (optind < argc) {
int rc2;
continue;
}
- rc2 = llapi_pcc_detach_file(fullpath);
+ rc2 = llapi_pcc_detach_file(fullpath, detach_opt);
if (rc2 < 0) {
+ rc2 = -errno;
fprintf(stderr, "%s: cannot detach '%s' from PCC: "
- "%s\n", argv[0], path, strerror(-rc2));
+ "%s\n", argv[0], path, strerror(errno));
if (rc == 0)
rc = rc2;
}
static int lfs_pcc_detach_fid(int argc, char **argv)
{
+ struct option long_opts[] = {
+ { .val = 'k', .name = "keep", .has_arg = no_argument },
+ { .name = NULL } };
+ char short_opts[] = "k";
+ int c;
int rc = 0;
const char *fid;
const char *mntpath;
+ __u32 detach_opt = PCC_DETACH_OPT_UNCACHE;
- optind = 1;
-
- if (argc <= 2) {
- fprintf(stderr, "%s: not enough argument\n",
- argv[0]);
- return CMD_HELP;
+ optind = 0;
+ while ((c = getopt_long(argc, argv, short_opts,
+ long_opts, NULL)) != -1) {
+ switch (c) {
+ case 'k':
+ detach_opt = PCC_DETACH_OPT_NONE;
+ break;
+ case '?':
+ return CMD_HELP;
+ default:
+ fprintf(stderr, "%s: option '%s' unrecognized\n",
+ argv[0], argv[optind - 1]);
+ return CMD_HELP;
+ }
}
mntpath = argv[optind++];
fid = argv[optind++];
- rc2 = llapi_pcc_detach_fid_str(mntpath, fid);
+ rc2 = llapi_pcc_detach_fid_str(mntpath, fid, detach_opt);
if (rc2 < 0) {
fprintf(stderr, "%s: cannot detach '%s' on '%s' "
"from PCC: %s\n", argv[0], fid, mntpath,
printf(", PCC file: %s", state.pccs_path);
printf(", user number: %u", state.pccs_open_count);
- printf(", attr cached: %s",
- state.pccs_flags & PCC_STATE_FLAG_ATTR_VALID ?
- "true" : "false");
+ printf(", flags: %x", state.pccs_flags);
printf("\n");
}
return rc;