summaryrefslogtreecommitdiffstats
path: root/fs/ceph/file.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2017-04-27 12:34:00 -0400
committerIlya Dryomov <idryomov@gmail.com>2017-05-04 03:19:24 -0400
commitf775ff7d89f33fc9ba63f6f70df3bcc98c2d9828 (patch)
tree78b25de67d31fd059fafbddee44e5c835694d1b5 /fs/ceph/file.c
parentb50c2de51e611da90cf3cf04c058f7e9bbe79e93 (diff)
ceph: fix file open flags on ppc64
The file open flags (O_foo) are platform specific and should never go out to an interface that is not local to the system. Unfortunately these flags have leaked out onto the wire in the cephfs implementation. That lead to bogus flags getting transmitted on ppc64. This patch converts the kernel view of flags to the ceph view of file open flags. Fixes: 124e68e74 ("ceph: file operations") Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/file.c')
-rw-r--r--fs/ceph/file.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 39866d6a34b6..9d2eeed9e323 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -13,6 +13,38 @@
13#include "mds_client.h" 13#include "mds_client.h"
14#include "cache.h" 14#include "cache.h"
15 15
16static __le32 ceph_flags_sys2wire(u32 flags)
17{
18 u32 wire_flags = 0;
19
20 switch (flags & O_ACCMODE) {
21 case O_RDONLY:
22 wire_flags |= CEPH_O_RDONLY;
23 break;
24 case O_WRONLY:
25 wire_flags |= CEPH_O_WRONLY;
26 break;
27 case O_RDWR:
28 wire_flags |= CEPH_O_RDWR;
29 break;
30 }
31
32#define ceph_sys2wire(a) if (flags & a) { wire_flags |= CEPH_##a; flags &= ~a; }
33
34 ceph_sys2wire(O_CREAT);
35 ceph_sys2wire(O_EXCL);
36 ceph_sys2wire(O_TRUNC);
37 ceph_sys2wire(O_DIRECTORY);
38 ceph_sys2wire(O_NOFOLLOW);
39
40#undef ceph_sys2wire
41
42 if (flags)
43 dout("unused open flags: %x", flags);
44
45 return cpu_to_le32(wire_flags);
46}
47
16/* 48/*
17 * Ceph file operations 49 * Ceph file operations
18 * 50 *
@@ -123,7 +155,7 @@ prepare_open_request(struct super_block *sb, int flags, int create_mode)
123 if (IS_ERR(req)) 155 if (IS_ERR(req))
124 goto out; 156 goto out;
125 req->r_fmode = ceph_flags_to_mode(flags); 157 req->r_fmode = ceph_flags_to_mode(flags);
126 req->r_args.open.flags = cpu_to_le32(flags); 158 req->r_args.open.flags = ceph_flags_sys2wire(flags);
127 req->r_args.open.mode = cpu_to_le32(create_mode); 159 req->r_args.open.mode = cpu_to_le32(create_mode);
128out: 160out:
129 return req; 161 return req;