PCC_DETACH_FL_CACHE_REMOVED = 0x08,
/* Indicate the file is being attached */
PCC_DETACH_FL_ATTACHING = 0x10,
+ /* Indicate to wait the attach process finished */
+ PCC_DETACH_FL_ATTACHING_WAIT = 0x20,
};
struct lu_pcc_detach_fid {
#include "pcc.h"
#include <linux/namei.h>
#include <linux/file.h>
+#include <linux/delay.h>
#include <lustre_compat.h>
#include "llite_internal.h"
ENTRY;
+repeat:
pcc_inode_lock(inode);
pcci = ll_i2pcci(inode);
if (lli->lli_pcc_state & PCC_STATE_FL_ATTACHING) {
+ if (*flags & PCC_DETACH_FL_ATTACHING_WAIT) {
+ pcc_inode_unlock(inode);
+ /*
+ * TODO: Add a flag to indicate aborting the PCC
+ * attach process.
+ */
+ while (lli->lli_pcc_state & PCC_STATE_FL_ATTACHING)
+ msleep(125);
+ GOTO(repeat, rc);
+ }
*flags |= PCC_DETACH_FL_ATTACHING;
GOTO(out_unlock, rc = 0);
}
hsm_scan_func_t hsc_func;
int hsc_errnum;
int hsc_mntfd;
+ __u32 hsc_flags;
};
int hsm_scan_process(struct hsm_scan_control *hsc);
int rc;
/* It is the saved lov file when archive on HSM backend. */
- detach.pccd_flags = PCC_DETACH_FL_UNCACHE;
+ detach.pccd_flags = hsc->hsc_flags | PCC_DETACH_FL_UNCACHE;
lov_file = endswith(fname, ".lov");
if (lov_file) {
size_t len;
.hsc_mntfd = -1,
.hsc_func = llapi_pcc_scan_detach,
.hsc_errnum = 0,
+ .hsc_flags = 0,
};
char cmd[PATH_MAX];
int rc;
- if (flags & PCC_CLEANUP_FL_WAIT)
+ if (flags & PCC_CLEANUP_FL_WAIT) {
snprintf(cmd, sizeof(cmd), "%s %s",
PCC_CMDNAME_DEL_WAIT, pccpath);
- else
+ hsc.hsc_flags = PCC_DETACH_FL_ATTACHING_WAIT;
+ } else {
snprintf(cmd, sizeof(cmd), "%s %s", PCC_CMDNAME_DEL, pccpath);
+ }
rc = llapi_pccdev_set(mntpath, cmd);
if (rc < 0) {