struct pcc_dataset *dataset;
struct pcc_dataset *selected = NULL;
- if (id == 0)
- return NULL;
-
/*
* archive ID (read-write ID) or read-only ID is unique in the list,
* we just return last added one as first priority.
+ * @id == 0, it will select the first one as candidate dataset.
*/
down_read(&super->pccs_rw_sem);
list_for_each_entry(dataset, &super->pccs_datasets, pccd_linkage) {
- if (type == LU_PCC_READWRITE && (dataset->pccd_rwid != id ||
- !(dataset->pccd_flags & PCC_DATASET_RWPCC)))
+ if (type == LU_PCC_READWRITE &&
+ (!(dataset->pccd_rwid == id || id == 0) ||
+ !(dataset->pccd_flags & PCC_DATASET_RWPCC)))
continue;
- if (type == LU_PCC_READONLY && (dataset->pccd_roid != id ||
- !(dataset->pccd_flags & PCC_DATASET_ROPCC)))
+ if (type == LU_PCC_READONLY &&
+ (!(dataset->pccd_roid == id || id == 0) ||
+ !(dataset->pccd_flags & PCC_DATASET_ROPCC)))
continue;
atomic_inc(&dataset->pccd_refcount);
selected = dataset;
}
run_test 41 "Test mtime rule for PCC-RO open attach with O_RDONLY mode"
+test_42() {
+ local loopfile="$TMP/$tfile"
+ local mntpt="/mnt/pcc.$tdir"
+ local hsm_root="$mntpt/$tdir"
+ local file=$DIR/$tfile
+
+ setup_loopdev $SINGLEAGT $loopfile $mntpt 60
+ do_facet $SINGLEAGT mkdir $hsm_root || error "mkdir $hsm_root failed"
+ setup_pcc_mapping $SINGLEAGT \
+ "projid={100}\ roid=$HSM_ARCHIVE_NUMBER\ ropcc=1"
+ do_facet $SINGLEAGT $LCTL pcc list $MOUNT
+
+ do_facet $SINGLEAGT echo -n attach_id_not_specified > $file ||
+ error "Write $file failed"
+ do_facet $SINGLEAGT $LFS pcc attach -r $file ||
+ error "PCC attach -r $file failed"
+ do_facet $SINGLEAGT $LFS pcc state $file
+ check_lpcc_state $file "readonly"
+}
+run_test 42 "PCC attach without attach ID specified"
+
test_99() {
local loopfile="$TMP/$tfile"
local mntpt="/mnt/pcc.$tdir"
}
}
- if (attach_id == 0) {
- fprintf(stderr, "%s: must specify attach ID\n", argv[0]);
- return CMD_HELP;
- }
-
if (argc <= optind) {
fprintf(stderr, "%s: must specify one or more file names\n",
argv[0]);
}
}
- if (attach_id == 0) {
- fprintf(stderr, "%s: must specify an archive ID\n", argv[0]);
- return CMD_HELP;
- }
-
if (!mntpath) {
fprintf(stderr, "%s: must specify Lustre mount point\n",
argv[0]);
continue;
}
- printf(", PCC file: %s", state.pccs_path);
- printf(", user number: %u", state.pccs_open_count);
+ printf(", PCC_file: %s", state.pccs_path);
+ printf(", open_count: %u", state.pccs_open_count);
printf(", flags: %x", state.pccs_flags);
printf("\n");
}