X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Finclude%2Flustre_capa.h;h=ac713d08a15899f674280b2dab0b290c5004bf25;hb=eb2e1b6322d85d088aaf195cc877dc598fc8dfe2;hp=44a06b7ddabe0218769b2577c155458cb5969e2f;hpb=23fad25a5b6b1e468d05dc7e81dfb9ad00c86a16;p=fs%2Flustre-release.git diff --git a/lustre/include/lustre_capa.h b/lustre/include/lustre_capa.h index 44a06b7d..ac713d0 100644 --- a/lustre/include/lustre_capa.h +++ b/lustre/include/lustre_capa.h @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,8 +24,10 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -41,6 +41,11 @@ #ifndef __LINUX_CAPA_H_ #define __LINUX_CAPA_H_ +/** \defgroup capa capa + * + * @{ + */ + /* * capability */ @@ -66,27 +71,27 @@ struct capa_hmac_alg { } struct client_capa { - struct inode *inode; - struct list_head lli_list; /* link to lli_oss_capas */ + struct inode *inode; + struct list_head lli_list; /* link to lli_oss_capas */ }; struct target_capa { - struct hlist_node c_hash; /* link to capa hash */ + struct hlist_node c_hash; /* link to capa hash */ }; struct obd_capa { - struct list_head c_list; /* link to capa_list */ - - struct lustre_capa c_capa; /* capa */ - atomic_t c_refc; /* ref count */ - cfs_time_t c_expiry; /* jiffies */ - spinlock_t c_lock; /* protect capa content */ - int c_site; - - union { - struct client_capa cli; - struct target_capa tgt; - } u; + struct list_head c_list; /* link to capa_list */ + + struct lustre_capa c_capa; /* capa */ + atomic_t c_refc; /* ref count */ + cfs_time_t c_expiry; /* jiffies */ + spinlock_t c_lock; /* protect capa content */ + int c_site; + + union { + struct client_capa cli; + struct target_capa tgt; + } u; }; enum { @@ -130,9 +135,9 @@ static inline __u32 capa_keyid(struct lustre_capa *capa) return capa->lc_keyid; } -static inline __u64 capa_key_mdsid(struct lustre_capa_key *key) +static inline __u64 capa_key_seq(struct lustre_capa_key *key) { - return key->lk_mdsid; + return key->lk_seq; } static inline __u32 capa_key_keyid(struct lustre_capa_key *key) @@ -150,19 +155,22 @@ static inline __u32 capa_expiry(struct lustre_capa *capa) return capa->lc_expiry; } -#define DEBUG_CAPA(level, c, fmt, args...) \ +void _debug_capa(struct lustre_capa *, struct libcfs_debug_msg_data *, + const char *fmt, ... ); +#define DEBUG_CAPA(level, capa, fmt, args...) \ do { \ -CDEBUG(level, fmt " capability@%p fid "DFID" opc "LPX64" uid "LPU64" gid " \ - LPU64" flags %u alg %d keyid %u timeout %u expiry %u\n", \ - ##args, c, PFID(capa_fid(c)), capa_opc(c), capa_uid(c), capa_gid(c), \ - capa_flags(c), capa_alg(c), capa_keyid(c), capa_timeout(c), \ - capa_expiry(c)); \ + if (((level) & D_CANTMASK) != 0 || \ + ((libcfs_debug & (level)) != 0 && \ + (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) { \ + LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, level, NULL); \ + _debug_capa((capa), &msgdata, fmt, ##args); \ + } \ } while (0) #define DEBUG_CAPA_KEY(level, k, fmt, args...) \ do { \ -CDEBUG(level, fmt " capability key@%p mdsid "LPU64" keyid %u\n", \ - ##args, k, capa_key_mdsid(k), capa_key_keyid(k)); \ +CDEBUG(level, fmt " capability key@%p seq "LPU64" keyid %u\n", \ + ##args, k, capa_key_seq(k), capa_key_keyid(k)); \ } while (0) typedef int (* renew_capa_cb_t)(struct obd_capa *, struct lustre_capa *); @@ -171,14 +179,15 @@ typedef int (* renew_capa_cb_t)(struct obd_capa *, struct lustre_capa *); extern struct list_head capa_list[]; extern spinlock_t capa_lock; extern int capa_count[]; -extern cfs_mem_cache_t *capa_cachep; +extern struct kmem_cache *capa_cachep; struct hlist_head *init_capa_hash(void); void cleanup_capa_hash(struct hlist_head *hash); -struct obd_capa *capa_add(struct hlist_head *hash, struct lustre_capa *capa); -struct obd_capa *capa_lookup(struct hlist_head *hash, struct lustre_capa *capa, - int alive); +struct obd_capa *capa_add(struct hlist_head *hash, + struct lustre_capa *capa); +struct obd_capa *capa_lookup(struct hlist_head *hash, + struct lustre_capa *capa, int alive); int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key); int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen); @@ -196,46 +205,46 @@ static inline struct obd_capa *alloc_capa(int site) if (unlikely(!ocapa)) return ERR_PTR(-ENOMEM); - CFS_INIT_LIST_HEAD(&ocapa->c_list); - atomic_set(&ocapa->c_refc, 1); - spin_lock_init(&ocapa->c_lock); - ocapa->c_site = site; - if (ocapa->c_site == CAPA_SITE_CLIENT) - CFS_INIT_LIST_HEAD(&ocapa->u.cli.lli_list); - else - CFS_INIT_HLIST_NODE(&ocapa->u.tgt.c_hash); + INIT_LIST_HEAD(&ocapa->c_list); + atomic_set(&ocapa->c_refc, 1); + spin_lock_init(&ocapa->c_lock); + ocapa->c_site = site; + if (ocapa->c_site == CAPA_SITE_CLIENT) + INIT_LIST_HEAD(&ocapa->u.cli.lli_list); + else + INIT_HLIST_NODE(&ocapa->u.tgt.c_hash); - return ocapa; + return ocapa; #else - return ERR_PTR(-EOPNOTSUPP); + return ERR_PTR(-EOPNOTSUPP); #endif } static inline struct obd_capa *capa_get(struct obd_capa *ocapa) { - if (!ocapa) - return NULL; + if (!ocapa) + return NULL; - atomic_inc(&ocapa->c_refc); - return ocapa; + atomic_inc(&ocapa->c_refc); + return ocapa; } static inline void capa_put(struct obd_capa *ocapa) { - if (!ocapa) - return; + if (!ocapa) + return; - if (atomic_read(&ocapa->c_refc) == 0) { - DEBUG_CAPA(D_ERROR, &ocapa->c_capa, "refc is 0 for"); - LBUG(); - } + if (atomic_read(&ocapa->c_refc) == 0) { + DEBUG_CAPA(D_ERROR, &ocapa->c_capa, "refc is 0 for"); + LBUG(); + } - if (atomic_dec_and_test(&ocapa->c_refc)) { - LASSERT(list_empty(&ocapa->c_list)); - if (ocapa->c_site == CAPA_SITE_CLIENT) { - LASSERT(list_empty(&ocapa->u.cli.lli_list)); - } else { - struct hlist_node *hnode; + if (atomic_dec_and_test(&ocapa->c_refc)) { + LASSERT(list_empty(&ocapa->c_list)); + if (ocapa->c_site == CAPA_SITE_CLIENT) { + LASSERT(list_empty(&ocapa->u.cli.lli_list)); + } else { + struct hlist_node *hnode; hnode = &ocapa->u.tgt.c_hash; LASSERT(!hnode->next && !hnode->pprev); @@ -285,15 +294,35 @@ static inline int capa_opc_supported(struct lustre_capa *capa, __u64 opc) } struct filter_capa_key { - struct list_head k_list; - struct lustre_capa_key k_key; + struct list_head k_list; + struct lustre_capa_key k_key; }; -enum { - LC_ID_NONE = 0, - LC_ID_PLAIN = 1, - LC_ID_CONVERT = 2 +enum lc_auth_id { + LC_ID_NONE = 0, + LC_ID_PLAIN = 1, + LC_ID_CONVERT = 2 }; #define BYPASS_CAPA (struct lustre_capa *)ERR_PTR(-ENOENT) + +enum { + LU_CAPAINFO_MAX = 5 +}; + +/** there are at most 5 FIDs in one operation, see rename, + * NOTE the last one is a temporary one used for is_subdir() */ +struct lu_capainfo { + enum lc_auth_id lci_auth; + __u32 lci_padding; + struct lu_fid lci_fid[LU_CAPAINFO_MAX]; + struct lustre_capa *lci_capa[LU_CAPAINFO_MAX]; +}; + +int lu_capainfo_init(void); +void lu_capainfo_fini(void); +struct lu_capainfo *lu_capainfo_get(const struct lu_env *env); + +/** @} capa */ + #endif /* __LINUX_CAPA_H_ */