Skip to content

Commit 64f29d8

Browse files
committed
Merge tag 'ceph-for-5.17-rc1' of git://github.com/ceph/ceph-client
Pull ceph updates from Ilya Dryomov: "The highlight is the new mount "device" string syntax implemented by Venky Shankar. It solves some long-standing issues with using different auth entities and/or mounting different CephFS filesystems from the same cluster, remounting and also misleading /proc/mounts contents. The existing syntax of course remains to be maintained. On top of that, there is a couple of fixes for edge cases in quota and a new mount option for turning on unbuffered I/O mode globally instead of on a per-file basis with ioctl(CEPH_IOC_SYNCIO)" * tag 'ceph-for-5.17-rc1' of git://github.com/ceph/ceph-client: ceph: move CEPH_SUPER_MAGIC definition to magic.h ceph: remove redundant Lsx caps check ceph: add new "nopagecache" option ceph: don't check for quotas on MDS stray dirs ceph: drop send metrics debug message rbd: make const pointer spaces a static const array ceph: Fix incorrect statfs report for small quota ceph: mount syntax module parameter doc: document new CephFS mount device syntax ceph: record updated mon_addr on remount ceph: new device mount syntax libceph: rename parse_fsid() to ceph_parse_fsid() and export libceph: generalize addr/ip parsing based on delimiter
2 parents 67ed868 + a0b3a15 commit 64f29d8

File tree

13 files changed

+255
-57
lines changed

13 files changed

+255
-57
lines changed

Documentation/filesystems/ceph.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,43 @@ Mount Syntax
8282

8383
The basic mount syntax is::
8484

85-
# mount -t ceph monip[:port][,monip2[:port]...]:/[subdir] mnt
85+
# mount -t ceph [email protected]_name=/[subdir] mnt -o mon_addr=monip1[:port][/monip2[:port]]
8686

