Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+60 -63
+4 -10
Documentation/filesystems/orangefs.txt
··· 45 45 BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER 46 46 ==================================================== 47 47 48 - When Orangefs is upstream, "--with-kernel" shouldn't be needed, but 49 - until then the path to where the kernel with the Orangefs kernel client 50 - patch was built is needed to ensure that pvfs2-client-core (the bridge 51 - between 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. 48 + You can omit --prefix if you don't care that things are sprinkled around in 49 + /usr/local. As of version 2.9.6, Orangefs uses Berkeley DB by default, we 50 + will probably be changing the default to lmdb soon. 54 51 55 - ./configure --prefix=/opt/ofs --with-kernel=/path/to/orangefs/kernel 52 + ./configure --prefix=/opt/ofs --with-db-backend=lmdb 56 53 57 54 make 58 55 ··· 78 81 prove things are working with: 79 82 80 83 /opt/osf/bin/pvfs2-ls /mymountpoint 81 - 82 - You might not want to enforce selinux, it doesn't seem to matter by 83 - linux 3.11... 84 84 85 85 If stuff seems to be working, turn on the client core: 86 86 /opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core
+42 -21
fs/orangefs/acl.c
··· 35 35 * I don't do that for now. 36 36 */ 37 37 value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL); 38 - if (value == NULL) 38 + if (!value) 39 39 return ERR_PTR(-ENOMEM); 40 40 41 41 gossip_debug(GOSSIP_ACL_DEBUG, ··· 61 61 return acl; 62 62 } 63 63 64 - int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 64 + static 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 67 int error = 0; 68 68 void *value = NULL; 69 69 size_t size = 0; ··· 72 72 switch (type) { 73 73 case ACL_TYPE_ACCESS: 74 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 75 break; 92 76 case ACL_TYPE_DEFAULT: 93 77 name = XATTR_NAME_POSIX_ACL_DEFAULT; ··· 116 132 return error; 117 133 } 118 134 135 + int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 136 + { 137 + int error; 138 + struct iattr iattr; 139 + int rc; 140 + 141 + if (type == ACL_TYPE_ACCESS && acl) { 142 + /* 143 + * posix_acl_update_mode checks to see if the permissions 144 + * described by the ACL can be encoded into the 145 + * object's mode. If so, it sets "acl" to NULL 146 + * and "mode" to the new desired value. It is up to 147 + * us to propagate the new mode back to the server... 148 + */ 149 + error = posix_acl_update_mode(inode, &iattr.ia_mode, &acl); 150 + if (error) { 151 + gossip_err("%s: posix_acl_update_mode err: %d\n", 152 + __func__, 153 + error); 154 + return error; 155 + } 156 + 157 + if (acl) { 158 + rc = __orangefs_set_acl(inode, acl, type); 159 + } else { 160 + iattr.ia_valid = ATTR_MODE; 161 + rc = orangefs_inode_setattr(inode, &iattr); 162 + } 163 + 164 + return rc; 165 + 166 + } else { 167 + return -EINVAL; 168 + } 169 + } 170 + 119 171 int orangefs_init_acl(struct inode *inode, struct inode *dir) 120 172 { 121 173 struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); ··· 166 146 return error; 167 147 168 148 if (default_acl) { 169 - error = orangefs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 149 + error = __orangefs_set_acl(inode, default_acl, 150 + ACL_TYPE_DEFAULT); 170 151 posix_acl_release(default_acl); 171 152 } 172 153 173 154 if (acl) { 174 155 if (!error) 175 - error = orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS); 156 + error = __orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS); 176 157 posix_acl_release(acl); 177 158 } 178 159
+3 -6
fs/orangefs/devorangefs-req.c
··· 461 461 if (op->downcall.type != ORANGEFS_VFS_OP_READDIR) 462 462 goto wakeup; 463 463 464 - op->downcall.trailer_buf = 465 - vmalloc(op->downcall.trailer_size); 466 - if (op->downcall.trailer_buf == NULL) { 467 - gossip_err("%s: failed trailer vmalloc.\n", 468 - __func__); 464 + op->downcall.trailer_buf = vmalloc(op->downcall.trailer_size); 465 + if (!op->downcall.trailer_buf) 469 466 goto Enomem; 470 - } 467 + 471 468 memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size); 472 469 if (!copy_from_iter_full(op->downcall.trailer_buf, 473 470 op->downcall.trailer_size, iter)) {
+1 -4
fs/orangefs/file.c
··· 646 646 loff_t end, 647 647 int datasync) 648 648 { 649 - int ret = -EINVAL; 649 + int ret; 650 650 struct orangefs_inode_s *orangefs_inode = 651 651 ORANGEFS_I(file_inode(file)); 652 652 struct orangefs_kernel_op_s *new_op = NULL; 653 - 654 - /* required call */ 655 - filemap_write_and_wait_range(file->f_mapping, start, end); 656 653 657 654 new_op = op_alloc(ORANGEFS_VFS_OP_FSYNC); 658 655 if (!new_op)
+2 -8
fs/orangefs/orangefs-bufmap.c
··· 244 244 245 245 bufmap->buffer_index_array = 246 246 kzalloc(DIV_ROUND_UP(bufmap->desc_count, BITS_PER_LONG), GFP_KERNEL); 247 - if (!bufmap->buffer_index_array) { 248 - gossip_err("orangefs: could not allocate %d buffer indices\n", 249 - bufmap->desc_count); 247 + if (!bufmap->buffer_index_array) 250 248 goto out_free_bufmap; 251 - } 252 249 253 250 bufmap->desc_array = 254 251 kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc), 255 252 GFP_KERNEL); 256 - if (!bufmap->desc_array) { 257 - gossip_err("orangefs: could not allocate %d descriptors\n", 258 - bufmap->desc_count); 253 + if (!bufmap->desc_array) 259 254 goto out_free_index_array; 260 - } 261 255 262 256 bufmap->page_count = bufmap->total_size / PAGE_SIZE; 263 257
+1 -4
fs/orangefs/orangefs-debugfs.c
··· 571 571 goto out; 572 572 } 573 573 574 - cdm_array = 575 - kzalloc(cdm_element_count * sizeof(struct client_debug_mask), 576 - GFP_KERNEL); 574 + cdm_array = kcalloc(cdm_element_count, sizeof(*cdm_array), GFP_KERNEL); 577 575 if (!cdm_array) { 578 - pr_info("malloc failed for cdm_array!\n"); 579 576 rc = -ENOMEM; 580 577 goto out; 581 578 }
-1
fs/orangefs/orangefs-mod.c
··· 98 98 orangefs_htable_ops_in_progress = 99 99 kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL); 100 100 if (!orangefs_htable_ops_in_progress) { 101 - gossip_err("Failed to initialize op hashtable"); 102 101 ret = -ENOMEM; 103 102 goto cleanup_inode; 104 103 }
+1 -3
fs/orangefs/super.c
··· 107 107 struct orangefs_inode_s *orangefs_inode; 108 108 109 109 orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL); 110 - if (orangefs_inode == NULL) { 111 - gossip_err("Failed to allocate orangefs_inode\n"); 110 + if (!orangefs_inode) 112 111 return NULL; 113 - } 114 112 115 113 /* 116 114 * We want to clear everything except for rw_semaphore and the
+6 -6
fs/orangefs/xattr.c
··· 76 76 if (S_ISLNK(inode->i_mode)) 77 77 return -EOPNOTSUPP; 78 78 79 - if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) 79 + if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) 80 80 return -EINVAL; 81 81 82 82 fsuid = from_kuid(&init_user_ns, current_fsuid()); ··· 169 169 struct orangefs_kernel_op_s *new_op = NULL; 170 170 int ret = -ENOMEM; 171 171 172 - if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) 172 + if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) 173 173 return -EINVAL; 174 174 175 175 down_write(&orangefs_inode->xattr_sem); ··· 233 233 234 234 if (size > ORANGEFS_MAX_XATTR_VALUELEN) 235 235 return -EINVAL; 236 - if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) 236 + if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) 237 237 return -EINVAL; 238 238 239 239 internal_flag = convert_to_internal_xattr_flags(flags); 240 240 241 241 /* This is equivalent to a removexattr */ 242 - if (size == 0 && value == NULL) { 242 + if (size == 0 && !value) { 243 243 gossip_debug(GOSSIP_XATTR_DEBUG, 244 244 "removing xattr (%s)\n", 245 245 name); ··· 311 311 int i = 0; 312 312 int returned_count = 0; 313 313 314 - if (size > 0 && buffer == NULL) { 314 + if (size > 0 && !buffer) { 315 315 gossip_err("%s: bogus NULL pointers\n", __func__); 316 316 return -EINVAL; 317 317 } ··· 442 442 443 443 } 444 444 445 - static struct xattr_handler orangefs_xattr_default_handler = { 445 + static const struct xattr_handler orangefs_xattr_default_handler = { 446 446 .prefix = "", /* match any name => handlers called with full name */ 447 447 .get = orangefs_xattr_get_default, 448 448 .set = orangefs_xattr_set_default,