Commit 18f92a6e authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman
Browse files

staging: lustre: discard cfs_cap_t, use kernel_cap_t



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: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f497115d
Loading
Loading
Loading
Loading
+0 −69
Original line number Diff line number Diff line
// 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:
 */
+0 −1
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@
#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"

+2 −2
Original line number Diff line number Diff line
@@ -717,7 +717,7 @@ struct md_op_data {
	__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;

@@ -912,7 +912,7 @@ struct md_ops {
		     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);
+1 −1
Original line number Diff line number Diff line
@@ -1226,7 +1226,7 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data,

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;
+1 −1
Original line number Diff line number Diff line
@@ -445,7 +445,7 @@ static int ll_dir_setdirstripe(struct inode *parent, struct lmv_user_md *lump,
	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);
Loading