summaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2016-02-03 08:24:49 -0500
committerIlya Dryomov <idryomov@gmail.com>2016-07-27 20:55:36 -0400
commit7627151ea30bce2051e3cb27d7bb2c30083f86a5 (patch)
tree8a4c9422b30c3e50eb76923c746747f4e09d0bb5 /fs/ceph
parent22748f9d617b8cd0a915c3a4c656c7232645b3b5 (diff)
libceph: define new ceph_file_layout structure
Define new ceph_file_layout structure and rename old ceph_file_layout to ceph_file_layout_legacy. This is preparation for adding namespace to ceph_file_layout structure. Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/addr.c18
-rw-r--r--fs/ceph/caps.c5
-rw-r--r--fs/ceph/file.c6
-rw-r--r--fs/ceph/inode.c7
-rw-r--r--fs/ceph/ioctl.c22
-rw-r--r--fs/ceph/mds_client.h2
-rw-r--r--fs/ceph/xattr.c28
7 files changed, 43 insertions, 45 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 26a9d10d75e9..3f8efd866fec 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1730,7 +1730,7 @@ enum {
1730 POOL_WRITE = 2, 1730 POOL_WRITE = 2,
1731}; 1731};
1732 1732
1733static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool) 1733static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool)
1734{ 1734{
1735 struct ceph_fs_client *fsc = ceph_inode_to_client(&ci->vfs_inode); 1735 struct ceph_fs_client *fsc = ceph_inode_to_client(&ci->vfs_inode);
1736 struct ceph_mds_client *mdsc = fsc->mdsc; 1736 struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1757,7 +1757,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool)
1757 if (*p) 1757 if (*p)
1758 goto out; 1758 goto out;
1759 1759
1760 dout("__ceph_pool_perm_get pool %u no perm cached\n", pool); 1760 dout("__ceph_pool_perm_get pool %lld no perm cached\n", pool);
1761 1761
1762 down_write(&mdsc->pool_perm_rwsem); 1762 down_write(&mdsc->pool_perm_rwsem);
1763 parent = NULL; 1763 parent = NULL;
@@ -1860,13 +1860,13 @@ out_unlock:
1860out: 1860out:
1861 if (!err) 1861 if (!err)
1862 err = have; 1862 err = have;
1863 dout("__ceph_pool_perm_get pool %u result = %d\n", pool, err); 1863 dout("__ceph_pool_perm_get pool %lld result = %d\n", pool, err);
1864 return err; 1864 return err;
1865} 1865}
1866 1866
1867int ceph_pool_perm_check(struct ceph_inode_info *ci, int need) 1867int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
1868{ 1868{
1869 u32 pool; 1869 s64 pool;
1870 int ret, flags; 1870 int ret, flags;
1871 1871
1872 /* does not support pool namespace yet */ 1872 /* does not support pool namespace yet */
@@ -1879,17 +1879,17 @@ int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
1879 1879
1880 spin_lock(&ci->i_ceph_lock); 1880 spin_lock(&ci->i_ceph_lock);
1881 flags = ci->i_ceph_flags; 1881 flags = ci->i_ceph_flags;
1882 pool = ceph_file_layout_pg_pool(ci->i_layout); 1882 pool = ci->i_layout.pool_id;
1883 spin_unlock(&ci->i_ceph_lock); 1883 spin_unlock(&ci->i_ceph_lock);
1884check: 1884check:
1885 if (flags & CEPH_I_POOL_PERM) { 1885 if (flags & CEPH_I_POOL_PERM) {
1886 if ((need & CEPH_CAP_FILE_RD) && !(flags & CEPH_I_POOL_RD)) { 1886 if ((need & CEPH_CAP_FILE_RD) && !(flags & CEPH_I_POOL_RD)) {
1887 dout("ceph_pool_perm_check pool %u no read perm\n", 1887 dout("ceph_pool_perm_check pool %lld no read perm\n",
1888 pool); 1888 pool);
1889 return -EPERM; 1889 return -EPERM;
1890 } 1890 }
1891 if ((need & CEPH_CAP_FILE_WR) && !(flags & CEPH_I_POOL_WR)) { 1891 if ((need & CEPH_CAP_FILE_WR) && !(flags & CEPH_I_POOL_WR)) {
1892 dout("ceph_pool_perm_check pool %u no write perm\n", 1892 dout("ceph_pool_perm_check pool %lld no write perm\n",
1893 pool); 1893 pool);
1894 return -EPERM; 1894 return -EPERM;
1895 } 1895 }
@@ -1907,10 +1907,10 @@ check:
1907 flags |= CEPH_I_POOL_WR; 1907 flags |= CEPH_I_POOL_WR;
1908 1908
1909 spin_lock(&ci->i_ceph_lock); 1909 spin_lock(&ci->i_ceph_lock);
1910 if (pool == ceph_file_layout_pg_pool(ci->i_layout)) { 1910 if (pool == ci->i_layout.pool_id) {
1911 ci->i_ceph_flags = flags; 1911 ci->i_ceph_flags = flags;
1912 } else { 1912 } else {
1913 pool = ceph_file_layout_pg_pool(ci->i_layout); 1913 pool = ci->i_layout.pool_id;
1914 flags = ci->i_ceph_flags; 1914 flags = ci->i_ceph_flags;
1915 } 1915 }
1916 spin_unlock(&ci->i_ceph_lock); 1916 spin_unlock(&ci->i_ceph_lock);
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 6f60d0a3d0f9..f24722dce167 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2895,8 +2895,11 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
2895 2895
2896 if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) { 2896 if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
2897 /* file layout may have changed */ 2897 /* file layout may have changed */
2898 ci->i_layout = grant->layout; 2898 s64 old_pool = ci->i_layout.pool_id;
2899 ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout);
2899 ci->i_pool_ns_len = pool_ns_len; 2900 ci->i_pool_ns_len = pool_ns_len;
2901 if (ci->i_layout.pool_id != old_pool)
2902 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
2900 2903
2901 /* size/truncate_seq? */ 2904 /* size/truncate_seq? */
2902 queue_trunc = ceph_fill_file_size(inode, issued, 2905 queue_trunc = ceph_fill_file_size(inode, issued,
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 0daaf7ceedc5..cba5dcf49a65 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1583,9 +1583,9 @@ static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length)
1583{ 1583{
1584 int ret = 0; 1584 int ret = 0;
1585 struct ceph_inode_info *ci = ceph_inode(inode); 1585 struct ceph_inode_info *ci = ceph_inode(inode);
1586 s32 stripe_unit = ceph_file_layout_su(ci->i_layout); 1586 s32 stripe_unit = ci->i_layout.stripe_unit;
1587 s32 stripe_count = ceph_file_layout_stripe_count(ci->i_layout); 1587 s32 stripe_count = ci->i_layout.stripe_count;
1588 s32 object_size = ceph_file_layout_object_size(ci->i_layout); 1588 s32 object_size = ci->i_layout.object_size;
1589 u64 object_set_size = object_size * stripe_count; 1589 u64 object_set_size = object_size * stripe_count;
1590 u64 nearly, t; 1590 u64 nearly, t;
1591 1591
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index f059b5997072..6c5903e0a976 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -814,10 +814,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
814 814
815 if (new_version || 815 if (new_version ||
816 (new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) { 816 (new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) {
817 if (ci->i_layout.fl_pg_pool != info->layout.fl_pg_pool) 817 s64 old_pool = ci->i_layout.pool_id;
818 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM; 818 ceph_file_layout_from_legacy(&ci->i_layout, &info->layout);
819 ci->i_layout = info->layout;
820 ci->i_pool_ns_len = iinfo->pool_ns_len; 819 ci->i_pool_ns_len = iinfo->pool_ns_len;
820 if (ci->i_layout.pool_id != old_pool)
821 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
821 822
822 queue_trunc = ceph_fill_file_size(inode, issued, 823 queue_trunc = ceph_fill_file_size(inode, issued,
823 le32_to_cpu(info->truncate_seq), 824 le32_to_cpu(info->truncate_seq),
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 0946f2d4a81f..843dd31a02cd 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -21,10 +21,10 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
21 21
22 err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false); 22 err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false);
23 if (!err) { 23 if (!err) {
24 l.stripe_unit = ceph_file_layout_su(ci->i_layout); 24 l.stripe_unit = ci->i_layout.stripe_unit;
25 l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout); 25 l.stripe_count = ci->i_layout.stripe_count;
26 l.object_size = ceph_file_layout_object_size(ci->i_layout); 26 l.object_size = ci->i_layout.object_size;
27 l.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool); 27 l.data_pool = ci->i_layout.pool_id;
28 l.preferred_osd = (s32)-1; 28 l.preferred_osd = (s32)-1;
29 if (copy_to_user(arg, &l, sizeof(l))) 29 if (copy_to_user(arg, &l, sizeof(l)))
30 return -EFAULT; 30 return -EFAULT;
@@ -82,19 +82,19 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
82 if (l.stripe_count) 82 if (l.stripe_count)
83 nl.stripe_count = l.stripe_count; 83 nl.stripe_count = l.stripe_count;
84 else 84 else
85 nl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout); 85 nl.stripe_count = ci->i_layout.stripe_count;
86 if (l.stripe_unit) 86 if (l.stripe_unit)
87 nl.stripe_unit = l.stripe_unit; 87 nl.stripe_unit = l.stripe_unit;
88 else 88 else
89 nl.stripe_unit = ceph_file_layout_su(ci->i_layout); 89 nl.stripe_unit = ci->i_layout.stripe_unit;
90 if (l.object_size) 90 if (l.object_size)
91 nl.object_size = l.object_size; 91 nl.object_size = l.object_size;
92 else 92 else
93 nl.object_size = ceph_file_layout_object_size(ci->i_layout); 93 nl.object_size = ci->i_layout.object_size;
94 if (l.data_pool) 94 if (l.data_pool)
95 nl.data_pool = l.data_pool; 95 nl.data_pool = l.data_pool;
96 else 96 else
97 nl.data_pool = ceph_file_layout_pg_pool(ci->i_layout); 97 nl.data_pool = ci->i_layout.pool_id;
98 98
99 /* this is obsolete, and always -1 */ 99 /* this is obsolete, and always -1 */
100 nl.preferred_osd = le64_to_cpu(-1); 100 nl.preferred_osd = le64_to_cpu(-1);
@@ -202,8 +202,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
202 return -EIO; 202 return -EIO;
203 } 203 }
204 dl.file_offset -= dl.object_offset; 204 dl.file_offset -= dl.object_offset;
205 dl.object_size = ceph_file_layout_object_size(ci->i_layout); 205 dl.object_size = ci->i_layout.object_size;
206 dl.block_size = ceph_file_layout_su(ci->i_layout); 206 dl.block_size = ci->i_layout.stripe_unit;
207 207
208 /* block_offset = object_offset % block_size */ 208 /* block_offset = object_offset % block_size */
209 tmp = dl.object_offset; 209 tmp = dl.object_offset;
@@ -212,7 +212,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
212 snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx", 212 snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
213 ceph_ino(inode), dl.object_no); 213 ceph_ino(inode), dl.object_no);
214 214
215 oloc.pool = ceph_file_layout_pg_pool(ci->i_layout); 215 oloc.pool = ci->i_layout.pool_id;
216 ceph_oid_printf(&oid, "%s", dl.object_name); 216 ceph_oid_printf(&oid, "%s", dl.object_name);
217 217
218 r = ceph_object_locator_to_pg(osdc->osdmap, &oid, &oloc, &pgid); 218 r = ceph_object_locator_to_pg(osdc->osdmap, &oid, &oloc, &pgid);
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index e7d38aac7109..75ecf967d0b7 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -275,8 +275,8 @@ struct ceph_mds_request {
275 275
276struct ceph_pool_perm { 276struct ceph_pool_perm {
277 struct rb_node node; 277 struct rb_node node;
278 u32 pool;
279 int perm; 278 int perm;
279 s64 pool;
280}; 280};
281 281
282/* 282/*
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 4870b29df224..5377c9c7a0c5 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -72,7 +72,7 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
72 int ret; 72 int ret;
73 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb); 73 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
74 struct ceph_osd_client *osdc = &fsc->client->osdc; 74 struct ceph_osd_client *osdc = &fsc->client->osdc;
75 s64 pool = ceph_file_layout_pg_pool(ci->i_layout); 75 s64 pool = ci->i_layout.pool_id;
76 const char *pool_name; 76 const char *pool_name;
77 char buf[128]; 77 char buf[128];
78 78
@@ -82,10 +82,9 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
82 if (pool_name) { 82 if (pool_name) {
83 size_t len = strlen(pool_name); 83 size_t len = strlen(pool_name);
84 ret = snprintf(buf, sizeof(buf), 84 ret = snprintf(buf, sizeof(buf),
85 "stripe_unit=%lld stripe_count=%lld object_size=%lld pool=", 85 "stripe_unit=%u stripe_count=%u object_size=%u pool=",
86 (unsigned long long)ceph_file_layout_su(ci->i_layout), 86 ci->i_layout.stripe_unit, ci->i_layout.stripe_count,
87 (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout), 87 ci->i_layout.object_size);
88 (unsigned long long)ceph_file_layout_object_size(ci->i_layout));
89 if (!size) { 88 if (!size) {
90 ret += len; 89 ret += len;
91 } else if (ret + len > size) { 90 } else if (ret + len > size) {
@@ -97,11 +96,9 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
97 } 96 }
98 } else { 97 } else {
99 ret = snprintf(buf, sizeof(buf), 98 ret = snprintf(buf, sizeof(buf),
100 "stripe_unit=%lld stripe_count=%lld object_size=%lld pool=%lld", 99 "stripe_unit=%u stripe_count=%u object_size=%u pool=%lld",
101 (unsigned long long)ceph_file_layout_su(ci->i_layout), 100 ci->i_layout.stripe_unit, ci->i_layout.stripe_count,
102 (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout), 101 ci->i_layout.object_size, (unsigned long long)pool);
103 (unsigned long long)ceph_file_layout_object_size(ci->i_layout),
104 (unsigned long long)pool);
105 if (size) { 102 if (size) {
106 if (ret <= size) 103 if (ret <= size)
107 memcpy(val, buf, ret); 104 memcpy(val, buf, ret);
@@ -116,22 +113,19 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
116static size_t ceph_vxattrcb_layout_stripe_unit(struct ceph_inode_info *ci, 113static size_t ceph_vxattrcb_layout_stripe_unit(struct ceph_inode_info *ci,
117 char *val, size_t size) 114 char *val, size_t size)
118{ 115{
119 return snprintf(val, size, "%lld", 116 return snprintf(val, size, "%u", ci->i_layout.stripe_unit);
120 (unsigned long long)ceph_file_layout_su(ci->i_layout));
121} 117}
122 118
123static size_t ceph_vxattrcb_layout_stripe_count(struct ceph_inode_info *ci, 119static size_t ceph_vxattrcb_layout_stripe_count(struct ceph_inode_info *ci,
124 char *val, size_t size) 120 char *val, size_t size)
125{ 121{
126 return snprintf(val, size, "%lld", 122 return snprintf(val, size, "%u", ci->i_layout.stripe_count);
127 (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout));
128} 123}
129 124
130static size_t ceph_vxattrcb_layout_object_size(struct ceph_inode_info *ci, 125static size_t ceph_vxattrcb_layout_object_size(struct ceph_inode_info *ci,
131 char *val, size_t size) 126 char *val, size_t size)
132{ 127{
133 return snprintf(val, size, "%lld", 128 return snprintf(val, size, "%u", ci->i_layout.object_size);
134 (unsigned long long)ceph_file_layout_object_size(ci->i_layout));
135} 129}
136 130
137static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci, 131static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,
@@ -140,7 +134,7 @@ static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,
140 int ret; 134 int ret;
141 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb); 135 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
142 struct ceph_osd_client *osdc = &fsc->client->osdc; 136 struct ceph_osd_client *osdc = &fsc->client->osdc;
143 s64 pool = ceph_file_layout_pg_pool(ci->i_layout); 137 s64 pool = ci->i_layout.pool_id;
144 const char *pool_name; 138 const char *pool_name;
145 139
146 down_read(&osdc->lock); 140 down_read(&osdc->lock);