X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fllite%2Fllite_lib.c;h=08936e2f539a7554b14820838992e4f158ebea15;hp=1a24d72a1fa76b3b131ff4fa2fa41bc788d324dc;hb=8f34119e3dc448f75605bf4968ef5540789426ec;hpb=ef5ada7eaf93f50f4df4b1eb837dd99822acb147 diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 1a24d72..08936e2 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -59,14 +59,12 @@ cfs_mem_cache_t *ll_file_data_slab; CFS_LIST_HEAD(ll_super_blocks); -cfs_spinlock_t ll_sb_lock = CFS_SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(ll_sb_lock); #ifndef MS_HAS_NEW_AOPS extern struct address_space_operations ll_aops; -extern struct address_space_operations ll_dir_aops; #else extern struct address_space_operations_ext ll_aops; -extern struct address_space_operations_ext ll_dir_aops; #endif #ifndef log2 @@ -227,6 +225,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, #ifdef CONFIG_FS_POSIX_ACL data->ocd_connect_flags |= OBD_CONNECT_ACL; #endif + + if (OBD_FAIL_CHECK(OBD_FAIL_MDC_LIGHTWEIGHT)) + /* flag mdc connection as lightweight, only used for test + * purpose, use with care */ + data->ocd_connect_flags |= OBD_CONNECT_LIGHTWEIGHT; + data->ocd_ibits_known = MDS_INODELOCK_FULL; data->ocd_version = LUSTRE_VERSION_CODE; @@ -463,7 +467,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid)); sb->s_op = &lustre_super_operations; -#if THREAD_SIZE >= 8192 +#if THREAD_SIZE >= 8192 /*b=17630*/ sb->s_export_op = &lustre_export_operations; #endif @@ -558,7 +562,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, uuid = obd_get_uuid(sbi->ll_md_exp); if (uuid != NULL) sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid)); - sbi->ll_mnt = mnt; if (data != NULL) OBD_FREE_PTR(data); @@ -773,7 +776,7 @@ static int ll_options(char *options, int *flags) *flags &= ~tmp; goto next; } -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2,5,50,0) +#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 5, 50, 0) tmp = ll_set_opt("acl", s1, LL_SBI_ACL); if (tmp) { /* Ignore deprecated mount option. The client will @@ -797,6 +800,16 @@ static int ll_options(char *options, int *flags) *flags |= tmp; goto next; } + tmp = ll_set_opt("user_fid2path", s1, LL_SBI_USER_FID2PATH); + if (tmp) { + *flags |= tmp; + goto next; + } + tmp = ll_set_opt("nouser_fid2path", s1, LL_SBI_USER_FID2PATH); + if (tmp) { + *flags &= ~tmp; + goto next; + } tmp = ll_set_opt("checksum", s1, LL_SBI_CHECKSUM); if (tmp) { @@ -896,7 +909,6 @@ void ll_lli_init(struct ll_inode_info *lli) cfs_mutex_init(&lli->lli_readdir_mutex); lli->lli_opendir_key = NULL; lli->lli_sai = NULL; - lli->lli_sa_pos = 0; lli->lli_def_acl = NULL; cfs_spin_lock_init(&lli->lli_sa_lock); lli->lli_opendir_pid = 0; @@ -906,13 +918,12 @@ void ll_lli_init(struct ll_inode_info *lli) lli->lli_symlink_name = NULL; cfs_init_rwsem(&lli->lli_trunc_sem); cfs_mutex_init(&lli->lli_write_mutex); - lli->lli_async_rc = 0; - lli->lli_write_rc = 0; - cfs_init_rwsem(&lli->lli_glimpse_sem); - lli->lli_glimpse_time = 0; - CFS_INIT_LIST_HEAD(&lli->lli_agl_list); - lli->lli_agl_index = 0; - } + cfs_init_rwsem(&lli->lli_glimpse_sem); + lli->lli_glimpse_time = 0; + CFS_INIT_LIST_HEAD(&lli->lli_agl_list); + lli->lli_agl_index = 0; + lli->lli_async_rc = 0; + } cfs_mutex_init(&lli->lli_layout_mutex); } @@ -982,7 +993,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) Use the address of the super itself.*/ cfg->cfg_instance = sb; cfg->cfg_uuid = lsi->lsi_llsbi->ll_sb_uuid; - + cfg->cfg_callback = class_config_llog_handler; /* set up client obds */ err = lustre_process_log(sb, profilenm, cfg); if (err < 0) { @@ -1315,6 +1326,50 @@ static int ll_setattr_ost(struct inode *inode, struct iattr *attr) return rc; } +#ifndef HAVE_VFS_INODE_NEWSIZE_OK +/** + * inode_newsize_ok - may this inode be truncated to a given size + * @inode: the inode to be truncated + * @offset: the new size to assign to the inode + * @Returns: 0 on success, -ve errno on failure + * + * inode_newsize_ok will check filesystem limits and ulimits to check that the + * new inode size is within limits. inode_newsize_ok will also send SIGXFSZ + * when necessary. Caller must not proceed with inode size change if failure is + * returned. @inode must be a file (not directory), with appropriate + * permissions to allow truncate (inode_newsize_ok does NOT check these + * conditions). + * + * inode_newsize_ok must be called with i_mutex held. + */ +int inode_newsize_ok(const struct inode *inode, loff_t offset) +{ + if (inode->i_size < offset) { + unsigned long limit; + + limit = rlimit(RLIMIT_FSIZE); + if (limit != RLIM_INFINITY && offset > limit) + goto out_sig; + if (offset > inode->i_sb->s_maxbytes) + goto out_big; + } else { + /* + * truncation of in-use swapfiles is disallowed - it would + * cause subsequent swapout to scribble on the now-freed + * blocks. + */ + if (IS_SWAPFILE(inode)) + return -ETXTBSY; + } + + return 0; +out_sig: + send_sig(SIGXFSZ, current, 0); +out_big: + return -EFBIG; +} +#endif + /* If this inode has objects allocated to it (lsm != NULL), then the OST * object(s) determine the file size and mtime. Otherwise, the MDS will * keep these values until such a time that objects are allocated for it. @@ -1539,16 +1594,11 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, RETURN(rc); } -#ifndef HAVE_STATFS_DENTRY_PARAM -int ll_statfs(struct super_block *sb, struct kstatfs *sfs) -{ -#else int ll_statfs(struct dentry *de, struct kstatfs *sfs) { - struct super_block *sb = de->d_sb; -#endif - struct obd_statfs osfs; - int rc; + struct super_block *sb = de->d_sb; + struct obd_statfs osfs; + int rc; CDEBUG(D_VFSTRACE, "VFS Op: at "LPU64" jiffies\n", get_jiffies_64()); ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_STAFS, 1); @@ -1679,9 +1729,6 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) } else { inode->i_blkbits = inode->i_sb->s_blocksize_bits; } -#ifdef HAVE_INODE_BLKSIZE - inode->i_blksize = 1<i_blkbits; -#endif if (body->valid & OBD_MD_FLUID) inode->i_uid = body->uid; if (body->valid & OBD_MD_FLGID) @@ -1794,7 +1841,6 @@ void ll_read_inode2(struct inode *inode, void *opaque) } else if (S_ISDIR(inode->i_mode)) { inode->i_op = &ll_dir_inode_operations; inode->i_fop = &ll_dir_operations; - inode->i_mapping->a_ops = (struct address_space_operations *)&ll_dir_aops; EXIT; } else if (S_ISLNK(inode->i_mode)) { inode->i_op = &ll_fast_symlink_inode_operations; @@ -1966,7 +2012,6 @@ void ll_umount_begin(struct vfsmount *vfsmnt, int flags) void ll_umount_begin(struct super_block *sb) { #endif - struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; struct obd_ioctl_data *ioc_data; @@ -1979,9 +2024,6 @@ void ll_umount_begin(struct super_block *sb) } #endif - /* Tell the MGC we got umount -f */ - lsi->lsi_flags |= LSI_UMOUNT_FORCE; - CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb, sb->s_count, atomic_read(&sb->s_active)); @@ -2116,8 +2158,8 @@ int ll_prep_inode(struct inode **inode, if (S_ISREG(md.body->mode) && sbi->ll_flags & LL_SBI_LAYOUT_LOCK && md.lsm != NULL && !ll_have_md_lock(*inode, &ibits, LCK_MINMODE)) { CERROR("%s: inode "DFID" (%p) layout lock not granted.\n", - ll_get_fsname(*inode), PFID(ll_inode2fid(*inode)), - *inode); + ll_get_fsname(sb, NULL, 0), + PFID(ll_inode2fid(*inode)), *inode); } out: @@ -2132,6 +2174,7 @@ int ll_obd_statfs(struct inode *inode, void *arg) char *buf = NULL; struct obd_ioctl_data *data = NULL; __u32 type; + __u32 flags; int len = 0, rc; if (!inode || !(sbi = ll_i2sbi(inode))) @@ -2153,14 +2196,15 @@ int ll_obd_statfs(struct inode *inode, void *arg) GOTO(out_statfs, rc = -EINVAL); memcpy(&type, data->ioc_inlbuf1, sizeof(__u32)); - if (type == LL_STATFS_LMV) + if (type & LL_STATFS_LMV) exp = sbi->ll_md_exp; - else if (type == LL_STATFS_LOV) + else if (type & LL_STATFS_LOV) exp = sbi->ll_dt_exp; else GOTO(out_statfs, rc = -ENODEV); - rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL); + flags = (type & LL_STATFS_NODELAY) ? OBD_STATFS_NODELAY : 0; + rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, &flags); if (rc) GOTO(out_statfs, rc); out_statfs: @@ -2285,6 +2329,9 @@ int ll_show_options(struct seq_file *seq, struct vfsmount *vfs) if (sbi->ll_flags & LL_SBI_LAZYSTATFS) seq_puts(seq, ",lazystatfs"); + if (sbi->ll_flags & LL_SBI_USER_FID2PATH) + seq_puts(seq, ",user_fid2path"); + RETURN(0); } @@ -2313,3 +2360,36 @@ int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg) RETURN(0); } + +/** + * Get lustre file system name by \a sbi. If \a buf is provided(non-NULL), the + * fsname will be returned in this buffer; otherwise, a static buffer will be + * used to store the fsname and returned to caller. + */ +char *ll_get_fsname(struct super_block *sb, char *buf, int buflen) +{ + static char fsname_static[MTI_NAME_MAXLEN]; + struct lustre_sb_info *lsi = s2lsi(sb); + char *ptr; + int len; + + if (buf == NULL) { + /* this means the caller wants to use static buffer + * and it doesn't care about race. Usually this is + * in error reporting path */ + buf = fsname_static; + buflen = sizeof(fsname_static); + } + + len = strlen(lsi->lsi_lmd->lmd_profile); + ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-'); + if (ptr && (strcmp(ptr, "-client") == 0)) + len -= 7; + + if (unlikely(len >= buflen)) + len = buflen - 1; + strncpy(buf, lsi->lsi_lmd->lmd_profile, len); + buf[len] = '\0'; + + return buf; +}