diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/ceph/ioctl.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'fs/ceph/ioctl.c')
-rw-r--r-- | fs/ceph/ioctl.c | 81 |
1 files changed, 76 insertions, 5 deletions
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index 76e307d2aba1..ef0b5f48e13a 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c | |||
@@ -1,8 +1,10 @@ | |||
1 | #include <linux/in.h> | 1 | #include <linux/in.h> |
2 | 2 | ||
3 | #include "ioctl.h" | ||
4 | #include "super.h" | 3 | #include "super.h" |
5 | #include "ceph_debug.h" | 4 | #include "mds_client.h" |
5 | #include <linux/ceph/ceph_debug.h> | ||
6 | |||
7 | #include "ioctl.h" | ||
6 | 8 | ||
7 | 9 | ||
8 | /* | 10 | /* |
@@ -37,7 +39,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) | |||
37 | { | 39 | { |
38 | struct inode *inode = file->f_dentry->d_inode; | 40 | struct inode *inode = file->f_dentry->d_inode; |
39 | struct inode *parent_inode = file->f_dentry->d_parent->d_inode; | 41 | struct inode *parent_inode = file->f_dentry->d_parent->d_inode; |
40 | struct ceph_mds_client *mdsc = &ceph_sb_to_client(inode->i_sb)->mdsc; | 42 | struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; |
41 | struct ceph_mds_request *req; | 43 | struct ceph_mds_request *req; |
42 | struct ceph_ioctl_layout l; | 44 | struct ceph_ioctl_layout l; |
43 | int err, i; | 45 | int err, i; |
@@ -71,7 +73,8 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) | |||
71 | USE_AUTH_MDS); | 73 | USE_AUTH_MDS); |
72 | if (IS_ERR(req)) | 74 | if (IS_ERR(req)) |
73 | return PTR_ERR(req); | 75 | return PTR_ERR(req); |
74 | req->r_inode = igrab(inode); | 76 | req->r_inode = inode; |
77 | ihold(inode); | ||
75 | req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL; | 78 | req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL; |
76 | 79 | ||
77 | req->r_args.setlayout.layout.fl_stripe_unit = | 80 | req->r_args.setlayout.layout.fl_stripe_unit = |
@@ -90,6 +93,69 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) | |||
90 | } | 93 | } |
91 | 94 | ||
92 | /* | 95 | /* |
96 | * Set a layout policy on a directory inode. All items in the tree | ||
97 | * rooted at this inode will inherit this layout on creation, | ||
98 | * (It doesn't apply retroactively ) | ||
99 | * unless a subdirectory has its own layout policy. | ||
100 | */ | ||
101 | static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg) | ||
102 | { | ||
103 | struct inode *inode = file->f_dentry->d_inode; | ||
104 | struct ceph_mds_request *req; | ||
105 | struct ceph_ioctl_layout l; | ||
106 | int err, i; | ||
107 | struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; | ||
108 | |||
109 | /* copy and validate */ | ||
110 | if (copy_from_user(&l, arg, sizeof(l))) | ||
111 | return -EFAULT; | ||
112 | |||
113 | if ((l.object_size & ~PAGE_MASK) || | ||
114 | (l.stripe_unit & ~PAGE_MASK) || | ||
115 | !l.stripe_unit || | ||
116 | (l.object_size && | ||
117 | (unsigned)l.object_size % (unsigned)l.stripe_unit)) | ||
118 | return -EINVAL; | ||
119 | |||
120 | /* make sure it's a valid data pool */ | ||
121 | if (l.data_pool > 0) { | ||
122 | mutex_lock(&mdsc->mutex); | ||
123 | err = -EINVAL; | ||
124 | for (i = 0; i < mdsc->mdsmap->m_num_data_pg_pools; i++) | ||
125 | if (mdsc->mdsmap->m_data_pg_pools[i] == l.data_pool) { | ||
126 | err = 0; | ||
127 | break; | ||
128 | } | ||
129 | mutex_unlock(&mdsc->mutex); | ||
130 | if (err) | ||
131 | return err; | ||
132 | } | ||
133 | |||
134 | req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETDIRLAYOUT, | ||
135 | USE_AUTH_MDS); | ||
136 | |||
137 | if (IS_ERR(req)) | ||
138 | return PTR_ERR(req); | ||
139 | req->r_inode = inode; | ||
140 | ihold(inode); | ||
141 | |||
142 | req->r_args.setlayout.layout.fl_stripe_unit = | ||
143 | cpu_to_le32(l.stripe_unit); | ||
144 | req->r_args.setlayout.layout.fl_stripe_count = | ||
145 | cpu_to_le32(l.stripe_count); | ||
146 | req->r_args.setlayout.layout.fl_object_size = | ||
147 | cpu_to_le32(l.object_size); | ||
148 | req->r_args.setlayout.layout.fl_pg_pool = | ||
149 | cpu_to_le32(l.data_pool); | ||
150 | req->r_args.setlayout.layout.fl_pg_preferred = | ||
151 | cpu_to_le32(l.preferred_osd); | ||
152 | |||
153 | err = ceph_mdsc_do_request(mdsc, inode, req); | ||
154 | ceph_mdsc_put_request(req); | ||
155 | return err; | ||
156 | } | ||
157 | |||
158 | /* | ||
93 | * Return object name, size/offset information, and location (OSD | 159 | * Return object name, size/offset information, and location (OSD |
94 | * number, network address) for a given file offset. | 160 | * number, network address) for a given file offset. |
95 | */ | 161 | */ |
@@ -98,7 +164,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) | |||
98 | struct ceph_ioctl_dataloc dl; | 164 | struct ceph_ioctl_dataloc dl; |
99 | struct inode *inode = file->f_dentry->d_inode; | 165 | struct inode *inode = file->f_dentry->d_inode; |
100 | struct ceph_inode_info *ci = ceph_inode(inode); | 166 | struct ceph_inode_info *ci = ceph_inode(inode); |
101 | struct ceph_osd_client *osdc = &ceph_sb_to_client(inode->i_sb)->osdc; | 167 | struct ceph_osd_client *osdc = |
168 | &ceph_sb_to_client(inode->i_sb)->client->osdc; | ||
102 | u64 len = 1, olen; | 169 | u64 len = 1, olen; |
103 | u64 tmp; | 170 | u64 tmp; |
104 | struct ceph_object_layout ol; | 171 | struct ceph_object_layout ol; |
@@ -174,11 +241,15 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
174 | case CEPH_IOC_SET_LAYOUT: | 241 | case CEPH_IOC_SET_LAYOUT: |
175 | return ceph_ioctl_set_layout(file, (void __user *)arg); | 242 | return ceph_ioctl_set_layout(file, (void __user *)arg); |
176 | 243 | ||
244 | case CEPH_IOC_SET_LAYOUT_POLICY: | ||
245 | return ceph_ioctl_set_layout_policy(file, (void __user *)arg); | ||
246 | |||
177 | case CEPH_IOC_GET_DATALOC: | 247 | case CEPH_IOC_GET_DATALOC: |
178 | return ceph_ioctl_get_dataloc(file, (void __user *)arg); | 248 | return ceph_ioctl_get_dataloc(file, (void __user *)arg); |
179 | 249 | ||
180 | case CEPH_IOC_LAZYIO: | 250 | case CEPH_IOC_LAZYIO: |
181 | return ceph_ioctl_lazyio(file); | 251 | return ceph_ioctl_lazyio(file); |
182 | } | 252 | } |
253 | |||
183 | return -ENOTTY; | 254 | return -ENOTTY; |
184 | } | 255 | } |