X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fllite%2Fllite_lib.c;h=14573039f0b1ee85666ded855c1652dd37d6c1db;hp=674f47a9562ad9258d29d9f2d3212cd0137f66e0;hb=9eeff6d09450e1144b6b9dc1bdbc222ac2af9d67;hpb=8dd29b639f4f54aa7d1ca2767bf1eb7094c64392 diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 674f47a..1457303 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -59,7 +59,7 @@ 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; @@ -463,7 +463,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*/ && !defined(HAVE_FSTYPE_MOUNT) /*LU-812*/ sb->s_export_op = &lustre_export_operations; #endif @@ -906,13 +906,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); } @@ -1315,6 +1314,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.