aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-15 15:16:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-15 15:16:18 -0400
commit30db202e54d251e4887935f7b4538b44911bb091 (patch)
tree634596b162622dff2253e0d29d34f5c03c35f8b2
parent711aab1dbb324d321e3d84368a435a78908c7bce (diff)
parent0b08273c8ab7e688832120c4817b1adfdc56e231 (diff)
Merge tag 'for-linus-4.14-ofs2' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux
Pull orangefs updates from Mike Marshall: "Some cleanups and a big bug fix for ACLs. When I was reviewing Jan Kara's ACL patch, I realized that Orangefs ACL code was busted, not just in the kernel module, but in the server as well. I've been working on the code in the server mostly, but here's one kernel patch, there will be more" * tag 'for-linus-4.14-ofs2' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux: orangefs: Adjust three checks for null pointers orangefs: Use kcalloc() in orangefs_prepare_cdm_array() orangefs: Delete error messages for a failed memory allocation in five functions orangefs: constify xattr_handler structure orangefs: don't call filemap_write_and_wait from fsync orangefs: off by ones in xattr size checks orangefs: documentation clean up orangefs: react properly to posix_acl_update_mode's aftermath. orangefs: Don't clear SGID when inheriting ACLs
-rw-r--r--Documentation/filesystems/orangefs.txt14
-rw-r--r--fs/orangefs/acl.c63
-rw-r--r--fs/orangefs/devorangefs-req.c9
-rw-r--r--fs/orangefs/file.c5
-rw-r--r--fs/orangefs/orangefs-bufmap.c10
-rw-r--r--fs/orangefs/orangefs-debugfs.c5
-rw-r--r--fs/orangefs/orangefs-mod.c1
-rw-r--r--fs/orangefs/super.c4
-rw-r--r--fs/orangefs/xattr.c12
9 files changed, 60 insertions, 63 deletions
diff --git a/Documentation/filesystems/orangefs.txt b/Documentation/filesystems/orangefs.txt
index 1dfdec790946..e2818b60a5c2 100644
--- a/Documentation/filesystems/orangefs.txt
+++ b/Documentation/filesystems/orangefs.txt
@@ -45,14 +45,11 @@ upstream version of the kernel client.
45BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER 45BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER
46==================================================== 46====================================================
47 47
48When Orangefs is upstream, "--with-kernel" shouldn't be needed, but 48You can omit --prefix if you don't care that things are sprinkled around in
49until then the path to where the kernel with the Orangefs kernel client 49/usr/local. As of version 2.9.6, Orangefs uses Berkeley DB by default, we
50patch was built is needed to ensure that pvfs2-client-core (the bridge 50will probably be changing the default to lmdb soon.
51between kernel space and user space) will build properly. You can omit
52--prefix if you don't care that things are sprinkled around in
53/usr/local.
54 51
55./configure --prefix=/opt/ofs --with-kernel=/path/to/orangefs/kernel 52./configure --prefix=/opt/ofs --with-db-backend=lmdb
56 53
57make 54make
58 55
@@ -82,9 +79,6 @@ prove things are working with:
82 79
83/opt/osf/bin/pvfs2-ls /mymountpoint 80/opt/osf/bin/pvfs2-ls /mymountpoint
84 81
85You might not want to enforce selinux, it doesn't seem to matter by
86linux 3.11...
87
88If stuff seems to be working, turn on the client core: 82If stuff seems to be working, turn on the client core:
89/opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core 83/opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core
90 84
diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
index 7a3754488312..9108ef433e6d 100644
--- a/fs/orangefs/acl.c
+++ b/fs/orangefs/acl.c
@@ -35,7 +35,7 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
35 * I don't do that for now. 35 * I don't do that for now.
36 */ 36 */
37 value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL); 37 value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL);
38 if (value == NULL) 38 if (!value)
39 return ERR_PTR(-ENOMEM); 39 return ERR_PTR(-ENOMEM);
40 40
41 gossip_debug(GOSSIP_ACL_DEBUG, 41 gossip_debug(GOSSIP_ACL_DEBUG,
@@ -61,9 +61,9 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
61 return acl; 61 return acl;
62} 62}
63 63
64int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 64static int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl,
65 int type)
65{ 66{
66 struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
67 int error = 0; 67 int error = 0;
68 void *value = NULL; 68 void *value = NULL;
69 size_t size = 0; 69 size_t size = 0;
@@ -72,22 +72,6 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
72 switch (type) { 72 switch (type) {
73 case ACL_TYPE_ACCESS: 73 case ACL_TYPE_ACCESS:
74 name = XATTR_NAME_POSIX_ACL_ACCESS; 74 name = XATTR_NAME_POSIX_ACL_ACCESS;
75 if (acl) {
76 umode_t mode;
77
78 error = posix_acl_update_mode(inode, &mode, &acl);
79 if (error) {
80 gossip_err("%s: posix_acl_update_mode err: %d\n",
81 __func__,
82 error);
83 return error;
84 }
85
86 if (inode->i_mode != mode)
87 SetModeFlag(orangefs_inode);
88 inode->i_mode = mode;
89 mark_inode_dirty_sync(inode);
90 }
91 break; 75 break;
92 case ACL_TYPE_DEFAULT: 76 case ACL_TYPE_DEFAULT:
93 name = XATTR_NAME_POSIX_ACL_DEFAULT; 77 name = XATTR_NAME_POSIX_ACL_DEFAULT;
@@ -132,6 +116,42 @@ out:
132 return error; 116 return error;
133} 117}
134 118
119int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
120{
121 int error;
122 struct iattr iattr;
123 int rc;
124
125 if (type == ACL_TYPE_ACCESS && acl) {
126 /*
127 * posix_acl_update_mode checks to see if the permissions
128 * described by the ACL can be encoded into the
129 * object's mode. If so, it sets "acl" to NULL
130 * and "mode" to the new desired value. It is up to
131 * us to propagate the new mode back to the server...
132 */
133 error = posix_acl_update_mode(inode, &iattr.ia_mode, &acl);
134 if (error) {
135 gossip_err("%s: posix_acl_update_mode err: %d\n",
136 __func__,
137 error);
138 return error;
139 }
140
141 if (acl) {
142 rc = __orangefs_set_acl(inode, acl, type);
143 } else {
144 iattr.ia_valid = ATTR_MODE;
145 rc = orangefs_inode_setattr(inode, &iattr);
146 }
147
148 return rc;
149
150 } else {
151 return -EINVAL;
152 }
153}
154
135int orangefs_init_acl(struct inode *inode, struct inode *dir) 155int orangefs_init_acl(struct inode *inode, struct inode *dir)
136{ 156{
137 struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); 157 struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
@@ -146,13 +166,14 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir)
146 return error; 166 return error;
147 167
148 if (default_acl) { 168 if (default_acl) {
149 error = orangefs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 169 error = __orangefs_set_acl(inode, default_acl,
170 ACL_TYPE_DEFAULT);
150 posix_acl_release(default_acl); 171 posix_acl_release(default_acl);
151 } 172 }
152 173
153 if (acl) { 174 if (acl) {
154 if (!error) 175 if (!error)
155 error = orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS); 176 error = __orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
156 posix_acl_release(acl); 177 posix_acl_release(acl);
157 } 178 }
158 179
diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c
index c19f0787c9c6..2826859bdc2c 100644
--- a/fs/orangefs/devorangefs-req.c
+++ b/fs/orangefs/devorangefs-req.c
@@ -461,13 +461,10 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb,
461 if (op->downcall.type != ORANGEFS_VFS_OP_READDIR) 461 if (op->downcall.type != ORANGEFS_VFS_OP_READDIR)
462 goto wakeup; 462 goto wakeup;
463 463
464 op->downcall.trailer_buf = 464 op->downcall.trailer_buf = vmalloc(op->downcall.trailer_size);
465 vmalloc(op->downcall.trailer_size); 465 if (!op->downcall.trailer_buf)
466 if (op->downcall.trailer_buf == NULL) {
467 gossip_err("%s: failed trailer vmalloc.\n",
468 __func__);
469 goto Enomem; 466 goto Enomem;
470 } 467
471 memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size); 468 memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size);
472 if (!copy_from_iter_full(op->downcall.trailer_buf, 469 if (!copy_from_iter_full(op->downcall.trailer_buf,
473 op->downcall.trailer_size, iter)) { 470 op->downcall.trailer_size, iter)) {
diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c
index 28f38d813ad2..336ecbf8c268 100644
--- a/fs/orangefs/file.c
+++ b/fs/orangefs/file.c
@@ -646,14 +646,11 @@ static int orangefs_fsync(struct file *file,
646 loff_t end, 646 loff_t end,
647 int datasync) 647 int datasync)
648{ 648{
649 int ret = -EINVAL; 649 int ret;
650 struct orangefs_inode_s *orangefs_inode = 650 struct orangefs_inode_s *orangefs_inode =
651 ORANGEFS_I(file_inode(file)); 651 ORANGEFS_I(file_inode(file));
652 struct orangefs_kernel_op_s *new_op = NULL; 652 struct orangefs_kernel_op_s *new_op = NULL;
653 653
654 /* required call */
655 filemap_write_and_wait_range(file->f_mapping, start, end);
656
657 new_op = op_alloc(ORANGEFS_VFS_OP_FSYNC); 654 new_op = op_alloc(ORANGEFS_VFS_OP_FSYNC);
658 if (!new_op) 655 if (!new_op)
659 return -ENOMEM; 656 return -ENOMEM;
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index 038d67545d9f..7ef473f3d642 100644
--- a/fs/orangefs/orangefs-bufmap.c
+++ b/fs/orangefs/orangefs-bufmap.c
@@ -244,20 +244,14 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc)
244 244
245 bufmap->buffer_index_array = 245 bufmap->buffer_index_array =
246 kzalloc(DIV_ROUND_UP(bufmap->desc_count, BITS_PER_LONG), GFP_KERNEL); 246 kzalloc(DIV_ROUND_UP(bufmap->desc_count, BITS_PER_LONG), GFP_KERNEL);
247 if (!bufmap->buffer_index_array) { 247 if (!bufmap->buffer_index_array)
248 gossip_err("orangefs: could not allocate %d buffer indices\n",
249 bufmap->desc_count);
250 goto out_free_bufmap; 248 goto out_free_bufmap;
251 }
252 249
253 bufmap->desc_array = 250 bufmap->desc_array =
254 kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc), 251 kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc),
255 GFP_KERNEL); 252 GFP_KERNEL);
256 if (!bufmap->desc_array) { 253 if (!bufmap->desc_array)
257 gossip_err("orangefs: could not allocate %d descriptors\n",
258 bufmap->desc_count);
259 goto out_free_index_array; 254 goto out_free_index_array;
260 }
261 255
262 bufmap->page_count = bufmap->total_size / PAGE_SIZE; 256 bufmap->page_count = bufmap->total_size / PAGE_SIZE;
263 257
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 716ed337f166..5f59917fd631 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -571,11 +571,8 @@ static int orangefs_prepare_cdm_array(char *debug_array_string)
571 goto out; 571 goto out;
572 } 572 }
573 573
574 cdm_array = 574 cdm_array = kcalloc(cdm_element_count, sizeof(*cdm_array), GFP_KERNEL);
575 kzalloc(cdm_element_count * sizeof(struct client_debug_mask),
576 GFP_KERNEL);
577 if (!cdm_array) { 575 if (!cdm_array) {
578 pr_info("malloc failed for cdm_array!\n");
579 rc = -ENOMEM; 576 rc = -ENOMEM;
580 goto out; 577 goto out;
581 } 578 }
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index c1b5174cb5a9..85ef87245a87 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -98,7 +98,6 @@ static int __init orangefs_init(void)
98 orangefs_htable_ops_in_progress = 98 orangefs_htable_ops_in_progress =
99 kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL); 99 kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL);
100 if (!orangefs_htable_ops_in_progress) { 100 if (!orangefs_htable_ops_in_progress) {
101 gossip_err("Failed to initialize op hashtable");
102 ret = -ENOMEM; 101 ret = -ENOMEM;
103 goto cleanup_inode; 102 goto cleanup_inode;
104 } 103 }
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index 5a1bed6c8c6a..47f3fb9cbec4 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -107,10 +107,8 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb)
107 struct orangefs_inode_s *orangefs_inode; 107 struct orangefs_inode_s *orangefs_inode;
108 108
109 orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL); 109 orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL);
110 if (orangefs_inode == NULL) { 110 if (!orangefs_inode)
111 gossip_err("Failed to allocate orangefs_inode\n");
112 return NULL; 111 return NULL;
113 }
114 112
115 /* 113 /*
116 * We want to clear everything except for rw_semaphore and the 114 * We want to clear everything except for rw_semaphore and the
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c
index 237c9c04dc3b..81ac88bb91ff 100644
--- a/fs/orangefs/xattr.c
+++ b/fs/orangefs/xattr.c
@@ -76,7 +76,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
76 if (S_ISLNK(inode->i_mode)) 76 if (S_ISLNK(inode->i_mode))
77 return -EOPNOTSUPP; 77 return -EOPNOTSUPP;
78 78
79 if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) 79 if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
80 return -EINVAL; 80 return -EINVAL;
81 81
82 fsuid = from_kuid(&init_user_ns, current_fsuid()); 82 fsuid = from_kuid(&init_user_ns, current_fsuid());
@@ -169,7 +169,7 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name,
169 struct orangefs_kernel_op_s *new_op = NULL; 169 struct orangefs_kernel_op_s *new_op = NULL;
170 int ret = -ENOMEM; 170 int ret = -ENOMEM;
171 171
172 if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) 172 if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
173 return -EINVAL; 173 return -EINVAL;
174 174
175 down_write(&orangefs_inode->xattr_sem); 175 down_write(&orangefs_inode->xattr_sem);
@@ -233,13 +233,13 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name,
233 233
234 if (size > ORANGEFS_MAX_XATTR_VALUELEN) 234 if (size > ORANGEFS_MAX_XATTR_VALUELEN)
235 return -EINVAL; 235 return -EINVAL;
236 if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) 236 if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
237 return -EINVAL; 237 return -EINVAL;
238 238
239 internal_flag = convert_to_internal_xattr_flags(flags); 239 internal_flag = convert_to_internal_xattr_flags(flags);
240 240
241 /* This is equivalent to a removexattr */ 241 /* This is equivalent to a removexattr */
242 if (size == 0 && value == NULL) { 242 if (size == 0 && !value) {
243 gossip_debug(GOSSIP_XATTR_DEBUG, 243 gossip_debug(GOSSIP_XATTR_DEBUG,
244 "removing xattr (%s)\n", 244 "removing xattr (%s)\n",
245 name); 245 name);
@@ -311,7 +311,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size)
311 int i = 0; 311 int i = 0;
312 int returned_count = 0; 312 int returned_count = 0;
313 313
314 if (size > 0 && buffer == NULL) { 314 if (size > 0 && !buffer) {
315 gossip_err("%s: bogus NULL pointers\n", __func__); 315 gossip_err("%s: bogus NULL pointers\n", __func__);
316 return -EINVAL; 316 return -EINVAL;
317 } 317 }
@@ -442,7 +442,7 @@ static int orangefs_xattr_get_default(const struct xattr_handler *handler,
442 442
443} 443}
444 444
445static struct xattr_handler orangefs_xattr_default_handler = { 445static const struct xattr_handler orangefs_xattr_default_handler = {
446 .prefix = "", /* match any name => handlers called with full name */ 446 .prefix = "", /* match any name => handlers called with full name */
447 .get = orangefs_xattr_get_default, 447 .get = orangefs_xattr_get_default,
448 .set = orangefs_xattr_set_default, 448 .set = orangefs_xattr_set_default,