From: yury Date: Wed, 10 Aug 2005 13:03:33 +0000 (+0000) Subject: - many fixes in liblustre related stuff. By now liblustre is at least build-able... X-Git-Tag: 1.4.10~765 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=56a32318ff0509aaddb69466b4f17069c3f207b6;p=fs%2Flustre-release.git - many fixes in liblustre related stuff. By now liblustre is at least build-able in HEAD. --- diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index 56ed008..c5446ff 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -70,6 +70,56 @@ typedef unsigned short umode_t; #define smp_processor_id() 0 #endif +#ifndef smp_mb +#define smp_mb() do {} while (0) +#endif + +#ifndef might_sleep_if +#define might_sleep_if(cond) do {} while (0) +#endif + +#ifndef might_sleep +#define might_sleep() do {} while (0) +#endif + +#ifndef signal_pending +#define signal_pending(proc) 0 +#endif + +#ifndef MAY_EXEC +#define MAY_EXEC 1 +#endif + +#ifndef MAY_WRITE +#define MAY_WRITE 2 +#endif + +#ifndef MAY_READ +#define MAY_READ 4 +#endif + +#ifndef MAY_APPEND +#define MAY_APPEND 8 +#endif + +#ifndef FMODE_READ +#define FMODE_READ 1 +#endif + +#ifndef FMODE_WRITE +#define FMODE_WRITE 2 +#endif + +#ifndef FMODE_EXEC +#define FMODE_EXEC 4 +#endif + +#define LBUG() \ + do { \ + printf("!!!LBUG at %s:%d\n", __FILE__, __LINE__); \ + sleep(1000000); \ + } while (0) + /* always adopt 2.5 definitions */ #define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c) #define LINUX_VERSION_CODE (2*200+5*10+0) @@ -122,7 +172,7 @@ static inline void *kmalloc(int size, int prot) typedef struct { void *cwd; -}mm_segment_t; +} mm_segment_t; typedef int (read_proc_t)(char *page, char **start, off_t off, int count, int *eof, void *data); @@ -181,6 +231,16 @@ static __inline__ int test_bit(int nr, long * addr) return ((mask & *addr) != 0); } +static __inline__ int test_and_set_bit(int nr, long * addr) +{ + int res; + + res = test_bit(nr, addr); + set_bit(nr, addr); + + return res; +} + static __inline__ int ext2_set_bit(int nr, void *addr) { return set_bit(nr, (long*)addr); @@ -532,6 +592,78 @@ struct semaphore { int count; }; +struct crypto_tfm; + +struct scatterlist { + struct page *page; + unsigned int offset; + __u32 dma_address; + unsigned int length; +}; + +struct cipher_tfm { + void *cit_iv; + unsigned int cit_ivsize; + __u32 cit_mode; + int (*cit_setkey)(struct crypto_tfm *tfm, + const __u8 *key, unsigned int keylen); + int (*cit_encrypt)(struct crypto_tfm *tfm, + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes); + int (*cit_encrypt_iv)(struct crypto_tfm *tfm, + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, __u8 *iv); + int (*cit_decrypt)(struct crypto_tfm *tfm, + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes); + int (*cit_decrypt_iv)(struct crypto_tfm *tfm, + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, __u8 *iv); + void (*cit_xor_block)(__u8 *dst, const __u8 *src); +}; + +struct digest_tfm { + void (*dit_init)(struct crypto_tfm *tfm); + void (*dit_update)(struct crypto_tfm *tfm, + struct scatterlist *sg, unsigned int nsg); + void (*dit_update_kernel)(struct crypto_tfm *tfm, + const void *data, size_t count); + void (*dit_final)(struct crypto_tfm *tfm, __u8 *out); + void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg, + unsigned int nsg, __u8 *out); + int (*dit_setkey)(struct crypto_tfm *tfm, + const __u8 *key, unsigned int keylen); +#ifdef CONFIG_CRYPTO_HMAC + void *dit_hmac_block; +#endif +}; + +struct compress_tfm { + int (*cot_compress)(struct crypto_tfm *tfm, + const __u8 *src, unsigned int slen, + __u8 *dst, unsigned int *dlen); + int (*cot_decompress)(struct crypto_tfm *tfm, + const __u8 *src, unsigned int slen, + __u8 *dst, unsigned int *dlen); +}; + +struct crypto_tfm { + + __u32 crt_flags; + + union { + struct cipher_tfm cipher; + struct digest_tfm digest; + struct compress_tfm compress; + } crt_u; + + struct crypto_alg *__crt_alg; +}; + /* use the macro's argument to avoid unused warnings */ #define down(a) do { (void)a; } while (0) #define up(a) do { (void)a; } while (0) @@ -541,16 +673,25 @@ struct semaphore { #define up_write(a) do { (void)a; } while (0) #define sema_init(a,b) do { (void)a; } while (0) #define init_rwsem(a) do { (void)a; } while (0) + #define DECLARE_MUTEX(name) \ struct semaphore name = { 1 } + static inline void init_MUTEX (struct semaphore *sem) { sema_init(sem, 1); } +struct rpc_pipe_msg { + struct list_head list; + void *data; + size_t len; + size_t copied; + int error; +}; typedef struct { - struct list_head sleepers; + struct list_head task_list; } wait_queue_head_t; typedef struct { @@ -580,6 +721,7 @@ struct task_struct { int ngroups; gid_t *groups; __u32 cap_effective; + __u32 pag; struct fs_struct __fs; }; @@ -597,15 +739,15 @@ static inline int capable(int cap) #define set_current_state(foo) do { current->state = foo; } while (0) #define init_waitqueue_entry(q,p) do { (q)->process = p; } while (0) -#define add_wait_queue(q,p) do { list_add(&(q)->sleepers, &(p)->sleeping); } while (0) +#define add_wait_queue(q,p) do { list_add(&(q)->task_list, &(p)->sleeping); } while (0) #define del_wait_queue(p) do { list_del(&(p)->sleeping); } while (0) #define remove_wait_queue(q,p) do { list_del(&(p)->sleeping); } while (0) #define DECLARE_WAIT_QUEUE_HEAD(HEAD) \ wait_queue_head_t HEAD = { \ - .sleepers = LIST_HEAD_INIT(HEAD.sleepers) \ + .task_list = LIST_HEAD_INIT(HEAD.task_list) \ } -#define init_waitqueue_head(l) INIT_LIST_HEAD(&(l)->sleepers) +#define init_waitqueue_head(l) INIT_LIST_HEAD(&(l)->task_list) #define wake_up(l) do { int a; a++; } while (0) #define TASK_INTERRUPTIBLE 0 #define TASK_UNINTERRUPTIBLE 1 @@ -702,6 +844,7 @@ typedef struct { volatile int counter; } atomic_t; #define atomic_read(a) ((a)->counter) #define atomic_set(a,b) do {(a)->counter = b; } while (0) #define atomic_dec_and_test(a) ((--((a)->counter)) == 0) +#define atomic_dec_and_lock(a, l) atomic_dec_and_test(a) #define atomic_inc(a) (((a)->counter)++) #define atomic_dec(a) do { (a)->counter--; } while (0) #define atomic_add(b,a) do {(a)->counter += b;} while (0) @@ -749,14 +892,6 @@ static inline int llog_cleanup_commit_master(int force) { return 0; } static inline void portals_run_lbug_upcall(char *file, const char *fn, const int l){} -#define LBUG() \ - do { \ - printf("!!!LBUG at %s:%d\n", __FILE__, __LINE__); \ - sleep(1000000); \ - } while (0) - - - /* completion */ struct completion { unsigned int done; diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 2ee7cd0..b78582f 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -1288,7 +1288,6 @@ typedef enum { GKS_GET_MAC = 704, } gks_cmd_t; -#ifdef __KERNEL__ #define KEY_SIZE 16 #define MAC_SIZE 16 @@ -1298,6 +1297,14 @@ struct crypto_key { __u32 ck_type; }; +#ifndef __KERNEL__ +struct posix_acl_entry { + short e_tag; + unsigned short e_perm; + unsigned int e_id; +}; +#endif + struct key_perm { uid_t kp_uid; gid_t kp_gid; @@ -1312,11 +1319,11 @@ struct key_context { __u32 kc_valid; struct key_perm kc_perm; }; -typedef int (*crypt_cb_t)(struct page *page, __u64 offset, __u64 count, - int flags); +typedef int (*crypt_cb_t)(struct page *page, __u64 offset, + __u64 count, int flags); + extern void lustre_swab_key_context (struct key_context *kctxt); extern void lustre_swab_key_perms (struct key_perm *kperm); -#endif /*for define __KERNEL*/ extern void lustre_swab_lustre_id(struct lustre_id *id); extern void lustre_swab_lov_desc(struct lov_desc *desc); diff --git a/lustre/include/linux/lustre_sec.h b/lustre/include/linux/lustre_sec.h index 22bcffa..cafae26 100644 --- a/lustre/include/linux/lustre_sec.h +++ b/lustre/include/linux/lustre_sec.h @@ -128,8 +128,6 @@ __u32 ptlrpcs_name2flavor(const char *name); char *ptlrpcs_flavor2name(__u32 flavor); -#ifdef __KERNEL__ - /* forward declaration */ struct obd_import; struct ptlrpc_request; @@ -138,7 +136,6 @@ struct ptlrpc_credops; struct ptlrpc_sec; struct ptlrpc_secops; - typedef struct { struct list_head list; __u32 flavor; @@ -506,7 +503,9 @@ int svcsec_null_init(void); int svcsec_null_exit(void); /* capability */ +#ifdef __KERNEL__ #include +#endif #define NR_CAPAHASH 32 #define CAPA_TIMEOUT 1800 /* sec, == 30 min */ @@ -578,7 +577,7 @@ struct obd_capa *capa_get(uid_t uid, int capa_op, __u64 mdsid, struct lustre_handle *handle); void capa_put(struct obd_capa *ocapa, int type); int capa_renew(struct lustre_capa *capa, int type); -void capa_hmac(struct crypto_tfm *tfm, u8 *key, struct lustre_capa *capa); +void capa_hmac(struct crypto_tfm *tfm, __u8 *key, struct lustre_capa *capa); void capa_dup(void *dst, struct obd_capa *ocapa); void capa_dup2(void *dst, struct lustre_capa *capa); int capa_expired(struct lustre_capa *capa); @@ -632,8 +631,6 @@ expiry_to_jiffies(__u64 expiry) return jiffies + ((unsigned long)expiry - tv.tv_sec) * HZ; } -#endif /* __KERNEL__ */ - struct mds_capa_key { struct list_head k_list; @@ -643,7 +640,6 @@ struct mds_capa_key { struct filter_capa_key { struct list_head k_list; - struct lustre_capa_key k_key; }; diff --git a/lustre/include/linux/lvfs.h b/lustre/include/linux/lvfs.h index 4c3c8e1..0fc302f 100644 --- a/lustre/include/linux/lvfs.h +++ b/lustre/include/linux/lvfs.h @@ -35,10 +35,8 @@ #include #include #include -#endif - -#ifdef LIBLUSTRE -#include +#else +#include #endif struct mds_grp_hash_entry; diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index b2fa8f4..1563798 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -408,8 +408,9 @@ static void llu_truncate(struct inode *inode) oa.o_id, lli->lli_st_size); /* truncate == punch from new size to absolute end of file */ + /* XXX: capa is NULL here, is it correct? */ err = obd_punch(llu_i2dtexp(inode), &oa, lsm, lli->lli_st_size, - OBD_OBJECT_EOF, NULL); + OBD_OBJECT_EOF, NULL, NULL); if (err) CERROR("obd_truncate fails (%d) ino %lu\n", err, lli->lli_st_ino); else diff --git a/lustre/liblustre/genlib.sh b/lustre/liblustre/genlib.sh index f5c489e..c60cd66 100755 --- a/lustre/liblustre/genlib.sh +++ b/lustre/liblustre/genlib.sh @@ -53,7 +53,7 @@ build_sysio_obj_list() { _objs=`$AR -t $1` mkdir -p $sysio_tmp cd $sysio_tmp - $AR -x ../$1 + $AR -x $1 cd .. for _lib in $_objs; do ALL_OBJS=$ALL_OBJS"$sysio_tmp/$_lib "; diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c index c4b00a5..d1528e6 100644 --- a/lustre/liblustre/llite_lib.c +++ b/lustre/liblustre/llite_lib.c @@ -124,16 +124,16 @@ int liblustre_process_log(struct config_llog_instance *cfg, int allow_recov) lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs); lcfg->lcfg_nid = nid; lcfg->lcfg_nal = nal; - err = class_process_config(&lcfg); + err = class_process_config(lcfg); lustre_cfg_free(lcfg); if (err < 0) GOTO(out, err); lustre_cfg_bufs_reset(&bufs, name); - lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_MDC_NAME); + lustre_cfg_bufs_set_string(&bufs, 1, OBD_MDC_DEVICENAME); lustre_cfg_bufs_set_string(&bufs, 2, mdc_uuid.uuid); lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs); - err = class_process_config(&lcfg); + err = class_process_config(lcfg); lustre_cfg_free(lcfg); if (err < 0) GOTO(out_del_uuid, err); @@ -142,7 +142,7 @@ int liblustre_process_log(struct config_llog_instance *cfg, int allow_recov) lustre_cfg_bufs_set_string(&bufs, 1, g_zconf_mdsname); lustre_cfg_bufs_set_string(&bufs, 2, peer); lcfg = lustre_cfg_new(LCFG_SETUP, &bufs); - err = class_process_config(&lcfg); + err = class_process_config(lcfg); lustre_cfg_free(lcfg); if (err < 0) GOTO(out_detach, err); @@ -175,7 +175,7 @@ int liblustre_process_log(struct config_llog_instance *cfg, int allow_recov) out_cleanup: lustre_cfg_bufs_reset(&bufs, name); lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - err = class_process_config(&lcfg); + err = class_process_config(lcfg); lustre_cfg_free(lcfg); if (err < 0) GOTO(out, err); @@ -183,7 +183,7 @@ out_cleanup: out_detach: lustre_cfg_bufs_reset(&bufs, name); lcfg = lustre_cfg_new(LCFG_DETACH, &bufs); - err = class_process_config(&lcfg); + err = class_process_config(lcfg); lustre_cfg_free(lcfg); if (err < 0) GOTO(out, err); diff --git a/lustre/liblustre/namei.c b/lustre/liblustre/namei.c index 92d9444..02abb60 100644 --- a/lustre/liblustre/namei.c +++ b/lustre/liblustre/namei.c @@ -385,7 +385,8 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, struct inode *llu_inode_from_lock(struct ldlm_lock *lock) { struct inode *inode; - l_lock(&lock->l_resource->lr_namespace->ns_lock); +#warning "fix l_lock() using here!" +// l_lock(&lock->l_resource->lr_namespace->ns_lock); if (lock->l_ast_data) { inode = (struct inode *)lock->l_ast_data; @@ -393,7 +394,7 @@ struct inode *llu_inode_from_lock(struct ldlm_lock *lock) } else inode = NULL; - l_unlock(&lock->l_resource->lr_namespace->ns_lock); +// l_unlock(&lock->l_resource->lr_namespace->ns_lock); return inode; } diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index c6f4bd0..543be8a 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -147,10 +147,11 @@ static int llu_extent_lock_callback(struct ldlm_lock *lock, lsm = lli->lli_smd; stripe = llu_lock_to_stripe_offset(inode, lock); - l_lock(&lock->l_resource->lr_namespace->ns_lock); +#warning "fix l_lock() using here!" +// l_lock(&lock->l_resource->lr_namespace->ns_lock); kms = ldlm_extent_shift_kms(lock, lsm->lsm_oinfo[stripe].loi_kms); - l_unlock(&lock->l_resource->lr_namespace->ns_lock); +// l_unlock(&lock->l_resource->lr_namespace->ns_lock); if (lsm->lsm_oinfo[stripe].loi_kms != kms) LDLM_DEBUG(lock, "updating kms from "LPU64" to "LPU64, lsm->lsm_oinfo[stripe].loi_kms, kms); diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 111f038..3ac318b 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -106,13 +106,13 @@ static void llu_fsop_gone(struct filesys *fs) lustre_cfg_bufs_reset(&bufs, obd->obd_name); lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - err = class_process_config(&lcfg); + err = class_process_config(lcfg); if (err) { CERROR("cleanup failed: %s\n", obd->obd_name); } lcfg->lcfg_command = LCFG_DETACH; - err = class_process_config(&lcfg); + err = class_process_config(lcfg); lustre_cfg_free(lcfg); if (err) { CERROR("detach failed: %s\n", obd->obd_name); @@ -346,10 +346,11 @@ int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm) RETURN(0); } -static struct inode* llu_new_inode(struct filesys *fs, +static struct inode *llu_new_inode(struct filesys *fs, struct lustre_id *id) { struct inode *inode; + struct intnl_stat stat; struct llu_inode_info *lli; OBD_ALLOC(lli, sizeof(*lli)); @@ -369,15 +370,13 @@ static struct inode* llu_new_inode(struct filesys *fs, memcpy(&lli->lli_id, id, sizeof(*id)); +#warning "fill @stat by desired attributes of new inode before using_sysio_i_new()" + memset(&stat, 0, sizeof(stat)); + stat.st_ino = id_ino(id); + /* file identifier is needed by functions like _sysio_i_find() */ inode = _sysio_i_new(fs, &lli->lli_sysio_fid, -#ifndef AUTOMOUNT_FILE_NAME - id->li_stc.u.e3s.l3s_type & S_IFMT, -#else - id->li_stc.u.e3s.l3s_type, /* all of the bits! */ -#endif - 0, 0, - &llu_inode_ops, lli); + &stat, 0, &llu_inode_ops, lli); if (!inode) OBD_FREE(lli, sizeof(*lli)); @@ -446,8 +445,10 @@ static int llu_inode_revalidate(struct inode *inode) valid |= OBD_MD_FLEASIZE; } ll_inode2id(&id, inode); - rc = mdc_getattr(sbi->ll_md_exp, &id, valid, NULL, 0, - NULL, ealen, &req); + + /* XXX: capa is NULL here, is it correct? */ + rc = mdc_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL, + 0, ealen, NULL, &req); if (rc) { CERROR("failure %d inode %lu\n", rc, lli->lli_st_ino); RETURN(-abs(rc)); @@ -489,10 +490,9 @@ static int llu_inode_revalidate(struct inode *inode) RETURN(llu_glimpse_size(inode)); } -static void copy_stat_buf(struct inode *ino, struct intnl_stat *b) +static void copy_stat_buf_lli(struct llu_inode_info *lli, + struct intnl_stat *b) { - struct llu_inode_info *lli = llu_i2info(ino); - b->st_dev = lli->lli_st_dev; b->st_ino = lli->lli_st_ino; b->st_mode = lli->lli_st_mode; @@ -508,6 +508,12 @@ static void copy_stat_buf(struct inode *ino, struct intnl_stat *b) b->st_ctime = lli->lli_st_ctime; } +static void copy_stat_buf(struct inode *ino, struct intnl_stat *b) +{ + struct llu_inode_info *lli = llu_i2info(ino); + copy_stat_buf_lli(lli, b); +} + static int llu_iop_getattr(struct pnode *pno, struct inode *ino, struct intnl_stat *b) @@ -690,7 +696,7 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) llu_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0); rc = mdc_setattr(sbi->ll_md_exp, &op_data, - attr, NULL, 0, NULL, 0, &request); + attr, NULL, 0, NULL, 0, NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); @@ -877,8 +883,10 @@ static int llu_readlink_internal(struct inode *inode, } ll_inode2id(&id, inode); - rc = mdc_getattr(sbi->ll_md_exp, &id, - OBD_MD_LINKNAME, NULL, 0, NULL, symlen, request); + + /* XXX: capa is NULL here, is it correct? */ + rc = mdc_getattr(sbi->ll_md_exp, &id, OBD_MD_LINKNAME, NULL, 0, + 0, symlen, NULL, request); if (rc) { CERROR("inode %lu: rc = %d\n", lli->lli_st_ino, rc); RETURN(rc); @@ -1530,10 +1538,10 @@ llu_fsswop_mount(const char *source, CDEBUG(D_SUPER, "rootid "LPU64"\n", rootid.li_stc.u.e3s.l3s_ino); sbi->ll_rootino = rootid.li_stc.u.e3s.l3s_ino; - /* fetch attr of root inode */ + /* XXX: capa is NULL here, is it correct? */ err = mdc_getattr(sbi->ll_md_exp, &rootid, - OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, NULL, 0, - NULL, 0, &request); + (OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS), NULL, 0, + 0, 0, NULL, &request); if (err) { CERROR("mdc_getattr failed for root: rc = %d\n", err); GOTO(out_lov, err); diff --git a/lustre/llite/llite_capa.c b/lustre/llite/llite_capa.c index 40ae02a..4bebb59 100644 --- a/lustre/llite/llite_capa.c +++ b/lustre/llite/llite_capa.c @@ -196,7 +196,7 @@ void ll_capa_stop_thread(void) } int ll_set_och_capa(struct inode *inode, struct lookup_intent *it, - struct obd_client_handle *och) + struct obd_client_handle *och) { struct ptlrpc_request *req = LUSTRE_IT(it)->it_data; struct ll_inode_info *lli = ll_i2info(inode); diff --git a/lustre/obdclass/capa.c b/lustre/obdclass/capa.c index 8d2cb21..18d4311 100644 --- a/lustre/obdclass/capa.c +++ b/lustre/obdclass/capa.c @@ -28,6 +28,7 @@ #define DEBUG_SUBSYSTEM S_SEC +#ifdef __KERNEL__ #include #include #include @@ -39,7 +40,12 @@ #include #include #include +#else +#include +#endif + #include +#include kmem_cache_t *capa_cachep = NULL; @@ -147,20 +153,19 @@ static void destroy_capa(struct obd_capa *ocapa) int capa_cache_init(void) { - int order = 0, nr_hash, i; + int nr_hash, i; - capa_hash = (struct hlist_head *) - __get_free_pages(GFP_ATOMIC, order); + OBD_ALLOC(capa_hash, PAGE_SIZE); if (!capa_hash) - panic("Cannot create capa_hash hash table"); + return -ENOMEM; - nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head); + nr_hash = PAGE_SIZE / sizeof(struct hlist_head); LASSERT(nr_hash > NR_CAPAHASH); for (i = 0; i < NR_CAPAHASH; i++) INIT_HLIST_HEAD(capa_hash + i); - for (i =0; i < 3; i++) + for (i = 0; i < 3; i++) INIT_LIST_HEAD(&capa_list[i]); return 0; @@ -224,7 +229,9 @@ get_new_capa_locked(struct hlist_head *head, uid_t uid, int capa_op,__u64 mdsid, ocapa->c_type = type; if (type == CLIENT_CAPA) { LASSERT(inode); +#ifdef __KERNEL__ igrab(inode); +#endif ocapa->c_inode = inode; memcpy(&ocapa->c_handle, handle, sizeof(*handle)); } @@ -304,7 +311,9 @@ void capa_put(struct obd_capa *ocapa, int type) if (ocapa) { if (atomic_dec_and_lock(&ocapa->c_refc, &capa_lock)) { if (type == CLIENT_CAPA) { +#ifdef __KERNEL__ iput(ocapa->c_inode); +#endif __capa_put(ocapa, type); destroy_capa(ocapa); } @@ -349,7 +358,7 @@ int capa_renew(struct lustre_capa *capa, int type) return update_capa_locked(capa, type); } -void capa_hmac(struct crypto_tfm *tfm, u8 *key, struct lustre_capa *capa) +void capa_hmac(struct crypto_tfm *tfm, __u8 *key, struct lustre_capa *capa) { int keylen = CAPA_KEY_LEN; struct scatterlist sl = { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index aeae7d0..00aeb83 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -778,8 +778,8 @@ static int osc_brw_prep_request(int cmd, struct obd_import *imp,struct obdo *oa, struct client_obd *cli = &imp->imp_obd->u.cli; struct ost_body *body; struct lustre_id *raw_id = obdo_id(oa); - struct obd_capa *ocapa; - struct lustre_capa *capa; + struct obd_capa *ocapa = NULL; + struct lustre_capa *capa = NULL; struct obd_ioobj *ioobj; struct niobuf_remote *niobuf; int niocount; diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index f319244..5fc436a 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -36,8 +36,6 @@ #include #include #include -#include - #define HDR_SIZE(count) \ size_round(offsetof (struct lustre_msg, buflens[(count)])) @@ -966,6 +964,7 @@ int llog_log_swabbed(struct llog_log_hdr *hdr) void lustre_assert_wire_constants(void) { } + /* for gks key rec */ void lustre_swab_key_perms(struct key_perm *kperm) { @@ -980,9 +979,10 @@ void lustre_swab_key_perms(struct key_perm *kperm) __swab32s(&kperm->kp_acls[i].e_id); } } + void lustre_swab_key_context (struct key_context *kctxt) { - __swab32s (&kctxt->kc_command); - __swab32s (&kctxt->kc_valid); /* for use with open */ + __swab32s(&kctxt->kc_command); + __swab32s(&kctxt->kc_valid); /* for use with open */ lustre_swab_key_perms(&kctxt->kc_perm); } diff --git a/lustre/sec/gss/gss_internal.h b/lustre/sec/gss/gss_internal.h index eadb6e4..d1e0521 100644 --- a/lustre/sec/gss/gss_internal.h +++ b/lustre/sec/gss/gss_internal.h @@ -46,13 +46,6 @@ #define CRYPTO_UNSPEC 0 #define CRYPTO_MAX_ALG_NAME 64 -struct scatterlist { - struct page *page; - unsigned int offset; - __u32 dma_address; - unsigned int length; -}; - static inline struct crypto_tfm * crypto_alloc_tfm(const char *name, __u32 flags) { diff --git a/lustre/sec/gss/sec_gss.c b/lustre/sec/gss/sec_gss.c index a2e6a83..b11872f 100644 --- a/lustre/sec/gss/sec_gss.c +++ b/lustre/sec/gss/sec_gss.c @@ -384,18 +384,12 @@ out_copy: struct gss_sec { struct ptlrpc_sec gs_base; struct gss_api_mech *gs_mech; -#ifdef __KERNEL__ spinlock_t gs_lock; struct list_head gs_upcalls; char *gs_pipepath; struct dentry *gs_depipe; -#endif }; -#ifdef __KERNEL__ - -static rwlock_t gss_ctx_lock = RW_LOCK_UNLOCKED; - struct gss_upcall_msg_data { __u64 gum_pag; __u32 gum_uid; @@ -415,6 +409,8 @@ struct gss_upcall_msg { struct gss_upcall_msg_data gum_data; }; +#ifdef __KERNEL__ +static rwlock_t gss_ctx_lock = RW_LOCK_UNLOCKED; /********************************************** * rpc_pipe upcall helpers * **********************************************/ @@ -436,10 +432,11 @@ void gss_release_msg(struct gss_upcall_msg *gmsg) #else /* XXX */ if (!list_empty(&gmsg->gum_base.list)) { + int error = gmsg->gum_base.errno; + CWARN("msg %p: list: %p/%p/%p, copied %d, err %d, wq %d\n", - gmsg, &gmsg->gum_base.list, - gmsg->gum_base.list.prev, gmsg->gum_base.list.next, - gmsg->gum_base.copied, gmsg->gum_base.errno, + gmsg, &gmsg->gum_base.list, gmsg->gum_base.list.prev, + gmsg->gum_base.list.next, gmsg->gum_base.copied, error, list_empty(&gmsg->gum_waitq.task_list)); LBUG(); } @@ -522,10 +519,11 @@ static void gss_init_upcall_msg(struct gss_upcall_msg *gmsg, } #endif /* __KERNEL__ */ +/* this seems to be used only from userspace code */ +#ifndef __KERNEL__ /******************************************** * gss cred manipulation helpers * ********************************************/ -#if 0 static int gss_cred_is_uptodate_ctx(struct ptlrpc_cred *cred) { @@ -543,7 +541,7 @@ int gss_cred_is_uptodate_ctx(struct ptlrpc_cred *cred) #endif static inline -struct gss_cl_ctx * gss_get_ctx(struct gss_cl_ctx *ctx) +struct gss_cl_ctx *gss_get_ctx(struct gss_cl_ctx *ctx) { atomic_inc(&ctx->gc_refcount); return ctx; @@ -880,8 +878,7 @@ out: } #else /* !__KERNEL__ */ extern int lgss_handle_krb5_upcall(uid_t uid, __u32 dest_ip, - char *obd_name, - char *buf, int bufsize, + char *obd_name, char *buf, int bufsize, int (*callback)(char*, unsigned long)); static int gss_cred_refresh(struct ptlrpc_cred *cred) @@ -892,11 +889,11 @@ static int gss_cred_refresh(struct ptlrpc_cred *cred) struct gss_sec *gsec; struct gss_api_mech *mech; struct gss_cl_ctx *ctx = NULL; - struct vfs_cred vcred = { 0 }; ptl_nid_t peer_nid; __u32 dest_ip; __u32 subflavor; int rc, gss_err; + struct gss_upcall_msg_data gmd = { 0 }; LASSERT(cred); LASSERT(cred->pc_sec); @@ -909,9 +906,9 @@ static int gss_cred_refresh(struct ptlrpc_cred *cred) imp = cred->pc_sec->ps_import; peer_nid = imp->imp_connection->c_peer.peer_id.nid; dest_ip = (__u32) (peer_nid & 0xFFFFFFFF); - subflavor = cred->pc_sec->ps_flavor.subflavor; + subflavor = cred->pc_sec->ps_flavor; - if (subflavor != PTLRPC_SEC_GSS_KRB5I) { + if (subflavor != PTLRPCS_SUBFLVR_KRB5I) { CERROR("unknown subflavor %u\n", subflavor); GOTO(err_out, rc = -EINVAL); } @@ -930,7 +927,8 @@ static int gss_cred_refresh(struct ptlrpc_cred *cred) gsec = container_of(cred->pc_sec, struct gss_sec, gs_base); mech = gsec->gs_mech; LASSERT(mech); - rc = gss_parse_init_downcall(mech, &obj, &ctx, &vcred, &dest_ip, + + rc = gss_parse_init_downcall(mech, &obj, &ctx, &gmd, &gss_err); if (rc || gss_err) { CERROR("parse init downcall: rpc %d, gss 0x%x\n", rc, gss_err); @@ -1671,10 +1669,11 @@ struct ptlrpc_sec* gss_create_sec(__u32 flavor, { struct gss_sec *gsec; struct ptlrpc_sec *sec; + uid_t save_uid; + #ifdef __KERNEL__ char *pos; int pipepath_len; - uid_t save_uid; #endif ENTRY; diff --git a/lustre/sec/sec.c b/lustre/sec/sec.c index b2e8b64..a9f4e56 100644 --- a/lustre/sec/sec.c +++ b/lustre/sec/sec.c @@ -1112,12 +1112,13 @@ int __init ptlrpc_sec_init(void) return 0; } +#if defined __KERNEL__ && defined ENABLE_GSS static void __exit ptlrpc_sec_exit(void) { svcsec_null_exit(); ptlrpcs_null_exit(); } - +#endif EXPORT_SYMBOL(ptlrpcs_register); EXPORT_SYMBOL(ptlrpcs_unregister); diff --git a/lustre/tests/test45.sh b/lustre/tests/test45.sh index ef1f6f7..0662f8e 100644 --- a/lustre/tests/test45.sh +++ b/lustre/tests/test45.sh @@ -78,8 +78,9 @@ ${LMC} -m $config --add filesystem --filesystem $FS_NODE2 || exit 1 ${LMC} -m $config --add filesystem --filesystem $FS_MASTER || exit 1 # node 1 -${LMC} -m $config --add node --node $NODE1 || exit 1 +${LMC} -m $config --add net --node client --nid "*" --nettype $NETTYPE || exit 1 +${LMC} -m $config --add node --node $NODE1 || exit 1 ${LMC} -m $config --add net --node $NODE1 --nid `h2$NIDTYPE $NODE1` \ --nettype $NETTYPE || exit 1 @@ -119,7 +120,6 @@ ${LMC} -m $config --add cmobd --node $NODE1 --cmobd $CMOBD_OST1 \ # node 2 ${LMC} -m $config --add node --node $NODE2 || exit 1 - ${LMC} -m $config --add net --node $NODE2 --nid `h2$NIDTYPE $NODE2` \ --nettype $NETTYPE || exit 1 diff --git a/lustre/utils/lconf b/lustre/utils/lconf index bbc5787..b4ff31c 100755 --- a/lustre/utils/lconf +++ b/lustre/utils/lconf @@ -2963,6 +2963,9 @@ class Mountpoint(Module): cmd = "mount -t lustre_lite -o osc=%s,mdc=%s,gkc=%s,mds_sec=%s,oss_sec=%s%s %s %s" % \ (self.vosc.get_name(), self.vmdc.get_name(), gkc_name, self.mds_sec, self.oss_sec, self.clientoptions, config.config, self.path) + log("mount -t lustre_lite -o osc=%s,mdc=%s,gkc=%s,mds_sec=%s,oss_sec=%s%s %s %s" % \ + (self.vosc.get_name(), self.vmdc.get_name(), gkc_name, self.mds_sec, + self.oss_sec, self.clientoptions, config.config, self.path)) run("mkdir", self.path) ret, val = run(cmd) if ret: diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index bcba4ae..f13072a 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -32,9 +32,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -55,7 +55,6 @@ #include #include #include - #include static void err_msg(char *fmt, ...)