8787
You only need to specify a single monitor, as the client will get the
8888
full list when it connects. (However, if the monitor you specify
8989
happens to be down, the mount won't succeed.) The port can be left
9090
off if the monitor is using the default. So if the monitor is at
9191
1.2.3.4::
9292

93-
# mount -t ceph 1.2.3.4:/ /mnt/ceph
93+
# mount -t ceph [email protected]=/ /mnt/ceph -o mon_addr=1.2.3.4
9494

9595
is sufficient. If /sbin/mount.ceph is installed, a hostname can be
96-
used instead of an IP address.
96+
used instead of an IP address and the cluster FSID can be left out
97+
(as the mount helper will fill it in by reading the ceph configuration
98+
file)::
9799

100+
# mount -t ceph cephuser@cephfs=/ /mnt/ceph -o mon_addr=mon-addr
98101

102+
Multiple monitor addresses can be passed by separating each address with a slash (`/`)::
103+
104+
# mount -t ceph cephuser@cephfs=/ /mnt/ceph -o mon_addr=192.168.1.100/192.168.1.101
105+
106+
When using the mount helper, monitor address can be read from ceph
107+
configuration file if available. Note that, the cluster FSID (passed as part
108+
of the device string) is validated by checking it with the FSID reported by
109+
the monitor.
99110

100111
Mount Options
101112
=============
102113

114+
mon_addr=ip_address[:port][/ip_address[:port]]
115+
Monitor address to the cluster. This is used to bootstrap the
116+
connection to the cluster. Once connection is established, the
117+
monitor addresses in the monitor map are followed.
118+
119+
fsid=cluster-id
120+
FSID of the cluster (from `ceph fsid` command).
121+
103122
ip=A.B.C.D[:N]
104123
Specify the IP and/or port the client should bind to locally.
105124
There is normally not much reason to do this. If the IP is not

drivers/block/rbd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,7 +6189,7 @@ static inline size_t next_token(const char **buf)
61896189
* These are the characters that produce nonzero for
61906190
* isspace() in the "C" and "POSIX" locales.
61916191
*/
6192-
const char *spaces = " \f\n\r\t\v";
6192+
static const char spaces[] = " \f\n\r\t\v";
61936193

61946194
*buf += strspn(*buf, spaces); /* Find start of token */
61956195

@@ -6495,7 +6495,8 @@ static int rbd_add_parse_args(const char *buf,
64956495
pctx.opts->exclusive = RBD_EXCLUSIVE_DEFAULT;
64966496
pctx.opts->trim = RBD_TRIM_DEFAULT;
64976497

6498-
ret = ceph_parse_mon_ips(mon_addrs, mon_addrs_size, pctx.copts, NULL);
6498+
ret = ceph_parse_mon_ips(mon_addrs, mon_addrs_size, pctx.copts, NULL,
6499+
',');
64996500
if (ret)
65006501
goto out_err;
65016502

fs/ceph/caps.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,8 +3376,7 @@ static void handle_cap_grant(struct inode *inode,
33763376
if ((newcaps & CEPH_CAP_LINK_SHARED) &&
33773377
(extra_info->issued & CEPH_CAP_LINK_EXCL) == 0) {
33783378
set_nlink(inode, le32_to_cpu(grant->nlink));
3379-
if (inode->i_nlink == 0 &&
3380-
(newcaps & (CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL)))
3379+
if (inode->i_nlink == 0)
33813380
deleted_inode = true;
33823381
}
33833382

fs/ceph/file.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ static int ceph_init_file_info(struct inode *inode, struct file *file,
204204
int fmode, bool isdir)
205205
{
206206
struct ceph_inode_info *ci = ceph_inode(inode);
207+
struct ceph_mount_options *opt =
208+
ceph_inode_to_client(&ci->vfs_inode)->mount_options;
207209
struct ceph_file_info *fi;
208210

209211
dout("%s %p %p 0%o (%s)\n", __func__, inode, file,
@@ -225,6 +227,9 @@ static int ceph_init_file_info(struct inode *inode, struct file *file,
225227
if (!fi)
226228
return -ENOMEM;
227229

230+
if (opt->flags & CEPH_MOUNT_OPT_NOPAGECACHE)
231+
fi->flags |= CEPH_F_SYNC;
232+
228233
file->private_data = fi;
229234
}
230235

@@ -1541,7 +1546,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
15411546
struct ceph_inode_info *ci = ceph_inode(inode);
15421547
bool direct_lock = iocb->ki_flags & IOCB_DIRECT;
15431548
ssize_t ret;
1544-
int want, got = 0;
1549+
int want = 0, got = 0;
15451550
int retry_op = 0, read = 0;
15461551

15471552
again:
@@ -1556,13 +1561,14 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
15561561
else
15571562
ceph_start_io_read(inode);
15581563

1564+
if (!(fi->flags & CEPH_F_SYNC) && !direct_lock)
1565+
want |= CEPH_CAP_FILE_CACHE;
15591566
if (fi->fmode & CEPH_FILE_MODE_LAZY)
1560-
want = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO;
1561-
else
1562-
want = CEPH_CAP_FILE_CACHE;
1567+
want |= CEPH_CAP_FILE_LAZYIO;
1568+
15631569
ret = ceph_get_caps(filp, CEPH_CAP_FILE_RD, want, -1, &got);
15641570
if (ret < 0) {
1565-
if (iocb->ki_flags & IOCB_DIRECT)
1571+
if (direct_lock)
15661572
ceph_end_io_direct(inode);
15671573
else
15681574
ceph_end_io_read(inode);
@@ -1696,7 +1702,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
16961702
struct ceph_osd_client *osdc = &fsc->client->osdc;
16971703
struct ceph_cap_flush *prealloc_cf;
16981704
ssize_t count, written = 0;
1699-
int err, want, got;
1705+
int err, want = 0, got;
17001706
bool direct_lock = false;
17011707
u32 map_flags;
17021708
u64 pool_flags;
@@ -1771,10 +1777,10 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
17711777

17721778
dout("aio_write %p %llx.%llx %llu~%zd getting caps. i_size %llu\n",
17731779
inode, ceph_vinop(inode), pos, count, i_size_read(inode));
1780+
if (!(fi->flags & CEPH_F_SYNC) && !direct_lock)
1781+
want |= CEPH_CAP_FILE_BUFFER;
17741782
if (fi->fmode & CEPH_FILE_MODE_LAZY)
1775-
want = CEPH_CAP_FILE_BUFFER | CEPH_CAP_FILE_LAZYIO;
1776-
else
1777-
want = CEPH_CAP_FILE_BUFFER;
1783+
want |= CEPH_CAP_FILE_LAZYIO;
17781784
got = 0;
17791785
err = ceph_get_caps(file, CEPH_CAP_FILE_WR, want, pos + count, &got);
17801786
if (err < 0)

fs/ceph/metric.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc,
160160
msg->hdr.version = cpu_to_le16(1);
161161
msg->hdr.compat_version = cpu_to_le16(1);
162162
msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
163-
dout("client%llu send metrics to mds%d\n",
164-
ceph_client_gid(mdsc->fsc->client), s->s_mds);
165163
ceph_con_send(&s->s_con, msg);
166164

167165
return true;

fs/ceph/quota.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ static inline bool ceph_has_realms_with_quotas(struct inode *inode)
3030
/* if root is the real CephFS root, we don't have quota realms */
3131
if (root && ceph_ino(root) == CEPH_INO_ROOT)
3232
return false;
33+
/* MDS stray dirs have no quota realms */
34+
if (ceph_vino_is_reserved(ceph_inode(inode)->i_vino))
35+
return false;
3336
/* otherwise, we can't know for sure */
3437
return true;
3538
}
@@ -494,10 +497,24 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)
494497
if (ci->i_max_bytes) {
495498
total = ci->i_max_bytes >> CEPH_BLOCK_SHIFT;
496499
used = ci->i_rbytes >> CEPH_BLOCK_SHIFT;
500+
/* For quota size less than 4MB, use 4KB block size */
501+
if (!total) {
502+
total = ci->i_max_bytes >> CEPH_4K_BLOCK_SHIFT;
503+
used = ci->i_rbytes >> CEPH_4K_BLOCK_SHIFT;
504+
buf->f_frsize = 1 << CEPH_4K_BLOCK_SHIFT;
505+
}
497506
/* It is possible for a quota to be exceeded.
498507
* Report 'zero' in that case
499508
*/
500509
free = total > used ? total - used : 0;
510+
/* For quota size less than 4KB, report the
511+
* total=used=4KB,free=0 when quota is full
512+
* and total=free=4KB, used=0 otherwise */
513+
if (!total) {
514+
total = 1;
515+
free = ci->i_max_bytes > ci->i_rbytes ? 1 : 0;
516+
buf->f_frsize = 1 << CEPH_4K_BLOCK_SHIFT;
517+
}
501518
}
502519
spin_unlock(&ci->i_ceph_lock);
503520
if (total) {

0 commit comments

Comments
 (0)