lustre only sends 32bits of capabilities in on-the-wire RPC calls.
It current strips off higher bits and uses a 32bit cfs_cap_t
throughout.
Though there is a small memory cost, it is cleaner to use
kernel_cap_t throughout and only truncate when marshalling
data for RPC calls.
So this patch replaces cfs_cap_t with kernel_cap_t throughout,
and where a cfs_cap_t was previous stored in a __u32, we now
store cap.cap[0] instead.
With this, we can remove include/linux/libcfs/curproc.h
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/curproc.h
- *
- * Lustre curproc API declaration
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_CURPROC_H__
-#define __LIBCFS_CURPROC_H__
-
-/*
- * Plus, platform-specific constant
- *
- * and opaque scalar type
- *
- * kernel_cap_t
- */
-
-typedef u32 cfs_cap_t;
-
-static inline cfs_cap_t cfs_curproc_cap_pack(void)
-{
- /* cfs_cap_t is only the first word of kernel_cap_t */
- return (cfs_cap_t)(current_cap().cap[0]);
-}
-
-/* __LIBCFS_CURPROC_H__ */
-#endif
-/*
- * Local variables:
- * c-indentation-style: "K&R"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
#include <linux/libcfs/libcfs_string.h>
#include <linux/libcfs/libcfs_hash.h>
#include <linux/libcfs/libcfs_fail.h>
-#include <linux/libcfs/curproc.h>
#define LIBCFS_VERSION "0.7.0"
__u32 op_suppgids[2];
__u32 op_fsuid;
__u32 op_fsgid;
- cfs_cap_t op_cap;
+ kernel_cap_t op_cap;
void *op_data;
size_t op_data_size;
struct md_open_data *, struct ptlrpc_request **);
int (*create)(struct obd_export *, struct md_op_data *,
const void *, size_t, umode_t, uid_t, gid_t,
- cfs_cap_t, __u64, struct ptlrpc_request **);
+ kernel_cap_t, __u64, struct ptlrpc_request **);
int (*enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
const union ldlm_policy_data *, struct md_op_data *,
struct lustre_handle *, __u64);
static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode,
- uid_t uid, gid_t gid, cfs_cap_t cap_effective,
+ uid_t uid, gid_t gid, kernel_cap_t cap_effective,
__u64 rdev, struct ptlrpc_request **request)
{
int rc;
err = md_create(sbi->ll_md_exp, op_data, lump, sizeof(*lump), mode,
from_kuid(&init_user_ns, current_fsuid()),
from_kgid(&init_user_ns, current_fsgid()),
- cfs_curproc_cap_pack(), 0, &request);
+ current_cap(), 0, &request);
ll_finish_md_op_data(op_data);
err = ll_prep_inode(&inode, request, parent->i_sb, NULL);
op_data->op_mod_time = ktime_get_real_seconds();
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
- op_data->op_cap = cfs_curproc_cap_pack();
+ op_data->op_cap = current_cap();
if ((opc == LUSTRE_OPC_CREATE) && name &&
filename_is_volatile(name, namelen, &op_data->op_mds))
op_data->op_bias |= MDS_CREATE_VOLATILE;
err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode,
from_kuid(&init_user_ns, current_fsuid()),
from_kgid(&init_user_ns, current_fsgid()),
- cfs_curproc_cap_pack(), rdev, &request);
+ current_cap(), rdev, &request);
ll_finish_md_op_data(op_data);
if (err < 0 && err != -EREMOTE)
goto err_exit;
static int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode,
- uid_t uid, gid_t gid, cfs_cap_t cap_effective,
+ uid_t uid, gid_t gid, kernel_cap_t cap_effective,
__u64 rdev, struct ptlrpc_request **request)
{
struct obd_device *obd = exp->exp_obd;
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
- op_data->op_cap = cfs_curproc_cap_pack();
+ op_data->op_cap = current_cap();
if (op_data->op_mea2) {
struct lmv_stripe_md *lsm = op_data->op_mea2;
const struct lmv_oinfo *oinfo;
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
- op_data->op_cap = cfs_curproc_cap_pack();
+ op_data->op_cap = current_cap();
if (op_data->op_cli_flags & CLI_MIGRATE) {
LASSERTF(fid_is_sane(&op_data->op_fid3), "invalid FID " DFID "\n",
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
- op_data->op_cap = cfs_curproc_cap_pack();
+ op_data->op_cap = current_cap();
/*
* If child's fid is given, cancel unused locks for it if it is from
void *ea, size_t ealen);
void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode, uid_t uid,
- gid_t gid, cfs_cap_t capability, __u64 rdev);
+ gid_t gid, kernel_cap_t capability, __u64 rdev);
void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
umode_t mode, __u64 rdev, __u64 flags, const void *data,
size_t datalen);
int mdc_create(struct obd_export *exp, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode, uid_t uid,
- gid_t gid, cfs_cap_t capability, __u64 rdev,
+ gid_t gid, kernel_cap_t capability, __u64 rdev,
struct ptlrpc_request **request);
int mdc_link(struct obd_export *exp, struct md_op_data *op_data,
struct ptlrpc_request **request);
b->mbo_gid = from_kgid(&init_user_ns, current_gid());
b->mbo_fsuid = from_kuid(&init_user_ns, current_fsuid());
b->mbo_fsgid = from_kgid(&init_user_ns, current_fsgid());
- b->mbo_capability = cfs_curproc_cap_pack();
+ b->mbo_capability = current_cap().cap[0];
}
void mdc_swap_layouts_pack(struct ptlrpc_request *req,
/* packing of MDS records */
void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode,
- uid_t uid, gid_t gid, cfs_cap_t cap_effective, __u64 rdev)
+ uid_t uid, gid_t gid, kernel_cap_t cap_effective,
+ __u64 rdev)
{
struct mdt_rec_create *rec;
char *tmp;
rec->cr_opcode = REINT_CREATE;
rec->cr_fsuid = uid;
rec->cr_fsgid = gid;
- rec->cr_cap = cap_effective;
+ rec->cr_cap = cap_effective.cap[0];
rec->cr_fid1 = op_data->op_fid1;
rec->cr_fid2 = op_data->op_fid2;
rec->cr_mode = mode;
rec->cr_opcode = REINT_OPEN;
rec->cr_fsuid = from_kuid(&init_user_ns, current_fsuid());
rec->cr_fsgid = from_kgid(&init_user_ns, current_fsgid());
- rec->cr_cap = cfs_curproc_cap_pack();
+ rec->cr_cap = current_cap().cap[0];
rec->cr_fid1 = op_data->op_fid1;
rec->cr_fid2 = op_data->op_fid2;
rec->sa_opcode = REINT_SETATTR;
rec->sa_fsuid = from_kuid(&init_user_ns, current_fsuid());
rec->sa_fsgid = from_kgid(&init_user_ns, current_fsgid());
- rec->sa_cap = cfs_curproc_cap_pack();
+ rec->sa_cap = current_cap().cap[0];
rec->sa_suppgid = -1;
rec->sa_fid = op_data->op_fid1;
REINT_RMENTRY : REINT_UNLINK;
rec->ul_fsuid = op_data->op_fsuid;
rec->ul_fsgid = op_data->op_fsgid;
- rec->ul_cap = op_data->op_cap;
+ rec->ul_cap = op_data->op_cap.cap[0];
rec->ul_mode = op_data->op_mode;
rec->ul_suppgid1 = op_data->op_suppgids[0];
rec->ul_suppgid2 = -1;
rec->lk_opcode = REINT_LINK;
rec->lk_fsuid = op_data->op_fsuid; /* current->fsuid; */
rec->lk_fsgid = op_data->op_fsgid; /* current->fsgid; */
- rec->lk_cap = op_data->op_cap; /* current->cap_effective; */
+ rec->lk_cap = op_data->op_cap.cap[0]; /* current->cap_effective; */
rec->lk_suppgid1 = op_data->op_suppgids[0];
rec->lk_suppgid2 = op_data->op_suppgids[1];
rec->lk_fid1 = op_data->op_fid1;
rec->rn_opcode = REINT_RENAME;
rec->rn_fsuid = op_data->op_fsuid;
rec->rn_fsgid = op_data->op_fsgid;
- rec->rn_cap = op_data->op_cap;
+ rec->rn_cap = op_data->op_cap.cap[0];
rec->rn_suppgid1 = op_data->op_suppgids[0];
rec->rn_suppgid2 = op_data->op_suppgids[1];
rec->rn_fid1 = op_data->op_fid1;
int mdc_create(struct obd_export *exp, struct md_op_data *op_data,
const void *data, size_t datalen, umode_t mode,
- uid_t uid, gid_t gid, cfs_cap_t cap_effective,
+ uid_t uid, gid_t gid, kernel_cap_t cap_effective,
__u64 rdev, struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
rec->sx_opcode = REINT_SETXATTR;
rec->sx_fsuid = from_kuid(&init_user_ns, current_fsuid());
rec->sx_fsgid = from_kgid(&init_user_ns, current_fsgid());
- rec->sx_cap = cfs_curproc_cap_pack();
+ rec->sx_cap = current_cap().cap[0];
rec->sx_suppgid1 = suppgid;
rec->sx_suppgid2 = -1;
rec->sx_fid = *fid;
pud->pud_gid = from_kgid(&init_user_ns, current_gid());
pud->pud_fsuid = from_kuid(&init_user_ns, current_fsuid());
pud->pud_fsgid = from_kgid(&init_user_ns, current_fsgid());
- pud->pud_cap = cfs_curproc_cap_pack();
+ pud->pud_cap = current_cap().cap[0];
pud->pud_ngroups = (msg->lm_buflens[offset] - sizeof(*pud)) / 4;
task_lock(current);