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);
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;
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;
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);
}