ceph: remove the extra slashes in the server path
It's possible to pass the mount helper a server path that has more
than one contiguous slash character. For example:
mount -t ceph 192.168.195.165:40176:/// /mnt/cephfs/
In the MDS server side the extra slashes of the server path will be
treated as snap dir, and then we can get the following debug logs:
<7>[ ...] ceph: mount opening path //
<7>[ ...] ceph: open_root_inode opening '//'
<7>[ ...] ceph: fill_trace
0000000059b8a3bc is_dentry 0 is_target 1
<7>[ ...] ceph: alloc_inode
00000000dc4ca00b
<7>[ ...] ceph: get_inode created new inode
00000000dc4ca00b 1.
ffffffffffffffff ino 1
<7>[ ...] ceph: get_inode on 1=1.
ffffffffffffffff got
00000000dc4ca00b
And then when creating any new file or directory under the mount
point, we can get the following crash core dump:
<4>[ ...] ------------[ cut here ]------------
<2>[ ...] kernel BUG at fs/ceph/inode.c:1347!
<4>[ ...] invalid opcode: 0000 [#1] SMP PTI
<4>[ ...] CPU: 0 PID: 7 Comm: kworker/0:1 Tainted: G E 5.4.0-rc5+ #1
<4>[ ...] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
<4>[ ...] Workqueue: ceph-msgr ceph_con_workfn [libceph]
<4>[ ...] RIP: 0010:ceph_fill_trace+0x992/0xb30 [ceph]
<4>[ ...] Code: ff 0f 0b 0f 0b 0f 0b 4c 89 fa 48 c7 c6 4d [...]
<4>[ ...] RSP: 0018:
ffffa23d40067c70 EFLAGS:
00010297
<4>[ ...] RAX:
fffffffffffffffe RBX:
ffff8a229eb566c0 RCX:
0000000000000006
<4>[ ...] RDX:
0000000000000000 RSI:
0000000000000092 RDI:
ffff8a23aec17900
<4>[ ...] RBP:
ffff8a226bd91eb0 R08:
0000000000000001 R09:
0000000000000885
<4>[ ...] R10:
000000000002dfd8 R11:
ffff8a226bd95b30 R12:
ffff8a239347e000
<4>[ ...] R13:
0000000000000000 R14:
ffff8a22fabeb000 R15:
ffff8a2338b0c900
<4>[ ...] FS:
0000000000000000(0000) GS:
ffff8a23aec00000(0000) knlGS:
0000000000000000
<4>[ ...] CS: 0010 DS: 0000 ES: 0000 CR0:
0000000080050033
<4>[ ...] CR2:
000055b479d92068 CR3:
00000003764f6004 CR4:
00000000003606f0
<4>[ ...] DR0:
0000000000000000 DR1:
0000000000000000 DR2:
0000000000000000
<4>[ ...] DR3:
0000000000000000 DR6:
00000000fffe0ff0 DR7:
0000000000000400
<4>[ ...] Call Trace:
<4>[ ...] dispatch+0x2ac/0x12b0 [ceph]
<4>[ ...] ceph_con_workfn+0xd40/0x27c0 [libceph]
<4>[ ...] process_one_work+0x1b0/0x350
<4>[ ...] worker_thread+0x50/0x3b0
<4>[ ...] kthread+0xfb/0x130
<4>[ ...] ? process_one_work+0x350/0x350
<4>[ ...] ? kthread_park+0x90/0x90
<4>[ ...] ret_from_fork+0x35/0x40
<4>[ ...] Modules linked in: ceph(E) libceph fscache [...]
<4>[ ...] ---[ end trace
ba883d8ccf9afcb0 ]---
<4>[ ...] RIP: 0010:ceph_fill_trace+0x992/0xb30 [ceph]
<4>[ ...] Code: ff 0f 0b 0f 0b 0f 0b 4c 89 fa 48 c7 c6 [...]
<4>[ ...] RSP: 0018:
ffffa23d40067c70 EFLAGS:
00010297
<4>[ ...] RAX:
fffffffffffffffe RBX:
ffff8a229eb566c0 RCX:
0000000000000006
<4>[ ...] RDX:
0000000000000000 RSI:
0000000000000092 RDI:
ffff8a23aec17900
<4>[ ...] RBP:
ffff8a226bd91eb0 R08:
0000000000000001 R09:
0000000000000885
<4>[ ...] R10:
000000000002dfd8 R11:
ffff8a226bd95b30 R12:
ffff8a239347e000
<4>[ ...] R13:
0000000000000000 R14:
ffff8a22fabeb000 R15:
ffff8a2338b0c900
<4>[ ...] FS:
0000000000000000(0000) GS:
ffff8a23aec00000(0000) knlGS:
0000000000000000
<4>[ ...] CS: 0010 DS: 0000 ES: 0000 CR0:
0000000080050033
<4>[ ...] CR2:
000055b479d92068 CR3:
00000003764f6004 CR4:
00000000003606f0
<4>[ ...] DR0:
0000000000000000 DR1:
0000000000000000 DR2:
0000000000000000
<4>[ ...] DR3:
0000000000000000 DR6:
00000000fffe0ff0 DR7:
0000000000000400
Have the client ignore the extra slashes in the server path when
mounting. This will also canonicalize the path, so that identical mounts
can be consilidated.
1) "//mydir1///mydir//"
2) "/mydir1/mydir"
3) "/mydir1/mydir/"
Regardless of the internal treatment of these paths, the kernel still
stores the original string including the leading '/' for presentation
to userland.
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>