.SH NAME
lfs pcc detach|detach_fid \- Detach given files from PCC
.SH SYNOPSIS
-.B lfs pcc detach \fR[\fB--keep\fR|\fB-k\fR] [\fB--wait\fR|\fB-w\fR] \fR<\fIFILE ...\fR>
+.B lfs pcc detach \fR[\fB--keep\fR|\fB-k\fR] [\fB--wait\fR|\fB-w\fR] [\fB--abort\fR|\fB-a\fR] \fR<\fIFILE ...\fR>
.br
-.B lfs pcc detach_fid \fR[\fB--keep\fR|\fB-k\fR] [\fB--wait\fR|\fB-w\fR]\fB \fR<\fB--mnt\fR|\fB-m \fIMNTPATH\fR> <\fIFID ...\fR>
+.B lfs pcc detach_fid \fR[\fB--keep\fR|\fB-k\fR] [\fB--wait\fR|\fB-w\fR] [\fB--abort\fR|\fB-a\fR] \fR<\fB--mnt\fR|\fB-m \fIMNTPATH\fR> <\fIFID ...\fR>
.SH DESCRIPTION
Detach specified
.I FILE
automatically at next open if the cached copy of the file is still valid.
.TP
.BR --wait | -w
-Indicate to wait for the in-pregress attach finished during detach.
+Indicate to wait for the in-progress attach finished during detach.
+.TP
+.BR --abort | -a
+Indicate to abort the in-progress attach during detach.
.TP
.BR --mnt | -m
Specify the Lustre client mountpoint for the file
PCC_DETACH_FL_CACHE_REMOVED = 0x08,
PCC_DETACH_FL_ATTACHING = 0x10,
PCC_DETACH_FL_ATTACHING_WAIT = 0x20,
+ PCC_DETACH_FL_ATTACH_ABORT = 0x40,
.fi
.TP
PCC_DETACH_FL_NONE
.TP
PCC_DETACH_FL_ATTACHING_WAIT
indicates to wait the in-progress attach finished.
+.TP
+PCC_DETACH_FL_ATTACH_ABORT
+indicates to abort the in-progress attach during detach.
.SH RETURN VALUES
.LP
.BR llapi_pcc_detach_fid_fd() ,
PCC_DETACH_FL_ATTACHING = 0x10,
/* Indicate to wait the attach process finished */
PCC_DETACH_FL_ATTACHING_WAIT = 0x20,
+ /* Indicate to abort the in-progress attach during detach */
+ PCC_DETACH_FL_ATTACH_ABORT = 0x40,
};
struct lu_pcc_detach_fid {
PCC_STATE_FL_UNLINKED = 0x04,
/* The file is detached, but PCC copy is still valid cached */
PCC_STATE_FL_CACHE_VALID = 0x08,
+ /* The user tries to abort the in-progress attach */
+ PCC_STATE_FL_ATTACH_ABORTING = 0x10,
};
struct lu_pcc_state {
{
size_t buf_len = PCC_COPY_BUFFER_BYTES;
struct inode *inode = file_inode(src);
+ struct ll_inode_info *lli = ll_i2info(inode);
loff_t offset = 0;
ssize_t rc = 0;
ssize_t rc2;
if (signal_pending(current))
GOTO(out_free, rc = -EINTR);
+ if (lli->lli_pcc_state & PCC_STATE_FL_ATTACH_ABORTING)
+ GOTO(out_free, rc = -ECANCELED);
+
pos = offset;
if (inode && IS_ENCRYPTED(inode))
/* Setting the S_PCCCOPY flag prevents the Lustre file
ENTRY;
-repeat:
pcc_inode_lock(inode);
+repeat:
pcci = ll_i2pcci(inode);
if (lli->lli_pcc_state & PCC_STATE_FL_ATTACHING) {
- if (*flags & PCC_DETACH_FL_ATTACHING_WAIT) {
+ if (*flags & (PCC_DETACH_FL_ATTACHING_WAIT |
+ PCC_DETACH_FL_ATTACH_ABORT)) {
+ if (*flags & PCC_DETACH_FL_ATTACH_ABORT)
+ lli->lli_pcc_state |=
+ PCC_STATE_FL_ATTACH_ABORTING;
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);
+ pcc_inode_lock(inode);
+ if (*flags & PCC_DETACH_FL_ATTACH_ABORT)
+ lli->lli_pcc_state &=
+ ~PCC_STATE_FL_ATTACH_ABORTING;
GOTO(repeat, rc);
}
*flags |= PCC_DETACH_FL_ATTACHING;
static int lfs_pcc_detach(int argc, char **argv)
{
struct option long_opts[] = {
- { .val = 'k', .name = "keep", .has_arg = no_argument },
- { .val = 'w', .name = "wait", .has_arg = no_argument },
+ { .val = 'k', .name = "keep", .has_arg = no_argument },
+ { .val = 'w', .name = "wait", .has_arg = no_argument },
+ { .val = 'a', .name = "abort", .has_arg = no_argument },
{ .name = NULL } };
- char short_opts[] = "kw";
+ char short_opts[] = "kwa";
int c;
int rc = 0;
const char *path;
case 'w':
detach_flags |= PCC_DETACH_FL_ATTACHING_WAIT;
break;
+ case 'a':
+ detach_flags |= PCC_DETACH_FL_ATTACH_ABORT;
+ break;
case '?':
return CMD_HELP;
default:
static int lfs_pcc_detach_fid(int argc, char **argv)
{
struct option long_opts[] = {
- { .val = 'k', .name = "keep", .has_arg = no_argument },
- { .val = 'w', .name = "wait", .has_arg = no_argument },
- { .val = 'm', .name = "mnt", .has_arg = required_argument },
+ { .val = 'k', .name = "keep", .has_arg = no_argument },
+ { .val = 'w', .name = "wait", .has_arg = no_argument },
+ { .val = 'a', .name = "abort", .has_arg = no_argument },
+ { .val = 'm', .name = "mnt", .has_arg = required_argument },
{ .name = NULL } };
- char short_opts[] = "kwm:";
+ char short_opts[] = "kwam:";
const char *mntpath = NULL;
const char *fidstr;
__u32 detach_flags = PCC_DETACH_FL_UNCACHE;
case 'w':
detach_flags |= PCC_DETACH_FL_ATTACHING_WAIT;
break;
+ case 'a':
+ detach_flags |= PCC_DETACH_FL_ATTACH_ABORT;
+ break;
case 'm':
mntpath = optarg;
break;