mirror of
https://github.com/ceph/ceph
synced 2025-03-06 08:20:12 +00:00
client: specify data pool on create operations
Fill in the data pool field if specified by the client, or set to -1. Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
3f4582176a
commit
32ab274a4f
@ -5270,6 +5270,7 @@ int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid, int gid)
|
||||
req->set_filepath(path);
|
||||
req->head.args.open.flags = flags & ~O_CREAT;
|
||||
req->head.args.open.mode = mode;
|
||||
req->head.args.open.pool = -1;
|
||||
req->head.args.open.old_size = in->size; // for O_TRUNC
|
||||
req->inode = in;
|
||||
result = make_request(req, uid, gid);
|
||||
@ -6638,11 +6639,20 @@ int Client::_create(Inode *dir, const char *name, int flags, mode_t mode, Inode
|
||||
if (dir->snapid != CEPH_NOSNAP) {
|
||||
return -EROFS;
|
||||
}
|
||||
|
||||
|
||||
int cmode = ceph_flags_to_mode(flags);
|
||||
if (cmode < 0)
|
||||
return -EINVAL;
|
||||
|
||||
int64_t pool_id = -1;
|
||||
if (data_pool && *data_pool) {
|
||||
pool_id = osdmap->lookup_pg_pool_name(data_pool);
|
||||
if (pool_id < 0)
|
||||
return -EINVAL;
|
||||
if (pool_id > 0xffffffffll)
|
||||
return -ERANGE; // bummer!
|
||||
}
|
||||
|
||||
MetaRequest *req = new MetaRequest(CEPH_MDS_OP_CREATE);
|
||||
|
||||
filepath path;
|
||||
@ -6656,6 +6666,7 @@ int Client::_create(Inode *dir, const char *name, int flags, mode_t mode, Inode
|
||||
req->head.args.open.stripe_unit = stripe_unit;
|
||||
req->head.args.open.stripe_count = stripe_count;
|
||||
req->head.args.open.object_size = object_size;
|
||||
req->head.args.open.pool = pool_id;
|
||||
req->dentry_drop = CEPH_CAP_FILE_SHARED;
|
||||
req->dentry_unless = CEPH_CAP_FILE_EXCL;
|
||||
|
||||
|
@ -166,8 +166,23 @@ TEST(LibCephFS, OpenLayout) {
|
||||
sprintf(test_layout_file, "test_layout_%d_c", getpid());
|
||||
fd = ceph_open_layout(cmount, test_layout_file, O_CREAT, 0666, (1<<20), 1, 19, NULL);
|
||||
ASSERT_EQ(fd, -EINVAL);
|
||||
|
||||
/* with data pool */
|
||||
sprintf(test_layout_file, "test_layout_%d_d", getpid());
|
||||
fd = ceph_open_layout(cmount, test_layout_file, O_CREAT, 0666, (1<<20), 7, (1<<20), "data");
|
||||
ASSERT_GT(fd, 0);
|
||||
ceph_close(cmount, fd);
|
||||
|
||||
/* with metadata pool (invalid) */
|
||||
sprintf(test_layout_file, "test_layout_%d_e", getpid());
|
||||
fd = ceph_open_layout(cmount, test_layout_file, O_CREAT, 0666, (1<<20), 7, (1<<20), "metadata");
|
||||
ASSERT_EQ(fd, -EINVAL);
|
||||
|
||||
/* with metadata pool (does not exist) */
|
||||
sprintf(test_layout_file, "test_layout_%d_f", getpid());
|
||||
fd = ceph_open_layout(cmount, test_layout_file, O_CREAT, 0666, (1<<20), 7, (1<<20), "asdfjasdfjasdf");
|
||||
ASSERT_EQ(fd, -EINVAL);
|
||||
|
||||
ceph_shutdown(cmount);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user