Skip to content

Commit f775ff7

Browse files
agrafidryomov
authored andcommitted
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: 124e68e ("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>
1 parent b50c2de commit f775ff7

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎fs/ceph/file.c‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,38 @@
1313
#include "mds_client.h"
1414
#include "cache.h"
1515

16+
static __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+
1648
/*
1749
* Ceph file operations
1850
*
@@ -123,7 +155,7 @@ prepare_open_request(struct super_block *sb, int flags, int create_mode)
123155
if (IS_ERR(req))
124156
goto out;
125157
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);
127159
req->r_args.open.mode = cpu_to_le32(create_mode);
128160
out:
129161
return req;

‎include/linux/ceph/ceph_fs.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,18 @@ extern const char *ceph_mds_op_name(int op);
367367
#define CEPH_READDIR_HASH_ORDER (1<<9)
368368
#define CEPH_READDIR_OFFSET_HASH (1<<10)
369369

370+
/*
371+
* open request flags
372+
*/
373+
#define CEPH_O_RDONLY 00000000
374+
#define CEPH_O_WRONLY 00000001
375+
#define CEPH_O_RDWR 00000002
376+
#define CEPH_O_CREAT 00000100
377+
#define CEPH_O_EXCL 00000200
378+
#define CEPH_O_TRUNC 00001000
379+
#define CEPH_O_DIRECTORY 00200000
380+
#define CEPH_O_NOFOLLOW 00400000
381+
370382
union ceph_mds_request_args {
371383
struct {
372384
__le32 mask; /* CEPH_CAP_* */

0 commit comments

Comments
 (0)