]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - fs/ceph/quota.c
1b69d8365ec2df2abe52e7209103a11dd619fbca
[mirror_ubuntu-bionic-kernel.git] / fs / ceph / quota.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * quota.c - CephFS quota
4 *
5 * Copyright (C) 2017-2018 SUSE
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "super.h"
22 #include "mds_client.h"
23
24 void ceph_handle_quota(struct ceph_mds_client *mdsc,
25 struct ceph_mds_session *session,
26 struct ceph_msg *msg)
27 {
28 struct super_block *sb = mdsc->fsc->sb;
29 struct ceph_mds_quota *h = msg->front.iov_base;
30 struct ceph_vino vino;
31 struct inode *inode;
32 struct ceph_inode_info *ci;
33
34 if (msg->front.iov_len != sizeof(*h)) {
35 pr_err("%s corrupt message mds%d len %d\n", __func__,
36 session->s_mds, (int)msg->front.iov_len);
37 ceph_msg_dump(msg);
38 return;
39 }
40
41 /* increment msg sequence number */
42 mutex_lock(&session->s_mutex);
43 session->s_seq++;
44 mutex_unlock(&session->s_mutex);
45
46 /* lookup inode */
47 vino.ino = le64_to_cpu(h->ino);
48 vino.snap = CEPH_NOSNAP;
49 inode = ceph_find_inode(sb, vino);
50 if (!inode) {
51 pr_warn("Failed to find inode %llu\n", vino.ino);
52 return;
53 }
54 ci = ceph_inode(inode);
55
56 spin_lock(&ci->i_ceph_lock);
57 ci->i_rbytes = le64_to_cpu(h->rbytes);
58 ci->i_rfiles = le64_to_cpu(h->rfiles);
59 ci->i_rsubdirs = le64_to_cpu(h->rsubdirs);
60 ci->i_max_bytes = le64_to_cpu(h->max_bytes);
61 ci->i_max_files = le64_to_cpu(h->max_files);
62 spin_unlock(&ci->i_ceph_lock);
63
64 iput(inode);
65 }