Skip to content

Commit 0ea611a

Browse files
ukernelidryomov
authored andcommitted
ceph: rename snapshot support
Signed-off-by: Yan, Zheng <zyan@redhat.com>
1 parent c0bd50e commit 0ea611a

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎fs/ceph/dir.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -947,16 +947,20 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
947947
struct ceph_fs_client *fsc = ceph_sb_to_client(old_dir->i_sb);
948948
struct ceph_mds_client *mdsc = fsc->mdsc;
949949
struct ceph_mds_request *req;
950+
int op = CEPH_MDS_OP_RENAME;
950951
int err;
951952

952953
if (ceph_snap(old_dir) != ceph_snap(new_dir))
953954
return -EXDEV;
954-
if (ceph_snap(old_dir) != CEPH_NOSNAP ||
955-
ceph_snap(new_dir) != CEPH_NOSNAP)
956-
return -EROFS;
955+
if (ceph_snap(old_dir) != CEPH_NOSNAP) {
956+
if (old_dir == new_dir && ceph_snap(old_dir) == CEPH_SNAPDIR)
957+
op = CEPH_MDS_OP_RENAMESNAP;
958+
else
959+
return -EROFS;
960+
}
957961
dout("rename dir %p dentry %p to dir %p dentry %p\n",
958962
old_dir, old_dentry, new_dir, new_dentry);
959-
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_RENAME, USE_AUTH_MDS);
963+
req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
960964
if (IS_ERR(req))
961965
return PTR_ERR(req);
962966
ihold(old_dir);
@@ -1387,6 +1391,7 @@ const struct inode_operations ceph_snapdir_iops = {
13871391
.getattr = ceph_getattr,
13881392
.mkdir = ceph_mkdir,
13891393
.rmdir = ceph_unlink,
1394+
.rename = ceph_rename,
13901395
};
13911396

13921397
const struct dentry_operations ceph_dentry_ops = {

‎fs/ceph/strings.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const char *ceph_mds_op_name(int op)
7575
case CEPH_MDS_OP_LSSNAP: return "lssnap";
7676
case CEPH_MDS_OP_MKSNAP: return "mksnap";
7777
case CEPH_MDS_OP_RMSNAP: return "rmsnap";
78+
case CEPH_MDS_OP_RENAMESNAP: return "renamesnap";
7879
case CEPH_MDS_OP_SETFILELOCK: return "setfilelock";
7980
case CEPH_MDS_OP_GETFILELOCK: return "getfilelock";
8081
}

‎include/linux/ceph/ceph_fs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ enum {
323323
CEPH_MDS_OP_MKSNAP = 0x01400,
324324
CEPH_MDS_OP_RMSNAP = 0x01401,
325325
CEPH_MDS_OP_LSSNAP = 0x00402,
326+
CEPH_MDS_OP_RENAMESNAP = 0x01403,
326327
};
327328

328329
extern const char *ceph_mds_op_name(int op);

0 commit comments

Comments
 (0)