Skip to content

Commit 30db202

Browse files
committed
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
2 parents 711aab1 + 0b08273 commit 30db202

File tree

9 files changed

+60
-63
lines changed

9 files changed

+60
-63
lines changed

Documentation/filesystems/orangefs.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,11 @@ upstream version of the kernel client.
4545
BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER
4646
====================================================
4747

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.
5451

55-
./configure --prefix=/opt/ofs --with-kernel=/path/to/orangefs/kernel
52+
./configure --prefix=/opt/ofs --with-db-backend=lmdb
5653

5754
make
5855

@@ -82,9 +79,6 @@ prove things are working with:
8279

8380
/opt/osf/bin/pvfs2-ls /mymountpoint
8481

85-
You might not want to enforce selinux, it doesn't seem to matter by
86-
linux 3.11...
87-
8882
If stuff seems to be working, turn on the client core:
8983
/opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core
9084

fs/orangefs/acl.c

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
3535
* I don't do that for now.
3636
*/
3737
value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL);
38-
if (value == NULL)
38+
if (!value)
3939
return ERR_PTR(-ENOMEM);
4040

4141
gossip_debug(GOSSIP_ACL_DEBUG,
@@ -61,9 +61,9 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
6161
return acl;
6262
}
6363

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)
6566
{
66-
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
6767
int error = 0;
6868
void *value = NULL;
6969
size_t size = 0;
@@ -72,22 +72,6 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
7272
switch (type) {
7373
case ACL_TYPE_ACCESS:
7474
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-
}
9175
break;
9276
case ACL_TYPE_DEFAULT:
9377
name = XATTR_NAME_POSIX_ACL_DEFAULT;
@@ -132,6 +116,42 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
132116
return error;
133117
}
134118

119+
int 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+
135155
int orangefs_init_acl(struct inode *inode, struct inode *dir)
136156
{
137157
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
@@ -146,13 +166,14 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir)
146166
return error;
147167

148168
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);
150171
posix_acl_release(default_acl);
151172
}
152173

153174
if (acl) {
154175
if (!error)
155-
error = orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
176+
error = __orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
156177
posix_acl_release(acl);
157178
}
158179

fs/orangefs/devorangefs-req.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,10 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb,
461461
if (op->downcall.type != ORANGEFS_VFS_OP_READDIR)
462462
goto wakeup;
463463

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)
469466
goto Enomem;
470-
}
467+
471468
memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size);
472469
if (!copy_from_iter_full(op->downcall.trailer_buf,
473470
op->downcall.trailer_size, iter)) {

fs/orangefs/file.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,14 +646,11 @@ static int orangefs_fsync(struct file *file,
646646
loff_t end,
647647
int datasync)
648648
{
649-
int ret = -EINVAL;
649+
int ret;
650650
struct orangefs_inode_s *orangefs_inode =
651651
ORANGEFS_I(file_inode(file));
652652
struct orangefs_kernel_op_s *new_op = NULL;
653653

654-
/* required call */
655-
filemap_write_and_wait_range(file->f_mapping, start, end);
656-
657654
new_op = op_alloc(ORANGEFS_VFS_OP_FSYNC);
658655
if (!new_op)
659656
return -ENOMEM;

fs/orangefs/orangefs-bufmap.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,20 +244,14 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc)
244244

245245
bufmap->buffer_index_array =
246246
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)
250248
goto out_free_bufmap;
251-
}
252249

253250
bufmap->desc_array =
254251
kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc),
255252
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)
259254
goto out_free_index_array;
260-
}
261255

262256
bufmap->page_count = bufmap->total_size / PAGE_SIZE;
263257

fs/orangefs/orangefs-debugfs.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,8 @@ static int orangefs_prepare_cdm_array(char *debug_array_string)
571571
goto out;
572572
}
573573

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);
577575
if (!cdm_array) {
578-
pr_info("malloc failed for cdm_array!\n");
579576
rc = -ENOMEM;
580577
goto out;
581578
}

fs/orangefs/orangefs-mod.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ static int __init orangefs_init(void)
9898
orangefs_htable_ops_in_progress =
9999
kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL);
100100
if (!orangefs_htable_ops_in_progress) {
101-
gossip_err("Failed to initialize op hashtable");
102101
ret = -ENOMEM;
103102
goto cleanup_inode;
104103
}

fs/orangefs/super.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,8 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb)
107107
struct orangefs_inode_s *orangefs_inode;
108108

109109
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)
112111
return NULL;
113-
}
114112

115113
/*
116114
* We want to clear everything except for rw_semaphore and the

fs/orangefs/xattr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
7676
if (S_ISLNK(inode->i_mode))
7777
return -EOPNOTSUPP;
7878

79-
if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
79+
if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
8080
return -EINVAL;
8181

8282
fsuid = from_kuid(&init_user_ns, current_fsuid());
@@ -169,7 +169,7 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name,
169169
struct orangefs_kernel_op_s *new_op = NULL;
170170
int ret = -ENOMEM;
171171

172-
if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
172+
if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
173173
return -EINVAL;
174174

175175
down_write(&orangefs_inode->xattr_sem);
@@ -233,13 +233,13 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name,
233233

234234
if (size > ORANGEFS_MAX_XATTR_VALUELEN)
235235
return -EINVAL;
236-
if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
236+
if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
237237
return -EINVAL;
238238

239239
internal_flag = convert_to_internal_xattr_flags(flags);
240240

241241
/* This is equivalent to a removexattr */
242-
if (size == 0 && value == NULL) {
242+
if (size == 0 && !value) {
243243
gossip_debug(GOSSIP_XATTR_DEBUG,
244244
"removing xattr (%s)\n",
245245
name);
@@ -311,7 +311,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size)
311311
int i = 0;
312312
int returned_count = 0;
313313

314-
if (size > 0 && buffer == NULL) {
314+
if (size > 0 && !buffer) {
315315
gossip_err("%s: bogus NULL pointers\n", __func__);
316316
return -EINVAL;
317317
}
@@ -442,7 +442,7 @@ static int orangefs_xattr_get_default(const struct xattr_handler *handler,
442442

443443
}
444444

445-
static struct xattr_handler orangefs_xattr_default_handler = {
445+
static const struct xattr_handler orangefs_xattr_default_handler = {
446446
.prefix = "", /* match any name => handlers called with full name */
447447
.get = orangefs_xattr_get_default,
448448
.set = orangefs_xattr_set_default,

0 commit comments

Comments
 (0)