diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/9p/v9fs_vfs.h | 6 | ||||
-rw-r--r-- | fs/9p/vfs_file.c | 36 | ||||
-rw-r--r-- | fs/9p/vfs_inode.c | 139 | ||||
-rw-r--r-- | fs/9p/vfs_inode_dotl.c | 86 | ||||
-rw-r--r-- | fs/9p/vfs_super.c | 2 | ||||
-rw-r--r-- | fs/attr.c | 5 | ||||
-rw-r--r-- | fs/autofs4/autofs_i.h | 26 | ||||
-rw-r--r-- | fs/autofs4/waitq.c | 2 | ||||
-rw-r--r-- | fs/befs/linuxvfs.c | 23 | ||||
-rw-r--r-- | fs/block_dev.c | 7 | ||||
-rw-r--r-- | fs/btrfs/btrfs_inode.h | 6 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 10 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 77 | ||||
-rw-r--r-- | fs/btrfs/file-item.c | 4 | ||||
-rw-r--r-- | fs/btrfs/file.c | 73 | ||||
-rw-r--r-- | fs/btrfs/free-space-cache.c | 20 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 52 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 47 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 4 | ||||
-rw-r--r-- | fs/btrfs/tree-log.c | 28 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 51 | ||||
-rw-r--r-- | fs/btrfs/volumes.h | 2 | ||||
-rw-r--r-- | fs/btrfs/xattr.c | 59 | ||||
-rw-r--r-- | fs/ceph/mds_client.c | 2 | ||||
-rw-r--r-- | fs/ceph/super.c | 4 | ||||
-rw-r--r-- | fs/cifs/cifs_debug.c | 2 | ||||
-rw-r--r-- | fs/cifs/cifsacl.c | 28 | ||||
-rw-r--r-- | fs/cifs/cifsencrypt.c | 54 | ||||
-rw-r--r-- | fs/cifs/cifsfs.c | 10 | ||||
-rw-r--r-- | fs/cifs/cifsfs.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 56 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 3 | ||||
-rw-r--r-- | fs/cifs/connect.c | 9 | ||||
-rw-r--r-- | fs/cifs/dir.c | 4 | ||||
-rw-r--r-- | fs/cifs/transport.c | 51 | ||||
-rw-r--r-- | fs/cifs/xattr.c | 40 | ||||
-rw-r--r-- | fs/coda/coda_linux.h | 5 | ||||
-rw-r--r-- | fs/compat.c | 5 | ||||
-rw-r--r-- | fs/compat_ioctl.c | 1 | ||||
-rw-r--r-- | fs/configfs/inode.c | 3 | ||||
-rw-r--r-- | fs/configfs/item.c | 2 | ||||
-rw-r--r-- | fs/debugfs/inode.c | 2 | ||||
-rw-r--r-- | fs/ecryptfs/Kconfig | 2 | ||||
-rw-r--r-- | fs/ecryptfs/keystore.c | 2 | ||||
-rw-r--r-- | fs/ecryptfs/main.c | 23 | ||||
-rw-r--r-- | fs/ecryptfs/read_write.c | 18 | ||||
-rw-r--r-- | fs/eventpoll.c | 2 | ||||
-rw-r--r-- | fs/exec.c | 17 | ||||
-rw-r--r-- | fs/ext2/xattr_security.c | 34 | ||||
-rw-r--r-- | fs/ext3/inode.c | 4 | ||||
-rw-r--r-- | fs/ext3/namei.c | 9 | ||||
-rw-r--r-- | fs/ext3/xattr_security.c | 36 | ||||
-rw-r--r-- | fs/ext4/ext4.h | 1 | ||||
-rw-r--r-- | fs/ext4/ext4_jbd2.h | 4 | ||||
-rw-r--r-- | fs/ext4/indirect.c | 9 | ||||
-rw-r--r-- | fs/ext4/inode.c | 27 | ||||
-rw-r--r-- | fs/ext4/namei.c | 9 | ||||
-rw-r--r-- | fs/ext4/page-io.c | 24 | ||||
-rw-r--r-- | fs/ext4/super.c | 1 | ||||
-rw-r--r-- | fs/ext4/xattr_security.c | 36 | ||||
-rw-r--r-- | fs/fat/dir.c | 2 | ||||
-rw-r--r-- | fs/fat/inode.c | 7 | ||||
-rw-r--r-- | fs/fuse/dev.c | 16 | ||||
-rw-r--r-- | fs/fuse/file.c | 84 | ||||
-rw-r--r-- | fs/fuse/fuse_i.h | 8 | ||||
-rw-r--r-- | fs/fuse/inode.c | 13 | ||||
-rw-r--r-- | fs/gfs2/inode.c | 38 | ||||
-rw-r--r-- | fs/gfs2/log.c | 4 | ||||
-rw-r--r-- | fs/gfs2/meta_io.c | 6 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 2 | ||||
-rw-r--r-- | fs/gfs2/quota.c | 2 | ||||
-rw-r--r-- | fs/hfsplus/super.c | 15 | ||||
-rw-r--r-- | fs/hfsplus/wrapper.c | 4 | ||||
-rw-r--r-- | fs/hugetlbfs/inode.c | 1 | ||||
-rw-r--r-- | fs/inode.c | 24 | ||||
-rw-r--r-- | fs/jffs2/security.c | 35 | ||||
-rw-r--r-- | fs/jfs/jfs_umount.c | 4 | ||||
-rw-r--r-- | fs/jfs/xattr.c | 57 | ||||
-rw-r--r-- | fs/locks.c | 2 | ||||
-rw-r--r-- | fs/namei.c | 41 | ||||
-rw-r--r-- | fs/namespace.c | 2 | ||||
-rw-r--r-- | fs/nfs/Kconfig | 16 | ||||
-rw-r--r-- | fs/nfs/blocklayout/blocklayout.c | 1 | ||||
-rw-r--r-- | fs/nfs/callback.h | 2 | ||||
-rw-r--r-- | fs/nfs/callback_proc.c | 25 | ||||
-rw-r--r-- | fs/nfs/callback_xdr.c | 24 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 8 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 20 | ||||
-rw-r--r-- | fs/nfs/nfs4renewd.c | 12 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 6 | ||||
-rw-r--r-- | fs/nfs/objlayout/objio_osd.c | 28 | ||||
-rw-r--r-- | fs/nfs/objlayout/pnfs_osd_xdr_cli.c | 3 | ||||
-rw-r--r-- | fs/nfs/super.c | 25 | ||||
-rw-r--r-- | fs/nfs/write.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/xattr.c | 38 | ||||
-rw-r--r-- | fs/proc/task_mmu.c | 80 | ||||
-rw-r--r-- | fs/quota/quota.c | 2 | ||||
-rw-r--r-- | fs/reiserfs/journal.c | 9 | ||||
-rw-r--r-- | fs/reiserfs/resize.c | 4 | ||||
-rw-r--r-- | fs/reiserfs/xattr_security.c | 4 | ||||
-rw-r--r-- | fs/squashfs/Kconfig | 6 | ||||
-rw-r--r-- | fs/stat.c | 2 | ||||
-rw-r--r-- | fs/sysfs/dir.c | 182 | ||||
-rw-r--r-- | fs/sysfs/file.c | 56 | ||||
-rw-r--r-- | fs/sysfs/inode.c | 16 | ||||
-rw-r--r-- | fs/sysfs/sysfs.h | 17 | ||||
-rw-r--r-- | fs/ubifs/debug.h | 6 | ||||
-rw-r--r-- | fs/xattr.c | 63 | ||||
-rw-r--r-- | fs/xfs/Makefile | 119 | ||||
-rw-r--r-- | fs/xfs/kmem.c (renamed from fs/xfs/linux-2.6/kmem.c) | 0 | ||||
-rw-r--r-- | fs/xfs/kmem.h (renamed from fs/xfs/linux-2.6/kmem.h) | 7 | ||||
-rw-r--r-- | fs/xfs/mrlock.h (renamed from fs/xfs/linux-2.6/mrlock.h) | 0 | ||||
-rw-r--r-- | fs/xfs/time.h (renamed from fs/xfs/linux-2.6/time.h) | 0 | ||||
-rw-r--r-- | fs/xfs/uuid.c (renamed from fs/xfs/support/uuid.c) | 0 | ||||
-rw-r--r-- | fs/xfs/uuid.h (renamed from fs/xfs/support/uuid.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs.h | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_acl.c (renamed from fs/xfs/linux-2.6/xfs_acl.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_ag.h | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_alloc.c | 7 | ||||
-rw-r--r-- | fs/xfs/xfs_aops.c (renamed from fs/xfs/linux-2.6/xfs_aops.c) | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_aops.h (renamed from fs/xfs/linux-2.6/xfs_aops.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_attr.c | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap.c | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.c | 17 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_buf.c (renamed from fs/xfs/linux-2.6/xfs_buf.c) | 15 | ||||
-rw-r--r-- | fs/xfs/xfs_buf.h (renamed from fs/xfs/linux-2.6/xfs_buf.h) | 32 | ||||
-rw-r--r-- | fs/xfs/xfs_buf_item.c | 27 | ||||
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 12 | ||||
-rw-r--r-- | fs/xfs/xfs_dinode.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_discard.c (renamed from fs/xfs/linux-2.6/xfs_discard.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_discard.h (renamed from fs/xfs/linux-2.6/xfs_discard.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot.c (renamed from fs/xfs/quota/xfs_dquot.c) | 16 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot.h (renamed from fs/xfs/quota/xfs_dquot.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot_item.c (renamed from fs/xfs/quota/xfs_dquot_item.c) | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot_item.h (renamed from fs/xfs/quota/xfs_dquot_item.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_export.c (renamed from fs/xfs/linux-2.6/xfs_export.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_export.h (renamed from fs/xfs/linux-2.6/xfs_export.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_file.c (renamed from fs/xfs/linux-2.6/xfs_file.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_fs_subr.c (renamed from fs/xfs/linux-2.6/xfs_fs_subr.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_globals.c (renamed from fs/xfs/linux-2.6/xfs_globals.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_ialloc.c | 5 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_inode_item.c | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl.c (renamed from fs/xfs/linux-2.6/xfs_ioctl.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl.h (renamed from fs/xfs/linux-2.6/xfs_ioctl.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl32.c (renamed from fs/xfs/linux-2.6/xfs_ioctl32.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl32.h (renamed from fs/xfs/linux-2.6/xfs_ioctl32.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_iops.c (renamed from fs/xfs/linux-2.6/xfs_iops.c) | 53 | ||||
-rw-r--r-- | fs/xfs/xfs_iops.h (renamed from fs/xfs/linux-2.6/xfs_iops.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_linux.h (renamed from fs/xfs/linux-2.6/xfs_linux.h) | 29 | ||||
-rw-r--r-- | fs/xfs/xfs_log.c | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 38 | ||||
-rw-r--r-- | fs/xfs/xfs_message.c (renamed from fs/xfs/linux-2.6/xfs_message.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_message.h (renamed from fs/xfs/linux-2.6/xfs_message.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_qm.c (renamed from fs/xfs/quota/xfs_qm.c) | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_qm.h (renamed from fs/xfs/quota/xfs_qm.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_qm_bhv.c (renamed from fs/xfs/quota/xfs_qm_bhv.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_qm_stats.c (renamed from fs/xfs/quota/xfs_qm_stats.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_qm_stats.h (renamed from fs/xfs/quota/xfs_qm_stats.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_qm_syscalls.c (renamed from fs/xfs/quota/xfs_qm_syscalls.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_quota_priv.h (renamed from fs/xfs/quota/xfs_quota_priv.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_quotaops.c (renamed from fs/xfs/linux-2.6/xfs_quotaops.c) | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 32 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_rw.c | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_sb.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_stats.c (renamed from fs/xfs/linux-2.6/xfs_stats.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_stats.h (renamed from fs/xfs/linux-2.6/xfs_stats.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_super.c (renamed from fs/xfs/linux-2.6/xfs_super.c) | 49 | ||||
-rw-r--r-- | fs/xfs/xfs_super.h (renamed from fs/xfs/linux-2.6/xfs_super.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_sync.c (renamed from fs/xfs/linux-2.6/xfs_sync.c) | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_sync.h (renamed from fs/xfs/linux-2.6/xfs_sync.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_sysctl.c (renamed from fs/xfs/linux-2.6/xfs_sysctl.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_sysctl.h (renamed from fs/xfs/linux-2.6/xfs_sysctl.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_trace.c (renamed from fs/xfs/linux-2.6/xfs_trace.c) | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_trace.h (renamed from fs/xfs/linux-2.6/xfs_trace.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_trans.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_ail.c | 150 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_buf.c | 28 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_dquot.c (renamed from fs/xfs/quota/xfs_trans_dquot.c) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_priv.h | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_vnode.h (renamed from fs/xfs/linux-2.6/xfs_vnode.h) | 0 | ||||
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 12 | ||||
-rw-r--r-- | fs/xfs/xfs_xattr.c (renamed from fs/xfs/linux-2.6/xfs_xattr.c) | 0 |
186 files changed, 1817 insertions, 1257 deletions
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 46ce357ca1ab..410ffd6ceb5f 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
@@ -54,9 +54,9 @@ extern struct kmem_cache *v9fs_inode_cache; | |||
54 | 54 | ||
55 | struct inode *v9fs_alloc_inode(struct super_block *sb); | 55 | struct inode *v9fs_alloc_inode(struct super_block *sb); |
56 | void v9fs_destroy_inode(struct inode *inode); | 56 | void v9fs_destroy_inode(struct inode *inode); |
57 | struct inode *v9fs_get_inode(struct super_block *sb, int mode); | 57 | struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t); |
58 | int v9fs_init_inode(struct v9fs_session_info *v9ses, | 58 | int v9fs_init_inode(struct v9fs_session_info *v9ses, |
59 | struct inode *inode, int mode); | 59 | struct inode *inode, int mode, dev_t); |
60 | void v9fs_evict_inode(struct inode *inode); | 60 | void v9fs_evict_inode(struct inode *inode); |
61 | ino_t v9fs_qid2ino(struct p9_qid *qid); | 61 | ino_t v9fs_qid2ino(struct p9_qid *qid); |
62 | void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *); | 62 | void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *); |
@@ -83,4 +83,6 @@ static inline void v9fs_invalidate_inode_attr(struct inode *inode) | |||
83 | v9inode->cache_validity |= V9FS_INO_INVALID_ATTR; | 83 | v9inode->cache_validity |= V9FS_INO_INVALID_ATTR; |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | |||
87 | int v9fs_open_to_dotl_flags(int flags); | ||
86 | #endif | 88 | #endif |
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 3c173fcc2c5a..62857a810a79 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -65,7 +65,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
65 | v9inode = V9FS_I(inode); | 65 | v9inode = V9FS_I(inode); |
66 | v9ses = v9fs_inode2v9ses(inode); | 66 | v9ses = v9fs_inode2v9ses(inode); |
67 | if (v9fs_proto_dotl(v9ses)) | 67 | if (v9fs_proto_dotl(v9ses)) |
68 | omode = file->f_flags; | 68 | omode = v9fs_open_to_dotl_flags(file->f_flags); |
69 | else | 69 | else |
70 | omode = v9fs_uflags2omode(file->f_flags, | 70 | omode = v9fs_uflags2omode(file->f_flags, |
71 | v9fs_proto_dotu(v9ses)); | 71 | v9fs_proto_dotu(v9ses)); |
@@ -169,7 +169,18 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
169 | 169 | ||
170 | /* convert posix lock to p9 tlock args */ | 170 | /* convert posix lock to p9 tlock args */ |
171 | memset(&flock, 0, sizeof(flock)); | 171 | memset(&flock, 0, sizeof(flock)); |
172 | flock.type = fl->fl_type; | 172 | /* map the lock type */ |
173 | switch (fl->fl_type) { | ||
174 | case F_RDLCK: | ||
175 | flock.type = P9_LOCK_TYPE_RDLCK; | ||
176 | break; | ||
177 | case F_WRLCK: | ||
178 | flock.type = P9_LOCK_TYPE_WRLCK; | ||
179 | break; | ||
180 | case F_UNLCK: | ||
181 | flock.type = P9_LOCK_TYPE_UNLCK; | ||
182 | break; | ||
183 | } | ||
173 | flock.start = fl->fl_start; | 184 | flock.start = fl->fl_start; |
174 | if (fl->fl_end == OFFSET_MAX) | 185 | if (fl->fl_end == OFFSET_MAX) |
175 | flock.length = 0; | 186 | flock.length = 0; |
@@ -245,7 +256,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) | |||
245 | 256 | ||
246 | /* convert posix lock to p9 tgetlock args */ | 257 | /* convert posix lock to p9 tgetlock args */ |
247 | memset(&glock, 0, sizeof(glock)); | 258 | memset(&glock, 0, sizeof(glock)); |
248 | glock.type = fl->fl_type; | 259 | glock.type = P9_LOCK_TYPE_UNLCK; |
249 | glock.start = fl->fl_start; | 260 | glock.start = fl->fl_start; |
250 | if (fl->fl_end == OFFSET_MAX) | 261 | if (fl->fl_end == OFFSET_MAX) |
251 | glock.length = 0; | 262 | glock.length = 0; |
@@ -257,17 +268,26 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) | |||
257 | res = p9_client_getlock_dotl(fid, &glock); | 268 | res = p9_client_getlock_dotl(fid, &glock); |
258 | if (res < 0) | 269 | if (res < 0) |
259 | return res; | 270 | return res; |
260 | if (glock.type != F_UNLCK) { | 271 | /* map 9p lock type to os lock type */ |
261 | fl->fl_type = glock.type; | 272 | switch (glock.type) { |
273 | case P9_LOCK_TYPE_RDLCK: | ||
274 | fl->fl_type = F_RDLCK; | ||
275 | break; | ||
276 | case P9_LOCK_TYPE_WRLCK: | ||
277 | fl->fl_type = F_WRLCK; | ||
278 | break; | ||
279 | case P9_LOCK_TYPE_UNLCK: | ||
280 | fl->fl_type = F_UNLCK; | ||
281 | break; | ||
282 | } | ||
283 | if (glock.type != P9_LOCK_TYPE_UNLCK) { | ||
262 | fl->fl_start = glock.start; | 284 | fl->fl_start = glock.start; |
263 | if (glock.length == 0) | 285 | if (glock.length == 0) |
264 | fl->fl_end = OFFSET_MAX; | 286 | fl->fl_end = OFFSET_MAX; |
265 | else | 287 | else |
266 | fl->fl_end = glock.start + glock.length - 1; | 288 | fl->fl_end = glock.start + glock.length - 1; |
267 | fl->fl_pid = glock.proc_id; | 289 | fl->fl_pid = glock.proc_id; |
268 | } else | 290 | } |
269 | fl->fl_type = F_UNLCK; | ||
270 | |||
271 | return res; | 291 | return res; |
272 | } | 292 | } |
273 | 293 | ||
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 8bb5507e822f..e3c03db3c788 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -95,15 +95,18 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) | |||
95 | /** | 95 | /** |
96 | * p9mode2unixmode- convert plan9 mode bits to unix mode bits | 96 | * p9mode2unixmode- convert plan9 mode bits to unix mode bits |
97 | * @v9ses: v9fs session information | 97 | * @v9ses: v9fs session information |
98 | * @mode: mode to convert | 98 | * @stat: p9_wstat from which mode need to be derived |
99 | * @rdev: major number, minor number in case of device files. | ||
99 | * | 100 | * |
100 | */ | 101 | */ |
101 | 102 | static int p9mode2unixmode(struct v9fs_session_info *v9ses, | |
102 | static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | 103 | struct p9_wstat *stat, dev_t *rdev) |
103 | { | 104 | { |
104 | int res; | 105 | int res; |
106 | int mode = stat->mode; | ||
105 | 107 | ||
106 | res = mode & 0777; | 108 | res = mode & S_IALLUGO; |
109 | *rdev = 0; | ||
107 | 110 | ||
108 | if ((mode & P9_DMDIR) == P9_DMDIR) | 111 | if ((mode & P9_DMDIR) == P9_DMDIR) |
109 | res |= S_IFDIR; | 112 | res |= S_IFDIR; |
@@ -116,9 +119,26 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | |||
116 | && (v9ses->nodev == 0)) | 119 | && (v9ses->nodev == 0)) |
117 | res |= S_IFIFO; | 120 | res |= S_IFIFO; |
118 | else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses)) | 121 | else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses)) |
119 | && (v9ses->nodev == 0)) | 122 | && (v9ses->nodev == 0)) { |
120 | res |= S_IFBLK; | 123 | char type = 0, ext[32]; |
121 | else | 124 | int major = -1, minor = -1; |
125 | |||
126 | strncpy(ext, stat->extension, sizeof(ext)); | ||
127 | sscanf(ext, "%c %u %u", &type, &major, &minor); | ||
128 | switch (type) { | ||
129 | case 'c': | ||
130 | res |= S_IFCHR; | ||
131 | break; | ||
132 | case 'b': | ||
133 | res |= S_IFBLK; | ||
134 | break; | ||
135 | default: | ||
136 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
137 | "Unknown special type %c %s\n", type, | ||
138 | stat->extension); | ||
139 | }; | ||
140 | *rdev = MKDEV(major, minor); | ||
141 | } else | ||
122 | res |= S_IFREG; | 142 | res |= S_IFREG; |
123 | 143 | ||
124 | if (v9fs_proto_dotu(v9ses)) { | 144 | if (v9fs_proto_dotu(v9ses)) { |
@@ -131,7 +151,6 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | |||
131 | if ((mode & P9_DMSETVTX) == P9_DMSETVTX) | 151 | if ((mode & P9_DMSETVTX) == P9_DMSETVTX) |
132 | res |= S_ISVTX; | 152 | res |= S_ISVTX; |
133 | } | 153 | } |
134 | |||
135 | return res; | 154 | return res; |
136 | } | 155 | } |
137 | 156 | ||
@@ -242,13 +261,13 @@ void v9fs_destroy_inode(struct inode *inode) | |||
242 | } | 261 | } |
243 | 262 | ||
244 | int v9fs_init_inode(struct v9fs_session_info *v9ses, | 263 | int v9fs_init_inode(struct v9fs_session_info *v9ses, |
245 | struct inode *inode, int mode) | 264 | struct inode *inode, int mode, dev_t rdev) |
246 | { | 265 | { |
247 | int err = 0; | 266 | int err = 0; |
248 | 267 | ||
249 | inode_init_owner(inode, NULL, mode); | 268 | inode_init_owner(inode, NULL, mode); |
250 | inode->i_blocks = 0; | 269 | inode->i_blocks = 0; |
251 | inode->i_rdev = 0; | 270 | inode->i_rdev = rdev; |
252 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 271 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
253 | inode->i_mapping->a_ops = &v9fs_addr_operations; | 272 | inode->i_mapping->a_ops = &v9fs_addr_operations; |
254 | 273 | ||
@@ -335,7 +354,7 @@ error: | |||
335 | * | 354 | * |
336 | */ | 355 | */ |
337 | 356 | ||
338 | struct inode *v9fs_get_inode(struct super_block *sb, int mode) | 357 | struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t rdev) |
339 | { | 358 | { |
340 | int err; | 359 | int err; |
341 | struct inode *inode; | 360 | struct inode *inode; |
@@ -348,7 +367,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
348 | P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n"); | 367 | P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n"); |
349 | return ERR_PTR(-ENOMEM); | 368 | return ERR_PTR(-ENOMEM); |
350 | } | 369 | } |
351 | err = v9fs_init_inode(v9ses, inode, mode); | 370 | err = v9fs_init_inode(v9ses, inode, mode, rdev); |
352 | if (err) { | 371 | if (err) { |
353 | iput(inode); | 372 | iput(inode); |
354 | return ERR_PTR(err); | 373 | return ERR_PTR(err); |
@@ -435,11 +454,12 @@ void v9fs_evict_inode(struct inode *inode) | |||
435 | static int v9fs_test_inode(struct inode *inode, void *data) | 454 | static int v9fs_test_inode(struct inode *inode, void *data) |
436 | { | 455 | { |
437 | int umode; | 456 | int umode; |
457 | dev_t rdev; | ||
438 | struct v9fs_inode *v9inode = V9FS_I(inode); | 458 | struct v9fs_inode *v9inode = V9FS_I(inode); |
439 | struct p9_wstat *st = (struct p9_wstat *)data; | 459 | struct p9_wstat *st = (struct p9_wstat *)data; |
440 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); | 460 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); |
441 | 461 | ||
442 | umode = p9mode2unixmode(v9ses, st->mode); | 462 | umode = p9mode2unixmode(v9ses, st, &rdev); |
443 | /* don't match inode of different type */ | 463 | /* don't match inode of different type */ |
444 | if ((inode->i_mode & S_IFMT) != (umode & S_IFMT)) | 464 | if ((inode->i_mode & S_IFMT) != (umode & S_IFMT)) |
445 | return 0; | 465 | return 0; |
@@ -473,6 +493,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, | |||
473 | struct p9_wstat *st, | 493 | struct p9_wstat *st, |
474 | int new) | 494 | int new) |
475 | { | 495 | { |
496 | dev_t rdev; | ||
476 | int retval, umode; | 497 | int retval, umode; |
477 | unsigned long i_ino; | 498 | unsigned long i_ino; |
478 | struct inode *inode; | 499 | struct inode *inode; |
@@ -496,8 +517,8 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, | |||
496 | * later. | 517 | * later. |
497 | */ | 518 | */ |
498 | inode->i_ino = i_ino; | 519 | inode->i_ino = i_ino; |
499 | umode = p9mode2unixmode(v9ses, st->mode); | 520 | umode = p9mode2unixmode(v9ses, st, &rdev); |
500 | retval = v9fs_init_inode(v9ses, inode, umode); | 521 | retval = v9fs_init_inode(v9ses, inode, umode, rdev); |
501 | if (retval) | 522 | if (retval) |
502 | goto error; | 523 | goto error; |
503 | 524 | ||
@@ -532,6 +553,19 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, | |||
532 | } | 553 | } |
533 | 554 | ||
534 | /** | 555 | /** |
556 | * v9fs_at_to_dotl_flags- convert Linux specific AT flags to | ||
557 | * plan 9 AT flag. | ||
558 | * @flags: flags to convert | ||
559 | */ | ||
560 | static int v9fs_at_to_dotl_flags(int flags) | ||
561 | { | ||
562 | int rflags = 0; | ||
563 | if (flags & AT_REMOVEDIR) | ||
564 | rflags |= P9_DOTL_AT_REMOVEDIR; | ||
565 | return rflags; | ||
566 | } | ||
567 | |||
568 | /** | ||
535 | * v9fs_remove - helper function to remove files and directories | 569 | * v9fs_remove - helper function to remove files and directories |
536 | * @dir: directory inode that is being deleted | 570 | * @dir: directory inode that is being deleted |
537 | * @dentry: dentry that is being deleted | 571 | * @dentry: dentry that is being deleted |
@@ -558,7 +592,8 @@ static int v9fs_remove(struct inode *dir, struct dentry *dentry, int flags) | |||
558 | return retval; | 592 | return retval; |
559 | } | 593 | } |
560 | if (v9fs_proto_dotl(v9ses)) | 594 | if (v9fs_proto_dotl(v9ses)) |
561 | retval = p9_client_unlinkat(dfid, dentry->d_name.name, flags); | 595 | retval = p9_client_unlinkat(dfid, dentry->d_name.name, |
596 | v9fs_at_to_dotl_flags(flags)); | ||
562 | if (retval == -EOPNOTSUPP) { | 597 | if (retval == -EOPNOTSUPP) { |
563 | /* Try the one based on path */ | 598 | /* Try the one based on path */ |
564 | v9fid = v9fs_fid_clone(dentry); | 599 | v9fid = v9fs_fid_clone(dentry); |
@@ -645,13 +680,11 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, | |||
645 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); | 680 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); |
646 | goto error; | 681 | goto error; |
647 | } | 682 | } |
648 | d_instantiate(dentry, inode); | ||
649 | err = v9fs_fid_add(dentry, fid); | 683 | err = v9fs_fid_add(dentry, fid); |
650 | if (err < 0) | 684 | if (err < 0) |
651 | goto error; | 685 | goto error; |
652 | 686 | d_instantiate(dentry, inode); | |
653 | return ofid; | 687 | return ofid; |
654 | |||
655 | error: | 688 | error: |
656 | if (ofid) | 689 | if (ofid) |
657 | p9_client_clunk(ofid); | 690 | p9_client_clunk(ofid); |
@@ -792,6 +825,7 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
792 | struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | 825 | struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, |
793 | struct nameidata *nameidata) | 826 | struct nameidata *nameidata) |
794 | { | 827 | { |
828 | struct dentry *res; | ||
795 | struct super_block *sb; | 829 | struct super_block *sb; |
796 | struct v9fs_session_info *v9ses; | 830 | struct v9fs_session_info *v9ses; |
797 | struct p9_fid *dfid, *fid; | 831 | struct p9_fid *dfid, *fid; |
@@ -823,22 +857,35 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
823 | 857 | ||
824 | return ERR_PTR(result); | 858 | return ERR_PTR(result); |
825 | } | 859 | } |
826 | 860 | /* | |
827 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); | 861 | * Make sure we don't use a wrong inode due to parallel |
862 | * unlink. For cached mode create calls request for new | ||
863 | * inode. But with cache disabled, lookup should do this. | ||
864 | */ | ||
865 | if (v9ses->cache) | ||
866 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); | ||
867 | else | ||
868 | inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); | ||
828 | if (IS_ERR(inode)) { | 869 | if (IS_ERR(inode)) { |
829 | result = PTR_ERR(inode); | 870 | result = PTR_ERR(inode); |
830 | inode = NULL; | 871 | inode = NULL; |
831 | goto error; | 872 | goto error; |
832 | } | 873 | } |
833 | |||
834 | result = v9fs_fid_add(dentry, fid); | 874 | result = v9fs_fid_add(dentry, fid); |
835 | if (result < 0) | 875 | if (result < 0) |
836 | goto error_iput; | 876 | goto error_iput; |
837 | |||
838 | inst_out: | 877 | inst_out: |
839 | d_add(dentry, inode); | 878 | /* |
840 | return NULL; | 879 | * If we had a rename on the server and a parallel lookup |
841 | 880 | * for the new name, then make sure we instantiate with | |
881 | * the new name. ie look up for a/b, while on server somebody | ||
882 | * moved b under k and client parallely did a lookup for | ||
883 | * k/b. | ||
884 | */ | ||
885 | res = d_materialise_unique(dentry, inode); | ||
886 | if (!IS_ERR(res)) | ||
887 | return res; | ||
888 | result = PTR_ERR(res); | ||
842 | error_iput: | 889 | error_iput: |
843 | iput(inode); | 890 | iput(inode); |
844 | error: | 891 | error: |
@@ -1002,7 +1049,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1002 | return PTR_ERR(st); | 1049 | return PTR_ERR(st); |
1003 | 1050 | ||
1004 | v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb); | 1051 | v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb); |
1005 | generic_fillattr(dentry->d_inode, stat); | 1052 | generic_fillattr(dentry->d_inode, stat); |
1006 | 1053 | ||
1007 | p9stat_free(st); | 1054 | p9stat_free(st); |
1008 | kfree(st); | 1055 | kfree(st); |
@@ -1086,6 +1133,7 @@ void | |||
1086 | v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, | 1133 | v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, |
1087 | struct super_block *sb) | 1134 | struct super_block *sb) |
1088 | { | 1135 | { |
1136 | mode_t mode; | ||
1089 | char ext[32]; | 1137 | char ext[32]; |
1090 | char tag_name[14]; | 1138 | char tag_name[14]; |
1091 | unsigned int i_nlink; | 1139 | unsigned int i_nlink; |
@@ -1121,31 +1169,9 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, | |||
1121 | inode->i_nlink = i_nlink; | 1169 | inode->i_nlink = i_nlink; |
1122 | } | 1170 | } |
1123 | } | 1171 | } |
1124 | inode->i_mode = p9mode2unixmode(v9ses, stat->mode); | 1172 | mode = stat->mode & S_IALLUGO; |
1125 | if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) { | 1173 | mode |= inode->i_mode & ~S_IALLUGO; |
1126 | char type = 0; | 1174 | inode->i_mode = mode; |
1127 | int major = -1; | ||
1128 | int minor = -1; | ||
1129 | |||
1130 | strncpy(ext, stat->extension, sizeof(ext)); | ||
1131 | sscanf(ext, "%c %u %u", &type, &major, &minor); | ||
1132 | switch (type) { | ||
1133 | case 'c': | ||
1134 | inode->i_mode &= ~S_IFBLK; | ||
1135 | inode->i_mode |= S_IFCHR; | ||
1136 | break; | ||
1137 | case 'b': | ||
1138 | break; | ||
1139 | default: | ||
1140 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
1141 | "Unknown special type %c %s\n", type, | ||
1142 | stat->extension); | ||
1143 | }; | ||
1144 | inode->i_rdev = MKDEV(major, minor); | ||
1145 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | ||
1146 | } else | ||
1147 | inode->i_rdev = 0; | ||
1148 | |||
1149 | i_size_write(inode, stat->length); | 1175 | i_size_write(inode, stat->length); |
1150 | 1176 | ||
1151 | /* not real number of blocks, but 512 byte ones ... */ | 1177 | /* not real number of blocks, but 512 byte ones ... */ |
@@ -1411,6 +1437,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
1411 | 1437 | ||
1412 | int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) | 1438 | int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) |
1413 | { | 1439 | { |
1440 | int umode; | ||
1441 | dev_t rdev; | ||
1414 | loff_t i_size; | 1442 | loff_t i_size; |
1415 | struct p9_wstat *st; | 1443 | struct p9_wstat *st; |
1416 | struct v9fs_session_info *v9ses; | 1444 | struct v9fs_session_info *v9ses; |
@@ -1419,6 +1447,12 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) | |||
1419 | st = p9_client_stat(fid); | 1447 | st = p9_client_stat(fid); |
1420 | if (IS_ERR(st)) | 1448 | if (IS_ERR(st)) |
1421 | return PTR_ERR(st); | 1449 | return PTR_ERR(st); |
1450 | /* | ||
1451 | * Don't update inode if the file type is different | ||
1452 | */ | ||
1453 | umode = p9mode2unixmode(v9ses, st, &rdev); | ||
1454 | if ((inode->i_mode & S_IFMT) != (umode & S_IFMT)) | ||
1455 | goto out; | ||
1422 | 1456 | ||
1423 | spin_lock(&inode->i_lock); | 1457 | spin_lock(&inode->i_lock); |
1424 | /* | 1458 | /* |
@@ -1430,6 +1464,7 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) | |||
1430 | if (v9ses->cache) | 1464 | if (v9ses->cache) |
1431 | inode->i_size = i_size; | 1465 | inode->i_size = i_size; |
1432 | spin_unlock(&inode->i_lock); | 1466 | spin_unlock(&inode->i_lock); |
1467 | out: | ||
1433 | p9stat_free(st); | 1468 | p9stat_free(st); |
1434 | kfree(st); | 1469 | kfree(st); |
1435 | return 0; | 1470 | return 0; |
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index b6c8ed205192..aded79fcd5cf 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c | |||
@@ -153,7 +153,8 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, | |||
153 | * later. | 153 | * later. |
154 | */ | 154 | */ |
155 | inode->i_ino = i_ino; | 155 | inode->i_ino = i_ino; |
156 | retval = v9fs_init_inode(v9ses, inode, st->st_mode); | 156 | retval = v9fs_init_inode(v9ses, inode, |
157 | st->st_mode, new_decode_dev(st->st_rdev)); | ||
157 | if (retval) | 158 | if (retval) |
158 | goto error; | 159 | goto error; |
159 | 160 | ||
@@ -190,6 +191,58 @@ v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid, | |||
190 | return inode; | 191 | return inode; |
191 | } | 192 | } |
192 | 193 | ||
194 | struct dotl_openflag_map { | ||
195 | int open_flag; | ||
196 | int dotl_flag; | ||
197 | }; | ||
198 | |||
199 | static int v9fs_mapped_dotl_flags(int flags) | ||
200 | { | ||
201 | int i; | ||
202 | int rflags = 0; | ||
203 | struct dotl_openflag_map dotl_oflag_map[] = { | ||
204 | { O_CREAT, P9_DOTL_CREATE }, | ||
205 | { O_EXCL, P9_DOTL_EXCL }, | ||
206 | { O_NOCTTY, P9_DOTL_NOCTTY }, | ||
207 | { O_TRUNC, P9_DOTL_TRUNC }, | ||
208 | { O_APPEND, P9_DOTL_APPEND }, | ||
209 | { O_NONBLOCK, P9_DOTL_NONBLOCK }, | ||
210 | { O_DSYNC, P9_DOTL_DSYNC }, | ||
211 | { FASYNC, P9_DOTL_FASYNC }, | ||
212 | { O_DIRECT, P9_DOTL_DIRECT }, | ||
213 | { O_LARGEFILE, P9_DOTL_LARGEFILE }, | ||
214 | { O_DIRECTORY, P9_DOTL_DIRECTORY }, | ||
215 | { O_NOFOLLOW, P9_DOTL_NOFOLLOW }, | ||
216 | { O_NOATIME, P9_DOTL_NOATIME }, | ||
217 | { O_CLOEXEC, P9_DOTL_CLOEXEC }, | ||
218 | { O_SYNC, P9_DOTL_SYNC}, | ||
219 | }; | ||
220 | for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) { | ||
221 | if (flags & dotl_oflag_map[i].open_flag) | ||
222 | rflags |= dotl_oflag_map[i].dotl_flag; | ||
223 | } | ||
224 | return rflags; | ||
225 | } | ||
226 | |||
227 | /** | ||
228 | * v9fs_open_to_dotl_flags- convert Linux specific open flags to | ||
229 | * plan 9 open flag. | ||
230 | * @flags: flags to convert | ||
231 | */ | ||
232 | int v9fs_open_to_dotl_flags(int flags) | ||
233 | { | ||
234 | int rflags = 0; | ||
235 | |||
236 | /* | ||
237 | * We have same bits for P9_DOTL_READONLY, P9_DOTL_WRONLY | ||
238 | * and P9_DOTL_NOACCESS | ||
239 | */ | ||
240 | rflags |= flags & O_ACCMODE; | ||
241 | rflags |= v9fs_mapped_dotl_flags(flags); | ||
242 | |||
243 | return rflags; | ||
244 | } | ||
245 | |||
193 | /** | 246 | /** |
194 | * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol. | 247 | * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol. |
195 | * @dir: directory inode that is being created | 248 | * @dir: directory inode that is being created |
@@ -258,7 +311,8 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
258 | "Failed to get acl values in creat %d\n", err); | 311 | "Failed to get acl values in creat %d\n", err); |
259 | goto error; | 312 | goto error; |
260 | } | 313 | } |
261 | err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid); | 314 | err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags), |
315 | mode, gid, &qid); | ||
262 | if (err < 0) { | 316 | if (err < 0) { |
263 | P9_DPRINTK(P9_DEBUG_VFS, | 317 | P9_DPRINTK(P9_DEBUG_VFS, |
264 | "p9_client_open_dotl failed in creat %d\n", | 318 | "p9_client_open_dotl failed in creat %d\n", |
@@ -281,10 +335,10 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
281 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); | 335 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); |
282 | goto error; | 336 | goto error; |
283 | } | 337 | } |
284 | d_instantiate(dentry, inode); | ||
285 | err = v9fs_fid_add(dentry, fid); | 338 | err = v9fs_fid_add(dentry, fid); |
286 | if (err < 0) | 339 | if (err < 0) |
287 | goto error; | 340 | goto error; |
341 | d_instantiate(dentry, inode); | ||
288 | 342 | ||
289 | /* Now set the ACL based on the default value */ | 343 | /* Now set the ACL based on the default value */ |
290 | v9fs_set_create_acl(dentry, &dacl, &pacl); | 344 | v9fs_set_create_acl(dentry, &dacl, &pacl); |
@@ -403,10 +457,10 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, | |||
403 | err); | 457 | err); |
404 | goto error; | 458 | goto error; |
405 | } | 459 | } |
406 | d_instantiate(dentry, inode); | ||
407 | err = v9fs_fid_add(dentry, fid); | 460 | err = v9fs_fid_add(dentry, fid); |
408 | if (err < 0) | 461 | if (err < 0) |
409 | goto error; | 462 | goto error; |
463 | d_instantiate(dentry, inode); | ||
410 | fid = NULL; | 464 | fid = NULL; |
411 | } else { | 465 | } else { |
412 | /* | 466 | /* |
@@ -414,7 +468,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, | |||
414 | * inode with stat. We need to get an inode | 468 | * inode with stat. We need to get an inode |
415 | * so that we can set the acl with dentry | 469 | * so that we can set the acl with dentry |
416 | */ | 470 | */ |
417 | inode = v9fs_get_inode(dir->i_sb, mode); | 471 | inode = v9fs_get_inode(dir->i_sb, mode, 0); |
418 | if (IS_ERR(inode)) { | 472 | if (IS_ERR(inode)) { |
419 | err = PTR_ERR(inode); | 473 | err = PTR_ERR(inode); |
420 | goto error; | 474 | goto error; |
@@ -540,6 +594,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) | |||
540 | void | 594 | void |
541 | v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) | 595 | v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) |
542 | { | 596 | { |
597 | mode_t mode; | ||
543 | struct v9fs_inode *v9inode = V9FS_I(inode); | 598 | struct v9fs_inode *v9inode = V9FS_I(inode); |
544 | 599 | ||
545 | if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) { | 600 | if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) { |
@@ -552,11 +607,10 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) | |||
552 | inode->i_uid = stat->st_uid; | 607 | inode->i_uid = stat->st_uid; |
553 | inode->i_gid = stat->st_gid; | 608 | inode->i_gid = stat->st_gid; |
554 | inode->i_nlink = stat->st_nlink; | 609 | inode->i_nlink = stat->st_nlink; |
555 | inode->i_mode = stat->st_mode; | ||
556 | inode->i_rdev = new_decode_dev(stat->st_rdev); | ||
557 | 610 | ||
558 | if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) | 611 | mode = stat->st_mode & S_IALLUGO; |
559 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | 612 | mode |= inode->i_mode & ~S_IALLUGO; |
613 | inode->i_mode = mode; | ||
560 | 614 | ||
561 | i_size_write(inode, stat->st_size); | 615 | i_size_write(inode, stat->st_size); |
562 | inode->i_blocks = stat->st_blocks; | 616 | inode->i_blocks = stat->st_blocks; |
@@ -657,14 +711,14 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry, | |||
657 | err); | 711 | err); |
658 | goto error; | 712 | goto error; |
659 | } | 713 | } |
660 | d_instantiate(dentry, inode); | ||
661 | err = v9fs_fid_add(dentry, fid); | 714 | err = v9fs_fid_add(dentry, fid); |
662 | if (err < 0) | 715 | if (err < 0) |
663 | goto error; | 716 | goto error; |
717 | d_instantiate(dentry, inode); | ||
664 | fid = NULL; | 718 | fid = NULL; |
665 | } else { | 719 | } else { |
666 | /* Not in cached mode. No need to populate inode with stat */ | 720 | /* Not in cached mode. No need to populate inode with stat */ |
667 | inode = v9fs_get_inode(dir->i_sb, S_IFLNK); | 721 | inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0); |
668 | if (IS_ERR(inode)) { | 722 | if (IS_ERR(inode)) { |
669 | err = PTR_ERR(inode); | 723 | err = PTR_ERR(inode); |
670 | goto error; | 724 | goto error; |
@@ -810,17 +864,17 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
810 | err); | 864 | err); |
811 | goto error; | 865 | goto error; |
812 | } | 866 | } |
813 | d_instantiate(dentry, inode); | ||
814 | err = v9fs_fid_add(dentry, fid); | 867 | err = v9fs_fid_add(dentry, fid); |
815 | if (err < 0) | 868 | if (err < 0) |
816 | goto error; | 869 | goto error; |
870 | d_instantiate(dentry, inode); | ||
817 | fid = NULL; | 871 | fid = NULL; |
818 | } else { | 872 | } else { |
819 | /* | 873 | /* |
820 | * Not in cached mode. No need to populate inode with stat. | 874 | * Not in cached mode. No need to populate inode with stat. |
821 | * socket syscall returns a fd, so we need instantiate | 875 | * socket syscall returns a fd, so we need instantiate |
822 | */ | 876 | */ |
823 | inode = v9fs_get_inode(dir->i_sb, mode); | 877 | inode = v9fs_get_inode(dir->i_sb, mode, rdev); |
824 | if (IS_ERR(inode)) { | 878 | if (IS_ERR(inode)) { |
825 | err = PTR_ERR(inode); | 879 | err = PTR_ERR(inode); |
826 | goto error; | 880 | goto error; |
@@ -886,6 +940,11 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode) | |||
886 | st = p9_client_getattr_dotl(fid, P9_STATS_ALL); | 940 | st = p9_client_getattr_dotl(fid, P9_STATS_ALL); |
887 | if (IS_ERR(st)) | 941 | if (IS_ERR(st)) |
888 | return PTR_ERR(st); | 942 | return PTR_ERR(st); |
943 | /* | ||
944 | * Don't update inode if the file type is different | ||
945 | */ | ||
946 | if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT)) | ||
947 | goto out; | ||
889 | 948 | ||
890 | spin_lock(&inode->i_lock); | 949 | spin_lock(&inode->i_lock); |
891 | /* | 950 | /* |
@@ -897,6 +956,7 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode) | |||
897 | if (v9ses->cache) | 956 | if (v9ses->cache) |
898 | inode->i_size = i_size; | 957 | inode->i_size = i_size; |
899 | spin_unlock(&inode->i_lock); | 958 | spin_unlock(&inode->i_lock); |
959 | out: | ||
900 | kfree(st); | 960 | kfree(st); |
901 | return 0; | 961 | return 0; |
902 | } | 962 | } |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index feef6cdc1fd2..c70251d47ed1 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -149,7 +149,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags, | |||
149 | else | 149 | else |
150 | sb->s_d_op = &v9fs_dentry_operations; | 150 | sb->s_d_op = &v9fs_dentry_operations; |
151 | 151 | ||
152 | inode = v9fs_get_inode(sb, S_IFDIR | mode); | 152 | inode = v9fs_get_inode(sb, S_IFDIR | mode, 0); |
153 | if (IS_ERR(inode)) { | 153 | if (IS_ERR(inode)) { |
154 | retval = PTR_ERR(inode); | 154 | retval = PTR_ERR(inode); |
155 | goto release_sb; | 155 | goto release_sb; |
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/fsnotify.h> | 13 | #include <linux/fsnotify.h> |
14 | #include <linux/fcntl.h> | 14 | #include <linux/fcntl.h> |
15 | #include <linux/security.h> | 15 | #include <linux/security.h> |
16 | #include <linux/evm.h> | ||
16 | 17 | ||
17 | /** | 18 | /** |
18 | * inode_change_ok - check if attribute changes to an inode are allowed | 19 | * inode_change_ok - check if attribute changes to an inode are allowed |
@@ -237,8 +238,10 @@ int notify_change(struct dentry * dentry, struct iattr * attr) | |||
237 | else | 238 | else |
238 | error = simple_setattr(dentry, attr); | 239 | error = simple_setattr(dentry, attr); |
239 | 240 | ||
240 | if (!error) | 241 | if (!error) { |
241 | fsnotify_change(dentry, ia_valid); | 242 | fsnotify_change(dentry, ia_valid); |
243 | evm_inode_post_setattr(dentry, ia_valid); | ||
244 | } | ||
242 | 245 | ||
243 | return error; | 246 | return error; |
244 | } | 247 | } |
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h index 475f9c597cb7..326dc08d3e3f 100644 --- a/fs/autofs4/autofs_i.h +++ b/fs/autofs4/autofs_i.h | |||
@@ -39,27 +39,17 @@ | |||
39 | 39 | ||
40 | /* #define DEBUG */ | 40 | /* #define DEBUG */ |
41 | 41 | ||
42 | #ifdef DEBUG | 42 | #define DPRINTK(fmt, ...) \ |
43 | #define DPRINTK(fmt, args...) \ | 43 | pr_debug("pid %d: %s: " fmt "\n", \ |
44 | do { \ | 44 | current->pid, __func__, ##__VA_ARGS__) |
45 | printk(KERN_DEBUG "pid %d: %s: " fmt "\n", \ | 45 | |
46 | current->pid, __func__, ##args); \ | 46 | #define AUTOFS_WARN(fmt, ...) \ |
47 | } while (0) | ||
48 | #else | ||
49 | #define DPRINTK(fmt, args...) do {} while (0) | ||
50 | #endif | ||
51 | |||
52 | #define AUTOFS_WARN(fmt, args...) \ | ||
53 | do { \ | ||
54 | printk(KERN_WARNING "pid %d: %s: " fmt "\n", \ | 47 | printk(KERN_WARNING "pid %d: %s: " fmt "\n", \ |
55 | current->pid, __func__, ##args); \ | 48 | current->pid, __func__, ##__VA_ARGS__) |
56 | } while (0) | ||
57 | 49 | ||
58 | #define AUTOFS_ERROR(fmt, args...) \ | 50 | #define AUTOFS_ERROR(fmt, ...) \ |
59 | do { \ | ||
60 | printk(KERN_ERR "pid %d: %s: " fmt "\n", \ | 51 | printk(KERN_ERR "pid %d: %s: " fmt "\n", \ |
61 | current->pid, __func__, ##args); \ | 52 | current->pid, __func__, ##__VA_ARGS__) |
62 | } while (0) | ||
63 | 53 | ||
64 | /* Unified info structure. This is pointed to by both the dentry and | 54 | /* Unified info structure. This is pointed to by both the dentry and |
65 | inode structures. Each file in the filesystem has an instance of this | 55 | inode structures. Each file in the filesystem has an instance of this |
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c index 25435987d6ae..e1fbdeef85db 100644 --- a/fs/autofs4/waitq.c +++ b/fs/autofs4/waitq.c | |||
@@ -104,7 +104,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi, | |||
104 | size_t pktsz; | 104 | size_t pktsz; |
105 | 105 | ||
106 | DPRINTK("wait id = 0x%08lx, name = %.*s, type=%d", | 106 | DPRINTK("wait id = 0x%08lx, name = %.*s, type=%d", |
107 | wq->wait_queue_token, wq->name.len, wq->name.name, type); | 107 | (unsigned long) wq->wait_queue_token, wq->name.len, wq->name.name, type); |
108 | 108 | ||
109 | memset(&pkt,0,sizeof pkt); /* For security reasons */ | 109 | memset(&pkt,0,sizeof pkt); /* For security reasons */ |
110 | 110 | ||
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 54b8c28bebc8..720d885e8dca 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -474,17 +474,22 @@ befs_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
474 | befs_data_stream *data = &befs_ino->i_data.ds; | 474 | befs_data_stream *data = &befs_ino->i_data.ds; |
475 | befs_off_t len = data->size; | 475 | befs_off_t len = data->size; |
476 | 476 | ||
477 | befs_debug(sb, "Follow long symlink"); | 477 | if (len == 0) { |
478 | 478 | befs_error(sb, "Long symlink with illegal length"); | |
479 | link = kmalloc(len, GFP_NOFS); | ||
480 | if (!link) { | ||
481 | link = ERR_PTR(-ENOMEM); | ||
482 | } else if (befs_read_lsymlink(sb, data, link, len) != len) { | ||
483 | kfree(link); | ||
484 | befs_error(sb, "Failed to read entire long symlink"); | ||
485 | link = ERR_PTR(-EIO); | 479 | link = ERR_PTR(-EIO); |
486 | } else { | 480 | } else { |
487 | link[len - 1] = '\0'; | 481 | befs_debug(sb, "Follow long symlink"); |
482 | |||
483 | link = kmalloc(len, GFP_NOFS); | ||
484 | if (!link) { | ||
485 | link = ERR_PTR(-ENOMEM); | ||
486 | } else if (befs_read_lsymlink(sb, data, link, len) != len) { | ||
487 | kfree(link); | ||
488 | befs_error(sb, "Failed to read entire long symlink"); | ||
489 | link = ERR_PTR(-EIO); | ||
490 | } else { | ||
491 | link[len - 1] = '\0'; | ||
492 | } | ||
488 | } | 493 | } |
489 | } else { | 494 | } else { |
490 | link = befs_ino->i_data.symlink; | 495 | link = befs_ino->i_data.symlink; |
diff --git a/fs/block_dev.c b/fs/block_dev.c index ff77262e887c..95f786ec7f08 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1429,6 +1429,11 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) | |||
1429 | WARN_ON_ONCE(bdev->bd_holders); | 1429 | WARN_ON_ONCE(bdev->bd_holders); |
1430 | sync_blockdev(bdev); | 1430 | sync_blockdev(bdev); |
1431 | kill_bdev(bdev); | 1431 | kill_bdev(bdev); |
1432 | /* ->release can cause the old bdi to disappear, | ||
1433 | * so must switch it out first | ||
1434 | */ | ||
1435 | bdev_inode_switch_bdi(bdev->bd_inode, | ||
1436 | &default_backing_dev_info); | ||
1432 | } | 1437 | } |
1433 | if (bdev->bd_contains == bdev) { | 1438 | if (bdev->bd_contains == bdev) { |
1434 | if (disk->fops->release) | 1439 | if (disk->fops->release) |
@@ -1442,8 +1447,6 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) | |||
1442 | disk_put_part(bdev->bd_part); | 1447 | disk_put_part(bdev->bd_part); |
1443 | bdev->bd_part = NULL; | 1448 | bdev->bd_part = NULL; |
1444 | bdev->bd_disk = NULL; | 1449 | bdev->bd_disk = NULL; |
1445 | bdev_inode_switch_bdi(bdev->bd_inode, | ||
1446 | &default_backing_dev_info); | ||
1447 | if (bdev != bdev->bd_contains) | 1450 | if (bdev != bdev->bd_contains) |
1448 | victim = bdev->bd_contains; | 1451 | victim = bdev->bd_contains; |
1449 | bdev->bd_contains = NULL; | 1452 | bdev->bd_contains = NULL; |
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 502b9e988679..d9f99a16edd6 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
@@ -176,7 +176,11 @@ static inline u64 btrfs_ino(struct inode *inode) | |||
176 | { | 176 | { |
177 | u64 ino = BTRFS_I(inode)->location.objectid; | 177 | u64 ino = BTRFS_I(inode)->location.objectid; |
178 | 178 | ||
179 | if (ino <= BTRFS_FIRST_FREE_OBJECTID) | 179 | /* |
180 | * !ino: btree_inode | ||
181 | * type == BTRFS_ROOT_ITEM_KEY: subvol dir | ||
182 | */ | ||
183 | if (!ino || BTRFS_I(inode)->location.type == BTRFS_ROOT_ITEM_KEY) | ||
180 | ino = inode->i_ino; | 184 | ino = inode->i_ino; |
181 | return ino; | 185 | return ino; |
182 | } | 186 | } |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0469263e327e..03912c5c6f49 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1415,17 +1415,15 @@ void btrfs_set_##name(struct extent_buffer *eb, type *s, u##bits val); | |||
1415 | #define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ | 1415 | #define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ |
1416 | static inline u##bits btrfs_##name(struct extent_buffer *eb) \ | 1416 | static inline u##bits btrfs_##name(struct extent_buffer *eb) \ |
1417 | { \ | 1417 | { \ |
1418 | type *p = kmap_atomic(eb->first_page, KM_USER0); \ | 1418 | type *p = page_address(eb->first_page); \ |
1419 | u##bits res = le##bits##_to_cpu(p->member); \ | 1419 | u##bits res = le##bits##_to_cpu(p->member); \ |
1420 | kunmap_atomic(p, KM_USER0); \ | ||
1421 | return res; \ | 1420 | return res; \ |
1422 | } \ | 1421 | } \ |
1423 | static inline void btrfs_set_##name(struct extent_buffer *eb, \ | 1422 | static inline void btrfs_set_##name(struct extent_buffer *eb, \ |
1424 | u##bits val) \ | 1423 | u##bits val) \ |
1425 | { \ | 1424 | { \ |
1426 | type *p = kmap_atomic(eb->first_page, KM_USER0); \ | 1425 | type *p = page_address(eb->first_page); \ |
1427 | p->member = cpu_to_le##bits(val); \ | 1426 | p->member = cpu_to_le##bits(val); \ |
1428 | kunmap_atomic(p, KM_USER0); \ | ||
1429 | } | 1427 | } |
1430 | 1428 | ||
1431 | #define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \ | 1429 | #define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \ |
@@ -2367,8 +2365,8 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans, | |||
2367 | int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); | 2365 | int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); |
2368 | int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path); | 2366 | int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path); |
2369 | int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf); | 2367 | int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf); |
2370 | int btrfs_drop_snapshot(struct btrfs_root *root, | 2368 | void btrfs_drop_snapshot(struct btrfs_root *root, |
2371 | struct btrfs_block_rsv *block_rsv, int update_ref); | 2369 | struct btrfs_block_rsv *block_rsv, int update_ref); |
2372 | int btrfs_drop_subtree(struct btrfs_trans_handle *trans, | 2370 | int btrfs_drop_subtree(struct btrfs_trans_handle *trans, |
2373 | struct btrfs_root *root, | 2371 | struct btrfs_root *root, |
2374 | struct extent_buffer *node, | 2372 | struct extent_buffer *node, |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 66bac226944e..f5be06a2462f 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -1782,6 +1782,9 @@ static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, | |||
1782 | 1782 | ||
1783 | 1783 | ||
1784 | for (i = 0; i < multi->num_stripes; i++, stripe++) { | 1784 | for (i = 0; i < multi->num_stripes; i++, stripe++) { |
1785 | if (!stripe->dev->can_discard) | ||
1786 | continue; | ||
1787 | |||
1785 | ret = btrfs_issue_discard(stripe->dev->bdev, | 1788 | ret = btrfs_issue_discard(stripe->dev->bdev, |
1786 | stripe->physical, | 1789 | stripe->physical, |
1787 | stripe->length); | 1790 | stripe->length); |
@@ -1789,11 +1792,16 @@ static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, | |||
1789 | discarded_bytes += stripe->length; | 1792 | discarded_bytes += stripe->length; |
1790 | else if (ret != -EOPNOTSUPP) | 1793 | else if (ret != -EOPNOTSUPP) |
1791 | break; | 1794 | break; |
1795 | |||
1796 | /* | ||
1797 | * Just in case we get back EOPNOTSUPP for some reason, | ||
1798 | * just ignore the return value so we don't screw up | ||
1799 | * people calling discard_extent. | ||
1800 | */ | ||
1801 | ret = 0; | ||
1792 | } | 1802 | } |
1793 | kfree(multi); | 1803 | kfree(multi); |
1794 | } | 1804 | } |
1795 | if (discarded_bytes && ret == -EOPNOTSUPP) | ||
1796 | ret = 0; | ||
1797 | 1805 | ||
1798 | if (actual_bytes) | 1806 | if (actual_bytes) |
1799 | *actual_bytes = discarded_bytes; | 1807 | *actual_bytes = discarded_bytes; |
@@ -6269,8 +6277,8 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans, | |||
6269 | * also make sure backrefs for the shared block and all lower level | 6277 | * also make sure backrefs for the shared block and all lower level |
6270 | * blocks are properly updated. | 6278 | * blocks are properly updated. |
6271 | */ | 6279 | */ |
6272 | int btrfs_drop_snapshot(struct btrfs_root *root, | 6280 | void btrfs_drop_snapshot(struct btrfs_root *root, |
6273 | struct btrfs_block_rsv *block_rsv, int update_ref) | 6281 | struct btrfs_block_rsv *block_rsv, int update_ref) |
6274 | { | 6282 | { |
6275 | struct btrfs_path *path; | 6283 | struct btrfs_path *path; |
6276 | struct btrfs_trans_handle *trans; | 6284 | struct btrfs_trans_handle *trans; |
@@ -6283,13 +6291,16 @@ int btrfs_drop_snapshot(struct btrfs_root *root, | |||
6283 | int level; | 6291 | int level; |
6284 | 6292 | ||
6285 | path = btrfs_alloc_path(); | 6293 | path = btrfs_alloc_path(); |
6286 | if (!path) | 6294 | if (!path) { |
6287 | return -ENOMEM; | 6295 | err = -ENOMEM; |
6296 | goto out; | ||
6297 | } | ||
6288 | 6298 | ||
6289 | wc = kzalloc(sizeof(*wc), GFP_NOFS); | 6299 | wc = kzalloc(sizeof(*wc), GFP_NOFS); |
6290 | if (!wc) { | 6300 | if (!wc) { |
6291 | btrfs_free_path(path); | 6301 | btrfs_free_path(path); |
6292 | return -ENOMEM; | 6302 | err = -ENOMEM; |
6303 | goto out; | ||
6293 | } | 6304 | } |
6294 | 6305 | ||
6295 | trans = btrfs_start_transaction(tree_root, 0); | 6306 | trans = btrfs_start_transaction(tree_root, 0); |
@@ -6318,7 +6329,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, | |||
6318 | path->lowest_level = 0; | 6329 | path->lowest_level = 0; |
6319 | if (ret < 0) { | 6330 | if (ret < 0) { |
6320 | err = ret; | 6331 | err = ret; |
6321 | goto out; | 6332 | goto out_free; |
6322 | } | 6333 | } |
6323 | WARN_ON(ret > 0); | 6334 | WARN_ON(ret > 0); |
6324 | 6335 | ||
@@ -6425,11 +6436,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root, | |||
6425 | free_extent_buffer(root->commit_root); | 6436 | free_extent_buffer(root->commit_root); |
6426 | kfree(root); | 6437 | kfree(root); |
6427 | } | 6438 | } |
6428 | out: | 6439 | out_free: |
6429 | btrfs_end_transaction_throttle(trans, tree_root); | 6440 | btrfs_end_transaction_throttle(trans, tree_root); |
6430 | kfree(wc); | 6441 | kfree(wc); |
6431 | btrfs_free_path(path); | 6442 | btrfs_free_path(path); |
6432 | return err; | 6443 | out: |
6444 | if (err) | ||
6445 | btrfs_std_error(root->fs_info, err); | ||
6446 | return; | ||
6433 | } | 6447 | } |
6434 | 6448 | ||
6435 | /* | 6449 | /* |
@@ -6720,6 +6734,10 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) | |||
6720 | struct btrfs_space_info *space_info; | 6734 | struct btrfs_space_info *space_info; |
6721 | struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; | 6735 | struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; |
6722 | struct btrfs_device *device; | 6736 | struct btrfs_device *device; |
6737 | u64 min_free; | ||
6738 | u64 dev_min = 1; | ||
6739 | u64 dev_nr = 0; | ||
6740 | int index; | ||
6723 | int full = 0; | 6741 | int full = 0; |
6724 | int ret = 0; | 6742 | int ret = 0; |
6725 | 6743 | ||
@@ -6729,8 +6747,10 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) | |||
6729 | if (!block_group) | 6747 | if (!block_group) |
6730 | return -1; | 6748 | return -1; |
6731 | 6749 | ||
6750 | min_free = btrfs_block_group_used(&block_group->item); | ||
6751 | |||
6732 | /* no bytes used, we're good */ | 6752 | /* no bytes used, we're good */ |
6733 | if (!btrfs_block_group_used(&block_group->item)) | 6753 | if (!min_free) |
6734 | goto out; | 6754 | goto out; |
6735 | 6755 | ||
6736 | space_info = block_group->space_info; | 6756 | space_info = block_group->space_info; |
@@ -6746,10 +6766,9 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) | |||
6746 | * all of the extents from this block group. If we can, we're good | 6766 | * all of the extents from this block group. If we can, we're good |
6747 | */ | 6767 | */ |
6748 | if ((space_info->total_bytes != block_group->key.offset) && | 6768 | if ((space_info->total_bytes != block_group->key.offset) && |
6749 | (space_info->bytes_used + space_info->bytes_reserved + | 6769 | (space_info->bytes_used + space_info->bytes_reserved + |
6750 | space_info->bytes_pinned + space_info->bytes_readonly + | 6770 | space_info->bytes_pinned + space_info->bytes_readonly + |
6751 | btrfs_block_group_used(&block_group->item) < | 6771 | min_free < space_info->total_bytes)) { |
6752 | space_info->total_bytes)) { | ||
6753 | spin_unlock(&space_info->lock); | 6772 | spin_unlock(&space_info->lock); |
6754 | goto out; | 6773 | goto out; |
6755 | } | 6774 | } |
@@ -6766,9 +6785,31 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) | |||
6766 | if (full) | 6785 | if (full) |
6767 | goto out; | 6786 | goto out; |
6768 | 6787 | ||
6788 | /* | ||
6789 | * index: | ||
6790 | * 0: raid10 | ||
6791 | * 1: raid1 | ||
6792 | * 2: dup | ||
6793 | * 3: raid0 | ||
6794 | * 4: single | ||
6795 | */ | ||
6796 | index = get_block_group_index(block_group); | ||
6797 | if (index == 0) { | ||
6798 | dev_min = 4; | ||
6799 | /* Divide by 2 */ | ||
6800 | min_free >>= 1; | ||
6801 | } else if (index == 1) { | ||
6802 | dev_min = 2; | ||
6803 | } else if (index == 2) { | ||
6804 | /* Multiply by 2 */ | ||
6805 | min_free <<= 1; | ||
6806 | } else if (index == 3) { | ||
6807 | dev_min = fs_devices->rw_devices; | ||
6808 | do_div(min_free, dev_min); | ||
6809 | } | ||
6810 | |||
6769 | mutex_lock(&root->fs_info->chunk_mutex); | 6811 | mutex_lock(&root->fs_info->chunk_mutex); |
6770 | list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list) { | 6812 | list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list) { |
6771 | u64 min_free = btrfs_block_group_used(&block_group->item); | ||
6772 | u64 dev_offset; | 6813 | u64 dev_offset; |
6773 | 6814 | ||
6774 | /* | 6815 | /* |
@@ -6779,7 +6820,11 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) | |||
6779 | ret = find_free_dev_extent(NULL, device, min_free, | 6820 | ret = find_free_dev_extent(NULL, device, min_free, |
6780 | &dev_offset, NULL); | 6821 | &dev_offset, NULL); |
6781 | if (!ret) | 6822 | if (!ret) |
6823 | dev_nr++; | ||
6824 | |||
6825 | if (dev_nr >= dev_min) | ||
6782 | break; | 6826 | break; |
6827 | |||
6783 | ret = -1; | 6828 | ret = -1; |
6784 | } | 6829 | } |
6785 | } | 6830 | } |
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index b910694f61ed..a1cb7821becd 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c | |||
@@ -183,8 +183,10 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root, | |||
183 | * read from the commit root and sidestep a nasty deadlock | 183 | * read from the commit root and sidestep a nasty deadlock |
184 | * between reading the free space cache and updating the csum tree. | 184 | * between reading the free space cache and updating the csum tree. |
185 | */ | 185 | */ |
186 | if (btrfs_is_free_space_inode(root, inode)) | 186 | if (btrfs_is_free_space_inode(root, inode)) { |
187 | path->search_commit_root = 1; | 187 | path->search_commit_root = 1; |
188 | path->skip_locking = 1; | ||
189 | } | ||
188 | 190 | ||
189 | disk_bytenr = (u64)bio->bi_sector << 9; | 191 | disk_bytenr = (u64)bio->bi_sector << 9; |
190 | if (dio) | 192 | if (dio) |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 658d66959abe..e4e57d59edb7 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -150,6 +150,8 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, | |||
150 | spin_lock(&root->fs_info->defrag_inodes_lock); | 150 | spin_lock(&root->fs_info->defrag_inodes_lock); |
151 | if (!BTRFS_I(inode)->in_defrag) | 151 | if (!BTRFS_I(inode)->in_defrag) |
152 | __btrfs_add_inode_defrag(inode, defrag); | 152 | __btrfs_add_inode_defrag(inode, defrag); |
153 | else | ||
154 | kfree(defrag); | ||
153 | spin_unlock(&root->fs_info->defrag_inodes_lock); | 155 | spin_unlock(&root->fs_info->defrag_inodes_lock); |
154 | return 0; | 156 | return 0; |
155 | } | 157 | } |
@@ -1034,11 +1036,13 @@ out: | |||
1034 | * on error we return an unlocked page and the error value | 1036 | * on error we return an unlocked page and the error value |
1035 | * on success we return a locked page and 0 | 1037 | * on success we return a locked page and 0 |
1036 | */ | 1038 | */ |
1037 | static int prepare_uptodate_page(struct page *page, u64 pos) | 1039 | static int prepare_uptodate_page(struct page *page, u64 pos, |
1040 | bool force_uptodate) | ||
1038 | { | 1041 | { |
1039 | int ret = 0; | 1042 | int ret = 0; |
1040 | 1043 | ||
1041 | if ((pos & (PAGE_CACHE_SIZE - 1)) && !PageUptodate(page)) { | 1044 | if (((pos & (PAGE_CACHE_SIZE - 1)) || force_uptodate) && |
1045 | !PageUptodate(page)) { | ||
1042 | ret = btrfs_readpage(NULL, page); | 1046 | ret = btrfs_readpage(NULL, page); |
1043 | if (ret) | 1047 | if (ret) |
1044 | return ret; | 1048 | return ret; |
@@ -1059,7 +1063,7 @@ static int prepare_uptodate_page(struct page *page, u64 pos) | |||
1059 | static noinline int prepare_pages(struct btrfs_root *root, struct file *file, | 1063 | static noinline int prepare_pages(struct btrfs_root *root, struct file *file, |
1060 | struct page **pages, size_t num_pages, | 1064 | struct page **pages, size_t num_pages, |
1061 | loff_t pos, unsigned long first_index, | 1065 | loff_t pos, unsigned long first_index, |
1062 | size_t write_bytes) | 1066 | size_t write_bytes, bool force_uptodate) |
1063 | { | 1067 | { |
1064 | struct extent_state *cached_state = NULL; | 1068 | struct extent_state *cached_state = NULL; |
1065 | int i; | 1069 | int i; |
@@ -1073,12 +1077,6 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, | |||
1073 | start_pos = pos & ~((u64)root->sectorsize - 1); | 1077 | start_pos = pos & ~((u64)root->sectorsize - 1); |
1074 | last_pos = ((u64)index + num_pages) << PAGE_CACHE_SHIFT; | 1078 | last_pos = ((u64)index + num_pages) << PAGE_CACHE_SHIFT; |
1075 | 1079 | ||
1076 | if (start_pos > inode->i_size) { | ||
1077 | err = btrfs_cont_expand(inode, i_size_read(inode), start_pos); | ||
1078 | if (err) | ||
1079 | return err; | ||
1080 | } | ||
1081 | |||
1082 | again: | 1080 | again: |
1083 | for (i = 0; i < num_pages; i++) { | 1081 | for (i = 0; i < num_pages; i++) { |
1084 | pages[i] = find_or_create_page(inode->i_mapping, index + i, | 1082 | pages[i] = find_or_create_page(inode->i_mapping, index + i, |
@@ -1090,10 +1088,11 @@ again: | |||
1090 | } | 1088 | } |
1091 | 1089 | ||
1092 | if (i == 0) | 1090 | if (i == 0) |
1093 | err = prepare_uptodate_page(pages[i], pos); | 1091 | err = prepare_uptodate_page(pages[i], pos, |
1092 | force_uptodate); | ||
1094 | if (i == num_pages - 1) | 1093 | if (i == num_pages - 1) |
1095 | err = prepare_uptodate_page(pages[i], | 1094 | err = prepare_uptodate_page(pages[i], |
1096 | pos + write_bytes); | 1095 | pos + write_bytes, false); |
1097 | if (err) { | 1096 | if (err) { |
1098 | page_cache_release(pages[i]); | 1097 | page_cache_release(pages[i]); |
1099 | faili = i - 1; | 1098 | faili = i - 1; |
@@ -1162,6 +1161,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, | |||
1162 | size_t num_written = 0; | 1161 | size_t num_written = 0; |
1163 | int nrptrs; | 1162 | int nrptrs; |
1164 | int ret = 0; | 1163 | int ret = 0; |
1164 | bool force_page_uptodate = false; | ||
1165 | 1165 | ||
1166 | nrptrs = min((iov_iter_count(i) + PAGE_CACHE_SIZE - 1) / | 1166 | nrptrs = min((iov_iter_count(i) + PAGE_CACHE_SIZE - 1) / |
1167 | PAGE_CACHE_SIZE, PAGE_CACHE_SIZE / | 1167 | PAGE_CACHE_SIZE, PAGE_CACHE_SIZE / |
@@ -1204,7 +1204,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, | |||
1204 | * contents of pages from loop to loop | 1204 | * contents of pages from loop to loop |
1205 | */ | 1205 | */ |
1206 | ret = prepare_pages(root, file, pages, num_pages, | 1206 | ret = prepare_pages(root, file, pages, num_pages, |
1207 | pos, first_index, write_bytes); | 1207 | pos, first_index, write_bytes, |
1208 | force_page_uptodate); | ||
1208 | if (ret) { | 1209 | if (ret) { |
1209 | btrfs_delalloc_release_space(inode, | 1210 | btrfs_delalloc_release_space(inode, |
1210 | num_pages << PAGE_CACHE_SHIFT); | 1211 | num_pages << PAGE_CACHE_SHIFT); |
@@ -1221,12 +1222,15 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, | |||
1221 | if (copied < write_bytes) | 1222 | if (copied < write_bytes) |
1222 | nrptrs = 1; | 1223 | nrptrs = 1; |
1223 | 1224 | ||
1224 | if (copied == 0) | 1225 | if (copied == 0) { |
1226 | force_page_uptodate = true; | ||
1225 | dirty_pages = 0; | 1227 | dirty_pages = 0; |
1226 | else | 1228 | } else { |
1229 | force_page_uptodate = false; | ||
1227 | dirty_pages = (copied + offset + | 1230 | dirty_pages = (copied + offset + |
1228 | PAGE_CACHE_SIZE - 1) >> | 1231 | PAGE_CACHE_SIZE - 1) >> |
1229 | PAGE_CACHE_SHIFT; | 1232 | PAGE_CACHE_SHIFT; |
1233 | } | ||
1230 | 1234 | ||
1231 | /* | 1235 | /* |
1232 | * If we had a short copy we need to release the excess delaloc | 1236 | * If we had a short copy we need to release the excess delaloc |
@@ -1336,6 +1340,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1336 | struct inode *inode = fdentry(file)->d_inode; | 1340 | struct inode *inode = fdentry(file)->d_inode; |
1337 | struct btrfs_root *root = BTRFS_I(inode)->root; | 1341 | struct btrfs_root *root = BTRFS_I(inode)->root; |
1338 | loff_t *ppos = &iocb->ki_pos; | 1342 | loff_t *ppos = &iocb->ki_pos; |
1343 | u64 start_pos; | ||
1339 | ssize_t num_written = 0; | 1344 | ssize_t num_written = 0; |
1340 | ssize_t err = 0; | 1345 | ssize_t err = 0; |
1341 | size_t count, ocount; | 1346 | size_t count, ocount; |
@@ -1384,6 +1389,15 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1384 | file_update_time(file); | 1389 | file_update_time(file); |
1385 | BTRFS_I(inode)->sequence++; | 1390 | BTRFS_I(inode)->sequence++; |
1386 | 1391 | ||
1392 | start_pos = round_down(pos, root->sectorsize); | ||
1393 | if (start_pos > i_size_read(inode)) { | ||
1394 | err = btrfs_cont_expand(inode, i_size_read(inode), start_pos); | ||
1395 | if (err) { | ||
1396 | mutex_unlock(&inode->i_mutex); | ||
1397 | goto out; | ||
1398 | } | ||
1399 | } | ||
1400 | |||
1387 | if (unlikely(file->f_flags & O_DIRECT)) { | 1401 | if (unlikely(file->f_flags & O_DIRECT)) { |
1388 | num_written = __btrfs_direct_write(iocb, iov, nr_segs, | 1402 | num_written = __btrfs_direct_write(iocb, iov, nr_segs, |
1389 | pos, ppos, count, ocount); | 1403 | pos, ppos, count, ocount); |
@@ -1638,11 +1652,15 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
1638 | 1652 | ||
1639 | cur_offset = alloc_start; | 1653 | cur_offset = alloc_start; |
1640 | while (1) { | 1654 | while (1) { |
1655 | u64 actual_end; | ||
1656 | |||
1641 | em = btrfs_get_extent(inode, NULL, 0, cur_offset, | 1657 | em = btrfs_get_extent(inode, NULL, 0, cur_offset, |
1642 | alloc_end - cur_offset, 0); | 1658 | alloc_end - cur_offset, 0); |
1643 | BUG_ON(IS_ERR_OR_NULL(em)); | 1659 | BUG_ON(IS_ERR_OR_NULL(em)); |
1644 | last_byte = min(extent_map_end(em), alloc_end); | 1660 | last_byte = min(extent_map_end(em), alloc_end); |
1661 | actual_end = min_t(u64, extent_map_end(em), offset + len); | ||
1645 | last_byte = (last_byte + mask) & ~mask; | 1662 | last_byte = (last_byte + mask) & ~mask; |
1663 | |||
1646 | if (em->block_start == EXTENT_MAP_HOLE || | 1664 | if (em->block_start == EXTENT_MAP_HOLE || |
1647 | (cur_offset >= inode->i_size && | 1665 | (cur_offset >= inode->i_size && |
1648 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { | 1666 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { |
@@ -1655,6 +1673,16 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
1655 | free_extent_map(em); | 1673 | free_extent_map(em); |
1656 | break; | 1674 | break; |
1657 | } | 1675 | } |
1676 | } else if (actual_end > inode->i_size && | ||
1677 | !(mode & FALLOC_FL_KEEP_SIZE)) { | ||
1678 | /* | ||
1679 | * We didn't need to allocate any more space, but we | ||
1680 | * still extended the size of the file so we need to | ||
1681 | * update i_size. | ||
1682 | */ | ||
1683 | inode->i_ctime = CURRENT_TIME; | ||
1684 | i_size_write(inode, actual_end); | ||
1685 | btrfs_ordered_update_i_size(inode, actual_end, NULL); | ||
1658 | } | 1686 | } |
1659 | free_extent_map(em); | 1687 | free_extent_map(em); |
1660 | 1688 | ||
@@ -1797,6 +1825,11 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int origin) | |||
1797 | goto out; | 1825 | goto out; |
1798 | case SEEK_DATA: | 1826 | case SEEK_DATA: |
1799 | case SEEK_HOLE: | 1827 | case SEEK_HOLE: |
1828 | if (offset >= i_size_read(inode)) { | ||
1829 | mutex_unlock(&inode->i_mutex); | ||
1830 | return -ENXIO; | ||
1831 | } | ||
1832 | |||
1800 | ret = find_desired_extent(inode, &offset, origin); | 1833 | ret = find_desired_extent(inode, &offset, origin); |
1801 | if (ret) { | 1834 | if (ret) { |
1802 | mutex_unlock(&inode->i_mutex); | 1835 | mutex_unlock(&inode->i_mutex); |
@@ -1804,10 +1837,14 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int origin) | |||
1804 | } | 1837 | } |
1805 | } | 1838 | } |
1806 | 1839 | ||
1807 | if (offset < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET)) | 1840 | if (offset < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET)) { |
1808 | return -EINVAL; | 1841 | offset = -EINVAL; |
1809 | if (offset > inode->i_sb->s_maxbytes) | 1842 | goto out; |
1810 | return -EINVAL; | 1843 | } |
1844 | if (offset > inode->i_sb->s_maxbytes) { | ||
1845 | offset = -EINVAL; | ||
1846 | goto out; | ||
1847 | } | ||
1811 | 1848 | ||
1812 | /* Special lock needed here? */ | 1849 | /* Special lock needed here? */ |
1813 | if (offset != file->f_pos) { | 1850 | if (offset != file->f_pos) { |
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 6377713f639c..41ac927401d0 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -190,9 +190,11 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
190 | struct btrfs_path *path, | 190 | struct btrfs_path *path, |
191 | struct inode *inode) | 191 | struct inode *inode) |
192 | { | 192 | { |
193 | struct btrfs_block_rsv *rsv; | ||
193 | loff_t oldsize; | 194 | loff_t oldsize; |
194 | int ret = 0; | 195 | int ret = 0; |
195 | 196 | ||
197 | rsv = trans->block_rsv; | ||
196 | trans->block_rsv = root->orphan_block_rsv; | 198 | trans->block_rsv = root->orphan_block_rsv; |
197 | ret = btrfs_block_rsv_check(trans, root, | 199 | ret = btrfs_block_rsv_check(trans, root, |
198 | root->orphan_block_rsv, | 200 | root->orphan_block_rsv, |
@@ -210,6 +212,8 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
210 | */ | 212 | */ |
211 | ret = btrfs_truncate_inode_items(trans, root, inode, | 213 | ret = btrfs_truncate_inode_items(trans, root, inode, |
212 | 0, BTRFS_EXTENT_DATA_KEY); | 214 | 0, BTRFS_EXTENT_DATA_KEY); |
215 | |||
216 | trans->block_rsv = rsv; | ||
213 | if (ret) { | 217 | if (ret) { |
214 | WARN_ON(1); | 218 | WARN_ON(1); |
215 | return ret; | 219 | return ret; |
@@ -1168,9 +1172,9 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) | |||
1168 | div64_u64(extent_bytes, (sizeof(struct btrfs_free_space))); | 1172 | div64_u64(extent_bytes, (sizeof(struct btrfs_free_space))); |
1169 | } | 1173 | } |
1170 | 1174 | ||
1171 | static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, | 1175 | static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, |
1172 | struct btrfs_free_space *info, u64 offset, | 1176 | struct btrfs_free_space *info, |
1173 | u64 bytes) | 1177 | u64 offset, u64 bytes) |
1174 | { | 1178 | { |
1175 | unsigned long start, count; | 1179 | unsigned long start, count; |
1176 | 1180 | ||
@@ -1181,6 +1185,13 @@ static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, | |||
1181 | bitmap_clear(info->bitmap, start, count); | 1185 | bitmap_clear(info->bitmap, start, count); |
1182 | 1186 | ||
1183 | info->bytes -= bytes; | 1187 | info->bytes -= bytes; |
1188 | } | ||
1189 | |||
1190 | static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, | ||
1191 | struct btrfs_free_space *info, u64 offset, | ||
1192 | u64 bytes) | ||
1193 | { | ||
1194 | __bitmap_clear_bits(ctl, info, offset, bytes); | ||
1184 | ctl->free_space -= bytes; | 1195 | ctl->free_space -= bytes; |
1185 | } | 1196 | } |
1186 | 1197 | ||
@@ -1984,7 +1995,7 @@ static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group_cache *block_group, | |||
1984 | return 0; | 1995 | return 0; |
1985 | 1996 | ||
1986 | ret = search_start; | 1997 | ret = search_start; |
1987 | bitmap_clear_bits(ctl, entry, ret, bytes); | 1998 | __bitmap_clear_bits(ctl, entry, ret, bytes); |
1988 | 1999 | ||
1989 | return ret; | 2000 | return ret; |
1990 | } | 2001 | } |
@@ -2039,7 +2050,6 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group, | |||
2039 | continue; | 2050 | continue; |
2040 | } | 2051 | } |
2041 | } else { | 2052 | } else { |
2042 | |||
2043 | ret = entry->offset; | 2053 | ret = entry->offset; |
2044 | 2054 | ||
2045 | entry->offset += bytes; | 2055 | entry->offset += bytes; |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 15fceefbca0a..b2d004ad66a0 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1786,7 +1786,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
1786 | &ordered_extent->list); | 1786 | &ordered_extent->list); |
1787 | 1787 | ||
1788 | ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent); | 1788 | ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent); |
1789 | if (!ret) { | 1789 | if (!ret || !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { |
1790 | ret = btrfs_update_inode(trans, root, inode); | 1790 | ret = btrfs_update_inode(trans, root, inode); |
1791 | BUG_ON(ret); | 1791 | BUG_ON(ret); |
1792 | } | 1792 | } |
@@ -3510,15 +3510,19 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size) | |||
3510 | err = btrfs_drop_extents(trans, inode, cur_offset, | 3510 | err = btrfs_drop_extents(trans, inode, cur_offset, |
3511 | cur_offset + hole_size, | 3511 | cur_offset + hole_size, |
3512 | &hint_byte, 1); | 3512 | &hint_byte, 1); |
3513 | if (err) | 3513 | if (err) { |
3514 | btrfs_end_transaction(trans, root); | ||
3514 | break; | 3515 | break; |
3516 | } | ||
3515 | 3517 | ||
3516 | err = btrfs_insert_file_extent(trans, root, | 3518 | err = btrfs_insert_file_extent(trans, root, |
3517 | btrfs_ino(inode), cur_offset, 0, | 3519 | btrfs_ino(inode), cur_offset, 0, |
3518 | 0, hole_size, 0, hole_size, | 3520 | 0, hole_size, 0, hole_size, |
3519 | 0, 0, 0); | 3521 | 0, 0, 0); |
3520 | if (err) | 3522 | if (err) { |
3523 | btrfs_end_transaction(trans, root); | ||
3521 | break; | 3524 | break; |
3525 | } | ||
3522 | 3526 | ||
3523 | btrfs_drop_extent_cache(inode, hole_start, | 3527 | btrfs_drop_extent_cache(inode, hole_start, |
3524 | last_byte - 1, 0); | 3528 | last_byte - 1, 0); |
@@ -3952,7 +3956,6 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | |||
3952 | struct btrfs_root *root, int *new) | 3956 | struct btrfs_root *root, int *new) |
3953 | { | 3957 | { |
3954 | struct inode *inode; | 3958 | struct inode *inode; |
3955 | int bad_inode = 0; | ||
3956 | 3959 | ||
3957 | inode = btrfs_iget_locked(s, location->objectid, root); | 3960 | inode = btrfs_iget_locked(s, location->objectid, root); |
3958 | if (!inode) | 3961 | if (!inode) |
@@ -3968,15 +3971,12 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | |||
3968 | if (new) | 3971 | if (new) |
3969 | *new = 1; | 3972 | *new = 1; |
3970 | } else { | 3973 | } else { |
3971 | bad_inode = 1; | 3974 | unlock_new_inode(inode); |
3975 | iput(inode); | ||
3976 | inode = ERR_PTR(-ESTALE); | ||
3972 | } | 3977 | } |
3973 | } | 3978 | } |
3974 | 3979 | ||
3975 | if (bad_inode) { | ||
3976 | iput(inode); | ||
3977 | inode = ERR_PTR(-ESTALE); | ||
3978 | } | ||
3979 | |||
3980 | return inode; | 3980 | return inode; |
3981 | } | 3981 | } |
3982 | 3982 | ||
@@ -4018,7 +4018,8 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) | |||
4018 | memcpy(&location, dentry->d_fsdata, sizeof(struct btrfs_key)); | 4018 | memcpy(&location, dentry->d_fsdata, sizeof(struct btrfs_key)); |
4019 | kfree(dentry->d_fsdata); | 4019 | kfree(dentry->d_fsdata); |
4020 | dentry->d_fsdata = NULL; | 4020 | dentry->d_fsdata = NULL; |
4021 | d_clear_need_lookup(dentry); | 4021 | /* This thing is hashed, drop it for now */ |
4022 | d_drop(dentry); | ||
4022 | } else { | 4023 | } else { |
4023 | ret = btrfs_inode_by_name(dir, dentry, &location); | 4024 | ret = btrfs_inode_by_name(dir, dentry, &location); |
4024 | } | 4025 | } |
@@ -4085,7 +4086,15 @@ static void btrfs_dentry_release(struct dentry *dentry) | |||
4085 | static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, | 4086 | static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, |
4086 | struct nameidata *nd) | 4087 | struct nameidata *nd) |
4087 | { | 4088 | { |
4088 | return d_splice_alias(btrfs_lookup_dentry(dir, dentry), dentry); | 4089 | struct dentry *ret; |
4090 | |||
4091 | ret = d_splice_alias(btrfs_lookup_dentry(dir, dentry), dentry); | ||
4092 | if (unlikely(d_need_lookup(dentry))) { | ||
4093 | spin_lock(&dentry->d_lock); | ||
4094 | dentry->d_flags &= ~DCACHE_NEED_LOOKUP; | ||
4095 | spin_unlock(&dentry->d_lock); | ||
4096 | } | ||
4097 | return ret; | ||
4089 | } | 4098 | } |
4090 | 4099 | ||
4091 | unsigned char btrfs_filetype_table[] = { | 4100 | unsigned char btrfs_filetype_table[] = { |
@@ -4125,7 +4134,8 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4125 | 4134 | ||
4126 | /* special case for "." */ | 4135 | /* special case for "." */ |
4127 | if (filp->f_pos == 0) { | 4136 | if (filp->f_pos == 0) { |
4128 | over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR); | 4137 | over = filldir(dirent, ".", 1, |
4138 | filp->f_pos, btrfs_ino(inode), DT_DIR); | ||
4129 | if (over) | 4139 | if (over) |
4130 | return 0; | 4140 | return 0; |
4131 | filp->f_pos = 1; | 4141 | filp->f_pos = 1; |
@@ -4134,7 +4144,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, | |||
4134 | if (filp->f_pos == 1) { | 4144 | if (filp->f_pos == 1) { |
4135 | u64 pino = parent_ino(filp->f_path.dentry); | 4145 | u64 pino = parent_ino(filp->f_path.dentry); |
4136 | over = filldir(dirent, "..", 2, | 4146 | over = filldir(dirent, "..", 2, |
4137 | 2, pino, DT_DIR); | 4147 | filp->f_pos, pino, DT_DIR); |
4138 | if (over) | 4148 | if (over) |
4139 | return 0; | 4149 | return 0; |
4140 | filp->f_pos = 2; | 4150 | filp->f_pos = 2; |
@@ -5823,7 +5833,7 @@ again: | |||
5823 | 5833 | ||
5824 | add_pending_csums(trans, inode, ordered->file_offset, &ordered->list); | 5834 | add_pending_csums(trans, inode, ordered->file_offset, &ordered->list); |
5825 | ret = btrfs_ordered_update_i_size(inode, 0, ordered); | 5835 | ret = btrfs_ordered_update_i_size(inode, 0, ordered); |
5826 | if (!ret) | 5836 | if (!ret || !test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags)) |
5827 | btrfs_update_inode(trans, root, inode); | 5837 | btrfs_update_inode(trans, root, inode); |
5828 | ret = 0; | 5838 | ret = 0; |
5829 | out_unlock: | 5839 | out_unlock: |
@@ -7354,11 +7364,15 @@ static int btrfs_set_page_dirty(struct page *page) | |||
7354 | static int btrfs_permission(struct inode *inode, int mask) | 7364 | static int btrfs_permission(struct inode *inode, int mask) |
7355 | { | 7365 | { |
7356 | struct btrfs_root *root = BTRFS_I(inode)->root; | 7366 | struct btrfs_root *root = BTRFS_I(inode)->root; |
7367 | umode_t mode = inode->i_mode; | ||
7357 | 7368 | ||
7358 | if (btrfs_root_readonly(root) && (mask & MAY_WRITE)) | 7369 | if (mask & MAY_WRITE && |
7359 | return -EROFS; | 7370 | (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))) { |
7360 | if ((BTRFS_I(inode)->flags & BTRFS_INODE_READONLY) && (mask & MAY_WRITE)) | 7371 | if (btrfs_root_readonly(root)) |
7361 | return -EACCES; | 7372 | return -EROFS; |
7373 | if (BTRFS_I(inode)->flags & BTRFS_INODE_READONLY) | ||
7374 | return -EACCES; | ||
7375 | } | ||
7362 | return generic_permission(inode, mask); | 7376 | return generic_permission(inode, mask); |
7363 | } | 7377 | } |
7364 | 7378 | ||
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 7cf013349941..dae5dfe41ba5 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -1047,7 +1047,16 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, | |||
1047 | if (!max_to_defrag) | 1047 | if (!max_to_defrag) |
1048 | max_to_defrag = last_index - 1; | 1048 | max_to_defrag = last_index - 1; |
1049 | 1049 | ||
1050 | while (i <= last_index && defrag_count < max_to_defrag) { | 1050 | /* |
1051 | * make writeback starts from i, so the defrag range can be | ||
1052 | * written sequentially. | ||
1053 | */ | ||
1054 | if (i < inode->i_mapping->writeback_index) | ||
1055 | inode->i_mapping->writeback_index = i; | ||
1056 | |||
1057 | while (i <= last_index && defrag_count < max_to_defrag && | ||
1058 | (i < (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> | ||
1059 | PAGE_CACHE_SHIFT)) { | ||
1051 | /* | 1060 | /* |
1052 | * make sure we stop running if someone unmounts | 1061 | * make sure we stop running if someone unmounts |
1053 | * the FS | 1062 | * the FS |
@@ -2177,6 +2186,11 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2177 | if (!(src_file->f_mode & FMODE_READ)) | 2186 | if (!(src_file->f_mode & FMODE_READ)) |
2178 | goto out_fput; | 2187 | goto out_fput; |
2179 | 2188 | ||
2189 | /* don't make the dst file partly checksummed */ | ||
2190 | if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) != | ||
2191 | (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) | ||
2192 | goto out_fput; | ||
2193 | |||
2180 | ret = -EISDIR; | 2194 | ret = -EISDIR; |
2181 | if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode)) | 2195 | if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode)) |
2182 | goto out_fput; | 2196 | goto out_fput; |
@@ -2220,6 +2234,16 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2220 | !IS_ALIGNED(destoff, bs)) | 2234 | !IS_ALIGNED(destoff, bs)) |
2221 | goto out_unlock; | 2235 | goto out_unlock; |
2222 | 2236 | ||
2237 | if (destoff > inode->i_size) { | ||
2238 | ret = btrfs_cont_expand(inode, inode->i_size, destoff); | ||
2239 | if (ret) | ||
2240 | goto out_unlock; | ||
2241 | } | ||
2242 | |||
2243 | /* truncate page cache pages from target inode range */ | ||
2244 | truncate_inode_pages_range(&inode->i_data, destoff, | ||
2245 | PAGE_CACHE_ALIGN(destoff + len) - 1); | ||
2246 | |||
2223 | /* do any pending delalloc/csum calc on src, one way or | 2247 | /* do any pending delalloc/csum calc on src, one way or |
2224 | another, and lock file content */ | 2248 | another, and lock file content */ |
2225 | while (1) { | 2249 | while (1) { |
@@ -2313,7 +2337,12 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2313 | else | 2337 | else |
2314 | new_key.offset = destoff; | 2338 | new_key.offset = destoff; |
2315 | 2339 | ||
2316 | trans = btrfs_start_transaction(root, 1); | 2340 | /* |
2341 | * 1 - adjusting old extent (we may have to split it) | ||
2342 | * 1 - add new extent | ||
2343 | * 1 - inode update | ||
2344 | */ | ||
2345 | trans = btrfs_start_transaction(root, 3); | ||
2317 | if (IS_ERR(trans)) { | 2346 | if (IS_ERR(trans)) { |
2318 | ret = PTR_ERR(trans); | 2347 | ret = PTR_ERR(trans); |
2319 | goto out; | 2348 | goto out; |
@@ -2321,14 +2350,21 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2321 | 2350 | ||
2322 | if (type == BTRFS_FILE_EXTENT_REG || | 2351 | if (type == BTRFS_FILE_EXTENT_REG || |
2323 | type == BTRFS_FILE_EXTENT_PREALLOC) { | 2352 | type == BTRFS_FILE_EXTENT_PREALLOC) { |
2353 | /* | ||
2354 | * a | --- range to clone ---| b | ||
2355 | * | ------------- extent ------------- | | ||
2356 | */ | ||
2357 | |||
2358 | /* substract range b */ | ||
2359 | if (key.offset + datal > off + len) | ||
2360 | datal = off + len - key.offset; | ||
2361 | |||
2362 | /* substract range a */ | ||
2324 | if (off > key.offset) { | 2363 | if (off > key.offset) { |
2325 | datao += off - key.offset; | 2364 | datao += off - key.offset; |
2326 | datal -= off - key.offset; | 2365 | datal -= off - key.offset; |
2327 | } | 2366 | } |
2328 | 2367 | ||
2329 | if (key.offset + datal > off + len) | ||
2330 | datal = off + len - key.offset; | ||
2331 | |||
2332 | ret = btrfs_drop_extents(trans, inode, | 2368 | ret = btrfs_drop_extents(trans, inode, |
2333 | new_key.offset, | 2369 | new_key.offset, |
2334 | new_key.offset + datal, | 2370 | new_key.offset + datal, |
@@ -2425,7 +2461,6 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2425 | if (endoff > inode->i_size) | 2461 | if (endoff > inode->i_size) |
2426 | btrfs_i_size_write(inode, endoff); | 2462 | btrfs_i_size_write(inode, endoff); |
2427 | 2463 | ||
2428 | BTRFS_I(inode)->flags = BTRFS_I(src)->flags; | ||
2429 | ret = btrfs_update_inode(trans, root, inode); | 2464 | ret = btrfs_update_inode(trans, root, inode); |
2430 | BUG_ON(ret); | 2465 | BUG_ON(ret); |
2431 | btrfs_end_transaction(trans, root); | 2466 | btrfs_end_transaction(trans, root); |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 7dc36fab4afc..e24b7964a155 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -884,6 +884,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
884 | struct btrfs_root *tree_root = fs_info->tree_root; | 884 | struct btrfs_root *tree_root = fs_info->tree_root; |
885 | struct btrfs_root *root = pending->root; | 885 | struct btrfs_root *root = pending->root; |
886 | struct btrfs_root *parent_root; | 886 | struct btrfs_root *parent_root; |
887 | struct btrfs_block_rsv *rsv; | ||
887 | struct inode *parent_inode; | 888 | struct inode *parent_inode; |
888 | struct dentry *parent; | 889 | struct dentry *parent; |
889 | struct dentry *dentry; | 890 | struct dentry *dentry; |
@@ -895,6 +896,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
895 | u64 objectid; | 896 | u64 objectid; |
896 | u64 root_flags; | 897 | u64 root_flags; |
897 | 898 | ||
899 | rsv = trans->block_rsv; | ||
900 | |||
898 | new_root_item = kmalloc(sizeof(*new_root_item), GFP_NOFS); | 901 | new_root_item = kmalloc(sizeof(*new_root_item), GFP_NOFS); |
899 | if (!new_root_item) { | 902 | if (!new_root_item) { |
900 | pending->error = -ENOMEM; | 903 | pending->error = -ENOMEM; |
@@ -1002,6 +1005,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
1002 | btrfs_orphan_post_snapshot(trans, pending); | 1005 | btrfs_orphan_post_snapshot(trans, pending); |
1003 | fail: | 1006 | fail: |
1004 | kfree(new_root_item); | 1007 | kfree(new_root_item); |
1008 | trans->block_rsv = rsv; | ||
1005 | btrfs_block_rsv_release(root, &pending->block_rsv, (u64)-1); | 1009 | btrfs_block_rsv_release(root, &pending->block_rsv, (u64)-1); |
1006 | return 0; | 1010 | return 0; |
1007 | } | 1011 | } |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index babee65f8eda..786639fca067 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -799,14 +799,15 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, | |||
799 | struct extent_buffer *eb, int slot, | 799 | struct extent_buffer *eb, int slot, |
800 | struct btrfs_key *key) | 800 | struct btrfs_key *key) |
801 | { | 801 | { |
802 | struct inode *dir; | ||
803 | int ret; | ||
804 | struct btrfs_inode_ref *ref; | 802 | struct btrfs_inode_ref *ref; |
803 | struct btrfs_dir_item *di; | ||
804 | struct inode *dir; | ||
805 | struct inode *inode; | 805 | struct inode *inode; |
806 | char *name; | ||
807 | int namelen; | ||
808 | unsigned long ref_ptr; | 806 | unsigned long ref_ptr; |
809 | unsigned long ref_end; | 807 | unsigned long ref_end; |
808 | char *name; | ||
809 | int namelen; | ||
810 | int ret; | ||
810 | int search_done = 0; | 811 | int search_done = 0; |
811 | 812 | ||
812 | /* | 813 | /* |
@@ -909,6 +910,25 @@ again: | |||
909 | } | 910 | } |
910 | btrfs_release_path(path); | 911 | btrfs_release_path(path); |
911 | 912 | ||
913 | /* look for a conflicting sequence number */ | ||
914 | di = btrfs_lookup_dir_index_item(trans, root, path, btrfs_ino(dir), | ||
915 | btrfs_inode_ref_index(eb, ref), | ||
916 | name, namelen, 0); | ||
917 | if (di && !IS_ERR(di)) { | ||
918 | ret = drop_one_dir_item(trans, root, path, dir, di); | ||
919 | BUG_ON(ret); | ||
920 | } | ||
921 | btrfs_release_path(path); | ||
922 | |||
923 | /* look for a conflicing name */ | ||
924 | di = btrfs_lookup_dir_item(trans, root, path, btrfs_ino(dir), | ||
925 | name, namelen, 0); | ||
926 | if (di && !IS_ERR(di)) { | ||
927 | ret = drop_one_dir_item(trans, root, path, dir, di); | ||
928 | BUG_ON(ret); | ||
929 | } | ||
930 | btrfs_release_path(path); | ||
931 | |||
912 | insert: | 932 | insert: |
913 | /* insert our name */ | 933 | /* insert our name */ |
914 | ret = btrfs_add_link(trans, dir, inode, name, namelen, 0, | 934 | ret = btrfs_add_link(trans, dir, inode, name, namelen, 0, |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 53875ae73ad4..f2a4cc79da61 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -142,6 +142,7 @@ static noinline int run_scheduled_bios(struct btrfs_device *device) | |||
142 | unsigned long limit; | 142 | unsigned long limit; |
143 | unsigned long last_waited = 0; | 143 | unsigned long last_waited = 0; |
144 | int force_reg = 0; | 144 | int force_reg = 0; |
145 | int sync_pending = 0; | ||
145 | struct blk_plug plug; | 146 | struct blk_plug plug; |
146 | 147 | ||
147 | /* | 148 | /* |
@@ -229,6 +230,22 @@ loop_lock: | |||
229 | 230 | ||
230 | BUG_ON(atomic_read(&cur->bi_cnt) == 0); | 231 | BUG_ON(atomic_read(&cur->bi_cnt) == 0); |
231 | 232 | ||
233 | /* | ||
234 | * if we're doing the sync list, record that our | ||
235 | * plug has some sync requests on it | ||
236 | * | ||
237 | * If we're doing the regular list and there are | ||
238 | * sync requests sitting around, unplug before | ||
239 | * we add more | ||
240 | */ | ||
241 | if (pending_bios == &device->pending_sync_bios) { | ||
242 | sync_pending = 1; | ||
243 | } else if (sync_pending) { | ||
244 | blk_finish_plug(&plug); | ||
245 | blk_start_plug(&plug); | ||
246 | sync_pending = 0; | ||
247 | } | ||
248 | |||
232 | submit_bio(cur->bi_rw, cur); | 249 | submit_bio(cur->bi_rw, cur); |
233 | num_run++; | 250 | num_run++; |
234 | batch_run++; | 251 | batch_run++; |
@@ -500,6 +517,9 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices) | |||
500 | fs_devices->rw_devices--; | 517 | fs_devices->rw_devices--; |
501 | } | 518 | } |
502 | 519 | ||
520 | if (device->can_discard) | ||
521 | fs_devices->num_can_discard--; | ||
522 | |||
503 | new_device = kmalloc(sizeof(*new_device), GFP_NOFS); | 523 | new_device = kmalloc(sizeof(*new_device), GFP_NOFS); |
504 | BUG_ON(!new_device); | 524 | BUG_ON(!new_device); |
505 | memcpy(new_device, device, sizeof(*new_device)); | 525 | memcpy(new_device, device, sizeof(*new_device)); |
@@ -508,6 +528,7 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices) | |||
508 | new_device->bdev = NULL; | 528 | new_device->bdev = NULL; |
509 | new_device->writeable = 0; | 529 | new_device->writeable = 0; |
510 | new_device->in_fs_metadata = 0; | 530 | new_device->in_fs_metadata = 0; |
531 | new_device->can_discard = 0; | ||
511 | list_replace_rcu(&device->dev_list, &new_device->dev_list); | 532 | list_replace_rcu(&device->dev_list, &new_device->dev_list); |
512 | 533 | ||
513 | call_rcu(&device->rcu, free_device); | 534 | call_rcu(&device->rcu, free_device); |
@@ -547,6 +568,7 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices) | |||
547 | static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | 568 | static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, |
548 | fmode_t flags, void *holder) | 569 | fmode_t flags, void *holder) |
549 | { | 570 | { |
571 | struct request_queue *q; | ||
550 | struct block_device *bdev; | 572 | struct block_device *bdev; |
551 | struct list_head *head = &fs_devices->devices; | 573 | struct list_head *head = &fs_devices->devices; |
552 | struct btrfs_device *device; | 574 | struct btrfs_device *device; |
@@ -603,6 +625,12 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | |||
603 | seeding = 0; | 625 | seeding = 0; |
604 | } | 626 | } |
605 | 627 | ||
628 | q = bdev_get_queue(bdev); | ||
629 | if (blk_queue_discard(q)) { | ||
630 | device->can_discard = 1; | ||
631 | fs_devices->num_can_discard++; | ||
632 | } | ||
633 | |||
606 | device->bdev = bdev; | 634 | device->bdev = bdev; |
607 | device->in_fs_metadata = 0; | 635 | device->in_fs_metadata = 0; |
608 | device->mode = flags; | 636 | device->mode = flags; |
@@ -835,6 +863,7 @@ int find_free_dev_extent(struct btrfs_trans_handle *trans, | |||
835 | 863 | ||
836 | max_hole_start = search_start; | 864 | max_hole_start = search_start; |
837 | max_hole_size = 0; | 865 | max_hole_size = 0; |
866 | hole_size = 0; | ||
838 | 867 | ||
839 | if (search_start >= search_end) { | 868 | if (search_start >= search_end) { |
840 | ret = -ENOSPC; | 869 | ret = -ENOSPC; |
@@ -917,7 +946,14 @@ next: | |||
917 | cond_resched(); | 946 | cond_resched(); |
918 | } | 947 | } |
919 | 948 | ||
920 | hole_size = search_end- search_start; | 949 | /* |
950 | * At this point, search_start should be the end of | ||
951 | * allocated dev extents, and when shrinking the device, | ||
952 | * search_end may be smaller than search_start. | ||
953 | */ | ||
954 | if (search_end > search_start) | ||
955 | hole_size = search_end - search_start; | ||
956 | |||
921 | if (hole_size > max_hole_size) { | 957 | if (hole_size > max_hole_size) { |
922 | max_hole_start = search_start; | 958 | max_hole_start = search_start; |
923 | max_hole_size = hole_size; | 959 | max_hole_size = hole_size; |
@@ -1543,6 +1579,7 @@ error: | |||
1543 | 1579 | ||
1544 | int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | 1580 | int btrfs_init_new_device(struct btrfs_root *root, char *device_path) |
1545 | { | 1581 | { |
1582 | struct request_queue *q; | ||
1546 | struct btrfs_trans_handle *trans; | 1583 | struct btrfs_trans_handle *trans; |
1547 | struct btrfs_device *device; | 1584 | struct btrfs_device *device; |
1548 | struct block_device *bdev; | 1585 | struct block_device *bdev; |
@@ -1612,6 +1649,9 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
1612 | 1649 | ||
1613 | lock_chunks(root); | 1650 | lock_chunks(root); |
1614 | 1651 | ||
1652 | q = bdev_get_queue(bdev); | ||
1653 | if (blk_queue_discard(q)) | ||
1654 | device->can_discard = 1; | ||
1615 | device->writeable = 1; | 1655 | device->writeable = 1; |
1616 | device->work.func = pending_bios_fn; | 1656 | device->work.func = pending_bios_fn; |
1617 | generate_random_uuid(device->uuid); | 1657 | generate_random_uuid(device->uuid); |
@@ -1647,6 +1687,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
1647 | root->fs_info->fs_devices->num_devices++; | 1687 | root->fs_info->fs_devices->num_devices++; |
1648 | root->fs_info->fs_devices->open_devices++; | 1688 | root->fs_info->fs_devices->open_devices++; |
1649 | root->fs_info->fs_devices->rw_devices++; | 1689 | root->fs_info->fs_devices->rw_devices++; |
1690 | if (device->can_discard) | ||
1691 | root->fs_info->fs_devices->num_can_discard++; | ||
1650 | root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; | 1692 | root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; |
1651 | 1693 | ||
1652 | if (!blk_queue_nonrot(bdev_get_queue(bdev))) | 1694 | if (!blk_queue_nonrot(bdev_get_queue(bdev))) |
@@ -2413,9 +2455,10 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
2413 | total_avail = device->total_bytes - device->bytes_used; | 2455 | total_avail = device->total_bytes - device->bytes_used; |
2414 | else | 2456 | else |
2415 | total_avail = 0; | 2457 | total_avail = 0; |
2416 | /* avail is off by max(alloc_start, 1MB), but that is the same | 2458 | |
2417 | * for all devices, so it doesn't hurt the sorting later on | 2459 | /* If there is no space on this device, skip it. */ |
2418 | */ | 2460 | if (total_avail == 0) |
2461 | continue; | ||
2419 | 2462 | ||
2420 | ret = find_free_dev_extent(trans, device, | 2463 | ret = find_free_dev_extent(trans, device, |
2421 | max_stripe_size * dev_stripes, | 2464 | max_stripe_size * dev_stripes, |
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 7c12d61ae7ae..6d866db4e177 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -48,6 +48,7 @@ struct btrfs_device { | |||
48 | int writeable; | 48 | int writeable; |
49 | int in_fs_metadata; | 49 | int in_fs_metadata; |
50 | int missing; | 50 | int missing; |
51 | int can_discard; | ||
51 | 52 | ||
52 | spinlock_t io_lock; | 53 | spinlock_t io_lock; |
53 | 54 | ||
@@ -104,6 +105,7 @@ struct btrfs_fs_devices { | |||
104 | u64 rw_devices; | 105 | u64 rw_devices; |
105 | u64 missing_devices; | 106 | u64 missing_devices; |
106 | u64 total_rw_bytes; | 107 | u64 total_rw_bytes; |
108 | u64 num_can_discard; | ||
107 | struct block_device *latest_bdev; | 109 | struct block_device *latest_bdev; |
108 | 110 | ||
109 | /* all of the devices in the FS, protected by a mutex | 111 | /* all of the devices in the FS, protected by a mutex |
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index d733b9cfea34..426aa464f1af 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -116,6 +116,12 @@ static int do_setxattr(struct btrfs_trans_handle *trans, | |||
116 | if (ret) | 116 | if (ret) |
117 | goto out; | 117 | goto out; |
118 | btrfs_release_path(path); | 118 | btrfs_release_path(path); |
119 | |||
120 | /* | ||
121 | * remove the attribute | ||
122 | */ | ||
123 | if (!value) | ||
124 | goto out; | ||
119 | } | 125 | } |
120 | 126 | ||
121 | again: | 127 | again: |
@@ -158,6 +164,9 @@ out: | |||
158 | return ret; | 164 | return ret; |
159 | } | 165 | } |
160 | 166 | ||
167 | /* | ||
168 | * @value: "" makes the attribute to empty, NULL removes it | ||
169 | */ | ||
161 | int __btrfs_setxattr(struct btrfs_trans_handle *trans, | 170 | int __btrfs_setxattr(struct btrfs_trans_handle *trans, |
162 | struct inode *inode, const char *name, | 171 | struct inode *inode, const char *name, |
163 | const void *value, size_t size, int flags) | 172 | const void *value, size_t size, int flags) |
@@ -374,36 +383,36 @@ int btrfs_removexattr(struct dentry *dentry, const char *name) | |||
374 | XATTR_REPLACE); | 383 | XATTR_REPLACE); |
375 | } | 384 | } |
376 | 385 | ||
377 | int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, | 386 | int btrfs_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
378 | struct inode *inode, struct inode *dir, | 387 | void *fs_info) |
379 | const struct qstr *qstr) | ||
380 | { | 388 | { |
381 | int err; | 389 | const struct xattr *xattr; |
382 | size_t len; | 390 | struct btrfs_trans_handle *trans = fs_info; |
383 | void *value; | ||
384 | char *suffix; | ||
385 | char *name; | 391 | char *name; |
392 | int err = 0; | ||
386 | 393 | ||
387 | err = security_inode_init_security(inode, dir, qstr, &suffix, &value, | 394 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
388 | &len); | 395 | name = kmalloc(XATTR_SECURITY_PREFIX_LEN + |
389 | if (err) { | 396 | strlen(xattr->name) + 1, GFP_NOFS); |
390 | if (err == -EOPNOTSUPP) | 397 | if (!name) { |
391 | return 0; | 398 | err = -ENOMEM; |
392 | return err; | 399 | break; |
393 | } | 400 | } |
394 | |||
395 | name = kmalloc(XATTR_SECURITY_PREFIX_LEN + strlen(suffix) + 1, | ||
396 | GFP_NOFS); | ||
397 | if (!name) { | ||
398 | err = -ENOMEM; | ||
399 | } else { | ||
400 | strcpy(name, XATTR_SECURITY_PREFIX); | 401 | strcpy(name, XATTR_SECURITY_PREFIX); |
401 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); | 402 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, xattr->name); |
402 | err = __btrfs_setxattr(trans, inode, name, value, len, 0); | 403 | err = __btrfs_setxattr(trans, inode, name, |
404 | xattr->value, xattr->value_len, 0); | ||
403 | kfree(name); | 405 | kfree(name); |
406 | if (err < 0) | ||
407 | break; | ||
404 | } | 408 | } |
405 | |||
406 | kfree(suffix); | ||
407 | kfree(value); | ||
408 | return err; | 409 | return err; |
409 | } | 410 | } |
411 | |||
412 | int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, | ||
413 | struct inode *inode, struct inode *dir, | ||
414 | const struct qstr *qstr) | ||
415 | { | ||
416 | return security_inode_init_security(inode, dir, qstr, | ||
417 | &btrfs_initxattrs, trans); | ||
418 | } | ||
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index fee028b5332e..86c59e16ba74 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -1595,7 +1595,7 @@ static int set_request_path_attr(struct inode *rinode, struct dentry *rdentry, | |||
1595 | r = build_dentry_path(rdentry, ppath, pathlen, ino, freepath); | 1595 | r = build_dentry_path(rdentry, ppath, pathlen, ino, freepath); |
1596 | dout(" dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen, | 1596 | dout(" dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen, |
1597 | *ppath); | 1597 | *ppath); |
1598 | } else if (rpath) { | 1598 | } else if (rpath || rino) { |
1599 | *ino = rino; | 1599 | *ino = rino; |
1600 | *ppath = rpath; | 1600 | *ppath = rpath; |
1601 | *pathlen = strlen(rpath); | 1601 | *pathlen = strlen(rpath); |
diff --git a/fs/ceph/super.c b/fs/ceph/super.c index d47c5ec7fb1f..88bacaf385d9 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c | |||
@@ -813,8 +813,8 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type, | |||
813 | fsc = create_fs_client(fsopt, opt); | 813 | fsc = create_fs_client(fsopt, opt); |
814 | if (IS_ERR(fsc)) { | 814 | if (IS_ERR(fsc)) { |
815 | res = ERR_CAST(fsc); | 815 | res = ERR_CAST(fsc); |
816 | kfree(fsopt); | 816 | destroy_mount_options(fsopt); |
817 | kfree(opt); | 817 | ceph_destroy_options(opt); |
818 | goto out_final; | 818 | goto out_final; |
819 | } | 819 | } |
820 | 820 | ||
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 2fe3cf13b2e9..6d40656e1e29 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -176,7 +176,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) | |||
176 | 176 | ||
177 | #ifdef CONFIG_CIFS_STATS2 | 177 | #ifdef CONFIG_CIFS_STATS2 |
178 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", | 178 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", |
179 | atomic_read(&server->inSend), | 179 | atomic_read(&server->in_send), |
180 | atomic_read(&server->num_waiters)); | 180 | atomic_read(&server->num_waiters)); |
181 | #endif | 181 | #endif |
182 | 182 | ||
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 21de1d6d5849..d0f59faefb78 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -991,24 +991,6 @@ struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, | |||
991 | return pntsd; | 991 | return pntsd; |
992 | } | 992 | } |
993 | 993 | ||
994 | static int set_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, __u16 fid, | ||
995 | struct cifs_ntsd *pnntsd, u32 acllen) | ||
996 | { | ||
997 | int xid, rc; | ||
998 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); | ||
999 | |||
1000 | if (IS_ERR(tlink)) | ||
1001 | return PTR_ERR(tlink); | ||
1002 | |||
1003 | xid = GetXid(); | ||
1004 | rc = CIFSSMBSetCIFSACL(xid, tlink_tcon(tlink), fid, pnntsd, acllen); | ||
1005 | FreeXid(xid); | ||
1006 | cifs_put_tlink(tlink); | ||
1007 | |||
1008 | cFYI(DBG2, "SetCIFSACL rc = %d", rc); | ||
1009 | return rc; | ||
1010 | } | ||
1011 | |||
1012 | static int set_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const char *path, | 994 | static int set_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const char *path, |
1013 | struct cifs_ntsd *pnntsd, u32 acllen) | 995 | struct cifs_ntsd *pnntsd, u32 acllen) |
1014 | { | 996 | { |
@@ -1047,18 +1029,10 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
1047 | struct inode *inode, const char *path) | 1029 | struct inode *inode, const char *path) |
1048 | { | 1030 | { |
1049 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | 1031 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
1050 | struct cifsFileInfo *open_file; | ||
1051 | int rc; | ||
1052 | 1032 | ||
1053 | cFYI(DBG2, "set ACL for %s from mode 0x%x", path, inode->i_mode); | 1033 | cFYI(DBG2, "set ACL for %s from mode 0x%x", path, inode->i_mode); |
1054 | 1034 | ||
1055 | open_file = find_readable_file(CIFS_I(inode), true); | 1035 | return set_cifs_acl_by_path(cifs_sb, path, pnntsd, acllen); |
1056 | if (!open_file) | ||
1057 | return set_cifs_acl_by_path(cifs_sb, path, pnntsd, acllen); | ||
1058 | |||
1059 | rc = set_cifs_acl_by_fid(cifs_sb, open_file->netfid, pnntsd, acllen); | ||
1060 | cifsFileInfo_put(open_file); | ||
1061 | return rc; | ||
1062 | } | 1036 | } |
1063 | 1037 | ||
1064 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ | 1038 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ |
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index e76bfeb68267..30acd22147e1 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -351,9 +351,7 @@ static int | |||
351 | build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) | 351 | build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) |
352 | { | 352 | { |
353 | unsigned int dlen; | 353 | unsigned int dlen; |
354 | unsigned int wlen; | 354 | unsigned int size = 2 * sizeof(struct ntlmssp2_name); |
355 | unsigned int size = 6 * sizeof(struct ntlmssp2_name); | ||
356 | __le64 curtime; | ||
357 | char *defdmname = "WORKGROUP"; | 355 | char *defdmname = "WORKGROUP"; |
358 | unsigned char *blobptr; | 356 | unsigned char *blobptr; |
359 | struct ntlmssp2_name *attrptr; | 357 | struct ntlmssp2_name *attrptr; |
@@ -365,15 +363,14 @@ build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) | |||
365 | } | 363 | } |
366 | 364 | ||
367 | dlen = strlen(ses->domainName); | 365 | dlen = strlen(ses->domainName); |
368 | wlen = strlen(ses->server->hostname); | ||
369 | 366 | ||
370 | /* The length of this blob is a size which is | 367 | /* |
371 | * six times the size of a structure which holds name/size + | 368 | * The length of this blob is two times the size of a |
372 | * two times the unicode length of a domain name + | 369 | * structure (av pair) which holds name/size |
373 | * two times the unicode length of a server name + | 370 | * ( for NTLMSSP_AV_NB_DOMAIN_NAME followed by NTLMSSP_AV_EOL ) + |
374 | * size of a timestamp (which is 8 bytes). | 371 | * unicode length of a netbios domain name |
375 | */ | 372 | */ |
376 | ses->auth_key.len = size + 2 * (2 * dlen) + 2 * (2 * wlen) + 8; | 373 | ses->auth_key.len = size + 2 * dlen; |
377 | ses->auth_key.response = kzalloc(ses->auth_key.len, GFP_KERNEL); | 374 | ses->auth_key.response = kzalloc(ses->auth_key.len, GFP_KERNEL); |
378 | if (!ses->auth_key.response) { | 375 | if (!ses->auth_key.response) { |
379 | ses->auth_key.len = 0; | 376 | ses->auth_key.len = 0; |
@@ -384,44 +381,15 @@ build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) | |||
384 | blobptr = ses->auth_key.response; | 381 | blobptr = ses->auth_key.response; |
385 | attrptr = (struct ntlmssp2_name *) blobptr; | 382 | attrptr = (struct ntlmssp2_name *) blobptr; |
386 | 383 | ||
384 | /* | ||
385 | * As defined in MS-NTLM 3.3.2, just this av pair field | ||
386 | * is sufficient as part of the temp | ||
387 | */ | ||
387 | attrptr->type = cpu_to_le16(NTLMSSP_AV_NB_DOMAIN_NAME); | 388 | attrptr->type = cpu_to_le16(NTLMSSP_AV_NB_DOMAIN_NAME); |
388 | attrptr->length = cpu_to_le16(2 * dlen); | 389 | attrptr->length = cpu_to_le16(2 * dlen); |
389 | blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name); | 390 | blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name); |
390 | cifs_strtoUCS((__le16 *)blobptr, ses->domainName, dlen, nls_cp); | 391 | cifs_strtoUCS((__le16 *)blobptr, ses->domainName, dlen, nls_cp); |
391 | 392 | ||
392 | blobptr += 2 * dlen; | ||
393 | attrptr = (struct ntlmssp2_name *) blobptr; | ||
394 | |||
395 | attrptr->type = cpu_to_le16(NTLMSSP_AV_NB_COMPUTER_NAME); | ||
396 | attrptr->length = cpu_to_le16(2 * wlen); | ||
397 | blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name); | ||
398 | cifs_strtoUCS((__le16 *)blobptr, ses->server->hostname, wlen, nls_cp); | ||
399 | |||
400 | blobptr += 2 * wlen; | ||
401 | attrptr = (struct ntlmssp2_name *) blobptr; | ||
402 | |||
403 | attrptr->type = cpu_to_le16(NTLMSSP_AV_DNS_DOMAIN_NAME); | ||
404 | attrptr->length = cpu_to_le16(2 * dlen); | ||
405 | blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name); | ||
406 | cifs_strtoUCS((__le16 *)blobptr, ses->domainName, dlen, nls_cp); | ||
407 | |||
408 | blobptr += 2 * dlen; | ||
409 | attrptr = (struct ntlmssp2_name *) blobptr; | ||
410 | |||
411 | attrptr->type = cpu_to_le16(NTLMSSP_AV_DNS_COMPUTER_NAME); | ||
412 | attrptr->length = cpu_to_le16(2 * wlen); | ||
413 | blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name); | ||
414 | cifs_strtoUCS((__le16 *)blobptr, ses->server->hostname, wlen, nls_cp); | ||
415 | |||
416 | blobptr += 2 * wlen; | ||
417 | attrptr = (struct ntlmssp2_name *) blobptr; | ||
418 | |||
419 | attrptr->type = cpu_to_le16(NTLMSSP_AV_TIMESTAMP); | ||
420 | attrptr->length = cpu_to_le16(sizeof(__le64)); | ||
421 | blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name); | ||
422 | curtime = cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME)); | ||
423 | memcpy(blobptr, &curtime, sizeof(__le64)); | ||
424 | |||
425 | return 0; | 393 | return 0; |
426 | } | 394 | } |
427 | 395 | ||
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index f93eb948d071..54b8f1e7da94 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -548,6 +548,12 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) | |||
548 | struct inode *dir = dentry->d_inode; | 548 | struct inode *dir = dentry->d_inode; |
549 | struct dentry *child; | 549 | struct dentry *child; |
550 | 550 | ||
551 | if (!dir) { | ||
552 | dput(dentry); | ||
553 | dentry = ERR_PTR(-ENOENT); | ||
554 | break; | ||
555 | } | ||
556 | |||
551 | /* skip separators */ | 557 | /* skip separators */ |
552 | while (*s == sep) | 558 | while (*s == sep) |
553 | s++; | 559 | s++; |
@@ -563,10 +569,6 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) | |||
563 | mutex_unlock(&dir->i_mutex); | 569 | mutex_unlock(&dir->i_mutex); |
564 | dput(dentry); | 570 | dput(dentry); |
565 | dentry = child; | 571 | dentry = child; |
566 | if (!dentry->d_inode) { | ||
567 | dput(dentry); | ||
568 | dentry = ERR_PTR(-ENOENT); | ||
569 | } | ||
570 | } while (!IS_ERR(dentry)); | 572 | } while (!IS_ERR(dentry)); |
571 | _FreeXid(xid); | 573 | _FreeXid(xid); |
572 | kfree(full_path); | 574 | kfree(full_path); |
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index cb71dc1f94d1..95da8027983d 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
@@ -125,5 +125,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); | |||
125 | extern const struct export_operations cifs_export_ops; | 125 | extern const struct export_operations cifs_export_ops; |
126 | #endif /* CIFS_NFSD_EXPORT */ | 126 | #endif /* CIFS_NFSD_EXPORT */ |
127 | 127 | ||
128 | #define CIFS_VERSION "1.74" | 128 | #define CIFS_VERSION "1.75" |
129 | #endif /* _CIFSFS_H */ | 129 | #endif /* _CIFSFS_H */ |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 38ce6d44b145..95dad9d14cf1 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -291,7 +291,7 @@ struct TCP_Server_Info { | |||
291 | struct fscache_cookie *fscache; /* client index cache cookie */ | 291 | struct fscache_cookie *fscache; /* client index cache cookie */ |
292 | #endif | 292 | #endif |
293 | #ifdef CONFIG_CIFS_STATS2 | 293 | #ifdef CONFIG_CIFS_STATS2 |
294 | atomic_t inSend; /* requests trying to send */ | 294 | atomic_t in_send; /* requests trying to send */ |
295 | atomic_t num_waiters; /* blocked waiting to get in sendrecv */ | 295 | atomic_t num_waiters; /* blocked waiting to get in sendrecv */ |
296 | #endif | 296 | #endif |
297 | }; | 297 | }; |
@@ -672,12 +672,54 @@ struct mid_q_entry { | |||
672 | bool multiEnd:1; /* both received */ | 672 | bool multiEnd:1; /* both received */ |
673 | }; | 673 | }; |
674 | 674 | ||
675 | struct oplock_q_entry { | 675 | /* Make code in transport.c a little cleaner by moving |
676 | struct list_head qhead; | 676 | update of optional stats into function below */ |
677 | struct inode *pinode; | 677 | #ifdef CONFIG_CIFS_STATS2 |
678 | struct cifs_tcon *tcon; | 678 | |
679 | __u16 netfid; | 679 | static inline void cifs_in_send_inc(struct TCP_Server_Info *server) |
680 | }; | 680 | { |
681 | atomic_inc(&server->in_send); | ||
682 | } | ||
683 | |||
684 | static inline void cifs_in_send_dec(struct TCP_Server_Info *server) | ||
685 | { | ||
686 | atomic_dec(&server->in_send); | ||
687 | } | ||
688 | |||
689 | static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server) | ||
690 | { | ||
691 | atomic_inc(&server->num_waiters); | ||
692 | } | ||
693 | |||
694 | static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server) | ||
695 | { | ||
696 | atomic_dec(&server->num_waiters); | ||
697 | } | ||
698 | |||
699 | static inline void cifs_save_when_sent(struct mid_q_entry *mid) | ||
700 | { | ||
701 | mid->when_sent = jiffies; | ||
702 | } | ||
703 | #else | ||
704 | static inline void cifs_in_send_inc(struct TCP_Server_Info *server) | ||
705 | { | ||
706 | } | ||
707 | static inline void cifs_in_send_dec(struct TCP_Server_Info *server) | ||
708 | { | ||
709 | } | ||
710 | |||
711 | static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server) | ||
712 | { | ||
713 | } | ||
714 | |||
715 | static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server) | ||
716 | { | ||
717 | } | ||
718 | |||
719 | static inline void cifs_save_when_sent(struct mid_q_entry *mid) | ||
720 | { | ||
721 | } | ||
722 | #endif | ||
681 | 723 | ||
682 | /* for pending dnotify requests */ | 724 | /* for pending dnotify requests */ |
683 | struct dir_notify_req { | 725 | struct dir_notify_req { |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index aac37d99a487..a80f7bd97b90 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -4079,7 +4079,8 @@ int CIFSFindNext(const int xid, struct cifs_tcon *tcon, | |||
4079 | T2_FNEXT_RSP_PARMS *parms; | 4079 | T2_FNEXT_RSP_PARMS *parms; |
4080 | char *response_data; | 4080 | char *response_data; |
4081 | int rc = 0; | 4081 | int rc = 0; |
4082 | int bytes_returned, name_len; | 4082 | int bytes_returned; |
4083 | unsigned int name_len; | ||
4083 | __u16 params, byte_count; | 4084 | __u16 params, byte_count; |
4084 | 4085 | ||
4085 | cFYI(1, "In FindNext"); | 4086 | cFYI(1, "In FindNext"); |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 80c2e3add3a2..62abf9fd6ff0 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1298,7 +1298,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, | |||
1298 | /* ignore */ | 1298 | /* ignore */ |
1299 | } else if (strnicmp(data, "guest", 5) == 0) { | 1299 | } else if (strnicmp(data, "guest", 5) == 0) { |
1300 | /* ignore */ | 1300 | /* ignore */ |
1301 | } else if (strnicmp(data, "rw", 2) == 0) { | 1301 | } else if (strnicmp(data, "rw", 2) == 0 && strlen(data) == 2) { |
1302 | /* ignore */ | 1302 | /* ignore */ |
1303 | } else if (strnicmp(data, "ro", 2) == 0) { | 1303 | } else if (strnicmp(data, "ro", 2) == 0) { |
1304 | /* ignore */ | 1304 | /* ignore */ |
@@ -1401,7 +1401,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, | |||
1401 | vol->server_ino = 1; | 1401 | vol->server_ino = 1; |
1402 | } else if (strnicmp(data, "noserverino", 9) == 0) { | 1402 | } else if (strnicmp(data, "noserverino", 9) == 0) { |
1403 | vol->server_ino = 0; | 1403 | vol->server_ino = 0; |
1404 | } else if (strnicmp(data, "rwpidforward", 4) == 0) { | 1404 | } else if (strnicmp(data, "rwpidforward", 12) == 0) { |
1405 | vol->rwpidforward = 1; | 1405 | vol->rwpidforward = 1; |
1406 | } else if (strnicmp(data, "cifsacl", 7) == 0) { | 1406 | } else if (strnicmp(data, "cifsacl", 7) == 0) { |
1407 | vol->cifs_acl = 1; | 1407 | vol->cifs_acl = 1; |
@@ -2018,7 +2018,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) | |||
2018 | warned_on_ntlm = true; | 2018 | warned_on_ntlm = true; |
2019 | cERROR(1, "default security mechanism requested. The default " | 2019 | cERROR(1, "default security mechanism requested. The default " |
2020 | "security mechanism will be upgraded from ntlm to " | 2020 | "security mechanism will be upgraded from ntlm to " |
2021 | "ntlmv2 in kernel release 3.1"); | 2021 | "ntlmv2 in kernel release 3.2"); |
2022 | } | 2022 | } |
2023 | ses->overrideSecFlg = volume_info->secFlg; | 2023 | ses->overrideSecFlg = volume_info->secFlg; |
2024 | 2024 | ||
@@ -2877,8 +2877,9 @@ cleanup_volume_info_contents(struct smb_vol *volume_info) | |||
2877 | { | 2877 | { |
2878 | kfree(volume_info->username); | 2878 | kfree(volume_info->username); |
2879 | kzfree(volume_info->password); | 2879 | kzfree(volume_info->password); |
2880 | if (volume_info->UNCip != volume_info->UNC + 2) | ||
2881 | kfree(volume_info->UNCip); | ||
2880 | kfree(volume_info->UNC); | 2882 | kfree(volume_info->UNC); |
2881 | kfree(volume_info->UNCip); | ||
2882 | kfree(volume_info->domainname); | 2883 | kfree(volume_info->domainname); |
2883 | kfree(volume_info->iocharset); | 2884 | kfree(volume_info->iocharset); |
2884 | kfree(volume_info->prepath); | 2885 | kfree(volume_info->prepath); |
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index ae576fbb5142..72d448bf96ce 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -105,8 +105,8 @@ cifs_bp_rename_retry: | |||
105 | } | 105 | } |
106 | rcu_read_unlock(); | 106 | rcu_read_unlock(); |
107 | if (namelen != dfsplen || read_seqretry(&rename_lock, seq)) { | 107 | if (namelen != dfsplen || read_seqretry(&rename_lock, seq)) { |
108 | cERROR(1, "did not end path lookup where expected namelen is %d", | 108 | cFYI(1, "did not end path lookup where expected. namelen=%d " |
109 | namelen); | 109 | "dfsplen=%d", namelen, dfsplen); |
110 | /* presumably this is only possible if racing with a rename | 110 | /* presumably this is only possible if racing with a rename |
111 | of one of the parent directories (we can not lock the dentries | 111 | of one of the parent directories (we can not lock the dentries |
112 | above us to prevent this, but retrying should be harmless) */ | 112 | above us to prevent this, but retrying should be harmless) */ |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index c1b9c4b10739..10ca6b2c26b7 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -266,15 +266,11 @@ static int wait_for_free_request(struct TCP_Server_Info *server, | |||
266 | while (1) { | 266 | while (1) { |
267 | if (atomic_read(&server->inFlight) >= cifs_max_pending) { | 267 | if (atomic_read(&server->inFlight) >= cifs_max_pending) { |
268 | spin_unlock(&GlobalMid_Lock); | 268 | spin_unlock(&GlobalMid_Lock); |
269 | #ifdef CONFIG_CIFS_STATS2 | 269 | cifs_num_waiters_inc(server); |
270 | atomic_inc(&server->num_waiters); | ||
271 | #endif | ||
272 | wait_event(server->request_q, | 270 | wait_event(server->request_q, |
273 | atomic_read(&server->inFlight) | 271 | atomic_read(&server->inFlight) |
274 | < cifs_max_pending); | 272 | < cifs_max_pending); |
275 | #ifdef CONFIG_CIFS_STATS2 | 273 | cifs_num_waiters_dec(server); |
276 | atomic_dec(&server->num_waiters); | ||
277 | #endif | ||
278 | spin_lock(&GlobalMid_Lock); | 274 | spin_lock(&GlobalMid_Lock); |
279 | } else { | 275 | } else { |
280 | if (server->tcpStatus == CifsExiting) { | 276 | if (server->tcpStatus == CifsExiting) { |
@@ -381,15 +377,13 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, | |||
381 | mid->callback = callback; | 377 | mid->callback = callback; |
382 | mid->callback_data = cbdata; | 378 | mid->callback_data = cbdata; |
383 | mid->midState = MID_REQUEST_SUBMITTED; | 379 | mid->midState = MID_REQUEST_SUBMITTED; |
384 | #ifdef CONFIG_CIFS_STATS2 | 380 | |
385 | atomic_inc(&server->inSend); | 381 | cifs_in_send_inc(server); |
386 | #endif | ||
387 | rc = smb_sendv(server, iov, nvec); | 382 | rc = smb_sendv(server, iov, nvec); |
388 | #ifdef CONFIG_CIFS_STATS2 | 383 | cifs_in_send_dec(server); |
389 | atomic_dec(&server->inSend); | 384 | cifs_save_when_sent(mid); |
390 | mid->when_sent = jiffies; | ||
391 | #endif | ||
392 | mutex_unlock(&server->srv_mutex); | 385 | mutex_unlock(&server->srv_mutex); |
386 | |||
393 | if (rc) | 387 | if (rc) |
394 | goto out_err; | 388 | goto out_err; |
395 | 389 | ||
@@ -575,14 +569,10 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, | |||
575 | } | 569 | } |
576 | 570 | ||
577 | midQ->midState = MID_REQUEST_SUBMITTED; | 571 | midQ->midState = MID_REQUEST_SUBMITTED; |
578 | #ifdef CONFIG_CIFS_STATS2 | 572 | cifs_in_send_inc(ses->server); |
579 | atomic_inc(&ses->server->inSend); | ||
580 | #endif | ||
581 | rc = smb_sendv(ses->server, iov, n_vec); | 573 | rc = smb_sendv(ses->server, iov, n_vec); |
582 | #ifdef CONFIG_CIFS_STATS2 | 574 | cifs_in_send_dec(ses->server); |
583 | atomic_dec(&ses->server->inSend); | 575 | cifs_save_when_sent(midQ); |
584 | midQ->when_sent = jiffies; | ||
585 | #endif | ||
586 | 576 | ||
587 | mutex_unlock(&ses->server->srv_mutex); | 577 | mutex_unlock(&ses->server->srv_mutex); |
588 | 578 | ||
@@ -703,14 +693,11 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
703 | } | 693 | } |
704 | 694 | ||
705 | midQ->midState = MID_REQUEST_SUBMITTED; | 695 | midQ->midState = MID_REQUEST_SUBMITTED; |
706 | #ifdef CONFIG_CIFS_STATS2 | 696 | |
707 | atomic_inc(&ses->server->inSend); | 697 | cifs_in_send_inc(ses->server); |
708 | #endif | ||
709 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); | 698 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
710 | #ifdef CONFIG_CIFS_STATS2 | 699 | cifs_in_send_dec(ses->server); |
711 | atomic_dec(&ses->server->inSend); | 700 | cifs_save_when_sent(midQ); |
712 | midQ->when_sent = jiffies; | ||
713 | #endif | ||
714 | mutex_unlock(&ses->server->srv_mutex); | 701 | mutex_unlock(&ses->server->srv_mutex); |
715 | 702 | ||
716 | if (rc < 0) | 703 | if (rc < 0) |
@@ -843,14 +830,10 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
843 | } | 830 | } |
844 | 831 | ||
845 | midQ->midState = MID_REQUEST_SUBMITTED; | 832 | midQ->midState = MID_REQUEST_SUBMITTED; |
846 | #ifdef CONFIG_CIFS_STATS2 | 833 | cifs_in_send_inc(ses->server); |
847 | atomic_inc(&ses->server->inSend); | ||
848 | #endif | ||
849 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); | 834 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
850 | #ifdef CONFIG_CIFS_STATS2 | 835 | cifs_in_send_dec(ses->server); |
851 | atomic_dec(&ses->server->inSend); | 836 | cifs_save_when_sent(midQ); |
852 | midQ->when_sent = jiffies; | ||
853 | #endif | ||
854 | mutex_unlock(&ses->server->srv_mutex); | 837 | mutex_unlock(&ses->server->srv_mutex); |
855 | 838 | ||
856 | if (rc < 0) { | 839 | if (rc < 0) { |
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index 2a22fb2989e4..c32308882148 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
23 | #include <linux/posix_acl_xattr.h> | 23 | #include <linux/posix_acl_xattr.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/xattr.h> | ||
25 | #include "cifsfs.h" | 26 | #include "cifsfs.h" |
26 | #include "cifspdu.h" | 27 | #include "cifspdu.h" |
27 | #include "cifsglob.h" | 28 | #include "cifsglob.h" |
@@ -31,16 +32,8 @@ | |||
31 | #define MAX_EA_VALUE_SIZE 65535 | 32 | #define MAX_EA_VALUE_SIZE 65535 |
32 | #define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib" | 33 | #define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib" |
33 | #define CIFS_XATTR_CIFS_ACL "system.cifs_acl" | 34 | #define CIFS_XATTR_CIFS_ACL "system.cifs_acl" |
34 | #define CIFS_XATTR_USER_PREFIX "user." | ||
35 | #define CIFS_XATTR_SYSTEM_PREFIX "system." | ||
36 | #define CIFS_XATTR_OS2_PREFIX "os2." | ||
37 | #define CIFS_XATTR_SECURITY_PREFIX "security." | ||
38 | #define CIFS_XATTR_TRUSTED_PREFIX "trusted." | ||
39 | #define XATTR_TRUSTED_PREFIX_LEN 8 | ||
40 | #define XATTR_SECURITY_PREFIX_LEN 9 | ||
41 | /* BB need to add server (Samba e.g) support for security and trusted prefix */ | ||
42 | |||
43 | 35 | ||
36 | /* BB need to add server (Samba e.g) support for security and trusted prefix */ | ||
44 | 37 | ||
45 | int cifs_removexattr(struct dentry *direntry, const char *ea_name) | 38 | int cifs_removexattr(struct dentry *direntry, const char *ea_name) |
46 | { | 39 | { |
@@ -76,8 +69,8 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name) | |||
76 | } | 69 | } |
77 | if (ea_name == NULL) { | 70 | if (ea_name == NULL) { |
78 | cFYI(1, "Null xattr names not supported"); | 71 | cFYI(1, "Null xattr names not supported"); |
79 | } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) | 72 | } else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) |
80 | && (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4))) { | 73 | && (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN))) { |
81 | cFYI(1, | 74 | cFYI(1, |
82 | "illegal xattr request %s (only user namespace supported)", | 75 | "illegal xattr request %s (only user namespace supported)", |
83 | ea_name); | 76 | ea_name); |
@@ -88,7 +81,7 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name) | |||
88 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) | 81 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) |
89 | goto remove_ea_exit; | 82 | goto remove_ea_exit; |
90 | 83 | ||
91 | ea_name += 5; /* skip past user. prefix */ | 84 | ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ |
92 | rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL, | 85 | rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL, |
93 | (__u16)0, cifs_sb->local_nls, | 86 | (__u16)0, cifs_sb->local_nls, |
94 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 87 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
@@ -149,21 +142,23 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, | |||
149 | 142 | ||
150 | if (ea_name == NULL) { | 143 | if (ea_name == NULL) { |
151 | cFYI(1, "Null xattr names not supported"); | 144 | cFYI(1, "Null xattr names not supported"); |
152 | } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) { | 145 | } else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) |
146 | == 0) { | ||
153 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) | 147 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) |
154 | goto set_ea_exit; | 148 | goto set_ea_exit; |
155 | if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) | 149 | if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) |
156 | cFYI(1, "attempt to set cifs inode metadata"); | 150 | cFYI(1, "attempt to set cifs inode metadata"); |
157 | 151 | ||
158 | ea_name += 5; /* skip past user. prefix */ | 152 | ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ |
159 | rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, | 153 | rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, |
160 | (__u16)value_size, cifs_sb->local_nls, | 154 | (__u16)value_size, cifs_sb->local_nls, |
161 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 155 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
162 | } else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) { | 156 | } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) |
157 | == 0) { | ||
163 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) | 158 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) |
164 | goto set_ea_exit; | 159 | goto set_ea_exit; |
165 | 160 | ||
166 | ea_name += 4; /* skip past os2. prefix */ | 161 | ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */ |
167 | rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, | 162 | rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, |
168 | (__u16)value_size, cifs_sb->local_nls, | 163 | (__u16)value_size, cifs_sb->local_nls, |
169 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 164 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
@@ -269,7 +264,8 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, | |||
269 | /* return alt name if available as pseudo attr */ | 264 | /* return alt name if available as pseudo attr */ |
270 | if (ea_name == NULL) { | 265 | if (ea_name == NULL) { |
271 | cFYI(1, "Null xattr names not supported"); | 266 | cFYI(1, "Null xattr names not supported"); |
272 | } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) { | 267 | } else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) |
268 | == 0) { | ||
273 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) | 269 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) |
274 | goto get_ea_exit; | 270 | goto get_ea_exit; |
275 | 271 | ||
@@ -277,15 +273,15 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, | |||
277 | cFYI(1, "attempt to query cifs inode metadata"); | 273 | cFYI(1, "attempt to query cifs inode metadata"); |
278 | /* revalidate/getattr then populate from inode */ | 274 | /* revalidate/getattr then populate from inode */ |
279 | } /* BB add else when above is implemented */ | 275 | } /* BB add else when above is implemented */ |
280 | ea_name += 5; /* skip past user. prefix */ | 276 | ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ |
281 | rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value, | 277 | rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value, |
282 | buf_size, cifs_sb->local_nls, | 278 | buf_size, cifs_sb->local_nls, |
283 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 279 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
284 | } else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) { | 280 | } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { |
285 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) | 281 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) |
286 | goto get_ea_exit; | 282 | goto get_ea_exit; |
287 | 283 | ||
288 | ea_name += 4; /* skip past os2. prefix */ | 284 | ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */ |
289 | rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value, | 285 | rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value, |
290 | buf_size, cifs_sb->local_nls, | 286 | buf_size, cifs_sb->local_nls, |
291 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 287 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
@@ -339,10 +335,10 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, | |||
339 | cFYI(1, "Query CIFS ACL not supported yet"); | 335 | cFYI(1, "Query CIFS ACL not supported yet"); |
340 | #endif /* CONFIG_CIFS_ACL */ | 336 | #endif /* CONFIG_CIFS_ACL */ |
341 | } else if (strncmp(ea_name, | 337 | } else if (strncmp(ea_name, |
342 | CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) { | 338 | XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) { |
343 | cFYI(1, "Trusted xattr namespace not supported yet"); | 339 | cFYI(1, "Trusted xattr namespace not supported yet"); |
344 | } else if (strncmp(ea_name, | 340 | } else if (strncmp(ea_name, |
345 | CIFS_XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) { | 341 | XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) { |
346 | cFYI(1, "Security xattr namespace not supported yet"); | 342 | cFYI(1, "Security xattr namespace not supported yet"); |
347 | } else | 343 | } else |
348 | cFYI(1, | 344 | cFYI(1, |
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h index 44e17e9c21ae..cc0ea9fe5ecf 100644 --- a/fs/coda/coda_linux.h +++ b/fs/coda/coda_linux.h | |||
@@ -59,12 +59,11 @@ void coda_sysctl_clean(void); | |||
59 | 59 | ||
60 | #define CODA_ALLOC(ptr, cast, size) do { \ | 60 | #define CODA_ALLOC(ptr, cast, size) do { \ |
61 | if (size < PAGE_SIZE) \ | 61 | if (size < PAGE_SIZE) \ |
62 | ptr = kmalloc((unsigned long) size, GFP_KERNEL); \ | 62 | ptr = kzalloc((unsigned long) size, GFP_KERNEL); \ |
63 | else \ | 63 | else \ |
64 | ptr = (cast)vmalloc((unsigned long) size); \ | 64 | ptr = (cast)vzalloc((unsigned long) size); \ |
65 | if (!ptr) \ | 65 | if (!ptr) \ |
66 | printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \ | 66 | printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \ |
67 | else memset( ptr, 0, size ); \ | ||
68 | } while (0) | 67 | } while (0) |
69 | 68 | ||
70 | 69 | ||
diff --git a/fs/compat.c b/fs/compat.c index f2b36d472c73..05e3f3d2cd77 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1674,11 +1674,6 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, | |||
1674 | } | 1674 | } |
1675 | #endif /* HAVE_SET_RESTORE_SIGMASK */ | 1675 | #endif /* HAVE_SET_RESTORE_SIGMASK */ |
1676 | 1676 | ||
1677 | long asmlinkage compat_sys_nfsservctl(int cmd, void *notused, void *notused2) | ||
1678 | { | ||
1679 | return sys_ni_syscall(); | ||
1680 | } | ||
1681 | |||
1682 | #ifdef CONFIG_EPOLL | 1677 | #ifdef CONFIG_EPOLL |
1683 | 1678 | ||
1684 | #ifdef HAVE_SET_RESTORE_SIGMASK | 1679 | #ifdef HAVE_SET_RESTORE_SIGMASK |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 8be086e9abe4..51352de88ef1 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -1003,6 +1003,7 @@ COMPATIBLE_IOCTL(PPPIOCCONNECT) | |||
1003 | COMPATIBLE_IOCTL(PPPIOCDISCONN) | 1003 | COMPATIBLE_IOCTL(PPPIOCDISCONN) |
1004 | COMPATIBLE_IOCTL(PPPIOCATTCHAN) | 1004 | COMPATIBLE_IOCTL(PPPIOCATTCHAN) |
1005 | COMPATIBLE_IOCTL(PPPIOCGCHAN) | 1005 | COMPATIBLE_IOCTL(PPPIOCGCHAN) |
1006 | COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS) | ||
1006 | /* PPPOX */ | 1007 | /* PPPOX */ |
1007 | COMPATIBLE_IOCTL(PPPOEIOCSFWD) | 1008 | COMPATIBLE_IOCTL(PPPOEIOCSFWD) |
1008 | COMPATIBLE_IOCTL(PPPOEIOCDFWD) | 1009 | COMPATIBLE_IOCTL(PPPOEIOCDFWD) |
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index c83f4768eeaa..ca418aaf6352 100644 --- a/fs/configfs/inode.c +++ b/fs/configfs/inode.c | |||
@@ -23,7 +23,8 @@ | |||
23 | * | 23 | * |
24 | * configfs Copyright (C) 2005 Oracle. All rights reserved. | 24 | * configfs Copyright (C) 2005 Oracle. All rights reserved. |
25 | * | 25 | * |
26 | * Please see Documentation/filesystems/configfs.txt for more information. | 26 | * Please see Documentation/filesystems/configfs/configfs.txt for more |
27 | * information. | ||
27 | */ | 28 | */ |
28 | 29 | ||
29 | #undef DEBUG | 30 | #undef DEBUG |
diff --git a/fs/configfs/item.c b/fs/configfs/item.c index 76dc4c3e5d51..50cee7f9110b 100644 --- a/fs/configfs/item.c +++ b/fs/configfs/item.c | |||
@@ -23,7 +23,7 @@ | |||
23 | * | 23 | * |
24 | * configfs Copyright (C) 2005 Oracle. All rights reserved. | 24 | * configfs Copyright (C) 2005 Oracle. All rights reserved. |
25 | * | 25 | * |
26 | * Please see the file Documentation/filesystems/configfs.txt for | 26 | * Please see the file Documentation/filesystems/configfs/configfs.txt for |
27 | * critical information about using the config_item interface. | 27 | * critical information about using the config_item interface. |
28 | */ | 28 | */ |
29 | 29 | ||
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index e7a7a2f07324..f3a257d7a985 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * file.c - part of debugfs, a tiny little debug file system | 2 | * inode.c - part of debugfs, a tiny little debug file system |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> | 4 | * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> |
5 | * Copyright (C) 2004 IBM Inc. | 5 | * Copyright (C) 2004 IBM Inc. |
diff --git a/fs/ecryptfs/Kconfig b/fs/ecryptfs/Kconfig index 1cd6d9d3e29a..cc16562654de 100644 --- a/fs/ecryptfs/Kconfig +++ b/fs/ecryptfs/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config ECRYPT_FS | 1 | config ECRYPT_FS |
2 | tristate "eCrypt filesystem layer support (EXPERIMENTAL)" | 2 | tristate "eCrypt filesystem layer support (EXPERIMENTAL)" |
3 | depends on EXPERIMENTAL && KEYS && CRYPTO | 3 | depends on EXPERIMENTAL && KEYS && CRYPTO && (ENCRYPTED_KEYS || ENCRYPTED_KEYS=n) |
4 | select CRYPTO_ECB | 4 | select CRYPTO_ECB |
5 | select CRYPTO_CBC | 5 | select CRYPTO_CBC |
6 | select CRYPTO_MD5 | 6 | select CRYPTO_MD5 |
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index 08a2b52bf565..ac1ad48c2376 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c | |||
@@ -1973,7 +1973,7 @@ pki_encrypt_session_key(struct key *auth_tok_key, | |||
1973 | { | 1973 | { |
1974 | struct ecryptfs_msg_ctx *msg_ctx = NULL; | 1974 | struct ecryptfs_msg_ctx *msg_ctx = NULL; |
1975 | char *payload = NULL; | 1975 | char *payload = NULL; |
1976 | size_t payload_len; | 1976 | size_t payload_len = 0; |
1977 | struct ecryptfs_message *msg; | 1977 | struct ecryptfs_message *msg; |
1978 | int rc; | 1978 | int rc; |
1979 | 1979 | ||
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 9f1bb747d77d..b4a6befb1216 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -175,6 +175,7 @@ enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig, | |||
175 | ecryptfs_opt_encrypted_view, ecryptfs_opt_fnek_sig, | 175 | ecryptfs_opt_encrypted_view, ecryptfs_opt_fnek_sig, |
176 | ecryptfs_opt_fn_cipher, ecryptfs_opt_fn_cipher_key_bytes, | 176 | ecryptfs_opt_fn_cipher, ecryptfs_opt_fn_cipher_key_bytes, |
177 | ecryptfs_opt_unlink_sigs, ecryptfs_opt_mount_auth_tok_only, | 177 | ecryptfs_opt_unlink_sigs, ecryptfs_opt_mount_auth_tok_only, |
178 | ecryptfs_opt_check_dev_ruid, | ||
178 | ecryptfs_opt_err }; | 179 | ecryptfs_opt_err }; |
179 | 180 | ||
180 | static const match_table_t tokens = { | 181 | static const match_table_t tokens = { |
@@ -191,6 +192,7 @@ static const match_table_t tokens = { | |||
191 | {ecryptfs_opt_fn_cipher_key_bytes, "ecryptfs_fn_key_bytes=%u"}, | 192 | {ecryptfs_opt_fn_cipher_key_bytes, "ecryptfs_fn_key_bytes=%u"}, |
192 | {ecryptfs_opt_unlink_sigs, "ecryptfs_unlink_sigs"}, | 193 | {ecryptfs_opt_unlink_sigs, "ecryptfs_unlink_sigs"}, |
193 | {ecryptfs_opt_mount_auth_tok_only, "ecryptfs_mount_auth_tok_only"}, | 194 | {ecryptfs_opt_mount_auth_tok_only, "ecryptfs_mount_auth_tok_only"}, |
195 | {ecryptfs_opt_check_dev_ruid, "ecryptfs_check_dev_ruid"}, | ||
194 | {ecryptfs_opt_err, NULL} | 196 | {ecryptfs_opt_err, NULL} |
195 | }; | 197 | }; |
196 | 198 | ||
@@ -236,6 +238,7 @@ static void ecryptfs_init_mount_crypt_stat( | |||
236 | * ecryptfs_parse_options | 238 | * ecryptfs_parse_options |
237 | * @sb: The ecryptfs super block | 239 | * @sb: The ecryptfs super block |
238 | * @options: The options passed to the kernel | 240 | * @options: The options passed to the kernel |
241 | * @check_ruid: set to 1 if device uid should be checked against the ruid | ||
239 | * | 242 | * |
240 | * Parse mount options: | 243 | * Parse mount options: |
241 | * debug=N - ecryptfs_verbosity level for debug output | 244 | * debug=N - ecryptfs_verbosity level for debug output |
@@ -251,7 +254,8 @@ static void ecryptfs_init_mount_crypt_stat( | |||
251 | * | 254 | * |
252 | * Returns zero on success; non-zero on error | 255 | * Returns zero on success; non-zero on error |
253 | */ | 256 | */ |
254 | static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options) | 257 | static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options, |
258 | uid_t *check_ruid) | ||
255 | { | 259 | { |
256 | char *p; | 260 | char *p; |
257 | int rc = 0; | 261 | int rc = 0; |
@@ -276,6 +280,8 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options) | |||
276 | char *cipher_key_bytes_src; | 280 | char *cipher_key_bytes_src; |
277 | char *fn_cipher_key_bytes_src; | 281 | char *fn_cipher_key_bytes_src; |
278 | 282 | ||
283 | *check_ruid = 0; | ||
284 | |||
279 | if (!options) { | 285 | if (!options) { |
280 | rc = -EINVAL; | 286 | rc = -EINVAL; |
281 | goto out; | 287 | goto out; |
@@ -380,6 +386,9 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options) | |||
380 | mount_crypt_stat->flags |= | 386 | mount_crypt_stat->flags |= |
381 | ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY; | 387 | ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY; |
382 | break; | 388 | break; |
389 | case ecryptfs_opt_check_dev_ruid: | ||
390 | *check_ruid = 1; | ||
391 | break; | ||
383 | case ecryptfs_opt_err: | 392 | case ecryptfs_opt_err: |
384 | default: | 393 | default: |
385 | printk(KERN_WARNING | 394 | printk(KERN_WARNING |
@@ -475,6 +484,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags | |||
475 | const char *err = "Getting sb failed"; | 484 | const char *err = "Getting sb failed"; |
476 | struct inode *inode; | 485 | struct inode *inode; |
477 | struct path path; | 486 | struct path path; |
487 | uid_t check_ruid; | ||
478 | int rc; | 488 | int rc; |
479 | 489 | ||
480 | sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL); | 490 | sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL); |
@@ -483,7 +493,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags | |||
483 | goto out; | 493 | goto out; |
484 | } | 494 | } |
485 | 495 | ||
486 | rc = ecryptfs_parse_options(sbi, raw_data); | 496 | rc = ecryptfs_parse_options(sbi, raw_data, &check_ruid); |
487 | if (rc) { | 497 | if (rc) { |
488 | err = "Error parsing options"; | 498 | err = "Error parsing options"; |
489 | goto out; | 499 | goto out; |
@@ -521,6 +531,15 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags | |||
521 | "known incompatibilities\n"); | 531 | "known incompatibilities\n"); |
522 | goto out_free; | 532 | goto out_free; |
523 | } | 533 | } |
534 | |||
535 | if (check_ruid && path.dentry->d_inode->i_uid != current_uid()) { | ||
536 | rc = -EPERM; | ||
537 | printk(KERN_ERR "Mount of device (uid: %d) not owned by " | ||
538 | "requested user (uid: %d)\n", | ||
539 | path.dentry->d_inode->i_uid, current_uid()); | ||
540 | goto out_free; | ||
541 | } | ||
542 | |||
524 | ecryptfs_set_superblock_lower(s, path.dentry->d_sb); | 543 | ecryptfs_set_superblock_lower(s, path.dentry->d_sb); |
525 | s->s_maxbytes = path.dentry->d_sb->s_maxbytes; | 544 | s->s_maxbytes = path.dentry->d_sb->s_maxbytes; |
526 | s->s_blocksize = path.dentry->d_sb->s_blocksize; | 545 | s->s_blocksize = path.dentry->d_sb->s_blocksize; |
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c index 85d430963116..3745f7c2b9c2 100644 --- a/fs/ecryptfs/read_write.c +++ b/fs/ecryptfs/read_write.c | |||
@@ -39,15 +39,16 @@ | |||
39 | int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data, | 39 | int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data, |
40 | loff_t offset, size_t size) | 40 | loff_t offset, size_t size) |
41 | { | 41 | { |
42 | struct ecryptfs_inode_info *inode_info; | 42 | struct file *lower_file; |
43 | mm_segment_t fs_save; | 43 | mm_segment_t fs_save; |
44 | ssize_t rc; | 44 | ssize_t rc; |
45 | 45 | ||
46 | inode_info = ecryptfs_inode_to_private(ecryptfs_inode); | 46 | lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file; |
47 | BUG_ON(!inode_info->lower_file); | 47 | if (!lower_file) |
48 | return -EIO; | ||
48 | fs_save = get_fs(); | 49 | fs_save = get_fs(); |
49 | set_fs(get_ds()); | 50 | set_fs(get_ds()); |
50 | rc = vfs_write(inode_info->lower_file, data, size, &offset); | 51 | rc = vfs_write(lower_file, data, size, &offset); |
51 | set_fs(fs_save); | 52 | set_fs(fs_save); |
52 | mark_inode_dirty_sync(ecryptfs_inode); | 53 | mark_inode_dirty_sync(ecryptfs_inode); |
53 | return rc; | 54 | return rc; |
@@ -225,15 +226,16 @@ out: | |||
225 | int ecryptfs_read_lower(char *data, loff_t offset, size_t size, | 226 | int ecryptfs_read_lower(char *data, loff_t offset, size_t size, |
226 | struct inode *ecryptfs_inode) | 227 | struct inode *ecryptfs_inode) |
227 | { | 228 | { |
228 | struct ecryptfs_inode_info *inode_info = | 229 | struct file *lower_file; |
229 | ecryptfs_inode_to_private(ecryptfs_inode); | ||
230 | mm_segment_t fs_save; | 230 | mm_segment_t fs_save; |
231 | ssize_t rc; | 231 | ssize_t rc; |
232 | 232 | ||
233 | BUG_ON(!inode_info->lower_file); | 233 | lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file; |
234 | if (!lower_file) | ||
235 | return -EIO; | ||
234 | fs_save = get_fs(); | 236 | fs_save = get_fs(); |
235 | set_fs(get_ds()); | 237 | set_fs(get_ds()); |
236 | rc = vfs_read(inode_info->lower_file, data, size, &offset); | 238 | rc = vfs_read(lower_file, data, size, &offset); |
237 | set_fs(fs_save); | 239 | set_fs(fs_save); |
238 | return rc; | 240 | return rc; |
239 | } | 241 | } |
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index fe047d966dc5..9026fc91fe3b 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -700,7 +700,7 @@ static const struct file_operations eventpoll_fops = { | |||
700 | .llseek = noop_llseek, | 700 | .llseek = noop_llseek, |
701 | }; | 701 | }; |
702 | 702 | ||
703 | /* Fast test to see if the file is an evenpoll file */ | 703 | /* Fast test to see if the file is an eventpoll file */ |
704 | static inline int is_file_epoll(struct file *f) | 704 | static inline int is_file_epoll(struct file *f) |
705 | { | 705 | { |
706 | return f->f_op == &eventpoll_fops; | 706 | return f->f_op == &eventpoll_fops; |
@@ -1459,6 +1459,23 @@ static int do_execve_common(const char *filename, | |||
1459 | struct files_struct *displaced; | 1459 | struct files_struct *displaced; |
1460 | bool clear_in_exec; | 1460 | bool clear_in_exec; |
1461 | int retval; | 1461 | int retval; |
1462 | const struct cred *cred = current_cred(); | ||
1463 | |||
1464 | /* | ||
1465 | * We move the actual failure in case of RLIMIT_NPROC excess from | ||
1466 | * set*uid() to execve() because too many poorly written programs | ||
1467 | * don't check setuid() return code. Here we additionally recheck | ||
1468 | * whether NPROC limit is still exceeded. | ||
1469 | */ | ||
1470 | if ((current->flags & PF_NPROC_EXCEEDED) && | ||
1471 | atomic_read(&cred->user->processes) > rlimit(RLIMIT_NPROC)) { | ||
1472 | retval = -EAGAIN; | ||
1473 | goto out_ret; | ||
1474 | } | ||
1475 | |||
1476 | /* We're below the limit (still or again), so we don't want to make | ||
1477 | * further execve() calls fail. */ | ||
1478 | current->flags &= ~PF_NPROC_EXCEEDED; | ||
1462 | 1479 | ||
1463 | retval = unshare_files(&displaced); | 1480 | retval = unshare_files(&displaced); |
1464 | if (retval) | 1481 | if (retval) |
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c index 5d979b4347b0..c922adc8ef41 100644 --- a/fs/ext2/xattr_security.c +++ b/fs/ext2/xattr_security.c | |||
@@ -46,28 +46,30 @@ ext2_xattr_security_set(struct dentry *dentry, const char *name, | |||
46 | value, size, flags); | 46 | value, size, flags); |
47 | } | 47 | } |
48 | 48 | ||
49 | int | 49 | int ext2_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
50 | ext2_init_security(struct inode *inode, struct inode *dir, | 50 | void *fs_info) |
51 | const struct qstr *qstr) | ||
52 | { | 51 | { |
53 | int err; | 52 | const struct xattr *xattr; |
54 | size_t len; | 53 | int err = 0; |
55 | void *value; | ||
56 | char *name; | ||
57 | 54 | ||
58 | err = security_inode_init_security(inode, dir, qstr, &name, &value, &len); | 55 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
59 | if (err) { | 56 | err = ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, |
60 | if (err == -EOPNOTSUPP) | 57 | xattr->name, xattr->value, |
61 | return 0; | 58 | xattr->value_len, 0); |
62 | return err; | 59 | if (err < 0) |
60 | break; | ||
63 | } | 61 | } |
64 | err = ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, | ||
65 | name, value, len, 0); | ||
66 | kfree(name); | ||
67 | kfree(value); | ||
68 | return err; | 62 | return err; |
69 | } | 63 | } |
70 | 64 | ||
65 | int | ||
66 | ext2_init_security(struct inode *inode, struct inode *dir, | ||
67 | const struct qstr *qstr) | ||
68 | { | ||
69 | return security_inode_init_security(inode, dir, qstr, | ||
70 | &ext2_initxattrs, NULL); | ||
71 | } | ||
72 | |||
71 | const struct xattr_handler ext2_xattr_security_handler = { | 73 | const struct xattr_handler ext2_xattr_security_handler = { |
72 | .prefix = XATTR_SECURITY_PREFIX, | 74 | .prefix = XATTR_SECURITY_PREFIX, |
73 | .list = ext2_xattr_security_list, | 75 | .list = ext2_xattr_security_list, |
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 04da6acde85d..12661e1deedd 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -1134,7 +1134,7 @@ struct buffer_head *ext3_bread(handle_t *handle, struct inode *inode, | |||
1134 | return bh; | 1134 | return bh; |
1135 | if (buffer_uptodate(bh)) | 1135 | if (buffer_uptodate(bh)) |
1136 | return bh; | 1136 | return bh; |
1137 | ll_rw_block(READ_META, 1, &bh); | 1137 | ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh); |
1138 | wait_on_buffer(bh); | 1138 | wait_on_buffer(bh); |
1139 | if (buffer_uptodate(bh)) | 1139 | if (buffer_uptodate(bh)) |
1140 | return bh; | 1140 | return bh; |
@@ -2807,7 +2807,7 @@ make_io: | |||
2807 | trace_ext3_load_inode(inode); | 2807 | trace_ext3_load_inode(inode); |
2808 | get_bh(bh); | 2808 | get_bh(bh); |
2809 | bh->b_end_io = end_buffer_read_sync; | 2809 | bh->b_end_io = end_buffer_read_sync; |
2810 | submit_bh(READ_META, bh); | 2810 | submit_bh(READ | REQ_META | REQ_PRIO, bh); |
2811 | wait_on_buffer(bh); | 2811 | wait_on_buffer(bh); |
2812 | if (!buffer_uptodate(bh)) { | 2812 | if (!buffer_uptodate(bh)) { |
2813 | ext3_error(inode->i_sb, "ext3_get_inode_loc", | 2813 | ext3_error(inode->i_sb, "ext3_get_inode_loc", |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 6e18a0b7750d..0629e09f6511 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -922,7 +922,8 @@ restart: | |||
922 | bh = ext3_getblk(NULL, dir, b++, 0, &err); | 922 | bh = ext3_getblk(NULL, dir, b++, 0, &err); |
923 | bh_use[ra_max] = bh; | 923 | bh_use[ra_max] = bh; |
924 | if (bh) | 924 | if (bh) |
925 | ll_rw_block(READ_META, 1, &bh); | 925 | ll_rw_block(READ | REQ_META | REQ_PRIO, |
926 | 1, &bh); | ||
926 | } | 927 | } |
927 | } | 928 | } |
928 | if ((bh = bh_use[ra_ptr++]) == NULL) | 929 | if ((bh = bh_use[ra_ptr++]) == NULL) |
@@ -2209,9 +2210,11 @@ static int ext3_symlink (struct inode * dir, | |||
2209 | /* | 2210 | /* |
2210 | * For non-fast symlinks, we just allocate inode and put it on | 2211 | * For non-fast symlinks, we just allocate inode and put it on |
2211 | * orphan list in the first transaction => we need bitmap, | 2212 | * orphan list in the first transaction => we need bitmap, |
2212 | * group descriptor, sb, inode block, quota blocks. | 2213 | * group descriptor, sb, inode block, quota blocks, and |
2214 | * possibly selinux xattr blocks. | ||
2213 | */ | 2215 | */ |
2214 | credits = 4 + EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb); | 2216 | credits = 4 + EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) + |
2217 | EXT3_XATTR_TRANS_BLOCKS; | ||
2215 | } else { | 2218 | } else { |
2216 | /* | 2219 | /* |
2217 | * Fast symlink. We have to add entry to directory | 2220 | * Fast symlink. We have to add entry to directory |
diff --git a/fs/ext3/xattr_security.c b/fs/ext3/xattr_security.c index b8d9f83aa5c5..3c218b8a51d4 100644 --- a/fs/ext3/xattr_security.c +++ b/fs/ext3/xattr_security.c | |||
@@ -48,28 +48,32 @@ ext3_xattr_security_set(struct dentry *dentry, const char *name, | |||
48 | name, value, size, flags); | 48 | name, value, size, flags); |
49 | } | 49 | } |
50 | 50 | ||
51 | int | 51 | int ext3_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
52 | ext3_init_security(handle_t *handle, struct inode *inode, struct inode *dir, | 52 | void *fs_info) |
53 | const struct qstr *qstr) | ||
54 | { | 53 | { |
55 | int err; | 54 | const struct xattr *xattr; |
56 | size_t len; | 55 | handle_t *handle = fs_info; |
57 | void *value; | 56 | int err = 0; |
58 | char *name; | ||
59 | 57 | ||
60 | err = security_inode_init_security(inode, dir, qstr, &name, &value, &len); | 58 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
61 | if (err) { | 59 | err = ext3_xattr_set_handle(handle, inode, |
62 | if (err == -EOPNOTSUPP) | 60 | EXT3_XATTR_INDEX_SECURITY, |
63 | return 0; | 61 | xattr->name, xattr->value, |
64 | return err; | 62 | xattr->value_len, 0); |
63 | if (err < 0) | ||
64 | break; | ||
65 | } | 65 | } |
66 | err = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_SECURITY, | ||
67 | name, value, len, 0); | ||
68 | kfree(name); | ||
69 | kfree(value); | ||
70 | return err; | 66 | return err; |
71 | } | 67 | } |
72 | 68 | ||
69 | int | ||
70 | ext3_init_security(handle_t *handle, struct inode *inode, struct inode *dir, | ||
71 | const struct qstr *qstr) | ||
72 | { | ||
73 | return security_inode_init_security(inode, dir, qstr, | ||
74 | &ext3_initxattrs, handle); | ||
75 | } | ||
76 | |||
73 | const struct xattr_handler ext3_xattr_security_handler = { | 77 | const struct xattr_handler ext3_xattr_security_handler = { |
74 | .prefix = XATTR_SECURITY_PREFIX, | 78 | .prefix = XATTR_SECURITY_PREFIX, |
75 | .list = ext3_xattr_security_list, | 79 | .list = ext3_xattr_security_list, |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index e717dfd2f2b4..b7d7bd0f066e 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -175,6 +175,7 @@ struct mpage_da_data { | |||
175 | */ | 175 | */ |
176 | #define EXT4_IO_END_UNWRITTEN 0x0001 | 176 | #define EXT4_IO_END_UNWRITTEN 0x0001 |
177 | #define EXT4_IO_END_ERROR 0x0002 | 177 | #define EXT4_IO_END_ERROR 0x0002 |
178 | #define EXT4_IO_END_QUEUED 0x0004 | ||
178 | 179 | ||
179 | struct ext4_io_page { | 180 | struct ext4_io_page { |
180 | struct page *p_page; | 181 | struct page *p_page; |
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index bb85757689b6..5802fa1dab18 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h | |||
@@ -289,10 +289,10 @@ static inline int ext4_should_order_data(struct inode *inode) | |||
289 | 289 | ||
290 | static inline int ext4_should_writeback_data(struct inode *inode) | 290 | static inline int ext4_should_writeback_data(struct inode *inode) |
291 | { | 291 | { |
292 | if (!S_ISREG(inode->i_mode)) | ||
293 | return 0; | ||
294 | if (EXT4_JOURNAL(inode) == NULL) | 292 | if (EXT4_JOURNAL(inode) == NULL) |
295 | return 1; | 293 | return 1; |
294 | if (!S_ISREG(inode->i_mode)) | ||
295 | return 0; | ||
296 | if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA)) | 296 | if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA)) |
297 | return 0; | 297 | return 0; |
298 | if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA) | 298 | if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA) |
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c index b8602cde5b5a..0962642119c0 100644 --- a/fs/ext4/indirect.c +++ b/fs/ext4/indirect.c | |||
@@ -800,12 +800,17 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, | |||
800 | } | 800 | } |
801 | 801 | ||
802 | retry: | 802 | retry: |
803 | if (rw == READ && ext4_should_dioread_nolock(inode)) | 803 | if (rw == READ && ext4_should_dioread_nolock(inode)) { |
804 | if (unlikely(!list_empty(&ei->i_completed_io_list))) { | ||
805 | mutex_lock(&inode->i_mutex); | ||
806 | ext4_flush_completed_IO(inode); | ||
807 | mutex_unlock(&inode->i_mutex); | ||
808 | } | ||
804 | ret = __blockdev_direct_IO(rw, iocb, inode, | 809 | ret = __blockdev_direct_IO(rw, iocb, inode, |
805 | inode->i_sb->s_bdev, iov, | 810 | inode->i_sb->s_bdev, iov, |
806 | offset, nr_segs, | 811 | offset, nr_segs, |
807 | ext4_get_block, NULL, NULL, 0); | 812 | ext4_get_block, NULL, NULL, 0); |
808 | else { | 813 | } else { |
809 | ret = blockdev_direct_IO(rw, iocb, inode, iov, | 814 | ret = blockdev_direct_IO(rw, iocb, inode, iov, |
810 | offset, nr_segs, ext4_get_block); | 815 | offset, nr_segs, ext4_get_block); |
811 | 816 | ||
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index d47264cafee0..986e2388f031 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -120,6 +120,9 @@ void ext4_evict_inode(struct inode *inode) | |||
120 | int err; | 120 | int err; |
121 | 121 | ||
122 | trace_ext4_evict_inode(inode); | 122 | trace_ext4_evict_inode(inode); |
123 | |||
124 | ext4_ioend_wait(inode); | ||
125 | |||
123 | if (inode->i_nlink) { | 126 | if (inode->i_nlink) { |
124 | /* | 127 | /* |
125 | * When journalling data dirty buffers are tracked only in the | 128 | * When journalling data dirty buffers are tracked only in the |
@@ -644,7 +647,7 @@ struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode, | |||
644 | return bh; | 647 | return bh; |
645 | if (buffer_uptodate(bh)) | 648 | if (buffer_uptodate(bh)) |
646 | return bh; | 649 | return bh; |
647 | ll_rw_block(READ_META, 1, &bh); | 650 | ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh); |
648 | wait_on_buffer(bh); | 651 | wait_on_buffer(bh); |
649 | if (buffer_uptodate(bh)) | 652 | if (buffer_uptodate(bh)) |
650 | return bh; | 653 | return bh; |
@@ -983,6 +986,8 @@ static int ext4_journalled_write_end(struct file *file, | |||
983 | from = pos & (PAGE_CACHE_SIZE - 1); | 986 | from = pos & (PAGE_CACHE_SIZE - 1); |
984 | to = from + len; | 987 | to = from + len; |
985 | 988 | ||
989 | BUG_ON(!ext4_handle_valid(handle)); | ||
990 | |||
986 | if (copied < len) { | 991 | if (copied < len) { |
987 | if (!PageUptodate(page)) | 992 | if (!PageUptodate(page)) |
988 | copied = 0; | 993 | copied = 0; |
@@ -1283,7 +1288,12 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd, | |||
1283 | else if (test_opt(inode->i_sb, MBLK_IO_SUBMIT)) | 1288 | else if (test_opt(inode->i_sb, MBLK_IO_SUBMIT)) |
1284 | err = ext4_bio_write_page(&io_submit, page, | 1289 | err = ext4_bio_write_page(&io_submit, page, |
1285 | len, mpd->wbc); | 1290 | len, mpd->wbc); |
1286 | else | 1291 | else if (buffer_uninit(page_bufs)) { |
1292 | ext4_set_bh_endio(page_bufs, inode); | ||
1293 | err = block_write_full_page_endio(page, | ||
1294 | noalloc_get_block_write, | ||
1295 | mpd->wbc, ext4_end_io_buffer_write); | ||
1296 | } else | ||
1287 | err = block_write_full_page(page, | 1297 | err = block_write_full_page(page, |
1288 | noalloc_get_block_write, mpd->wbc); | 1298 | noalloc_get_block_write, mpd->wbc); |
1289 | 1299 | ||
@@ -1699,6 +1709,8 @@ static int __ext4_journalled_writepage(struct page *page, | |||
1699 | goto out; | 1709 | goto out; |
1700 | } | 1710 | } |
1701 | 1711 | ||
1712 | BUG_ON(!ext4_handle_valid(handle)); | ||
1713 | |||
1702 | ret = walk_page_buffers(handle, page_bufs, 0, len, NULL, | 1714 | ret = walk_page_buffers(handle, page_bufs, 0, len, NULL, |
1703 | do_journal_get_write_access); | 1715 | do_journal_get_write_access); |
1704 | 1716 | ||
@@ -2668,8 +2680,15 @@ static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate) | |||
2668 | goto out; | 2680 | goto out; |
2669 | } | 2681 | } |
2670 | 2682 | ||
2671 | io_end->flag = EXT4_IO_END_UNWRITTEN; | 2683 | /* |
2684 | * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now, | ||
2685 | * but being more careful is always safe for the future change. | ||
2686 | */ | ||
2672 | inode = io_end->inode; | 2687 | inode = io_end->inode; |
2688 | if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) { | ||
2689 | io_end->flag |= EXT4_IO_END_UNWRITTEN; | ||
2690 | atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); | ||
2691 | } | ||
2673 | 2692 | ||
2674 | /* Add the io_end to per-inode completed io list*/ | 2693 | /* Add the io_end to per-inode completed io list*/ |
2675 | spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags); | 2694 | spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags); |
@@ -3279,7 +3298,7 @@ make_io: | |||
3279 | trace_ext4_load_inode(inode); | 3298 | trace_ext4_load_inode(inode); |
3280 | get_bh(bh); | 3299 | get_bh(bh); |
3281 | bh->b_end_io = end_buffer_read_sync; | 3300 | bh->b_end_io = end_buffer_read_sync; |
3282 | submit_bh(READ_META, bh); | 3301 | submit_bh(READ | REQ_META | REQ_PRIO, bh); |
3283 | wait_on_buffer(bh); | 3302 | wait_on_buffer(bh); |
3284 | if (!buffer_uptodate(bh)) { | 3303 | if (!buffer_uptodate(bh)) { |
3285 | EXT4_ERROR_INODE_BLOCK(inode, block, | 3304 | EXT4_ERROR_INODE_BLOCK(inode, block, |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 565a154e22d4..1c924faeb6c8 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -922,7 +922,8 @@ restart: | |||
922 | bh = ext4_getblk(NULL, dir, b++, 0, &err); | 922 | bh = ext4_getblk(NULL, dir, b++, 0, &err); |
923 | bh_use[ra_max] = bh; | 923 | bh_use[ra_max] = bh; |
924 | if (bh) | 924 | if (bh) |
925 | ll_rw_block(READ_META, 1, &bh); | 925 | ll_rw_block(READ | REQ_META | REQ_PRIO, |
926 | 1, &bh); | ||
926 | } | 927 | } |
927 | } | 928 | } |
928 | if ((bh = bh_use[ra_ptr++]) == NULL) | 929 | if ((bh = bh_use[ra_ptr++]) == NULL) |
@@ -2253,9 +2254,11 @@ static int ext4_symlink(struct inode *dir, | |||
2253 | /* | 2254 | /* |
2254 | * For non-fast symlinks, we just allocate inode and put it on | 2255 | * For non-fast symlinks, we just allocate inode and put it on |
2255 | * orphan list in the first transaction => we need bitmap, | 2256 | * orphan list in the first transaction => we need bitmap, |
2256 | * group descriptor, sb, inode block, quota blocks. | 2257 | * group descriptor, sb, inode block, quota blocks, and |
2258 | * possibly selinux xattr blocks. | ||
2257 | */ | 2259 | */ |
2258 | credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb); | 2260 | credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) + |
2261 | EXT4_XATTR_TRANS_BLOCKS; | ||
2259 | } else { | 2262 | } else { |
2260 | /* | 2263 | /* |
2261 | * Fast symlink. We have to add entry to directory | 2264 | * Fast symlink. We have to add entry to directory |
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 430c401d0895..92f38ee13f8a 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c | |||
@@ -142,7 +142,23 @@ static void ext4_end_io_work(struct work_struct *work) | |||
142 | unsigned long flags; | 142 | unsigned long flags; |
143 | int ret; | 143 | int ret; |
144 | 144 | ||
145 | mutex_lock(&inode->i_mutex); | 145 | if (!mutex_trylock(&inode->i_mutex)) { |
146 | /* | ||
147 | * Requeue the work instead of waiting so that the work | ||
148 | * items queued after this can be processed. | ||
149 | */ | ||
150 | queue_work(EXT4_SB(inode->i_sb)->dio_unwritten_wq, &io->work); | ||
151 | /* | ||
152 | * To prevent the ext4-dio-unwritten thread from keeping | ||
153 | * requeueing end_io requests and occupying cpu for too long, | ||
154 | * yield the cpu if it sees an end_io request that has already | ||
155 | * been requeued. | ||
156 | */ | ||
157 | if (io->flag & EXT4_IO_END_QUEUED) | ||
158 | yield(); | ||
159 | io->flag |= EXT4_IO_END_QUEUED; | ||
160 | return; | ||
161 | } | ||
146 | ret = ext4_end_io_nolock(io); | 162 | ret = ext4_end_io_nolock(io); |
147 | if (ret < 0) { | 163 | if (ret < 0) { |
148 | mutex_unlock(&inode->i_mutex); | 164 | mutex_unlock(&inode->i_mutex); |
@@ -334,8 +350,10 @@ submit_and_retry: | |||
334 | if ((io_end->num_io_pages >= MAX_IO_PAGES) && | 350 | if ((io_end->num_io_pages >= MAX_IO_PAGES) && |
335 | (io_end->pages[io_end->num_io_pages-1] != io_page)) | 351 | (io_end->pages[io_end->num_io_pages-1] != io_page)) |
336 | goto submit_and_retry; | 352 | goto submit_and_retry; |
337 | if (buffer_uninit(bh)) | 353 | if (buffer_uninit(bh) && !(io_end->flag & EXT4_IO_END_UNWRITTEN)) { |
338 | io->io_end->flag |= EXT4_IO_END_UNWRITTEN; | 354 | io_end->flag |= EXT4_IO_END_UNWRITTEN; |
355 | atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); | ||
356 | } | ||
339 | io->io_end->size += bh->b_size; | 357 | io->io_end->size += bh->b_size; |
340 | io->io_next_block++; | 358 | io->io_next_block++; |
341 | ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh)); | 359 | ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh)); |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 4687fea0c00f..44d0c8db2239 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -919,7 +919,6 @@ static void ext4_i_callback(struct rcu_head *head) | |||
919 | 919 | ||
920 | static void ext4_destroy_inode(struct inode *inode) | 920 | static void ext4_destroy_inode(struct inode *inode) |
921 | { | 921 | { |
922 | ext4_ioend_wait(inode); | ||
923 | if (!list_empty(&(EXT4_I(inode)->i_orphan))) { | 922 | if (!list_empty(&(EXT4_I(inode)->i_orphan))) { |
924 | ext4_msg(inode->i_sb, KERN_ERR, | 923 | ext4_msg(inode->i_sb, KERN_ERR, |
925 | "Inode %lu (%p): orphan list check failed!", | 924 | "Inode %lu (%p): orphan list check failed!", |
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c index 007c3bfbf094..34e4350dd4d9 100644 --- a/fs/ext4/xattr_security.c +++ b/fs/ext4/xattr_security.c | |||
@@ -48,28 +48,32 @@ ext4_xattr_security_set(struct dentry *dentry, const char *name, | |||
48 | name, value, size, flags); | 48 | name, value, size, flags); |
49 | } | 49 | } |
50 | 50 | ||
51 | int | 51 | int ext4_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
52 | ext4_init_security(handle_t *handle, struct inode *inode, struct inode *dir, | 52 | void *fs_info) |
53 | const struct qstr *qstr) | ||
54 | { | 53 | { |
55 | int err; | 54 | const struct xattr *xattr; |
56 | size_t len; | 55 | handle_t *handle = fs_info; |
57 | void *value; | 56 | int err = 0; |
58 | char *name; | ||
59 | 57 | ||
60 | err = security_inode_init_security(inode, dir, qstr, &name, &value, &len); | 58 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
61 | if (err) { | 59 | err = ext4_xattr_set_handle(handle, inode, |
62 | if (err == -EOPNOTSUPP) | 60 | EXT4_XATTR_INDEX_SECURITY, |
63 | return 0; | 61 | xattr->name, xattr->value, |
64 | return err; | 62 | xattr->value_len, 0); |
63 | if (err < 0) | ||
64 | break; | ||
65 | } | 65 | } |
66 | err = ext4_xattr_set_handle(handle, inode, EXT4_XATTR_INDEX_SECURITY, | ||
67 | name, value, len, 0); | ||
68 | kfree(name); | ||
69 | kfree(value); | ||
70 | return err; | 66 | return err; |
71 | } | 67 | } |
72 | 68 | ||
69 | int | ||
70 | ext4_init_security(handle_t *handle, struct inode *inode, struct inode *dir, | ||
71 | const struct qstr *qstr) | ||
72 | { | ||
73 | return security_inode_init_security(inode, dir, qstr, | ||
74 | &ext4_initxattrs, handle); | ||
75 | } | ||
76 | |||
73 | const struct xattr_handler ext4_xattr_security_handler = { | 77 | const struct xattr_handler ext4_xattr_security_handler = { |
74 | .prefix = XATTR_SECURITY_PREFIX, | 78 | .prefix = XATTR_SECURITY_PREFIX, |
75 | .list = ext4_xattr_security_list, | 79 | .list = ext4_xattr_security_list, |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 4ad64732cbce..5efbd5d7701a 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -1231,7 +1231,7 @@ int fat_add_entries(struct inode *dir, void *slots, int nr_slots, | |||
1231 | struct super_block *sb = dir->i_sb; | 1231 | struct super_block *sb = dir->i_sb; |
1232 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | 1232 | struct msdos_sb_info *sbi = MSDOS_SB(sb); |
1233 | struct buffer_head *bh, *prev, *bhs[3]; /* 32*slots (672bytes) */ | 1233 | struct buffer_head *bh, *prev, *bhs[3]; /* 32*slots (672bytes) */ |
1234 | struct msdos_dir_entry *de; | 1234 | struct msdos_dir_entry *uninitialized_var(de); |
1235 | int err, free_slots, i, nr_bhs; | 1235 | int err, free_slots, i, nr_bhs; |
1236 | loff_t pos, i_pos; | 1236 | loff_t pos, i_pos; |
1237 | 1237 | ||
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 5942fec22c65..1726d7303047 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -1188,9 +1188,9 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat, | |||
1188 | out: | 1188 | out: |
1189 | /* UTF-8 doesn't provide FAT semantics */ | 1189 | /* UTF-8 doesn't provide FAT semantics */ |
1190 | if (!strcmp(opts->iocharset, "utf8")) { | 1190 | if (!strcmp(opts->iocharset, "utf8")) { |
1191 | fat_msg(sb, KERN_ERR, "utf8 is not a recommended IO charset" | 1191 | fat_msg(sb, KERN_WARNING, "utf8 is not a recommended IO charset" |
1192 | " for FAT filesystems, filesystem will be " | 1192 | " for FAT filesystems, filesystem will be " |
1193 | "case sensitive!\n"); | 1193 | "case sensitive!"); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | /* If user doesn't specify allow_utime, it's initialized from dmask. */ | 1196 | /* If user doesn't specify allow_utime, it's initialized from dmask. */ |
@@ -1367,6 +1367,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1367 | sbi->free_clusters = -1; /* Don't know yet */ | 1367 | sbi->free_clusters = -1; /* Don't know yet */ |
1368 | sbi->free_clus_valid = 0; | 1368 | sbi->free_clus_valid = 0; |
1369 | sbi->prev_free = FAT_START_ENT; | 1369 | sbi->prev_free = FAT_START_ENT; |
1370 | sb->s_maxbytes = 0xffffffff; | ||
1370 | 1371 | ||
1371 | if (!sbi->fat_length && b->fat32_length) { | 1372 | if (!sbi->fat_length && b->fat32_length) { |
1372 | struct fat_boot_fsinfo *fsinfo; | 1373 | struct fat_boot_fsinfo *fsinfo; |
@@ -1377,8 +1378,6 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1377 | sbi->fat_length = le32_to_cpu(b->fat32_length); | 1378 | sbi->fat_length = le32_to_cpu(b->fat32_length); |
1378 | sbi->root_cluster = le32_to_cpu(b->root_cluster); | 1379 | sbi->root_cluster = le32_to_cpu(b->root_cluster); |
1379 | 1380 | ||
1380 | sb->s_maxbytes = 0xffffffff; | ||
1381 | |||
1382 | /* MC - if info_sector is 0, don't multiply by 0 */ | 1381 | /* MC - if info_sector is 0, don't multiply by 0 */ |
1383 | sbi->fsinfo_sector = le16_to_cpu(b->info_sector); | 1382 | sbi->fsinfo_sector = le16_to_cpu(b->info_sector); |
1384 | if (sbi->fsinfo_sector == 0) | 1383 | if (sbi->fsinfo_sector == 0) |
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 640fc229df10..5cb8614508c3 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -258,10 +258,14 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, | |||
258 | forget->forget_one.nlookup = nlookup; | 258 | forget->forget_one.nlookup = nlookup; |
259 | 259 | ||
260 | spin_lock(&fc->lock); | 260 | spin_lock(&fc->lock); |
261 | fc->forget_list_tail->next = forget; | 261 | if (fc->connected) { |
262 | fc->forget_list_tail = forget; | 262 | fc->forget_list_tail->next = forget; |
263 | wake_up(&fc->waitq); | 263 | fc->forget_list_tail = forget; |
264 | kill_fasync(&fc->fasync, SIGIO, POLL_IN); | 264 | wake_up(&fc->waitq); |
265 | kill_fasync(&fc->fasync, SIGIO, POLL_IN); | ||
266 | } else { | ||
267 | kfree(forget); | ||
268 | } | ||
265 | spin_unlock(&fc->lock); | 269 | spin_unlock(&fc->lock); |
266 | } | 270 | } |
267 | 271 | ||
@@ -1358,6 +1362,10 @@ static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size, | |||
1358 | if (outarg.namelen > FUSE_NAME_MAX) | 1362 | if (outarg.namelen > FUSE_NAME_MAX) |
1359 | goto err; | 1363 | goto err; |
1360 | 1364 | ||
1365 | err = -EINVAL; | ||
1366 | if (size != sizeof(outarg) + outarg.namelen + 1) | ||
1367 | goto err; | ||
1368 | |||
1361 | name.name = buf; | 1369 | name.name = buf; |
1362 | name.len = outarg.namelen; | 1370 | name.len = outarg.namelen; |
1363 | err = fuse_copy_one(cs, buf, outarg.namelen + 1); | 1371 | err = fuse_copy_one(cs, buf, outarg.namelen + 1); |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index d480d9af46c9..594f07a81c28 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/compat.h> | 16 | #include <linux/compat.h> |
17 | #include <linux/swap.h> | ||
17 | 18 | ||
18 | static const struct file_operations fuse_direct_io_file_operations; | 19 | static const struct file_operations fuse_direct_io_file_operations; |
19 | 20 | ||
@@ -245,6 +246,12 @@ void fuse_release_common(struct file *file, int opcode) | |||
245 | req = ff->reserved_req; | 246 | req = ff->reserved_req; |
246 | fuse_prepare_release(ff, file->f_flags, opcode); | 247 | fuse_prepare_release(ff, file->f_flags, opcode); |
247 | 248 | ||
249 | if (ff->flock) { | ||
250 | struct fuse_release_in *inarg = &req->misc.release.in; | ||
251 | inarg->release_flags |= FUSE_RELEASE_FLOCK_UNLOCK; | ||
252 | inarg->lock_owner = fuse_lock_owner_id(ff->fc, | ||
253 | (fl_owner_t) file); | ||
254 | } | ||
248 | /* Hold vfsmount and dentry until release is finished */ | 255 | /* Hold vfsmount and dentry until release is finished */ |
249 | path_get(&file->f_path); | 256 | path_get(&file->f_path); |
250 | req->misc.release.path = file->f_path; | 257 | req->misc.release.path = file->f_path; |
@@ -755,18 +762,6 @@ static size_t fuse_send_write(struct fuse_req *req, struct file *file, | |||
755 | return req->misc.write.out.size; | 762 | return req->misc.write.out.size; |
756 | } | 763 | } |
757 | 764 | ||
758 | static int fuse_write_begin(struct file *file, struct address_space *mapping, | ||
759 | loff_t pos, unsigned len, unsigned flags, | ||
760 | struct page **pagep, void **fsdata) | ||
761 | { | ||
762 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; | ||
763 | |||
764 | *pagep = grab_cache_page_write_begin(mapping, index, flags); | ||
765 | if (!*pagep) | ||
766 | return -ENOMEM; | ||
767 | return 0; | ||
768 | } | ||
769 | |||
770 | void fuse_write_update_size(struct inode *inode, loff_t pos) | 765 | void fuse_write_update_size(struct inode *inode, loff_t pos) |
771 | { | 766 | { |
772 | struct fuse_conn *fc = get_fuse_conn(inode); | 767 | struct fuse_conn *fc = get_fuse_conn(inode); |
@@ -779,62 +774,6 @@ void fuse_write_update_size(struct inode *inode, loff_t pos) | |||
779 | spin_unlock(&fc->lock); | 774 | spin_unlock(&fc->lock); |
780 | } | 775 | } |
781 | 776 | ||
782 | static int fuse_buffered_write(struct file *file, struct inode *inode, | ||
783 | loff_t pos, unsigned count, struct page *page) | ||
784 | { | ||
785 | int err; | ||
786 | size_t nres; | ||
787 | struct fuse_conn *fc = get_fuse_conn(inode); | ||
788 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); | ||
789 | struct fuse_req *req; | ||
790 | |||
791 | if (is_bad_inode(inode)) | ||
792 | return -EIO; | ||
793 | |||
794 | /* | ||
795 | * Make sure writepages on the same page are not mixed up with | ||
796 | * plain writes. | ||
797 | */ | ||
798 | fuse_wait_on_page_writeback(inode, page->index); | ||
799 | |||
800 | req = fuse_get_req(fc); | ||
801 | if (IS_ERR(req)) | ||
802 | return PTR_ERR(req); | ||
803 | |||
804 | req->in.argpages = 1; | ||
805 | req->num_pages = 1; | ||
806 | req->pages[0] = page; | ||
807 | req->page_offset = offset; | ||
808 | nres = fuse_send_write(req, file, pos, count, NULL); | ||
809 | err = req->out.h.error; | ||
810 | fuse_put_request(fc, req); | ||
811 | if (!err && !nres) | ||
812 | err = -EIO; | ||
813 | if (!err) { | ||
814 | pos += nres; | ||
815 | fuse_write_update_size(inode, pos); | ||
816 | if (count == PAGE_CACHE_SIZE) | ||
817 | SetPageUptodate(page); | ||
818 | } | ||
819 | fuse_invalidate_attr(inode); | ||
820 | return err ? err : nres; | ||
821 | } | ||
822 | |||
823 | static int fuse_write_end(struct file *file, struct address_space *mapping, | ||
824 | loff_t pos, unsigned len, unsigned copied, | ||
825 | struct page *page, void *fsdata) | ||
826 | { | ||
827 | struct inode *inode = mapping->host; | ||
828 | int res = 0; | ||
829 | |||
830 | if (copied) | ||
831 | res = fuse_buffered_write(file, inode, pos, copied, page); | ||
832 | |||
833 | unlock_page(page); | ||
834 | page_cache_release(page); | ||
835 | return res; | ||
836 | } | ||
837 | |||
838 | static size_t fuse_send_write_pages(struct fuse_req *req, struct file *file, | 777 | static size_t fuse_send_write_pages(struct fuse_req *req, struct file *file, |
839 | struct inode *inode, loff_t pos, | 778 | struct inode *inode, loff_t pos, |
840 | size_t count) | 779 | size_t count) |
@@ -908,6 +847,8 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req, | |||
908 | pagefault_enable(); | 847 | pagefault_enable(); |
909 | flush_dcache_page(page); | 848 | flush_dcache_page(page); |
910 | 849 | ||
850 | mark_page_accessed(page); | ||
851 | |||
911 | if (!tmp) { | 852 | if (!tmp) { |
912 | unlock_page(page); | 853 | unlock_page(page); |
913 | page_cache_release(page); | 854 | page_cache_release(page); |
@@ -1559,11 +1500,14 @@ static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl) | |||
1559 | struct fuse_conn *fc = get_fuse_conn(inode); | 1500 | struct fuse_conn *fc = get_fuse_conn(inode); |
1560 | int err; | 1501 | int err; |
1561 | 1502 | ||
1562 | if (fc->no_lock) { | 1503 | if (fc->no_flock) { |
1563 | err = flock_lock_file_wait(file, fl); | 1504 | err = flock_lock_file_wait(file, fl); |
1564 | } else { | 1505 | } else { |
1506 | struct fuse_file *ff = file->private_data; | ||
1507 | |||
1565 | /* emulate flock with POSIX locks */ | 1508 | /* emulate flock with POSIX locks */ |
1566 | fl->fl_owner = (fl_owner_t) file; | 1509 | fl->fl_owner = (fl_owner_t) file; |
1510 | ff->flock = true; | ||
1567 | err = fuse_setlk(file, fl, 1); | 1511 | err = fuse_setlk(file, fl, 1); |
1568 | } | 1512 | } |
1569 | 1513 | ||
@@ -2201,8 +2145,6 @@ static const struct address_space_operations fuse_file_aops = { | |||
2201 | .readpage = fuse_readpage, | 2145 | .readpage = fuse_readpage, |
2202 | .writepage = fuse_writepage, | 2146 | .writepage = fuse_writepage, |
2203 | .launder_page = fuse_launder_page, | 2147 | .launder_page = fuse_launder_page, |
2204 | .write_begin = fuse_write_begin, | ||
2205 | .write_end = fuse_write_end, | ||
2206 | .readpages = fuse_readpages, | 2148 | .readpages = fuse_readpages, |
2207 | .set_page_dirty = __set_page_dirty_nobuffers, | 2149 | .set_page_dirty = __set_page_dirty_nobuffers, |
2208 | .bmap = fuse_bmap, | 2150 | .bmap = fuse_bmap, |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index c6aa2d4b8517..cf6db0a93219 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -135,6 +135,9 @@ struct fuse_file { | |||
135 | 135 | ||
136 | /** Wait queue head for poll */ | 136 | /** Wait queue head for poll */ |
137 | wait_queue_head_t poll_wait; | 137 | wait_queue_head_t poll_wait; |
138 | |||
139 | /** Has flock been performed on this file? */ | ||
140 | bool flock:1; | ||
138 | }; | 141 | }; |
139 | 142 | ||
140 | /** One input argument of a request */ | 143 | /** One input argument of a request */ |
@@ -448,7 +451,7 @@ struct fuse_conn { | |||
448 | /** Is removexattr not implemented by fs? */ | 451 | /** Is removexattr not implemented by fs? */ |
449 | unsigned no_removexattr:1; | 452 | unsigned no_removexattr:1; |
450 | 453 | ||
451 | /** Are file locking primitives not implemented by fs? */ | 454 | /** Are posix file locking primitives not implemented by fs? */ |
452 | unsigned no_lock:1; | 455 | unsigned no_lock:1; |
453 | 456 | ||
454 | /** Is access not implemented by fs? */ | 457 | /** Is access not implemented by fs? */ |
@@ -472,6 +475,9 @@ struct fuse_conn { | |||
472 | /** Don't apply umask to creation modes */ | 475 | /** Don't apply umask to creation modes */ |
473 | unsigned dont_mask:1; | 476 | unsigned dont_mask:1; |
474 | 477 | ||
478 | /** Are BSD file locking primitives not implemented by fs? */ | ||
479 | unsigned no_flock:1; | ||
480 | |||
475 | /** The number of requests waiting for completion */ | 481 | /** The number of requests waiting for completion */ |
476 | atomic_t num_waiting; | 482 | atomic_t num_waiting; |
477 | 483 | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 38f84cd48b67..add96f6ffda5 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -71,7 +71,7 @@ struct fuse_mount_data { | |||
71 | unsigned blksize; | 71 | unsigned blksize; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | struct fuse_forget_link *fuse_alloc_forget() | 74 | struct fuse_forget_link *fuse_alloc_forget(void) |
75 | { | 75 | { |
76 | return kzalloc(sizeof(struct fuse_forget_link), GFP_KERNEL); | 76 | return kzalloc(sizeof(struct fuse_forget_link), GFP_KERNEL); |
77 | } | 77 | } |
@@ -809,6 +809,13 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | |||
809 | fc->async_read = 1; | 809 | fc->async_read = 1; |
810 | if (!(arg->flags & FUSE_POSIX_LOCKS)) | 810 | if (!(arg->flags & FUSE_POSIX_LOCKS)) |
811 | fc->no_lock = 1; | 811 | fc->no_lock = 1; |
812 | if (arg->minor >= 17) { | ||
813 | if (!(arg->flags & FUSE_FLOCK_LOCKS)) | ||
814 | fc->no_flock = 1; | ||
815 | } else { | ||
816 | if (!(arg->flags & FUSE_POSIX_LOCKS)) | ||
817 | fc->no_flock = 1; | ||
818 | } | ||
812 | if (arg->flags & FUSE_ATOMIC_O_TRUNC) | 819 | if (arg->flags & FUSE_ATOMIC_O_TRUNC) |
813 | fc->atomic_o_trunc = 1; | 820 | fc->atomic_o_trunc = 1; |
814 | if (arg->minor >= 9) { | 821 | if (arg->minor >= 9) { |
@@ -823,6 +830,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | |||
823 | } else { | 830 | } else { |
824 | ra_pages = fc->max_read / PAGE_CACHE_SIZE; | 831 | ra_pages = fc->max_read / PAGE_CACHE_SIZE; |
825 | fc->no_lock = 1; | 832 | fc->no_lock = 1; |
833 | fc->no_flock = 1; | ||
826 | } | 834 | } |
827 | 835 | ||
828 | fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); | 836 | fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); |
@@ -843,7 +851,8 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req) | |||
843 | arg->minor = FUSE_KERNEL_MINOR_VERSION; | 851 | arg->minor = FUSE_KERNEL_MINOR_VERSION; |
844 | arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; | 852 | arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; |
845 | arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | | 853 | arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | |
846 | FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK; | 854 | FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK | |
855 | FUSE_FLOCK_LOCKS; | ||
847 | req->in.h.opcode = FUSE_INIT; | 856 | req->in.h.opcode = FUSE_INIT; |
848 | req->in.numargs = 1; | 857 | req->in.numargs = 1; |
849 | req->in.args[0].size = sizeof(*arg); | 858 | req->in.args[0].size = sizeof(*arg); |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 900cf986aadc..6525b804d5ec 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -624,31 +624,29 @@ fail: | |||
624 | return error; | 624 | return error; |
625 | } | 625 | } |
626 | 626 | ||
627 | static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip, | 627 | int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
628 | const struct qstr *qstr) | 628 | void *fs_info) |
629 | { | 629 | { |
630 | int err; | 630 | const struct xattr *xattr; |
631 | size_t len; | 631 | int err = 0; |
632 | void *value; | 632 | |
633 | char *name; | 633 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
634 | 634 | err = __gfs2_xattr_set(inode, xattr->name, xattr->value, | |
635 | err = security_inode_init_security(&ip->i_inode, &dip->i_inode, qstr, | 635 | xattr->value_len, 0, |
636 | &name, &value, &len); | 636 | GFS2_EATYPE_SECURITY); |
637 | 637 | if (err < 0) | |
638 | if (err) { | 638 | break; |
639 | if (err == -EOPNOTSUPP) | ||
640 | return 0; | ||
641 | return err; | ||
642 | } | 639 | } |
643 | |||
644 | err = __gfs2_xattr_set(&ip->i_inode, name, value, len, 0, | ||
645 | GFS2_EATYPE_SECURITY); | ||
646 | kfree(value); | ||
647 | kfree(name); | ||
648 | |||
649 | return err; | 640 | return err; |
650 | } | 641 | } |
651 | 642 | ||
643 | static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip, | ||
644 | const struct qstr *qstr) | ||
645 | { | ||
646 | return security_inode_init_security(&ip->i_inode, &dip->i_inode, qstr, | ||
647 | &gfs2_initxattrs, NULL); | ||
648 | } | ||
649 | |||
652 | /** | 650 | /** |
653 | * gfs2_create_inode - Create a new inode | 651 | * gfs2_create_inode - Create a new inode |
654 | * @dir: The parent directory | 652 | * @dir: The parent directory |
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 85c62923ee29..598646434362 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c | |||
@@ -624,9 +624,9 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull) | |||
624 | bh->b_end_io = end_buffer_write_sync; | 624 | bh->b_end_io = end_buffer_write_sync; |
625 | get_bh(bh); | 625 | get_bh(bh); |
626 | if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) | 626 | if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) |
627 | submit_bh(WRITE_SYNC | REQ_META, bh); | 627 | submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh); |
628 | else | 628 | else |
629 | submit_bh(WRITE_FLUSH_FUA | REQ_META, bh); | 629 | submit_bh(WRITE_FLUSH_FUA | REQ_META | REQ_PRIO, bh); |
630 | wait_on_buffer(bh); | 630 | wait_on_buffer(bh); |
631 | 631 | ||
632 | if (!buffer_uptodate(bh)) | 632 | if (!buffer_uptodate(bh)) |
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 747238cd9f96..be29858900f6 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c | |||
@@ -37,7 +37,7 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb | |||
37 | { | 37 | { |
38 | struct buffer_head *bh, *head; | 38 | struct buffer_head *bh, *head; |
39 | int nr_underway = 0; | 39 | int nr_underway = 0; |
40 | int write_op = REQ_META | | 40 | int write_op = REQ_META | REQ_PRIO | |
41 | (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); | 41 | (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); |
42 | 42 | ||
43 | BUG_ON(!PageLocked(page)); | 43 | BUG_ON(!PageLocked(page)); |
@@ -225,7 +225,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, | |||
225 | } | 225 | } |
226 | bh->b_end_io = end_buffer_read_sync; | 226 | bh->b_end_io = end_buffer_read_sync; |
227 | get_bh(bh); | 227 | get_bh(bh); |
228 | submit_bh(READ_SYNC | REQ_META, bh); | 228 | submit_bh(READ_SYNC | REQ_META | REQ_PRIO, bh); |
229 | if (!(flags & DIO_WAIT)) | 229 | if (!(flags & DIO_WAIT)) |
230 | return 0; | 230 | return 0; |
231 | 231 | ||
@@ -435,7 +435,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen) | |||
435 | if (buffer_uptodate(first_bh)) | 435 | if (buffer_uptodate(first_bh)) |
436 | goto out; | 436 | goto out; |
437 | if (!buffer_locked(first_bh)) | 437 | if (!buffer_locked(first_bh)) |
438 | ll_rw_block(READ_SYNC | REQ_META, 1, &first_bh); | 438 | ll_rw_block(READ_SYNC | REQ_META | REQ_PRIO, 1, &first_bh); |
439 | 439 | ||
440 | dblock++; | 440 | dblock++; |
441 | extlen--; | 441 | extlen--; |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 3bc073a4cf82..079587e53849 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -224,7 +224,7 @@ static int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector, int silent) | |||
224 | 224 | ||
225 | bio->bi_end_io = end_bio_io_page; | 225 | bio->bi_end_io = end_bio_io_page; |
226 | bio->bi_private = page; | 226 | bio->bi_private = page; |
227 | submit_bio(READ_SYNC | REQ_META, bio); | 227 | submit_bio(READ_SYNC | REQ_META | REQ_PRIO, bio); |
228 | wait_on_page_locked(page); | 228 | wait_on_page_locked(page); |
229 | bio_put(bio); | 229 | bio_put(bio); |
230 | if (!PageUptodate(page)) { | 230 | if (!PageUptodate(page)) { |
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 42e8d23bc047..0e8bb13381e4 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -709,7 +709,7 @@ get_a_page: | |||
709 | set_buffer_uptodate(bh); | 709 | set_buffer_uptodate(bh); |
710 | 710 | ||
711 | if (!buffer_uptodate(bh)) { | 711 | if (!buffer_uptodate(bh)) { |
712 | ll_rw_block(READ_META, 1, &bh); | 712 | ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh); |
713 | wait_on_buffer(bh); | 713 | wait_on_buffer(bh); |
714 | if (!buffer_uptodate(bh)) | 714 | if (!buffer_uptodate(bh)) |
715 | goto unlock_out; | 715 | goto unlock_out; |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index c106ca22e812..d24a9b666a23 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -344,6 +344,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
344 | struct inode *root, *inode; | 344 | struct inode *root, *inode; |
345 | struct qstr str; | 345 | struct qstr str; |
346 | struct nls_table *nls = NULL; | 346 | struct nls_table *nls = NULL; |
347 | u64 last_fs_block, last_fs_page; | ||
347 | int err; | 348 | int err; |
348 | 349 | ||
349 | err = -EINVAL; | 350 | err = -EINVAL; |
@@ -399,9 +400,13 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
399 | if (!sbi->rsrc_clump_blocks) | 400 | if (!sbi->rsrc_clump_blocks) |
400 | sbi->rsrc_clump_blocks = 1; | 401 | sbi->rsrc_clump_blocks = 1; |
401 | 402 | ||
402 | err = generic_check_addressable(sbi->alloc_blksz_shift, | 403 | err = -EFBIG; |
403 | sbi->total_blocks); | 404 | last_fs_block = sbi->total_blocks - 1; |
404 | if (err) { | 405 | last_fs_page = (last_fs_block << sbi->alloc_blksz_shift) >> |
406 | PAGE_CACHE_SHIFT; | ||
407 | |||
408 | if ((last_fs_block > (sector_t)(~0ULL) >> (sbi->alloc_blksz_shift - 9)) || | ||
409 | (last_fs_page > (pgoff_t)(~0ULL))) { | ||
405 | printk(KERN_ERR "hfs: filesystem size too large.\n"); | 410 | printk(KERN_ERR "hfs: filesystem size too large.\n"); |
406 | goto out_free_vhdr; | 411 | goto out_free_vhdr; |
407 | } | 412 | } |
@@ -525,8 +530,8 @@ out_close_cat_tree: | |||
525 | out_close_ext_tree: | 530 | out_close_ext_tree: |
526 | hfs_btree_close(sbi->ext_tree); | 531 | hfs_btree_close(sbi->ext_tree); |
527 | out_free_vhdr: | 532 | out_free_vhdr: |
528 | kfree(sbi->s_vhdr); | 533 | kfree(sbi->s_vhdr_buf); |
529 | kfree(sbi->s_backup_vhdr); | 534 | kfree(sbi->s_backup_vhdr_buf); |
530 | out_unload_nls: | 535 | out_unload_nls: |
531 | unload_nls(sbi->nls); | 536 | unload_nls(sbi->nls); |
532 | unload_nls(nls); | 537 | unload_nls(nls); |
diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c index 10e515a0d452..7daf4b852d1c 100644 --- a/fs/hfsplus/wrapper.c +++ b/fs/hfsplus/wrapper.c | |||
@@ -272,9 +272,9 @@ reread: | |||
272 | return 0; | 272 | return 0; |
273 | 273 | ||
274 | out_free_backup_vhdr: | 274 | out_free_backup_vhdr: |
275 | kfree(sbi->s_backup_vhdr); | 275 | kfree(sbi->s_backup_vhdr_buf); |
276 | out_free_vhdr: | 276 | out_free_vhdr: |
277 | kfree(sbi->s_vhdr); | 277 | kfree(sbi->s_vhdr_buf); |
278 | out: | 278 | out: |
279 | return error; | 279 | return error; |
280 | } | 280 | } |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 87b6e0421c12..ec889538e5a6 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -491,6 +491,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, | |||
491 | inode->i_op = &page_symlink_inode_operations; | 491 | inode->i_op = &page_symlink_inode_operations; |
492 | break; | 492 | break; |
493 | } | 493 | } |
494 | lockdep_annotate_inode_mutex_key(inode); | ||
494 | } | 495 | } |
495 | return inode; | 496 | return inode; |
496 | } | 497 | } |
diff --git a/fs/inode.c b/fs/inode.c index 73920d555c88..ec7924696a13 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -848,16 +848,9 @@ struct inode *new_inode(struct super_block *sb) | |||
848 | } | 848 | } |
849 | EXPORT_SYMBOL(new_inode); | 849 | EXPORT_SYMBOL(new_inode); |
850 | 850 | ||
851 | /** | ||
852 | * unlock_new_inode - clear the I_NEW state and wake up any waiters | ||
853 | * @inode: new inode to unlock | ||
854 | * | ||
855 | * Called when the inode is fully initialised to clear the new state of the | ||
856 | * inode and wake up anyone waiting for the inode to finish initialisation. | ||
857 | */ | ||
858 | void unlock_new_inode(struct inode *inode) | ||
859 | { | ||
860 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 851 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
852 | void lockdep_annotate_inode_mutex_key(struct inode *inode) | ||
853 | { | ||
861 | if (S_ISDIR(inode->i_mode)) { | 854 | if (S_ISDIR(inode->i_mode)) { |
862 | struct file_system_type *type = inode->i_sb->s_type; | 855 | struct file_system_type *type = inode->i_sb->s_type; |
863 | 856 | ||
@@ -873,7 +866,20 @@ void unlock_new_inode(struct inode *inode) | |||
873 | &type->i_mutex_dir_key); | 866 | &type->i_mutex_dir_key); |
874 | } | 867 | } |
875 | } | 868 | } |
869 | } | ||
870 | EXPORT_SYMBOL(lockdep_annotate_inode_mutex_key); | ||
876 | #endif | 871 | #endif |
872 | |||
873 | /** | ||
874 | * unlock_new_inode - clear the I_NEW state and wake up any waiters | ||
875 | * @inode: new inode to unlock | ||
876 | * | ||
877 | * Called when the inode is fully initialised to clear the new state of the | ||
878 | * inode and wake up anyone waiting for the inode to finish initialisation. | ||
879 | */ | ||
880 | void unlock_new_inode(struct inode *inode) | ||
881 | { | ||
882 | lockdep_annotate_inode_mutex_key(inode); | ||
877 | spin_lock(&inode->i_lock); | 883 | spin_lock(&inode->i_lock); |
878 | WARN_ON(!(inode->i_state & I_NEW)); | 884 | WARN_ON(!(inode->i_state & I_NEW)); |
879 | inode->i_state &= ~I_NEW; | 885 | inode->i_state &= ~I_NEW; |
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c index cfeb7164b085..0f20208df602 100644 --- a/fs/jffs2/security.c +++ b/fs/jffs2/security.c | |||
@@ -22,26 +22,29 @@ | |||
22 | #include <linux/security.h> | 22 | #include <linux/security.h> |
23 | #include "nodelist.h" | 23 | #include "nodelist.h" |
24 | 24 | ||
25 | /* ---- Initial Security Label Attachment -------------- */ | 25 | /* ---- Initial Security Label(s) Attachment callback --- */ |
26 | int jffs2_init_security(struct inode *inode, struct inode *dir, | 26 | int jffs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
27 | const struct qstr *qstr) | 27 | void *fs_info) |
28 | { | 28 | { |
29 | int rc; | 29 | const struct xattr *xattr; |
30 | size_t len; | 30 | int err = 0; |
31 | void *value; | ||
32 | char *name; | ||
33 | 31 | ||
34 | rc = security_inode_init_security(inode, dir, qstr, &name, &value, &len); | 32 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
35 | if (rc) { | 33 | err = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, |
36 | if (rc == -EOPNOTSUPP) | 34 | xattr->name, xattr->value, |
37 | return 0; | 35 | xattr->value_len, 0); |
38 | return rc; | 36 | if (err < 0) |
37 | break; | ||
39 | } | 38 | } |
40 | rc = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, value, len, 0); | 39 | return err; |
40 | } | ||
41 | 41 | ||
42 | kfree(name); | 42 | /* ---- Initial Security Label(s) Attachment ----------- */ |
43 | kfree(value); | 43 | int jffs2_init_security(struct inode *inode, struct inode *dir, |
44 | return rc; | 44 | const struct qstr *qstr) |
45 | { | ||
46 | return security_inode_init_security(inode, dir, qstr, | ||
47 | &jffs2_initxattrs, NULL); | ||
45 | } | 48 | } |
46 | 49 | ||
47 | /* ---- XATTR Handler for "security.*" ----------------- */ | 50 | /* ---- XATTR Handler for "security.*" ----------------- */ |
diff --git a/fs/jfs/jfs_umount.c b/fs/jfs/jfs_umount.c index adcf92d3b603..7971f37534a3 100644 --- a/fs/jfs/jfs_umount.c +++ b/fs/jfs/jfs_umount.c | |||
@@ -68,7 +68,7 @@ int jfs_umount(struct super_block *sb) | |||
68 | /* | 68 | /* |
69 | * Wait for outstanding transactions to be written to log: | 69 | * Wait for outstanding transactions to be written to log: |
70 | */ | 70 | */ |
71 | jfs_flush_journal(log, 1); | 71 | jfs_flush_journal(log, 2); |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * close fileset inode allocation map (aka fileset inode) | 74 | * close fileset inode allocation map (aka fileset inode) |
@@ -146,7 +146,7 @@ int jfs_umount_rw(struct super_block *sb) | |||
146 | * | 146 | * |
147 | * remove file system from log active file system list. | 147 | * remove file system from log active file system list. |
148 | */ | 148 | */ |
149 | jfs_flush_journal(log, 1); | 149 | jfs_flush_journal(log, 2); |
150 | 150 | ||
151 | /* | 151 | /* |
152 | * Make sure all metadata makes it to disk | 152 | * Make sure all metadata makes it to disk |
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index e87fedef23db..26683e15b3ac 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c | |||
@@ -1089,38 +1089,37 @@ int jfs_removexattr(struct dentry *dentry, const char *name) | |||
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | #ifdef CONFIG_JFS_SECURITY | 1091 | #ifdef CONFIG_JFS_SECURITY |
1092 | int jfs_init_security(tid_t tid, struct inode *inode, struct inode *dir, | 1092 | int jfs_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
1093 | const struct qstr *qstr) | 1093 | void *fs_info) |
1094 | { | 1094 | { |
1095 | int rc; | 1095 | const struct xattr *xattr; |
1096 | size_t len; | 1096 | tid_t *tid = fs_info; |
1097 | void *value; | ||
1098 | char *suffix; | ||
1099 | char *name; | 1097 | char *name; |
1100 | 1098 | int err = 0; | |
1101 | rc = security_inode_init_security(inode, dir, qstr, &suffix, &value, | 1099 | |
1102 | &len); | 1100 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
1103 | if (rc) { | 1101 | name = kmalloc(XATTR_SECURITY_PREFIX_LEN + |
1104 | if (rc == -EOPNOTSUPP) | 1102 | strlen(xattr->name) + 1, GFP_NOFS); |
1105 | return 0; | 1103 | if (!name) { |
1106 | return rc; | 1104 | err = -ENOMEM; |
1107 | } | 1105 | break; |
1108 | name = kmalloc(XATTR_SECURITY_PREFIX_LEN + 1 + strlen(suffix), | 1106 | } |
1109 | GFP_NOFS); | 1107 | strcpy(name, XATTR_SECURITY_PREFIX); |
1110 | if (!name) { | 1108 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, xattr->name); |
1111 | rc = -ENOMEM; | 1109 | |
1112 | goto kmalloc_failed; | 1110 | err = __jfs_setxattr(*tid, inode, name, |
1111 | xattr->value, xattr->value_len, 0); | ||
1112 | kfree(name); | ||
1113 | if (err < 0) | ||
1114 | break; | ||
1113 | } | 1115 | } |
1114 | strcpy(name, XATTR_SECURITY_PREFIX); | 1116 | return err; |
1115 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); | 1117 | } |
1116 | |||
1117 | rc = __jfs_setxattr(tid, inode, name, value, len, 0); | ||
1118 | |||
1119 | kfree(name); | ||
1120 | kmalloc_failed: | ||
1121 | kfree(suffix); | ||
1122 | kfree(value); | ||
1123 | 1118 | ||
1124 | return rc; | 1119 | int jfs_init_security(tid_t tid, struct inode *inode, struct inode *dir, |
1120 | const struct qstr *qstr) | ||
1121 | { | ||
1122 | return security_inode_init_security(inode, dir, qstr, | ||
1123 | &jfs_initxattrs, &tid); | ||
1125 | } | 1124 | } |
1126 | #endif | 1125 | #endif |
diff --git a/fs/locks.c b/fs/locks.c index b342902c38bc..3b0d05dcd7c1 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -60,7 +60,7 @@ | |||
60 | * | 60 | * |
61 | * Initial implementation of mandatory locks. SunOS turned out to be | 61 | * Initial implementation of mandatory locks. SunOS turned out to be |
62 | * a rotten model, so I implemented the "obvious" semantics. | 62 | * a rotten model, so I implemented the "obvious" semantics. |
63 | * See 'Documentation/mandatory.txt' for details. | 63 | * See 'Documentation/filesystems/mandatory-locking.txt' for details. |
64 | * Andy Walker (andy@lysaker.kvaerner.no), April 06, 1996. | 64 | * Andy Walker (andy@lysaker.kvaerner.no), April 06, 1996. |
65 | * | 65 | * |
66 | * Don't allow mandatory locks on mmap()'ed files. Added simple functions to | 66 | * Don't allow mandatory locks on mmap()'ed files. Added simple functions to |
diff --git a/fs/namei.c b/fs/namei.c index 2826db35dc25..0b3138de2a3b 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -721,31 +721,22 @@ static int follow_automount(struct path *path, unsigned flags, | |||
721 | if (!path->dentry->d_op || !path->dentry->d_op->d_automount) | 721 | if (!path->dentry->d_op || !path->dentry->d_op->d_automount) |
722 | return -EREMOTE; | 722 | return -EREMOTE; |
723 | 723 | ||
724 | /* We don't want to mount if someone supplied AT_NO_AUTOMOUNT | 724 | /* We don't want to mount if someone's just doing a stat - |
725 | * and this is the terminal part of the path. | 725 | * unless they're stat'ing a directory and appended a '/' to |
726 | * the name. | ||
727 | * | ||
728 | * We do, however, want to mount if someone wants to open or | ||
729 | * create a file of any type under the mountpoint, wants to | ||
730 | * traverse through the mountpoint or wants to open the | ||
731 | * mounted directory. Also, autofs may mark negative dentries | ||
732 | * as being automount points. These will need the attentions | ||
733 | * of the daemon to instantiate them before they can be used. | ||
726 | */ | 734 | */ |
727 | if ((flags & LOOKUP_NO_AUTOMOUNT) && !(flags & LOOKUP_PARENT)) | 735 | if (!(flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | |
728 | return -EISDIR; /* we actually want to stop here */ | 736 | LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) && |
737 | path->dentry->d_inode) | ||
738 | return -EISDIR; | ||
729 | 739 | ||
730 | /* | ||
731 | * We don't want to mount if someone's just doing a stat and they've | ||
732 | * set AT_SYMLINK_NOFOLLOW - unless they're stat'ing a directory and | ||
733 | * appended a '/' to the name. | ||
734 | */ | ||
735 | if (!(flags & LOOKUP_FOLLOW)) { | ||
736 | /* We do, however, want to mount if someone wants to open or | ||
737 | * create a file of any type under the mountpoint, wants to | ||
738 | * traverse through the mountpoint or wants to open the mounted | ||
739 | * directory. | ||
740 | * Also, autofs may mark negative dentries as being automount | ||
741 | * points. These will need the attentions of the daemon to | ||
742 | * instantiate them before they can be used. | ||
743 | */ | ||
744 | if (!(flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | | ||
745 | LOOKUP_OPEN | LOOKUP_CREATE)) && | ||
746 | path->dentry->d_inode) | ||
747 | return -EISDIR; | ||
748 | } | ||
749 | current->total_link_count++; | 740 | current->total_link_count++; |
750 | if (current->total_link_count >= 40) | 741 | if (current->total_link_count >= 40) |
751 | return -ELOOP; | 742 | return -ELOOP; |
@@ -2619,6 +2610,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
2619 | if (!dir->i_op->rmdir) | 2610 | if (!dir->i_op->rmdir) |
2620 | return -EPERM; | 2611 | return -EPERM; |
2621 | 2612 | ||
2613 | dget(dentry); | ||
2622 | mutex_lock(&dentry->d_inode->i_mutex); | 2614 | mutex_lock(&dentry->d_inode->i_mutex); |
2623 | 2615 | ||
2624 | error = -EBUSY; | 2616 | error = -EBUSY; |
@@ -2639,6 +2631,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
2639 | 2631 | ||
2640 | out: | 2632 | out: |
2641 | mutex_unlock(&dentry->d_inode->i_mutex); | 2633 | mutex_unlock(&dentry->d_inode->i_mutex); |
2634 | dput(dentry); | ||
2642 | if (!error) | 2635 | if (!error) |
2643 | d_delete(dentry); | 2636 | d_delete(dentry); |
2644 | return error; | 2637 | return error; |
@@ -3028,6 +3021,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, | |||
3028 | if (error) | 3021 | if (error) |
3029 | return error; | 3022 | return error; |
3030 | 3023 | ||
3024 | dget(new_dentry); | ||
3031 | if (target) | 3025 | if (target) |
3032 | mutex_lock(&target->i_mutex); | 3026 | mutex_lock(&target->i_mutex); |
3033 | 3027 | ||
@@ -3048,6 +3042,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, | |||
3048 | out: | 3042 | out: |
3049 | if (target) | 3043 | if (target) |
3050 | mutex_unlock(&target->i_mutex); | 3044 | mutex_unlock(&target->i_mutex); |
3045 | dput(new_dentry); | ||
3051 | if (!error) | 3046 | if (!error) |
3052 | if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) | 3047 | if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) |
3053 | d_move(old_dentry,new_dentry); | 3048 | d_move(old_dentry,new_dentry); |
diff --git a/fs/namespace.c b/fs/namespace.c index 22bfe8273c68..b4febb29d3bb 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -1757,7 +1757,7 @@ static int do_loopback(struct path *path, char *old_name, | |||
1757 | return err; | 1757 | return err; |
1758 | if (!old_name || !*old_name) | 1758 | if (!old_name || !*old_name) |
1759 | return -EINVAL; | 1759 | return -EINVAL; |
1760 | err = kern_path(old_name, LOOKUP_FOLLOW, &old_path); | 1760 | err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path); |
1761 | if (err) | 1761 | if (err) |
1762 | return err; | 1762 | return err; |
1763 | 1763 | ||
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig index be020771c6b4..dbcd82126aed 100644 --- a/fs/nfs/Kconfig +++ b/fs/nfs/Kconfig | |||
@@ -79,12 +79,9 @@ config NFS_V4_1 | |||
79 | depends on NFS_FS && NFS_V4 && EXPERIMENTAL | 79 | depends on NFS_FS && NFS_V4 && EXPERIMENTAL |
80 | select SUNRPC_BACKCHANNEL | 80 | select SUNRPC_BACKCHANNEL |
81 | select PNFS_FILE_LAYOUT | 81 | select PNFS_FILE_LAYOUT |
82 | select PNFS_BLOCK | ||
83 | select MD | ||
84 | select BLK_DEV_DM | ||
85 | help | 82 | help |
86 | This option enables support for minor version 1 of the NFSv4 protocol | 83 | This option enables support for minor version 1 of the NFSv4 protocol |
87 | (RFC 5661 and RFC 5663) in the kernel's NFS client. | 84 | (RFC 5661) in the kernel's NFS client. |
88 | 85 | ||
89 | If unsure, say N. | 86 | If unsure, say N. |
90 | 87 | ||
@@ -93,16 +90,13 @@ config PNFS_FILE_LAYOUT | |||
93 | 90 | ||
94 | config PNFS_BLOCK | 91 | config PNFS_BLOCK |
95 | tristate | 92 | tristate |
93 | depends on NFS_FS && NFS_V4_1 && BLK_DEV_DM | ||
94 | default m | ||
96 | 95 | ||
97 | config PNFS_OBJLAYOUT | 96 | config PNFS_OBJLAYOUT |
98 | tristate "Provide support for the pNFS Objects Layout Driver for NFSv4.1 pNFS (EXPERIMENTAL)" | 97 | tristate |
99 | depends on NFS_FS && NFS_V4_1 && SCSI_OSD_ULD | 98 | depends on NFS_FS && NFS_V4_1 && SCSI_OSD_ULD |
100 | help | 99 | default m |
101 | Say M here if you want your pNFS client to support the Objects Layout Driver. | ||
102 | Requires the SCSI osd initiator library (SCSI_OSD_INITIATOR) and | ||
103 | upper level driver (SCSI_OSD_ULD). | ||
104 | |||
105 | If unsure, say N. | ||
106 | 100 | ||
107 | config ROOT_NFS | 101 | config ROOT_NFS |
108 | bool "Root file system on NFS" | 102 | bool "Root file system on NFS" |
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index e56564d2ef95..9561c8fc8bdb 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/namei.h> | 36 | #include <linux/namei.h> |
37 | #include <linux/bio.h> /* struct bio */ | 37 | #include <linux/bio.h> /* struct bio */ |
38 | #include <linux/buffer_head.h> /* various write calls */ | 38 | #include <linux/buffer_head.h> /* various write calls */ |
39 | #include <linux/prefetch.h> | ||
39 | 40 | ||
40 | #include "blocklayout.h" | 41 | #include "blocklayout.h" |
41 | 42 | ||
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index b257383bb565..07df5f1d85e5 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h | |||
@@ -38,6 +38,7 @@ enum nfs4_callback_opnum { | |||
38 | struct cb_process_state { | 38 | struct cb_process_state { |
39 | __be32 drc_status; | 39 | __be32 drc_status; |
40 | struct nfs_client *clp; | 40 | struct nfs_client *clp; |
41 | int slotid; | ||
41 | }; | 42 | }; |
42 | 43 | ||
43 | struct cb_compound_hdr_arg { | 44 | struct cb_compound_hdr_arg { |
@@ -166,7 +167,6 @@ extern unsigned nfs4_callback_layoutrecall( | |||
166 | void *dummy, struct cb_process_state *cps); | 167 | void *dummy, struct cb_process_state *cps); |
167 | 168 | ||
168 | extern void nfs4_check_drain_bc_complete(struct nfs4_session *ses); | 169 | extern void nfs4_check_drain_bc_complete(struct nfs4_session *ses); |
169 | extern void nfs4_cb_take_slot(struct nfs_client *clp); | ||
170 | 170 | ||
171 | struct cb_devicenotifyitem { | 171 | struct cb_devicenotifyitem { |
172 | uint32_t cbd_notify_type; | 172 | uint32_t cbd_notify_type; |
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 74780f9f852c..43926add945b 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c | |||
@@ -348,7 +348,7 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args) | |||
348 | /* Normal */ | 348 | /* Normal */ |
349 | if (likely(args->csa_sequenceid == slot->seq_nr + 1)) { | 349 | if (likely(args->csa_sequenceid == slot->seq_nr + 1)) { |
350 | slot->seq_nr++; | 350 | slot->seq_nr++; |
351 | return htonl(NFS4_OK); | 351 | goto out_ok; |
352 | } | 352 | } |
353 | 353 | ||
354 | /* Replay */ | 354 | /* Replay */ |
@@ -367,11 +367,14 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args) | |||
367 | /* Wraparound */ | 367 | /* Wraparound */ |
368 | if (args->csa_sequenceid == 1 && (slot->seq_nr + 1) == 0) { | 368 | if (args->csa_sequenceid == 1 && (slot->seq_nr + 1) == 0) { |
369 | slot->seq_nr = 1; | 369 | slot->seq_nr = 1; |
370 | return htonl(NFS4_OK); | 370 | goto out_ok; |
371 | } | 371 | } |
372 | 372 | ||
373 | /* Misordered request */ | 373 | /* Misordered request */ |
374 | return htonl(NFS4ERR_SEQ_MISORDERED); | 374 | return htonl(NFS4ERR_SEQ_MISORDERED); |
375 | out_ok: | ||
376 | tbl->highest_used_slotid = args->csa_slotid; | ||
377 | return htonl(NFS4_OK); | ||
375 | } | 378 | } |
376 | 379 | ||
377 | /* | 380 | /* |
@@ -433,26 +436,37 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, | |||
433 | struct cb_sequenceres *res, | 436 | struct cb_sequenceres *res, |
434 | struct cb_process_state *cps) | 437 | struct cb_process_state *cps) |
435 | { | 438 | { |
439 | struct nfs4_slot_table *tbl; | ||
436 | struct nfs_client *clp; | 440 | struct nfs_client *clp; |
437 | int i; | 441 | int i; |
438 | __be32 status = htonl(NFS4ERR_BADSESSION); | 442 | __be32 status = htonl(NFS4ERR_BADSESSION); |
439 | 443 | ||
440 | cps->clp = NULL; | ||
441 | |||
442 | clp = nfs4_find_client_sessionid(args->csa_addr, &args->csa_sessionid); | 444 | clp = nfs4_find_client_sessionid(args->csa_addr, &args->csa_sessionid); |
443 | if (clp == NULL) | 445 | if (clp == NULL) |
444 | goto out; | 446 | goto out; |
445 | 447 | ||
448 | tbl = &clp->cl_session->bc_slot_table; | ||
449 | |||
450 | spin_lock(&tbl->slot_tbl_lock); | ||
446 | /* state manager is resetting the session */ | 451 | /* state manager is resetting the session */ |
447 | if (test_bit(NFS4_SESSION_DRAINING, &clp->cl_session->session_state)) { | 452 | if (test_bit(NFS4_SESSION_DRAINING, &clp->cl_session->session_state)) { |
448 | status = NFS4ERR_DELAY; | 453 | spin_unlock(&tbl->slot_tbl_lock); |
454 | status = htonl(NFS4ERR_DELAY); | ||
455 | /* Return NFS4ERR_BADSESSION if we're draining the session | ||
456 | * in order to reset it. | ||
457 | */ | ||
458 | if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state)) | ||
459 | status = htonl(NFS4ERR_BADSESSION); | ||
449 | goto out; | 460 | goto out; |
450 | } | 461 | } |
451 | 462 | ||
452 | status = validate_seqid(&clp->cl_session->bc_slot_table, args); | 463 | status = validate_seqid(&clp->cl_session->bc_slot_table, args); |
464 | spin_unlock(&tbl->slot_tbl_lock); | ||
453 | if (status) | 465 | if (status) |
454 | goto out; | 466 | goto out; |
455 | 467 | ||
468 | cps->slotid = args->csa_slotid; | ||
469 | |||
456 | /* | 470 | /* |
457 | * Check for pending referring calls. If a match is found, a | 471 | * Check for pending referring calls. If a match is found, a |
458 | * related callback was received before the response to the original | 472 | * related callback was received before the response to the original |
@@ -469,7 +483,6 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, | |||
469 | res->csr_slotid = args->csa_slotid; | 483 | res->csr_slotid = args->csa_slotid; |
470 | res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; | 484 | res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; |
471 | res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; | 485 | res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; |
472 | nfs4_cb_take_slot(clp); | ||
473 | 486 | ||
474 | out: | 487 | out: |
475 | cps->clp = clp; /* put in nfs4_callback_compound */ | 488 | cps->clp = clp; /* put in nfs4_callback_compound */ |
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index c6c86a77e043..918ad647afea 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c | |||
@@ -754,26 +754,15 @@ static void nfs4_callback_free_slot(struct nfs4_session *session) | |||
754 | * Let the state manager know callback processing done. | 754 | * Let the state manager know callback processing done. |
755 | * A single slot, so highest used slotid is either 0 or -1 | 755 | * A single slot, so highest used slotid is either 0 or -1 |
756 | */ | 756 | */ |
757 | tbl->highest_used_slotid--; | 757 | tbl->highest_used_slotid = -1; |
758 | nfs4_check_drain_bc_complete(session); | 758 | nfs4_check_drain_bc_complete(session); |
759 | spin_unlock(&tbl->slot_tbl_lock); | 759 | spin_unlock(&tbl->slot_tbl_lock); |
760 | } | 760 | } |
761 | 761 | ||
762 | static void nfs4_cb_free_slot(struct nfs_client *clp) | 762 | static void nfs4_cb_free_slot(struct cb_process_state *cps) |
763 | { | 763 | { |
764 | if (clp && clp->cl_session) | 764 | if (cps->slotid != -1) |
765 | nfs4_callback_free_slot(clp->cl_session); | 765 | nfs4_callback_free_slot(cps->clp->cl_session); |
766 | } | ||
767 | |||
768 | /* A single slot, so highest used slotid is either 0 or -1 */ | ||
769 | void nfs4_cb_take_slot(struct nfs_client *clp) | ||
770 | { | ||
771 | struct nfs4_slot_table *tbl = &clp->cl_session->bc_slot_table; | ||
772 | |||
773 | spin_lock(&tbl->slot_tbl_lock); | ||
774 | tbl->highest_used_slotid++; | ||
775 | BUG_ON(tbl->highest_used_slotid != 0); | ||
776 | spin_unlock(&tbl->slot_tbl_lock); | ||
777 | } | 766 | } |
778 | 767 | ||
779 | #else /* CONFIG_NFS_V4_1 */ | 768 | #else /* CONFIG_NFS_V4_1 */ |
@@ -784,7 +773,7 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) | |||
784 | return htonl(NFS4ERR_MINOR_VERS_MISMATCH); | 773 | return htonl(NFS4ERR_MINOR_VERS_MISMATCH); |
785 | } | 774 | } |
786 | 775 | ||
787 | static void nfs4_cb_free_slot(struct nfs_client *clp) | 776 | static void nfs4_cb_free_slot(struct cb_process_state *cps) |
788 | { | 777 | { |
789 | } | 778 | } |
790 | #endif /* CONFIG_NFS_V4_1 */ | 779 | #endif /* CONFIG_NFS_V4_1 */ |
@@ -866,6 +855,7 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *r | |||
866 | struct cb_process_state cps = { | 855 | struct cb_process_state cps = { |
867 | .drc_status = 0, | 856 | .drc_status = 0, |
868 | .clp = NULL, | 857 | .clp = NULL, |
858 | .slotid = -1, | ||
869 | }; | 859 | }; |
870 | unsigned int nops = 0; | 860 | unsigned int nops = 0; |
871 | 861 | ||
@@ -906,7 +896,7 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *r | |||
906 | 896 | ||
907 | *hdr_res.status = status; | 897 | *hdr_res.status = status; |
908 | *hdr_res.nops = htonl(nops); | 898 | *hdr_res.nops = htonl(nops); |
909 | nfs4_cb_free_slot(cps.clp); | 899 | nfs4_cb_free_slot(&cps); |
910 | nfs_put_client(cps.clp); | 900 | nfs_put_client(cps.clp); |
911 | dprintk("%s: done, status = %u\n", __func__, ntohl(status)); | 901 | dprintk("%s: done, status = %u\n", __func__, ntohl(status)); |
912 | return rpc_success; | 902 | return rpc_success; |
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 1a652a0bd7db..693ae22f8731 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -32,6 +32,9 @@ enum nfs4_session_state { | |||
32 | NFS4_SESSION_DRAINING, | 32 | NFS4_SESSION_DRAINING, |
33 | }; | 33 | }; |
34 | 34 | ||
35 | #define NFS4_RENEW_TIMEOUT 0x01 | ||
36 | #define NFS4_RENEW_DELEGATION_CB 0x02 | ||
37 | |||
35 | struct nfs4_minor_version_ops { | 38 | struct nfs4_minor_version_ops { |
36 | u32 minor_version; | 39 | u32 minor_version; |
37 | 40 | ||
@@ -201,7 +204,7 @@ struct nfs4_state_recovery_ops { | |||
201 | }; | 204 | }; |
202 | 205 | ||
203 | struct nfs4_state_maintenance_ops { | 206 | struct nfs4_state_maintenance_ops { |
204 | int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *); | 207 | int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *, unsigned); |
205 | struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *); | 208 | struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *); |
206 | int (*renew_lease)(struct nfs_client *, struct rpc_cred *); | 209 | int (*renew_lease)(struct nfs_client *, struct rpc_cred *); |
207 | }; | 210 | }; |
@@ -213,8 +216,6 @@ extern const struct inode_operations nfs4_dir_inode_operations; | |||
213 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *); | 216 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *); |
214 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *); | 217 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *); |
215 | extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); | 218 | extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); |
216 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); | ||
217 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); | ||
218 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); | 219 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); |
219 | extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); | 220 | extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); |
220 | extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc); | 221 | extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc); |
@@ -325,6 +326,7 @@ extern void nfs4_close_sync(struct nfs4_state *, fmode_t); | |||
325 | extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t); | 326 | extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t); |
326 | extern void nfs4_schedule_lease_recovery(struct nfs_client *); | 327 | extern void nfs4_schedule_lease_recovery(struct nfs_client *); |
327 | extern void nfs4_schedule_state_manager(struct nfs_client *); | 328 | extern void nfs4_schedule_state_manager(struct nfs_client *); |
329 | extern void nfs4_schedule_path_down_recovery(struct nfs_client *clp); | ||
328 | extern void nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *); | 330 | extern void nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *); |
329 | extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags); | 331 | extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags); |
330 | extern void nfs41_handle_recall_slot(struct nfs_client *clp); | 332 | extern void nfs41_handle_recall_slot(struct nfs_client *clp); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 8c77039e7a81..4700fae1ada0 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -3374,9 +3374,13 @@ static void nfs4_renew_done(struct rpc_task *task, void *calldata) | |||
3374 | 3374 | ||
3375 | if (task->tk_status < 0) { | 3375 | if (task->tk_status < 0) { |
3376 | /* Unless we're shutting down, schedule state recovery! */ | 3376 | /* Unless we're shutting down, schedule state recovery! */ |
3377 | if (test_bit(NFS_CS_RENEWD, &clp->cl_res_state) != 0) | 3377 | if (test_bit(NFS_CS_RENEWD, &clp->cl_res_state) == 0) |
3378 | return; | ||
3379 | if (task->tk_status != NFS4ERR_CB_PATH_DOWN) { | ||
3378 | nfs4_schedule_lease_recovery(clp); | 3380 | nfs4_schedule_lease_recovery(clp); |
3379 | return; | 3381 | return; |
3382 | } | ||
3383 | nfs4_schedule_path_down_recovery(clp); | ||
3380 | } | 3384 | } |
3381 | do_renew_lease(clp, timestamp); | 3385 | do_renew_lease(clp, timestamp); |
3382 | } | 3386 | } |
@@ -3386,7 +3390,7 @@ static const struct rpc_call_ops nfs4_renew_ops = { | |||
3386 | .rpc_release = nfs4_renew_release, | 3390 | .rpc_release = nfs4_renew_release, |
3387 | }; | 3391 | }; |
3388 | 3392 | ||
3389 | int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred) | 3393 | static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags) |
3390 | { | 3394 | { |
3391 | struct rpc_message msg = { | 3395 | struct rpc_message msg = { |
3392 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], | 3396 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], |
@@ -3395,9 +3399,11 @@ int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred) | |||
3395 | }; | 3399 | }; |
3396 | struct nfs4_renewdata *data; | 3400 | struct nfs4_renewdata *data; |
3397 | 3401 | ||
3402 | if (renew_flags == 0) | ||
3403 | return 0; | ||
3398 | if (!atomic_inc_not_zero(&clp->cl_count)) | 3404 | if (!atomic_inc_not_zero(&clp->cl_count)) |
3399 | return -EIO; | 3405 | return -EIO; |
3400 | data = kmalloc(sizeof(*data), GFP_KERNEL); | 3406 | data = kmalloc(sizeof(*data), GFP_NOFS); |
3401 | if (data == NULL) | 3407 | if (data == NULL) |
3402 | return -ENOMEM; | 3408 | return -ENOMEM; |
3403 | data->client = clp; | 3409 | data->client = clp; |
@@ -3406,7 +3412,7 @@ int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred) | |||
3406 | &nfs4_renew_ops, data); | 3412 | &nfs4_renew_ops, data); |
3407 | } | 3413 | } |
3408 | 3414 | ||
3409 | int nfs4_proc_renew(struct nfs_client *clp, struct rpc_cred *cred) | 3415 | static int nfs4_proc_renew(struct nfs_client *clp, struct rpc_cred *cred) |
3410 | { | 3416 | { |
3411 | struct rpc_message msg = { | 3417 | struct rpc_message msg = { |
3412 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], | 3418 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], |
@@ -5504,11 +5510,13 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, struct rpc_ | |||
5504 | return rpc_run_task(&task_setup_data); | 5510 | return rpc_run_task(&task_setup_data); |
5505 | } | 5511 | } |
5506 | 5512 | ||
5507 | static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cred) | 5513 | static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags) |
5508 | { | 5514 | { |
5509 | struct rpc_task *task; | 5515 | struct rpc_task *task; |
5510 | int ret = 0; | 5516 | int ret = 0; |
5511 | 5517 | ||
5518 | if ((renew_flags & NFS4_RENEW_TIMEOUT) == 0) | ||
5519 | return 0; | ||
5512 | task = _nfs41_proc_sequence(clp, cred); | 5520 | task = _nfs41_proc_sequence(clp, cred); |
5513 | if (IS_ERR(task)) | 5521 | if (IS_ERR(task)) |
5514 | ret = PTR_ERR(task); | 5522 | ret = PTR_ERR(task); |
diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c index df8e7f3ca56d..dc484c0eae7f 100644 --- a/fs/nfs/nfs4renewd.c +++ b/fs/nfs/nfs4renewd.c | |||
@@ -60,6 +60,7 @@ nfs4_renew_state(struct work_struct *work) | |||
60 | struct rpc_cred *cred; | 60 | struct rpc_cred *cred; |
61 | long lease; | 61 | long lease; |
62 | unsigned long last, now; | 62 | unsigned long last, now; |
63 | unsigned renew_flags = 0; | ||
63 | 64 | ||
64 | ops = clp->cl_mvops->state_renewal_ops; | 65 | ops = clp->cl_mvops->state_renewal_ops; |
65 | dprintk("%s: start\n", __func__); | 66 | dprintk("%s: start\n", __func__); |
@@ -72,18 +73,23 @@ nfs4_renew_state(struct work_struct *work) | |||
72 | last = clp->cl_last_renewal; | 73 | last = clp->cl_last_renewal; |
73 | now = jiffies; | 74 | now = jiffies; |
74 | /* Are we close to a lease timeout? */ | 75 | /* Are we close to a lease timeout? */ |
75 | if (time_after(now, last + lease/3)) { | 76 | if (time_after(now, last + lease/3)) |
77 | renew_flags |= NFS4_RENEW_TIMEOUT; | ||
78 | if (nfs_delegations_present(clp)) | ||
79 | renew_flags |= NFS4_RENEW_DELEGATION_CB; | ||
80 | |||
81 | if (renew_flags != 0) { | ||
76 | cred = ops->get_state_renewal_cred_locked(clp); | 82 | cred = ops->get_state_renewal_cred_locked(clp); |
77 | spin_unlock(&clp->cl_lock); | 83 | spin_unlock(&clp->cl_lock); |
78 | if (cred == NULL) { | 84 | if (cred == NULL) { |
79 | if (!nfs_delegations_present(clp)) { | 85 | if (!(renew_flags & NFS4_RENEW_DELEGATION_CB)) { |
80 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 86 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
81 | goto out; | 87 | goto out; |
82 | } | 88 | } |
83 | nfs_expire_all_delegations(clp); | 89 | nfs_expire_all_delegations(clp); |
84 | } else { | 90 | } else { |
85 | /* Queue an asynchronous RENEW. */ | 91 | /* Queue an asynchronous RENEW. */ |
86 | ops->sched_state_renewal(clp, cred); | 92 | ops->sched_state_renewal(clp, cred, renew_flags); |
87 | put_rpccred(cred); | 93 | put_rpccred(cred); |
88 | goto out_exp; | 94 | goto out_exp; |
89 | } | 95 | } |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 72ab97ef3d61..39914be40b03 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -1038,6 +1038,12 @@ void nfs4_schedule_lease_recovery(struct nfs_client *clp) | |||
1038 | nfs4_schedule_state_manager(clp); | 1038 | nfs4_schedule_state_manager(clp); |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | void nfs4_schedule_path_down_recovery(struct nfs_client *clp) | ||
1042 | { | ||
1043 | nfs_handle_cb_pathdown(clp); | ||
1044 | nfs4_schedule_state_manager(clp); | ||
1045 | } | ||
1046 | |||
1041 | static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_state *state) | 1047 | static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_state *state) |
1042 | { | 1048 | { |
1043 | 1049 | ||
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c index 9383ca7245bc..d0cda12fddc3 100644 --- a/fs/nfs/objlayout/objio_osd.c +++ b/fs/nfs/objlayout/objio_osd.c | |||
@@ -479,7 +479,6 @@ static int _io_check(struct objio_state *ios, bool is_write) | |||
479 | for (i = 0; i < ios->numdevs; i++) { | 479 | for (i = 0; i < ios->numdevs; i++) { |
480 | struct osd_sense_info osi; | 480 | struct osd_sense_info osi; |
481 | struct osd_request *or = ios->per_dev[i].or; | 481 | struct osd_request *or = ios->per_dev[i].or; |
482 | unsigned dev; | ||
483 | int ret; | 482 | int ret; |
484 | 483 | ||
485 | if (!or) | 484 | if (!or) |
@@ -500,9 +499,8 @@ static int _io_check(struct objio_state *ios, bool is_write) | |||
500 | 499 | ||
501 | continue; /* we recovered */ | 500 | continue; /* we recovered */ |
502 | } | 501 | } |
503 | dev = ios->per_dev[i].dev; | 502 | objlayout_io_set_result(&ios->ol_state, i, |
504 | objlayout_io_set_result(&ios->ol_state, dev, | 503 | &ios->layout->comps[i].oc_object_id, |
505 | &ios->layout->comps[dev].oc_object_id, | ||
506 | osd_pri_2_pnfs_err(osi.osd_err_pri), | 504 | osd_pri_2_pnfs_err(osi.osd_err_pri), |
507 | ios->per_dev[i].offset, | 505 | ios->per_dev[i].offset, |
508 | ios->per_dev[i].length, | 506 | ios->per_dev[i].length, |
@@ -589,22 +587,19 @@ static void _calc_stripe_info(struct objio_state *ios, u64 file_offset, | |||
589 | } | 587 | } |
590 | 588 | ||
591 | static int _add_stripe_unit(struct objio_state *ios, unsigned *cur_pg, | 589 | static int _add_stripe_unit(struct objio_state *ios, unsigned *cur_pg, |
592 | unsigned pgbase, struct _objio_per_comp *per_dev, int cur_len, | 590 | unsigned pgbase, struct _objio_per_comp *per_dev, int len, |
593 | gfp_t gfp_flags) | 591 | gfp_t gfp_flags) |
594 | { | 592 | { |
595 | unsigned pg = *cur_pg; | 593 | unsigned pg = *cur_pg; |
594 | int cur_len = len; | ||
596 | struct request_queue *q = | 595 | struct request_queue *q = |
597 | osd_request_queue(_io_od(ios, per_dev->dev)); | 596 | osd_request_queue(_io_od(ios, per_dev->dev)); |
598 | 597 | ||
599 | per_dev->length += cur_len; | ||
600 | |||
601 | if (per_dev->bio == NULL) { | 598 | if (per_dev->bio == NULL) { |
602 | unsigned stripes = ios->layout->num_comps / | 599 | unsigned pages_in_stripe = ios->layout->group_width * |
603 | ios->layout->mirrors_p1; | ||
604 | unsigned pages_in_stripe = stripes * | ||
605 | (ios->layout->stripe_unit / PAGE_SIZE); | 600 | (ios->layout->stripe_unit / PAGE_SIZE); |
606 | unsigned bio_size = (ios->ol_state.nr_pages + pages_in_stripe) / | 601 | unsigned bio_size = (ios->ol_state.nr_pages + pages_in_stripe) / |
607 | stripes; | 602 | ios->layout->group_width; |
608 | 603 | ||
609 | if (BIO_MAX_PAGES_KMALLOC < bio_size) | 604 | if (BIO_MAX_PAGES_KMALLOC < bio_size) |
610 | bio_size = BIO_MAX_PAGES_KMALLOC; | 605 | bio_size = BIO_MAX_PAGES_KMALLOC; |
@@ -632,6 +627,7 @@ static int _add_stripe_unit(struct objio_state *ios, unsigned *cur_pg, | |||
632 | } | 627 | } |
633 | BUG_ON(cur_len); | 628 | BUG_ON(cur_len); |
634 | 629 | ||
630 | per_dev->length += len; | ||
635 | *cur_pg = pg; | 631 | *cur_pg = pg; |
636 | return 0; | 632 | return 0; |
637 | } | 633 | } |
@@ -650,7 +646,7 @@ static int _prepare_one_group(struct objio_state *ios, u64 length, | |||
650 | int ret = 0; | 646 | int ret = 0; |
651 | 647 | ||
652 | while (length) { | 648 | while (length) { |
653 | struct _objio_per_comp *per_dev = &ios->per_dev[dev]; | 649 | struct _objio_per_comp *per_dev = &ios->per_dev[dev - first_dev]; |
654 | unsigned cur_len, page_off = 0; | 650 | unsigned cur_len, page_off = 0; |
655 | 651 | ||
656 | if (!per_dev->length) { | 652 | if (!per_dev->length) { |
@@ -670,8 +666,8 @@ static int _prepare_one_group(struct objio_state *ios, u64 length, | |||
670 | cur_len = stripe_unit; | 666 | cur_len = stripe_unit; |
671 | } | 667 | } |
672 | 668 | ||
673 | if (max_comp < dev) | 669 | if (max_comp < dev - first_dev) |
674 | max_comp = dev; | 670 | max_comp = dev - first_dev; |
675 | } else { | 671 | } else { |
676 | cur_len = stripe_unit; | 672 | cur_len = stripe_unit; |
677 | } | 673 | } |
@@ -806,7 +802,7 @@ static int _read_mirrors(struct objio_state *ios, unsigned cur_comp) | |||
806 | struct _objio_per_comp *per_dev = &ios->per_dev[cur_comp]; | 802 | struct _objio_per_comp *per_dev = &ios->per_dev[cur_comp]; |
807 | unsigned dev = per_dev->dev; | 803 | unsigned dev = per_dev->dev; |
808 | struct pnfs_osd_object_cred *cred = | 804 | struct pnfs_osd_object_cred *cred = |
809 | &ios->layout->comps[dev]; | 805 | &ios->layout->comps[cur_comp]; |
810 | struct osd_obj_id obj = { | 806 | struct osd_obj_id obj = { |
811 | .partition = cred->oc_object_id.oid_partition_id, | 807 | .partition = cred->oc_object_id.oid_partition_id, |
812 | .id = cred->oc_object_id.oid_object_id, | 808 | .id = cred->oc_object_id.oid_object_id, |
@@ -904,7 +900,7 @@ static int _write_mirrors(struct objio_state *ios, unsigned cur_comp) | |||
904 | for (; cur_comp < last_comp; ++cur_comp, ++dev) { | 900 | for (; cur_comp < last_comp; ++cur_comp, ++dev) { |
905 | struct osd_request *or = NULL; | 901 | struct osd_request *or = NULL; |
906 | struct pnfs_osd_object_cred *cred = | 902 | struct pnfs_osd_object_cred *cred = |
907 | &ios->layout->comps[dev]; | 903 | &ios->layout->comps[cur_comp]; |
908 | struct osd_obj_id obj = { | 904 | struct osd_obj_id obj = { |
909 | .partition = cred->oc_object_id.oid_partition_id, | 905 | .partition = cred->oc_object_id.oid_partition_id, |
910 | .id = cred->oc_object_id.oid_object_id, | 906 | .id = cred->oc_object_id.oid_object_id, |
diff --git a/fs/nfs/objlayout/pnfs_osd_xdr_cli.c b/fs/nfs/objlayout/pnfs_osd_xdr_cli.c index 16fc758e9123..b3918f7ac34d 100644 --- a/fs/nfs/objlayout/pnfs_osd_xdr_cli.c +++ b/fs/nfs/objlayout/pnfs_osd_xdr_cli.c | |||
@@ -170,6 +170,9 @@ int pnfs_osd_xdr_decode_layout_map(struct pnfs_osd_layout *layout, | |||
170 | p = _osd_xdr_decode_data_map(p, &layout->olo_map); | 170 | p = _osd_xdr_decode_data_map(p, &layout->olo_map); |
171 | layout->olo_comps_index = be32_to_cpup(p++); | 171 | layout->olo_comps_index = be32_to_cpup(p++); |
172 | layout->olo_num_comps = be32_to_cpup(p++); | 172 | layout->olo_num_comps = be32_to_cpup(p++); |
173 | dprintk("%s: olo_comps_index=%d olo_num_comps=%d\n", __func__, | ||
174 | layout->olo_comps_index, layout->olo_num_comps); | ||
175 | |||
173 | iter->total_comps = layout->olo_num_comps; | 176 | iter->total_comps = layout->olo_num_comps; |
174 | return 0; | 177 | return 0; |
175 | } | 178 | } |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index b961ceac66b4..5b19b6aabe18 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -2035,9 +2035,6 @@ static inline void nfs_initialise_sb(struct super_block *sb) | |||
2035 | sb->s_blocksize = nfs_block_bits(server->wsize, | 2035 | sb->s_blocksize = nfs_block_bits(server->wsize, |
2036 | &sb->s_blocksize_bits); | 2036 | &sb->s_blocksize_bits); |
2037 | 2037 | ||
2038 | if (server->flags & NFS_MOUNT_NOAC) | ||
2039 | sb->s_flags |= MS_SYNCHRONOUS; | ||
2040 | |||
2041 | sb->s_bdi = &server->backing_dev_info; | 2038 | sb->s_bdi = &server->backing_dev_info; |
2042 | 2039 | ||
2043 | nfs_super_set_maxbytes(sb, server->maxfilesize); | 2040 | nfs_super_set_maxbytes(sb, server->maxfilesize); |
@@ -2249,6 +2246,10 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type, | |||
2249 | if (server->flags & NFS_MOUNT_UNSHARED) | 2246 | if (server->flags & NFS_MOUNT_UNSHARED) |
2250 | compare_super = NULL; | 2247 | compare_super = NULL; |
2251 | 2248 | ||
2249 | /* -o noac implies -o sync */ | ||
2250 | if (server->flags & NFS_MOUNT_NOAC) | ||
2251 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2252 | |||
2252 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2253 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2253 | s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2254 | s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2254 | if (IS_ERR(s)) { | 2255 | if (IS_ERR(s)) { |
@@ -2361,6 +2362,10 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags, | |||
2361 | if (server->flags & NFS_MOUNT_UNSHARED) | 2362 | if (server->flags & NFS_MOUNT_UNSHARED) |
2362 | compare_super = NULL; | 2363 | compare_super = NULL; |
2363 | 2364 | ||
2365 | /* -o noac implies -o sync */ | ||
2366 | if (server->flags & NFS_MOUNT_NOAC) | ||
2367 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2368 | |||
2364 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2369 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2365 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2370 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2366 | if (IS_ERR(s)) { | 2371 | if (IS_ERR(s)) { |
@@ -2628,6 +2633,10 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags, | |||
2628 | if (server->flags & NFS4_MOUNT_UNSHARED) | 2633 | if (server->flags & NFS4_MOUNT_UNSHARED) |
2629 | compare_super = NULL; | 2634 | compare_super = NULL; |
2630 | 2635 | ||
2636 | /* -o noac implies -o sync */ | ||
2637 | if (server->flags & NFS_MOUNT_NOAC) | ||
2638 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2639 | |||
2631 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2640 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2632 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2641 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2633 | if (IS_ERR(s)) { | 2642 | if (IS_ERR(s)) { |
@@ -2789,7 +2798,7 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt, | |||
2789 | goto out_put_mnt_ns; | 2798 | goto out_put_mnt_ns; |
2790 | 2799 | ||
2791 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, | 2800 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, |
2792 | export_path, LOOKUP_FOLLOW, &path); | 2801 | export_path, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path); |
2793 | 2802 | ||
2794 | nfs_referral_loop_unprotect(); | 2803 | nfs_referral_loop_unprotect(); |
2795 | put_mnt_ns(ns_private); | 2804 | put_mnt_ns(ns_private); |
@@ -2916,6 +2925,10 @@ nfs4_xdev_mount(struct file_system_type *fs_type, int flags, | |||
2916 | if (server->flags & NFS4_MOUNT_UNSHARED) | 2925 | if (server->flags & NFS4_MOUNT_UNSHARED) |
2917 | compare_super = NULL; | 2926 | compare_super = NULL; |
2918 | 2927 | ||
2928 | /* -o noac implies -o sync */ | ||
2929 | if (server->flags & NFS_MOUNT_NOAC) | ||
2930 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2931 | |||
2919 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2932 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2920 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2933 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2921 | if (IS_ERR(s)) { | 2934 | if (IS_ERR(s)) { |
@@ -3003,6 +3016,10 @@ nfs4_remote_referral_mount(struct file_system_type *fs_type, int flags, | |||
3003 | if (server->flags & NFS4_MOUNT_UNSHARED) | 3016 | if (server->flags & NFS4_MOUNT_UNSHARED) |
3004 | compare_super = NULL; | 3017 | compare_super = NULL; |
3005 | 3018 | ||
3019 | /* -o noac implies -o sync */ | ||
3020 | if (server->flags & NFS_MOUNT_NOAC) | ||
3021 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
3022 | |||
3006 | /* Get a superblock - note that we may end up sharing one that already exists */ | 3023 | /* Get a superblock - note that we may end up sharing one that already exists */ |
3007 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 3024 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
3008 | if (IS_ERR(s)) { | 3025 | if (IS_ERR(s)) { |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index b39b37f80913..c9bd2a6b7d4b 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -958,7 +958,7 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc, struct list_head | |||
958 | if (!data) | 958 | if (!data) |
959 | goto out_bad; | 959 | goto out_bad; |
960 | data->pagevec[0] = page; | 960 | data->pagevec[0] = page; |
961 | nfs_write_rpcsetup(req, data, wsize, offset, desc->pg_ioflags); | 961 | nfs_write_rpcsetup(req, data, len, offset, desc->pg_ioflags); |
962 | list_add(&data->list, res); | 962 | list_add(&data->list, res); |
963 | requests++; | 963 | requests++; |
964 | nbytes -= len; | 964 | nbytes -= len; |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 81ecf9c0bf0a..194fb22ef79d 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -7185,20 +7185,9 @@ int ocfs2_init_security_and_acl(struct inode *dir, | |||
7185 | { | 7185 | { |
7186 | int ret = 0; | 7186 | int ret = 0; |
7187 | struct buffer_head *dir_bh = NULL; | 7187 | struct buffer_head *dir_bh = NULL; |
7188 | struct ocfs2_security_xattr_info si = { | ||
7189 | .enable = 1, | ||
7190 | }; | ||
7191 | 7188 | ||
7192 | ret = ocfs2_init_security_get(inode, dir, qstr, &si); | 7189 | ret = ocfs2_init_security_get(inode, dir, qstr, NULL); |
7193 | if (!ret) { | 7190 | if (!ret) { |
7194 | ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, | ||
7195 | si.name, si.value, si.value_len, | ||
7196 | XATTR_CREATE); | ||
7197 | if (ret) { | ||
7198 | mlog_errno(ret); | ||
7199 | goto leave; | ||
7200 | } | ||
7201 | } else if (ret != -EOPNOTSUPP) { | ||
7202 | mlog_errno(ret); | 7191 | mlog_errno(ret); |
7203 | goto leave; | 7192 | goto leave; |
7204 | } | 7193 | } |
@@ -7255,6 +7244,22 @@ static int ocfs2_xattr_security_set(struct dentry *dentry, const char *name, | |||
7255 | name, value, size, flags); | 7244 | name, value, size, flags); |
7256 | } | 7245 | } |
7257 | 7246 | ||
7247 | int ocfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, | ||
7248 | void *fs_info) | ||
7249 | { | ||
7250 | const struct xattr *xattr; | ||
7251 | int err = 0; | ||
7252 | |||
7253 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { | ||
7254 | err = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, | ||
7255 | xattr->name, xattr->value, | ||
7256 | xattr->value_len, XATTR_CREATE); | ||
7257 | if (err) | ||
7258 | break; | ||
7259 | } | ||
7260 | return err; | ||
7261 | } | ||
7262 | |||
7258 | int ocfs2_init_security_get(struct inode *inode, | 7263 | int ocfs2_init_security_get(struct inode *inode, |
7259 | struct inode *dir, | 7264 | struct inode *dir, |
7260 | const struct qstr *qstr, | 7265 | const struct qstr *qstr, |
@@ -7263,8 +7268,13 @@ int ocfs2_init_security_get(struct inode *inode, | |||
7263 | /* check whether ocfs2 support feature xattr */ | 7268 | /* check whether ocfs2 support feature xattr */ |
7264 | if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb))) | 7269 | if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb))) |
7265 | return -EOPNOTSUPP; | 7270 | return -EOPNOTSUPP; |
7266 | return security_inode_init_security(inode, dir, qstr, &si->name, | 7271 | if (si) |
7267 | &si->value, &si->value_len); | 7272 | return security_old_inode_init_security(inode, dir, qstr, |
7273 | &si->name, &si->value, | ||
7274 | &si->value_len); | ||
7275 | |||
7276 | return security_inode_init_security(inode, dir, qstr, | ||
7277 | &ocfs2_initxattrs, NULL); | ||
7268 | } | 7278 | } |
7269 | 7279 | ||
7270 | int ocfs2_init_security_set(handle_t *handle, | 7280 | int ocfs2_init_security_set(handle_t *handle, |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 25b6a887adb9..5afaa58a8630 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -877,30 +877,54 @@ struct numa_maps_private { | |||
877 | struct numa_maps md; | 877 | struct numa_maps md; |
878 | }; | 878 | }; |
879 | 879 | ||
880 | static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty) | 880 | static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty, |
881 | unsigned long nr_pages) | ||
881 | { | 882 | { |
882 | int count = page_mapcount(page); | 883 | int count = page_mapcount(page); |
883 | 884 | ||
884 | md->pages++; | 885 | md->pages += nr_pages; |
885 | if (pte_dirty || PageDirty(page)) | 886 | if (pte_dirty || PageDirty(page)) |
886 | md->dirty++; | 887 | md->dirty += nr_pages; |
887 | 888 | ||
888 | if (PageSwapCache(page)) | 889 | if (PageSwapCache(page)) |
889 | md->swapcache++; | 890 | md->swapcache += nr_pages; |
890 | 891 | ||
891 | if (PageActive(page) || PageUnevictable(page)) | 892 | if (PageActive(page) || PageUnevictable(page)) |
892 | md->active++; | 893 | md->active += nr_pages; |
893 | 894 | ||
894 | if (PageWriteback(page)) | 895 | if (PageWriteback(page)) |
895 | md->writeback++; | 896 | md->writeback += nr_pages; |
896 | 897 | ||
897 | if (PageAnon(page)) | 898 | if (PageAnon(page)) |
898 | md->anon++; | 899 | md->anon += nr_pages; |
899 | 900 | ||
900 | if (count > md->mapcount_max) | 901 | if (count > md->mapcount_max) |
901 | md->mapcount_max = count; | 902 | md->mapcount_max = count; |
902 | 903 | ||
903 | md->node[page_to_nid(page)]++; | 904 | md->node[page_to_nid(page)] += nr_pages; |
905 | } | ||
906 | |||
907 | static struct page *can_gather_numa_stats(pte_t pte, struct vm_area_struct *vma, | ||
908 | unsigned long addr) | ||
909 | { | ||
910 | struct page *page; | ||
911 | int nid; | ||
912 | |||
913 | if (!pte_present(pte)) | ||
914 | return NULL; | ||
915 | |||
916 | page = vm_normal_page(vma, addr, pte); | ||
917 | if (!page) | ||
918 | return NULL; | ||
919 | |||
920 | if (PageReserved(page)) | ||
921 | return NULL; | ||
922 | |||
923 | nid = page_to_nid(page); | ||
924 | if (!node_isset(nid, node_states[N_HIGH_MEMORY])) | ||
925 | return NULL; | ||
926 | |||
927 | return page; | ||
904 | } | 928 | } |
905 | 929 | ||
906 | static int gather_pte_stats(pmd_t *pmd, unsigned long addr, | 930 | static int gather_pte_stats(pmd_t *pmd, unsigned long addr, |
@@ -912,26 +936,32 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr, | |||
912 | pte_t *pte; | 936 | pte_t *pte; |
913 | 937 | ||
914 | md = walk->private; | 938 | md = walk->private; |
915 | orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); | 939 | spin_lock(&walk->mm->page_table_lock); |
916 | do { | 940 | if (pmd_trans_huge(*pmd)) { |
917 | struct page *page; | 941 | if (pmd_trans_splitting(*pmd)) { |
918 | int nid; | 942 | spin_unlock(&walk->mm->page_table_lock); |
943 | wait_split_huge_page(md->vma->anon_vma, pmd); | ||
944 | } else { | ||
945 | pte_t huge_pte = *(pte_t *)pmd; | ||
946 | struct page *page; | ||
919 | 947 | ||
920 | if (!pte_present(*pte)) | 948 | page = can_gather_numa_stats(huge_pte, md->vma, addr); |
921 | continue; | 949 | if (page) |
950 | gather_stats(page, md, pte_dirty(huge_pte), | ||
951 | HPAGE_PMD_SIZE/PAGE_SIZE); | ||
952 | spin_unlock(&walk->mm->page_table_lock); | ||
953 | return 0; | ||
954 | } | ||
955 | } else { | ||
956 | spin_unlock(&walk->mm->page_table_lock); | ||
957 | } | ||
922 | 958 | ||
923 | page = vm_normal_page(md->vma, addr, *pte); | 959 | orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); |
960 | do { | ||
961 | struct page *page = can_gather_numa_stats(*pte, md->vma, addr); | ||
924 | if (!page) | 962 | if (!page) |
925 | continue; | 963 | continue; |
926 | 964 | gather_stats(page, md, pte_dirty(*pte), 1); | |
927 | if (PageReserved(page)) | ||
928 | continue; | ||
929 | |||
930 | nid = page_to_nid(page); | ||
931 | if (!node_isset(nid, node_states[N_HIGH_MEMORY])) | ||
932 | continue; | ||
933 | |||
934 | gather_stats(page, md, pte_dirty(*pte)); | ||
935 | 965 | ||
936 | } while (pte++, addr += PAGE_SIZE, addr != end); | 966 | } while (pte++, addr += PAGE_SIZE, addr != end); |
937 | pte_unmap_unlock(orig_pte, ptl); | 967 | pte_unmap_unlock(orig_pte, ptl); |
@@ -952,7 +982,7 @@ static int gather_hugetbl_stats(pte_t *pte, unsigned long hmask, | |||
952 | return 0; | 982 | return 0; |
953 | 983 | ||
954 | md = walk->private; | 984 | md = walk->private; |
955 | gather_stats(page, md, pte_dirty(*pte)); | 985 | gather_stats(page, md, pte_dirty(*pte), 1); |
956 | return 0; | 986 | return 0; |
957 | } | 987 | } |
958 | 988 | ||
diff --git a/fs/quota/quota.c b/fs/quota/quota.c index b34bdb25490c..10b6be3ca280 100644 --- a/fs/quota/quota.c +++ b/fs/quota/quota.c | |||
@@ -355,7 +355,7 @@ SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special, | |||
355 | * resolution (think about autofs) and thus deadlocks could arise. | 355 | * resolution (think about autofs) and thus deadlocks could arise. |
356 | */ | 356 | */ |
357 | if (cmds == Q_QUOTAON) { | 357 | if (cmds == Q_QUOTAON) { |
358 | ret = user_path_at(AT_FDCWD, addr, LOOKUP_FOLLOW, &path); | 358 | ret = user_path_at(AT_FDCWD, addr, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path); |
359 | if (ret) | 359 | if (ret) |
360 | pathp = ERR_PTR(ret); | 360 | pathp = ERR_PTR(ret); |
361 | else | 361 | else |
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index a159ba5a35e7..eb711060a6f2 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -291,14 +291,13 @@ int reiserfs_allocate_list_bitmaps(struct super_block *sb, | |||
291 | for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) { | 291 | for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) { |
292 | jb = jb_array + i; | 292 | jb = jb_array + i; |
293 | jb->journal_list = NULL; | 293 | jb->journal_list = NULL; |
294 | jb->bitmaps = vmalloc(mem); | 294 | jb->bitmaps = vzalloc(mem); |
295 | if (!jb->bitmaps) { | 295 | if (!jb->bitmaps) { |
296 | reiserfs_warning(sb, "clm-2000", "unable to " | 296 | reiserfs_warning(sb, "clm-2000", "unable to " |
297 | "allocate bitmaps for journal lists"); | 297 | "allocate bitmaps for journal lists"); |
298 | failed = 1; | 298 | failed = 1; |
299 | break; | 299 | break; |
300 | } | 300 | } |
301 | memset(jb->bitmaps, 0, mem); | ||
302 | } | 301 | } |
303 | if (failed) { | 302 | if (failed) { |
304 | free_list_bitmaps(sb, jb_array); | 303 | free_list_bitmaps(sb, jb_array); |
@@ -353,11 +352,10 @@ static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes) | |||
353 | if (num_cnodes <= 0) { | 352 | if (num_cnodes <= 0) { |
354 | return NULL; | 353 | return NULL; |
355 | } | 354 | } |
356 | head = vmalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode)); | 355 | head = vzalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode)); |
357 | if (!head) { | 356 | if (!head) { |
358 | return NULL; | 357 | return NULL; |
359 | } | 358 | } |
360 | memset(head, 0, num_cnodes * sizeof(struct reiserfs_journal_cnode)); | ||
361 | head[0].prev = NULL; | 359 | head[0].prev = NULL; |
362 | head[0].next = head + 1; | 360 | head[0].next = head + 1; |
363 | for (i = 1; i < num_cnodes; i++) { | 361 | for (i = 1; i < num_cnodes; i++) { |
@@ -2685,14 +2683,13 @@ int journal_init(struct super_block *sb, const char *j_dev_name, | |||
2685 | * dependency inversion warnings. | 2683 | * dependency inversion warnings. |
2686 | */ | 2684 | */ |
2687 | reiserfs_write_unlock(sb); | 2685 | reiserfs_write_unlock(sb); |
2688 | journal = SB_JOURNAL(sb) = vmalloc(sizeof(struct reiserfs_journal)); | 2686 | journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal)); |
2689 | if (!journal) { | 2687 | if (!journal) { |
2690 | reiserfs_warning(sb, "journal-1256", | 2688 | reiserfs_warning(sb, "journal-1256", |
2691 | "unable to get memory for journal structure"); | 2689 | "unable to get memory for journal structure"); |
2692 | reiserfs_write_lock(sb); | 2690 | reiserfs_write_lock(sb); |
2693 | return 1; | 2691 | return 1; |
2694 | } | 2692 | } |
2695 | memset(journal, 0, sizeof(struct reiserfs_journal)); | ||
2696 | INIT_LIST_HEAD(&journal->j_bitmap_nodes); | 2693 | INIT_LIST_HEAD(&journal->j_bitmap_nodes); |
2697 | INIT_LIST_HEAD(&journal->j_prealloc_list); | 2694 | INIT_LIST_HEAD(&journal->j_prealloc_list); |
2698 | INIT_LIST_HEAD(&journal->j_working_list); | 2695 | INIT_LIST_HEAD(&journal->j_working_list); |
diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c index b6b9b1fe33b0..7483279b482d 100644 --- a/fs/reiserfs/resize.c +++ b/fs/reiserfs/resize.c | |||
@@ -111,15 +111,13 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) | |||
111 | /* allocate additional bitmap blocks, reallocate array of bitmap | 111 | /* allocate additional bitmap blocks, reallocate array of bitmap |
112 | * block pointers */ | 112 | * block pointers */ |
113 | bitmap = | 113 | bitmap = |
114 | vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new); | 114 | vzalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new); |
115 | if (!bitmap) { | 115 | if (!bitmap) { |
116 | /* Journal bitmaps are still supersized, but the memory isn't | 116 | /* Journal bitmaps are still supersized, but the memory isn't |
117 | * leaked, so I guess it's ok */ | 117 | * leaked, so I guess it's ok */ |
118 | printk("reiserfs_resize: unable to allocate memory.\n"); | 118 | printk("reiserfs_resize: unable to allocate memory.\n"); |
119 | return -ENOMEM; | 119 | return -ENOMEM; |
120 | } | 120 | } |
121 | memset(bitmap, 0, | ||
122 | sizeof(struct reiserfs_bitmap_info) * bmap_nr_new); | ||
123 | for (i = 0; i < bmap_nr; i++) | 121 | for (i = 0; i < bmap_nr; i++) |
124 | bitmap[i] = old_bitmap[i]; | 122 | bitmap[i] = old_bitmap[i]; |
125 | 123 | ||
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c index ef66c18a9332..534668fa41be 100644 --- a/fs/reiserfs/xattr_security.c +++ b/fs/reiserfs/xattr_security.c | |||
@@ -66,8 +66,8 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode, | |||
66 | if (IS_PRIVATE(dir)) | 66 | if (IS_PRIVATE(dir)) |
67 | return 0; | 67 | return 0; |
68 | 68 | ||
69 | error = security_inode_init_security(inode, dir, qstr, &sec->name, | 69 | error = security_old_inode_init_security(inode, dir, qstr, &sec->name, |
70 | &sec->value, &sec->length); | 70 | &sec->value, &sec->length); |
71 | if (error) { | 71 | if (error) { |
72 | if (error == -EOPNOTSUPP) | 72 | if (error == -EOPNOTSUPP) |
73 | error = 0; | 73 | error = 0; |
diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig index 1360d4f88f41..048b59d5b2f0 100644 --- a/fs/squashfs/Kconfig +++ b/fs/squashfs/Kconfig | |||
@@ -19,9 +19,9 @@ config SQUASHFS | |||
19 | 19 | ||
20 | If you want to compile this as a module ( = code which can be | 20 | If you want to compile this as a module ( = code which can be |
21 | inserted in and removed from the running kernel whenever you want), | 21 | inserted in and removed from the running kernel whenever you want), |
22 | say M here and read <file:Documentation/modules.txt>. The module | 22 | say M here. The module will be called squashfs. Note that the root |
23 | will be called squashfs. Note that the root file system (the one | 23 | file system (the one containing the directory /) cannot be compiled |
24 | containing the directory /) cannot be compiled as a module. | 24 | as a module. |
25 | 25 | ||
26 | If unsure, say N. | 26 | If unsure, say N. |
27 | 27 | ||
@@ -81,8 +81,6 @@ int vfs_fstatat(int dfd, const char __user *filename, struct kstat *stat, | |||
81 | 81 | ||
82 | if (!(flag & AT_SYMLINK_NOFOLLOW)) | 82 | if (!(flag & AT_SYMLINK_NOFOLLOW)) |
83 | lookup_flags |= LOOKUP_FOLLOW; | 83 | lookup_flags |= LOOKUP_FOLLOW; |
84 | if (flag & AT_NO_AUTOMOUNT) | ||
85 | lookup_flags |= LOOKUP_NO_AUTOMOUNT; | ||
86 | if (flag & AT_EMPTY_PATH) | 84 | if (flag & AT_EMPTY_PATH) |
87 | lookup_flags |= LOOKUP_EMPTY; | 85 | lookup_flags |= LOOKUP_EMPTY; |
88 | 86 | ||
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index ea9120a830d8..48ffbdf0d017 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -43,20 +43,48 @@ static DEFINE_IDA(sysfs_ino_ida); | |||
43 | static void sysfs_link_sibling(struct sysfs_dirent *sd) | 43 | static void sysfs_link_sibling(struct sysfs_dirent *sd) |
44 | { | 44 | { |
45 | struct sysfs_dirent *parent_sd = sd->s_parent; | 45 | struct sysfs_dirent *parent_sd = sd->s_parent; |
46 | struct sysfs_dirent **pos; | ||
47 | 46 | ||
48 | BUG_ON(sd->s_sibling); | 47 | struct rb_node **p; |
49 | 48 | struct rb_node *parent; | |
50 | /* Store directory entries in order by ino. This allows | 49 | |
51 | * readdir to properly restart without having to add a | 50 | if (sysfs_type(sd) == SYSFS_DIR) |
52 | * cursor into the s_dir.children list. | 51 | parent_sd->s_dir.subdirs++; |
53 | */ | 52 | |
54 | for (pos = &parent_sd->s_dir.children; *pos; pos = &(*pos)->s_sibling) { | 53 | p = &parent_sd->s_dir.inode_tree.rb_node; |
55 | if (sd->s_ino < (*pos)->s_ino) | 54 | parent = NULL; |
56 | break; | 55 | while (*p) { |
56 | parent = *p; | ||
57 | #define node rb_entry(parent, struct sysfs_dirent, inode_node) | ||
58 | if (sd->s_ino < node->s_ino) { | ||
59 | p = &node->inode_node.rb_left; | ||
60 | } else if (sd->s_ino > node->s_ino) { | ||
61 | p = &node->inode_node.rb_right; | ||
62 | } else { | ||
63 | printk(KERN_CRIT "sysfs: inserting duplicate inode '%lx'\n", | ||
64 | (unsigned long) sd->s_ino); | ||
65 | BUG(); | ||
66 | } | ||
67 | #undef node | ||
57 | } | 68 | } |
58 | sd->s_sibling = *pos; | 69 | rb_link_node(&sd->inode_node, parent, p); |
59 | *pos = sd; | 70 | rb_insert_color(&sd->inode_node, &parent_sd->s_dir.inode_tree); |
71 | |||
72 | p = &parent_sd->s_dir.name_tree.rb_node; | ||
73 | parent = NULL; | ||
74 | while (*p) { | ||
75 | int c; | ||
76 | parent = *p; | ||
77 | #define node rb_entry(parent, struct sysfs_dirent, name_node) | ||
78 | c = strcmp(sd->s_name, node->s_name); | ||
79 | if (c < 0) { | ||
80 | p = &node->name_node.rb_left; | ||
81 | } else { | ||
82 | p = &node->name_node.rb_right; | ||
83 | } | ||
84 | #undef node | ||
85 | } | ||
86 | rb_link_node(&sd->name_node, parent, p); | ||
87 | rb_insert_color(&sd->name_node, &parent_sd->s_dir.name_tree); | ||
60 | } | 88 | } |
61 | 89 | ||
62 | /** | 90 | /** |
@@ -71,16 +99,11 @@ static void sysfs_link_sibling(struct sysfs_dirent *sd) | |||
71 | */ | 99 | */ |
72 | static void sysfs_unlink_sibling(struct sysfs_dirent *sd) | 100 | static void sysfs_unlink_sibling(struct sysfs_dirent *sd) |
73 | { | 101 | { |
74 | struct sysfs_dirent **pos; | 102 | if (sysfs_type(sd) == SYSFS_DIR) |
103 | sd->s_parent->s_dir.subdirs--; | ||
75 | 104 | ||
76 | for (pos = &sd->s_parent->s_dir.children; *pos; | 105 | rb_erase(&sd->inode_node, &sd->s_parent->s_dir.inode_tree); |
77 | pos = &(*pos)->s_sibling) { | 106 | rb_erase(&sd->name_node, &sd->s_parent->s_dir.name_tree); |
78 | if (*pos == sd) { | ||
79 | *pos = sd->s_sibling; | ||
80 | sd->s_sibling = NULL; | ||
81 | break; | ||
82 | } | ||
83 | } | ||
84 | } | 107 | } |
85 | 108 | ||
86 | /** | 109 | /** |
@@ -126,7 +149,6 @@ struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd) | |||
126 | */ | 149 | */ |
127 | void sysfs_put_active(struct sysfs_dirent *sd) | 150 | void sysfs_put_active(struct sysfs_dirent *sd) |
128 | { | 151 | { |
129 | struct completion *cmpl; | ||
130 | int v; | 152 | int v; |
131 | 153 | ||
132 | if (unlikely(!sd)) | 154 | if (unlikely(!sd)) |
@@ -138,10 +160,9 @@ void sysfs_put_active(struct sysfs_dirent *sd) | |||
138 | return; | 160 | return; |
139 | 161 | ||
140 | /* atomic_dec_return() is a mb(), we'll always see the updated | 162 | /* atomic_dec_return() is a mb(), we'll always see the updated |
141 | * sd->s_sibling. | 163 | * sd->u.completion. |
142 | */ | 164 | */ |
143 | cmpl = (void *)sd->s_sibling; | 165 | complete(sd->u.completion); |
144 | complete(cmpl); | ||
145 | } | 166 | } |
146 | 167 | ||
147 | /** | 168 | /** |
@@ -155,16 +176,16 @@ static void sysfs_deactivate(struct sysfs_dirent *sd) | |||
155 | DECLARE_COMPLETION_ONSTACK(wait); | 176 | DECLARE_COMPLETION_ONSTACK(wait); |
156 | int v; | 177 | int v; |
157 | 178 | ||
158 | BUG_ON(sd->s_sibling || !(sd->s_flags & SYSFS_FLAG_REMOVED)); | 179 | BUG_ON(!(sd->s_flags & SYSFS_FLAG_REMOVED)); |
159 | 180 | ||
160 | if (!(sysfs_type(sd) & SYSFS_ACTIVE_REF)) | 181 | if (!(sysfs_type(sd) & SYSFS_ACTIVE_REF)) |
161 | return; | 182 | return; |
162 | 183 | ||
163 | sd->s_sibling = (void *)&wait; | 184 | sd->u.completion = (void *)&wait; |
164 | 185 | ||
165 | rwsem_acquire(&sd->dep_map, 0, 0, _RET_IP_); | 186 | rwsem_acquire(&sd->dep_map, 0, 0, _RET_IP_); |
166 | /* atomic_add_return() is a mb(), put_active() will always see | 187 | /* atomic_add_return() is a mb(), put_active() will always see |
167 | * the updated sd->s_sibling. | 188 | * the updated sd->u.completion. |
168 | */ | 189 | */ |
169 | v = atomic_add_return(SD_DEACTIVATED_BIAS, &sd->s_active); | 190 | v = atomic_add_return(SD_DEACTIVATED_BIAS, &sd->s_active); |
170 | 191 | ||
@@ -173,8 +194,6 @@ static void sysfs_deactivate(struct sysfs_dirent *sd) | |||
173 | wait_for_completion(&wait); | 194 | wait_for_completion(&wait); |
174 | } | 195 | } |
175 | 196 | ||
176 | sd->s_sibling = NULL; | ||
177 | |||
178 | lock_acquired(&sd->dep_map, _RET_IP_); | 197 | lock_acquired(&sd->dep_map, _RET_IP_); |
179 | rwsem_release(&sd->dep_map, 1, _RET_IP_); | 198 | rwsem_release(&sd->dep_map, 1, _RET_IP_); |
180 | } | 199 | } |
@@ -384,6 +403,13 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |||
384 | { | 403 | { |
385 | struct sysfs_inode_attrs *ps_iattr; | 404 | struct sysfs_inode_attrs *ps_iattr; |
386 | 405 | ||
406 | if (!!sysfs_ns_type(acxt->parent_sd) != !!sd->s_ns) { | ||
407 | WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n", | ||
408 | sysfs_ns_type(acxt->parent_sd)? "required": "invalid", | ||
409 | acxt->parent_sd->s_name, sd->s_name); | ||
410 | return -EINVAL; | ||
411 | } | ||
412 | |||
387 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_ns, sd->s_name)) | 413 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_ns, sd->s_name)) |
388 | return -EEXIST; | 414 | return -EEXIST; |
389 | 415 | ||
@@ -490,7 +516,7 @@ void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |||
490 | } | 516 | } |
491 | 517 | ||
492 | sd->s_flags |= SYSFS_FLAG_REMOVED; | 518 | sd->s_flags |= SYSFS_FLAG_REMOVED; |
493 | sd->s_sibling = acxt->removed; | 519 | sd->u.removed_list = acxt->removed; |
494 | acxt->removed = sd; | 520 | acxt->removed = sd; |
495 | } | 521 | } |
496 | 522 | ||
@@ -514,8 +540,7 @@ void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt) | |||
514 | while (acxt->removed) { | 540 | while (acxt->removed) { |
515 | struct sysfs_dirent *sd = acxt->removed; | 541 | struct sysfs_dirent *sd = acxt->removed; |
516 | 542 | ||
517 | acxt->removed = sd->s_sibling; | 543 | acxt->removed = sd->u.removed_list; |
518 | sd->s_sibling = NULL; | ||
519 | 544 | ||
520 | sysfs_deactivate(sd); | 545 | sysfs_deactivate(sd); |
521 | unmap_bin_file(sd); | 546 | unmap_bin_file(sd); |
@@ -540,15 +565,43 @@ struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, | |||
540 | const void *ns, | 565 | const void *ns, |
541 | const unsigned char *name) | 566 | const unsigned char *name) |
542 | { | 567 | { |
543 | struct sysfs_dirent *sd; | 568 | struct rb_node *p = parent_sd->s_dir.name_tree.rb_node; |
569 | struct sysfs_dirent *found = NULL; | ||
544 | 570 | ||
545 | for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) { | 571 | if (!!sysfs_ns_type(parent_sd) != !!ns) { |
546 | if (ns && sd->s_ns && (sd->s_ns != ns)) | 572 | WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n", |
547 | continue; | 573 | sysfs_ns_type(parent_sd)? "required": "invalid", |
548 | if (!strcmp(sd->s_name, name)) | 574 | parent_sd->s_name, name); |
549 | return sd; | 575 | return NULL; |
550 | } | 576 | } |
551 | return NULL; | 577 | |
578 | while (p) { | ||
579 | int c; | ||
580 | #define node rb_entry(p, struct sysfs_dirent, name_node) | ||
581 | c = strcmp(name, node->s_name); | ||
582 | if (c < 0) { | ||
583 | p = node->name_node.rb_left; | ||
584 | } else if (c > 0) { | ||
585 | p = node->name_node.rb_right; | ||
586 | } else { | ||
587 | found = node; | ||
588 | p = node->name_node.rb_left; | ||
589 | } | ||
590 | #undef node | ||
591 | } | ||
592 | |||
593 | if (found) { | ||
594 | while (found->s_ns != ns) { | ||
595 | p = rb_next(&found->name_node); | ||
596 | if (!p) | ||
597 | return NULL; | ||
598 | found = rb_entry(p, struct sysfs_dirent, name_node); | ||
599 | if (strcmp(name, found->s_name)) | ||
600 | return NULL; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | return found; | ||
552 | } | 605 | } |
553 | 606 | ||
554 | /** | 607 | /** |
@@ -744,21 +797,19 @@ void sysfs_remove_subdir(struct sysfs_dirent *sd) | |||
744 | static void __sysfs_remove_dir(struct sysfs_dirent *dir_sd) | 797 | static void __sysfs_remove_dir(struct sysfs_dirent *dir_sd) |
745 | { | 798 | { |
746 | struct sysfs_addrm_cxt acxt; | 799 | struct sysfs_addrm_cxt acxt; |
747 | struct sysfs_dirent **pos; | 800 | struct rb_node *pos; |
748 | 801 | ||
749 | if (!dir_sd) | 802 | if (!dir_sd) |
750 | return; | 803 | return; |
751 | 804 | ||
752 | pr_debug("sysfs %s: removing dir\n", dir_sd->s_name); | 805 | pr_debug("sysfs %s: removing dir\n", dir_sd->s_name); |
753 | sysfs_addrm_start(&acxt, dir_sd); | 806 | sysfs_addrm_start(&acxt, dir_sd); |
754 | pos = &dir_sd->s_dir.children; | 807 | pos = rb_first(&dir_sd->s_dir.inode_tree); |
755 | while (*pos) { | 808 | while (pos) { |
756 | struct sysfs_dirent *sd = *pos; | 809 | struct sysfs_dirent *sd = rb_entry(pos, struct sysfs_dirent, inode_node); |
757 | 810 | pos = rb_next(pos); | |
758 | if (sysfs_type(sd) != SYSFS_DIR) | 811 | if (sysfs_type(sd) != SYSFS_DIR) |
759 | sysfs_remove_one(&acxt, sd); | 812 | sysfs_remove_one(&acxt, sd); |
760 | else | ||
761 | pos = &(*pos)->s_sibling; | ||
762 | } | 813 | } |
763 | sysfs_addrm_finish(&acxt); | 814 | sysfs_addrm_finish(&acxt); |
764 | 815 | ||
@@ -881,12 +932,28 @@ static struct sysfs_dirent *sysfs_dir_pos(const void *ns, | |||
881 | pos = NULL; | 932 | pos = NULL; |
882 | } | 933 | } |
883 | if (!pos && (ino > 1) && (ino < INT_MAX)) { | 934 | if (!pos && (ino > 1) && (ino < INT_MAX)) { |
884 | pos = parent_sd->s_dir.children; | 935 | struct rb_node *p = parent_sd->s_dir.inode_tree.rb_node; |
885 | while (pos && (ino > pos->s_ino)) | 936 | while (p) { |
886 | pos = pos->s_sibling; | 937 | #define node rb_entry(p, struct sysfs_dirent, inode_node) |
938 | if (ino < node->s_ino) { | ||
939 | pos = node; | ||
940 | p = node->inode_node.rb_left; | ||
941 | } else if (ino > node->s_ino) { | ||
942 | p = node->inode_node.rb_right; | ||
943 | } else { | ||
944 | pos = node; | ||
945 | break; | ||
946 | } | ||
947 | #undef node | ||
948 | } | ||
949 | } | ||
950 | while (pos && pos->s_ns != ns) { | ||
951 | struct rb_node *p = rb_next(&pos->inode_node); | ||
952 | if (!p) | ||
953 | pos = NULL; | ||
954 | else | ||
955 | pos = rb_entry(p, struct sysfs_dirent, inode_node); | ||
887 | } | 956 | } |
888 | while (pos && pos->s_ns && pos->s_ns != ns) | ||
889 | pos = pos->s_sibling; | ||
890 | return pos; | 957 | return pos; |
891 | } | 958 | } |
892 | 959 | ||
@@ -894,10 +961,13 @@ static struct sysfs_dirent *sysfs_dir_next_pos(const void *ns, | |||
894 | struct sysfs_dirent *parent_sd, ino_t ino, struct sysfs_dirent *pos) | 961 | struct sysfs_dirent *parent_sd, ino_t ino, struct sysfs_dirent *pos) |
895 | { | 962 | { |
896 | pos = sysfs_dir_pos(ns, parent_sd, ino, pos); | 963 | pos = sysfs_dir_pos(ns, parent_sd, ino, pos); |
897 | if (pos) | 964 | if (pos) do { |
898 | pos = pos->s_sibling; | 965 | struct rb_node *p = rb_next(&pos->inode_node); |
899 | while (pos && pos->s_ns && pos->s_ns != ns) | 966 | if (!p) |
900 | pos = pos->s_sibling; | 967 | pos = NULL; |
968 | else | ||
969 | pos = rb_entry(p, struct sysfs_dirent, inode_node); | ||
970 | } while (pos && pos->s_ns != ns); | ||
901 | return pos; | 971 | return pos; |
902 | } | 972 | } |
903 | 973 | ||
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 1ad8c93c1b85..d4e6080b4b20 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -466,9 +466,6 @@ void sysfs_notify(struct kobject *k, const char *dir, const char *attr) | |||
466 | mutex_lock(&sysfs_mutex); | 466 | mutex_lock(&sysfs_mutex); |
467 | 467 | ||
468 | if (sd && dir) | 468 | if (sd && dir) |
469 | /* Only directories are tagged, so no need to pass | ||
470 | * a tag explicitly. | ||
471 | */ | ||
472 | sd = sysfs_find_dirent(sd, NULL, dir); | 469 | sd = sysfs_find_dirent(sd, NULL, dir); |
473 | if (sd && attr) | 470 | if (sd && attr) |
474 | sd = sysfs_find_dirent(sd, NULL, attr); | 471 | sd = sysfs_find_dirent(sd, NULL, attr); |
@@ -488,17 +485,56 @@ const struct file_operations sysfs_file_operations = { | |||
488 | .poll = sysfs_poll, | 485 | .poll = sysfs_poll, |
489 | }; | 486 | }; |
490 | 487 | ||
488 | int sysfs_attr_ns(struct kobject *kobj, const struct attribute *attr, | ||
489 | const void **pns) | ||
490 | { | ||
491 | struct sysfs_dirent *dir_sd = kobj->sd; | ||
492 | const struct sysfs_ops *ops; | ||
493 | const void *ns = NULL; | ||
494 | int err; | ||
495 | |||
496 | err = 0; | ||
497 | if (!sysfs_ns_type(dir_sd)) | ||
498 | goto out; | ||
499 | |||
500 | err = -EINVAL; | ||
501 | if (!kobj->ktype) | ||
502 | goto out; | ||
503 | ops = kobj->ktype->sysfs_ops; | ||
504 | if (!ops) | ||
505 | goto out; | ||
506 | if (!ops->namespace) | ||
507 | goto out; | ||
508 | |||
509 | err = 0; | ||
510 | ns = ops->namespace(kobj, attr); | ||
511 | out: | ||
512 | if (err) { | ||
513 | WARN(1, KERN_ERR "missing sysfs namespace attribute operation for " | ||
514 | "kobject: %s\n", kobject_name(kobj)); | ||
515 | } | ||
516 | *pns = ns; | ||
517 | return err; | ||
518 | } | ||
519 | |||
491 | int sysfs_add_file_mode(struct sysfs_dirent *dir_sd, | 520 | int sysfs_add_file_mode(struct sysfs_dirent *dir_sd, |
492 | const struct attribute *attr, int type, mode_t amode) | 521 | const struct attribute *attr, int type, mode_t amode) |
493 | { | 522 | { |
494 | umode_t mode = (amode & S_IALLUGO) | S_IFREG; | 523 | umode_t mode = (amode & S_IALLUGO) | S_IFREG; |
495 | struct sysfs_addrm_cxt acxt; | 524 | struct sysfs_addrm_cxt acxt; |
496 | struct sysfs_dirent *sd; | 525 | struct sysfs_dirent *sd; |
526 | const void *ns; | ||
497 | int rc; | 527 | int rc; |
498 | 528 | ||
529 | rc = sysfs_attr_ns(dir_sd->s_dir.kobj, attr, &ns); | ||
530 | if (rc) | ||
531 | return rc; | ||
532 | |||
499 | sd = sysfs_new_dirent(attr->name, mode, type); | 533 | sd = sysfs_new_dirent(attr->name, mode, type); |
500 | if (!sd) | 534 | if (!sd) |
501 | return -ENOMEM; | 535 | return -ENOMEM; |
536 | |||
537 | sd->s_ns = ns; | ||
502 | sd->s_attr.attr = (void *)attr; | 538 | sd->s_attr.attr = (void *)attr; |
503 | sysfs_dirent_init_lockdep(sd); | 539 | sysfs_dirent_init_lockdep(sd); |
504 | 540 | ||
@@ -586,12 +622,17 @@ int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr, | |||
586 | { | 622 | { |
587 | struct sysfs_dirent *sd; | 623 | struct sysfs_dirent *sd; |
588 | struct iattr newattrs; | 624 | struct iattr newattrs; |
625 | const void *ns; | ||
589 | int rc; | 626 | int rc; |
590 | 627 | ||
628 | rc = sysfs_attr_ns(kobj, attr, &ns); | ||
629 | if (rc) | ||
630 | return rc; | ||
631 | |||
591 | mutex_lock(&sysfs_mutex); | 632 | mutex_lock(&sysfs_mutex); |
592 | 633 | ||
593 | rc = -ENOENT; | 634 | rc = -ENOENT; |
594 | sd = sysfs_find_dirent(kobj->sd, NULL, attr->name); | 635 | sd = sysfs_find_dirent(kobj->sd, ns, attr->name); |
595 | if (!sd) | 636 | if (!sd) |
596 | goto out; | 637 | goto out; |
597 | 638 | ||
@@ -616,7 +657,12 @@ EXPORT_SYMBOL_GPL(sysfs_chmod_file); | |||
616 | 657 | ||
617 | void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) | 658 | void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) |
618 | { | 659 | { |
619 | sysfs_hash_and_remove(kobj->sd, NULL, attr->name); | 660 | const void *ns; |
661 | |||
662 | if (sysfs_attr_ns(kobj, attr, &ns)) | ||
663 | return; | ||
664 | |||
665 | sysfs_hash_and_remove(kobj->sd, ns, attr->name); | ||
620 | } | 666 | } |
621 | 667 | ||
622 | void sysfs_remove_files(struct kobject * kobj, const struct attribute **ptr) | 668 | void sysfs_remove_files(struct kobject * kobj, const struct attribute **ptr) |
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index e3f091a81c72..e23f28894a3a 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
@@ -202,18 +202,6 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr) | |||
202 | inode->i_ctime = iattr->ia_ctime; | 202 | inode->i_ctime = iattr->ia_ctime; |
203 | } | 203 | } |
204 | 204 | ||
205 | static int sysfs_count_nlink(struct sysfs_dirent *sd) | ||
206 | { | ||
207 | struct sysfs_dirent *child; | ||
208 | int nr = 0; | ||
209 | |||
210 | for (child = sd->s_dir.children; child; child = child->s_sibling) | ||
211 | if (sysfs_type(child) == SYSFS_DIR) | ||
212 | nr++; | ||
213 | |||
214 | return nr + 2; | ||
215 | } | ||
216 | |||
217 | static void sysfs_refresh_inode(struct sysfs_dirent *sd, struct inode *inode) | 205 | static void sysfs_refresh_inode(struct sysfs_dirent *sd, struct inode *inode) |
218 | { | 206 | { |
219 | struct sysfs_inode_attrs *iattrs = sd->s_iattr; | 207 | struct sysfs_inode_attrs *iattrs = sd->s_iattr; |
@@ -230,7 +218,7 @@ static void sysfs_refresh_inode(struct sysfs_dirent *sd, struct inode *inode) | |||
230 | } | 218 | } |
231 | 219 | ||
232 | if (sysfs_type(sd) == SYSFS_DIR) | 220 | if (sysfs_type(sd) == SYSFS_DIR) |
233 | inode->i_nlink = sysfs_count_nlink(sd); | 221 | inode->i_nlink = sd->s_dir.subdirs + 2; |
234 | } | 222 | } |
235 | 223 | ||
236 | int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) | 224 | int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) |
@@ -336,8 +324,6 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const cha | |||
336 | sysfs_addrm_start(&acxt, dir_sd); | 324 | sysfs_addrm_start(&acxt, dir_sd); |
337 | 325 | ||
338 | sd = sysfs_find_dirent(dir_sd, ns, name); | 326 | sd = sysfs_find_dirent(dir_sd, ns, name); |
339 | if (sd && (sd->s_ns != ns)) | ||
340 | sd = NULL; | ||
341 | if (sd) | 327 | if (sd) |
342 | sysfs_remove_one(&acxt, sd); | 328 | sysfs_remove_one(&acxt, sd); |
343 | 329 | ||
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index 845ab3ad229d..ce29e28b766d 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -11,14 +11,18 @@ | |||
11 | #include <linux/lockdep.h> | 11 | #include <linux/lockdep.h> |
12 | #include <linux/kobject_ns.h> | 12 | #include <linux/kobject_ns.h> |
13 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
14 | #include <linux/rbtree.h> | ||
14 | 15 | ||
15 | struct sysfs_open_dirent; | 16 | struct sysfs_open_dirent; |
16 | 17 | ||
17 | /* type-specific structures for sysfs_dirent->s_* union members */ | 18 | /* type-specific structures for sysfs_dirent->s_* union members */ |
18 | struct sysfs_elem_dir { | 19 | struct sysfs_elem_dir { |
19 | struct kobject *kobj; | 20 | struct kobject *kobj; |
20 | /* children list starts here and goes through sd->s_sibling */ | 21 | |
21 | struct sysfs_dirent *children; | 22 | unsigned long subdirs; |
23 | |||
24 | struct rb_root inode_tree; | ||
25 | struct rb_root name_tree; | ||
22 | }; | 26 | }; |
23 | 27 | ||
24 | struct sysfs_elem_symlink { | 28 | struct sysfs_elem_symlink { |
@@ -56,9 +60,16 @@ struct sysfs_dirent { | |||
56 | struct lockdep_map dep_map; | 60 | struct lockdep_map dep_map; |
57 | #endif | 61 | #endif |
58 | struct sysfs_dirent *s_parent; | 62 | struct sysfs_dirent *s_parent; |
59 | struct sysfs_dirent *s_sibling; | ||
60 | const char *s_name; | 63 | const char *s_name; |
61 | 64 | ||
65 | struct rb_node inode_node; | ||
66 | struct rb_node name_node; | ||
67 | |||
68 | union { | ||
69 | struct completion *completion; | ||
70 | struct sysfs_dirent *removed_list; | ||
71 | } u; | ||
72 | |||
62 | const void *s_ns; /* namespace tag */ | 73 | const void *s_ns; /* namespace tag */ |
63 | union { | 74 | union { |
64 | struct sysfs_elem_dir s_dir; | 75 | struct sysfs_elem_dir s_dir; |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 45174b534377..feb361e252ac 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -335,9 +335,9 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c); | |||
335 | #define DBGKEY(key) ((char *)(key)) | 335 | #define DBGKEY(key) ((char *)(key)) |
336 | #define DBGKEY1(key) ((char *)(key)) | 336 | #define DBGKEY1(key) ((char *)(key)) |
337 | 337 | ||
338 | #define ubifs_dbg_msg(fmt, ...) do { \ | 338 | #define ubifs_dbg_msg(fmt, ...) do { \ |
339 | if (0) \ | 339 | if (0) \ |
340 | pr_debug(fmt "\n", ##__VA_ARGS__); \ | 340 | printk(KERN_DEBUG fmt "\n", ##__VA_ARGS__); \ |
341 | } while (0) | 341 | } while (0) |
342 | 342 | ||
343 | #define dbg_dump_stack() | 343 | #define dbg_dump_stack() |
diff --git a/fs/xattr.c b/fs/xattr.c index f060663ab70c..67583de8218c 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/mount.h> | 14 | #include <linux/mount.h> |
15 | #include <linux/namei.h> | 15 | #include <linux/namei.h> |
16 | #include <linux/security.h> | 16 | #include <linux/security.h> |
17 | #include <linux/evm.h> | ||
17 | #include <linux/syscalls.h> | 18 | #include <linux/syscalls.h> |
18 | #include <linux/module.h> | 19 | #include <linux/module.h> |
19 | #include <linux/fsnotify.h> | 20 | #include <linux/fsnotify.h> |
@@ -166,6 +167,64 @@ out_noalloc: | |||
166 | } | 167 | } |
167 | EXPORT_SYMBOL_GPL(xattr_getsecurity); | 168 | EXPORT_SYMBOL_GPL(xattr_getsecurity); |
168 | 169 | ||
170 | /* | ||
171 | * vfs_getxattr_alloc - allocate memory, if necessary, before calling getxattr | ||
172 | * | ||
173 | * Allocate memory, if not already allocated, or re-allocate correct size, | ||
174 | * before retrieving the extended attribute. | ||
175 | * | ||
176 | * Returns the result of alloc, if failed, or the getxattr operation. | ||
177 | */ | ||
178 | ssize_t | ||
179 | vfs_getxattr_alloc(struct dentry *dentry, const char *name, char **xattr_value, | ||
180 | size_t xattr_size, gfp_t flags) | ||
181 | { | ||
182 | struct inode *inode = dentry->d_inode; | ||
183 | char *value = *xattr_value; | ||
184 | int error; | ||
185 | |||
186 | error = xattr_permission(inode, name, MAY_READ); | ||
187 | if (error) | ||
188 | return error; | ||
189 | |||
190 | if (!inode->i_op->getxattr) | ||
191 | return -EOPNOTSUPP; | ||
192 | |||
193 | error = inode->i_op->getxattr(dentry, name, NULL, 0); | ||
194 | if (error < 0) | ||
195 | return error; | ||
196 | |||
197 | if (!value || (error > xattr_size)) { | ||
198 | value = krealloc(*xattr_value, error + 1, flags); | ||
199 | if (!value) | ||
200 | return -ENOMEM; | ||
201 | memset(value, 0, error + 1); | ||
202 | } | ||
203 | |||
204 | error = inode->i_op->getxattr(dentry, name, value, error); | ||
205 | *xattr_value = value; | ||
206 | return error; | ||
207 | } | ||
208 | |||
209 | /* Compare an extended attribute value with the given value */ | ||
210 | int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name, | ||
211 | const char *value, size_t size, gfp_t flags) | ||
212 | { | ||
213 | char *xattr_value = NULL; | ||
214 | int rc; | ||
215 | |||
216 | rc = vfs_getxattr_alloc(dentry, xattr_name, &xattr_value, 0, flags); | ||
217 | if (rc < 0) | ||
218 | return rc; | ||
219 | |||
220 | if ((rc != size) || (memcmp(xattr_value, value, rc) != 0)) | ||
221 | rc = -EINVAL; | ||
222 | else | ||
223 | rc = 0; | ||
224 | kfree(xattr_value); | ||
225 | return rc; | ||
226 | } | ||
227 | |||
169 | ssize_t | 228 | ssize_t |
170 | vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) | 229 | vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) |
171 | { | 230 | { |
@@ -243,8 +302,10 @@ vfs_removexattr(struct dentry *dentry, const char *name) | |||
243 | error = inode->i_op->removexattr(dentry, name); | 302 | error = inode->i_op->removexattr(dentry, name); |
244 | mutex_unlock(&inode->i_mutex); | 303 | mutex_unlock(&inode->i_mutex); |
245 | 304 | ||
246 | if (!error) | 305 | if (!error) { |
247 | fsnotify_xattr(dentry); | 306 | fsnotify_xattr(dentry); |
307 | evm_inode_post_removexattr(dentry, name); | ||
308 | } | ||
248 | return error; | 309 | return error; |
249 | } | 310 | } |
250 | EXPORT_SYMBOL_GPL(vfs_removexattr); | 311 | EXPORT_SYMBOL_GPL(vfs_removexattr); |
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 75bb316529dd..427a4e82a588 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile | |||
@@ -16,44 +16,53 @@ | |||
16 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 16 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | # | 17 | # |
18 | 18 | ||
19 | ccflags-y := -I$(src) -I$(src)/linux-2.6 | 19 | ccflags-y += -I$(src) # needed for trace events |
20 | ccflags-$(CONFIG_XFS_DEBUG) += -g | ||
21 | 20 | ||
22 | XFS_LINUX := linux-2.6 | 21 | ccflags-$(CONFIG_XFS_DEBUG) += -g |
23 | 22 | ||
24 | obj-$(CONFIG_XFS_FS) += xfs.o | 23 | obj-$(CONFIG_XFS_FS) += xfs.o |
25 | 24 | ||
26 | xfs-y += linux-2.6/xfs_trace.o | 25 | # this one should be compiled first, as the tracing macros can easily blow up |
27 | 26 | xfs-y += xfs_trace.o | |
28 | xfs-$(CONFIG_XFS_QUOTA) += $(addprefix quota/, \ | ||
29 | xfs_dquot.o \ | ||
30 | xfs_dquot_item.o \ | ||
31 | xfs_trans_dquot.o \ | ||
32 | xfs_qm_syscalls.o \ | ||
33 | xfs_qm_bhv.o \ | ||
34 | xfs_qm.o) | ||
35 | xfs-$(CONFIG_XFS_QUOTA) += linux-2.6/xfs_quotaops.o | ||
36 | |||
37 | ifeq ($(CONFIG_XFS_QUOTA),y) | ||
38 | xfs-$(CONFIG_PROC_FS) += quota/xfs_qm_stats.o | ||
39 | endif | ||
40 | |||
41 | xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o | ||
42 | xfs-$(CONFIG_XFS_POSIX_ACL) += $(XFS_LINUX)/xfs_acl.o | ||
43 | xfs-$(CONFIG_PROC_FS) += $(XFS_LINUX)/xfs_stats.o | ||
44 | xfs-$(CONFIG_SYSCTL) += $(XFS_LINUX)/xfs_sysctl.o | ||
45 | xfs-$(CONFIG_COMPAT) += $(XFS_LINUX)/xfs_ioctl32.o | ||
46 | 27 | ||
28 | # highlevel code | ||
29 | xfs-y += xfs_aops.o \ | ||
30 | xfs_bit.o \ | ||
31 | xfs_buf.o \ | ||
32 | xfs_dfrag.o \ | ||
33 | xfs_discard.o \ | ||
34 | xfs_error.o \ | ||
35 | xfs_export.o \ | ||
36 | xfs_file.o \ | ||
37 | xfs_filestream.o \ | ||
38 | xfs_fsops.o \ | ||
39 | xfs_fs_subr.o \ | ||
40 | xfs_globals.o \ | ||
41 | xfs_iget.o \ | ||
42 | xfs_ioctl.o \ | ||
43 | xfs_iomap.o \ | ||
44 | xfs_iops.o \ | ||
45 | xfs_itable.o \ | ||
46 | xfs_message.o \ | ||
47 | xfs_mru_cache.o \ | ||
48 | xfs_super.o \ | ||
49 | xfs_sync.o \ | ||
50 | xfs_xattr.o \ | ||
51 | xfs_rename.o \ | ||
52 | xfs_rw.o \ | ||
53 | xfs_utils.o \ | ||
54 | xfs_vnodeops.o \ | ||
55 | kmem.o \ | ||
56 | uuid.o | ||
47 | 57 | ||
58 | # code shared with libxfs | ||
48 | xfs-y += xfs_alloc.o \ | 59 | xfs-y += xfs_alloc.o \ |
49 | xfs_alloc_btree.o \ | 60 | xfs_alloc_btree.o \ |
50 | xfs_attr.o \ | 61 | xfs_attr.o \ |
51 | xfs_attr_leaf.o \ | 62 | xfs_attr_leaf.o \ |
52 | xfs_bit.o \ | ||
53 | xfs_bmap.o \ | 63 | xfs_bmap.o \ |
54 | xfs_bmap_btree.o \ | 64 | xfs_bmap_btree.o \ |
55 | xfs_btree.o \ | 65 | xfs_btree.o \ |
56 | xfs_buf_item.o \ | ||
57 | xfs_da_btree.o \ | 66 | xfs_da_btree.o \ |
58 | xfs_dir2.o \ | 67 | xfs_dir2.o \ |
59 | xfs_dir2_block.o \ | 68 | xfs_dir2_block.o \ |
@@ -61,49 +70,37 @@ xfs-y += xfs_alloc.o \ | |||
61 | xfs_dir2_leaf.o \ | 70 | xfs_dir2_leaf.o \ |
62 | xfs_dir2_node.o \ | 71 | xfs_dir2_node.o \ |
63 | xfs_dir2_sf.o \ | 72 | xfs_dir2_sf.o \ |
64 | xfs_error.o \ | ||
65 | xfs_extfree_item.o \ | ||
66 | xfs_filestream.o \ | ||
67 | xfs_fsops.o \ | ||
68 | xfs_ialloc.o \ | 73 | xfs_ialloc.o \ |
69 | xfs_ialloc_btree.o \ | 74 | xfs_ialloc_btree.o \ |
70 | xfs_iget.o \ | ||
71 | xfs_inode.o \ | 75 | xfs_inode.o \ |
72 | xfs_inode_item.o \ | ||
73 | xfs_iomap.o \ | ||
74 | xfs_itable.o \ | ||
75 | xfs_dfrag.o \ | ||
76 | xfs_log.o \ | ||
77 | xfs_log_cil.o \ | ||
78 | xfs_log_recover.o \ | 76 | xfs_log_recover.o \ |
79 | xfs_mount.o \ | 77 | xfs_mount.o \ |
80 | xfs_mru_cache.o \ | 78 | xfs_trans.o |
81 | xfs_rename.o \ | 79 | |
82 | xfs_trans.o \ | 80 | # low-level transaction/log code |
81 | xfs-y += xfs_log.o \ | ||
82 | xfs_log_cil.o \ | ||
83 | xfs_buf_item.o \ | ||
84 | xfs_extfree_item.o \ | ||
85 | xfs_inode_item.o \ | ||
83 | xfs_trans_ail.o \ | 86 | xfs_trans_ail.o \ |
84 | xfs_trans_buf.o \ | 87 | xfs_trans_buf.o \ |
85 | xfs_trans_extfree.o \ | 88 | xfs_trans_extfree.o \ |
86 | xfs_trans_inode.o \ | 89 | xfs_trans_inode.o \ |
87 | xfs_utils.o \ | ||
88 | xfs_vnodeops.o \ | ||
89 | xfs_rw.o | ||
90 | |||
91 | # Objects in linux/ | ||
92 | xfs-y += $(addprefix $(XFS_LINUX)/, \ | ||
93 | kmem.o \ | ||
94 | xfs_aops.o \ | ||
95 | xfs_buf.o \ | ||
96 | xfs_discard.o \ | ||
97 | xfs_export.o \ | ||
98 | xfs_file.o \ | ||
99 | xfs_fs_subr.o \ | ||
100 | xfs_globals.o \ | ||
101 | xfs_ioctl.o \ | ||
102 | xfs_iops.o \ | ||
103 | xfs_message.o \ | ||
104 | xfs_super.o \ | ||
105 | xfs_sync.o \ | ||
106 | xfs_xattr.o) | ||
107 | 90 | ||
108 | # Objects in support/ | 91 | # optional features |
109 | xfs-y += support/uuid.o | 92 | xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \ |
93 | xfs_dquot_item.o \ | ||
94 | xfs_trans_dquot.o \ | ||
95 | xfs_qm_syscalls.o \ | ||
96 | xfs_qm_bhv.o \ | ||
97 | xfs_qm.o \ | ||
98 | xfs_quotaops.o | ||
99 | ifeq ($(CONFIG_XFS_QUOTA),y) | ||
100 | xfs-$(CONFIG_PROC_FS) += xfs_qm_stats.o | ||
101 | endif | ||
102 | xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o | ||
103 | xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o | ||
104 | xfs-$(CONFIG_PROC_FS) += xfs_stats.o | ||
105 | xfs-$(CONFIG_SYSCTL) += xfs_sysctl.o | ||
106 | xfs-$(CONFIG_COMPAT) += xfs_ioctl32.o | ||
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/kmem.c index a907de565db3..a907de565db3 100644 --- a/fs/xfs/linux-2.6/kmem.c +++ b/fs/xfs/kmem.c | |||
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/kmem.h index f7c8f7a9ea6d..292eff198030 100644 --- a/fs/xfs/linux-2.6/kmem.h +++ b/fs/xfs/kmem.h | |||
@@ -61,12 +61,7 @@ extern void kmem_free(const void *); | |||
61 | 61 | ||
62 | static inline void *kmem_zalloc_large(size_t size) | 62 | static inline void *kmem_zalloc_large(size_t size) |
63 | { | 63 | { |
64 | void *ptr; | 64 | return vzalloc(size); |
65 | |||
66 | ptr = vmalloc(size); | ||
67 | if (ptr) | ||
68 | memset(ptr, 0, size); | ||
69 | return ptr; | ||
70 | } | 65 | } |
71 | static inline void kmem_free_large(void *ptr) | 66 | static inline void kmem_free_large(void *ptr) |
72 | { | 67 | { |
diff --git a/fs/xfs/linux-2.6/mrlock.h b/fs/xfs/mrlock.h index ff6a19873e5c..ff6a19873e5c 100644 --- a/fs/xfs/linux-2.6/mrlock.h +++ b/fs/xfs/mrlock.h | |||
diff --git a/fs/xfs/linux-2.6/time.h b/fs/xfs/time.h index 387e695a184c..387e695a184c 100644 --- a/fs/xfs/linux-2.6/time.h +++ b/fs/xfs/time.h | |||
diff --git a/fs/xfs/support/uuid.c b/fs/xfs/uuid.c index b83f76b6d410..b83f76b6d410 100644 --- a/fs/xfs/support/uuid.c +++ b/fs/xfs/uuid.c | |||
diff --git a/fs/xfs/support/uuid.h b/fs/xfs/uuid.h index 4732d71262cc..4732d71262cc 100644 --- a/fs/xfs/support/uuid.h +++ b/fs/xfs/uuid.h | |||
diff --git a/fs/xfs/xfs.h b/fs/xfs/xfs.h index 53ec3ea9a625..d8b11b7f94aa 100644 --- a/fs/xfs/xfs.h +++ b/fs/xfs/xfs.h | |||
@@ -24,5 +24,6 @@ | |||
24 | #define XFS_BUF_LOCK_TRACKING 1 | 24 | #define XFS_BUF_LOCK_TRACKING 1 |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #include <linux-2.6/xfs_linux.h> | 27 | #include "xfs_linux.h" |
28 | |||
28 | #endif /* __XFS_H__ */ | 29 | #endif /* __XFS_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/xfs_acl.c index b6c4b3795c4a..b6c4b3795c4a 100644 --- a/fs/xfs/linux-2.6/xfs_acl.c +++ b/fs/xfs/xfs_acl.c | |||
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h index 6530769a999b..4805f009f923 100644 --- a/fs/xfs/xfs_ag.h +++ b/fs/xfs/xfs_ag.h | |||
@@ -103,7 +103,7 @@ typedef struct xfs_agf { | |||
103 | /* disk block (xfs_daddr_t) in the AG */ | 103 | /* disk block (xfs_daddr_t) in the AG */ |
104 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) | 104 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) |
105 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) | 105 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) |
106 | #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp)) | 106 | #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)((bp)->b_addr)) |
107 | 107 | ||
108 | extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, | 108 | extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, |
109 | xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); | 109 | xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); |
@@ -156,7 +156,7 @@ typedef struct xfs_agi { | |||
156 | /* disk block (xfs_daddr_t) in the AG */ | 156 | /* disk block (xfs_daddr_t) in the AG */ |
157 | #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) | 157 | #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) |
158 | #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) | 158 | #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) |
159 | #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp)) | 159 | #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr)) |
160 | 160 | ||
161 | extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, | 161 | extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, |
162 | xfs_agnumber_t agno, struct xfs_buf **bpp); | 162 | xfs_agnumber_t agno, struct xfs_buf **bpp); |
@@ -168,7 +168,7 @@ extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, | |||
168 | #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) | 168 | #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) |
169 | #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) | 169 | #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) |
170 | #define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t)) | 170 | #define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t)) |
171 | #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp)) | 171 | #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)((bp)->b_addr)) |
172 | 172 | ||
173 | typedef struct xfs_agfl { | 173 | typedef struct xfs_agfl { |
174 | __be32 agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ | 174 | __be32 agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ |
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 1e00b3ef6274..bdd9cb54d63b 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -451,8 +451,7 @@ xfs_alloc_read_agfl( | |||
451 | XFS_FSS_TO_BB(mp, 1), 0, &bp); | 451 | XFS_FSS_TO_BB(mp, 1), 0, &bp); |
452 | if (error) | 452 | if (error) |
453 | return error; | 453 | return error; |
454 | ASSERT(bp); | 454 | ASSERT(!xfs_buf_geterror(bp)); |
455 | ASSERT(!XFS_BUF_GETERROR(bp)); | ||
456 | XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGFL, XFS_AGFL_REF); | 455 | XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGFL, XFS_AGFL_REF); |
457 | *bpp = bp; | 456 | *bpp = bp; |
458 | return 0; | 457 | return 0; |
@@ -2116,7 +2115,7 @@ xfs_read_agf( | |||
2116 | if (!*bpp) | 2115 | if (!*bpp) |
2117 | return 0; | 2116 | return 0; |
2118 | 2117 | ||
2119 | ASSERT(!XFS_BUF_GETERROR(*bpp)); | 2118 | ASSERT(!(*bpp)->b_error); |
2120 | agf = XFS_BUF_TO_AGF(*bpp); | 2119 | agf = XFS_BUF_TO_AGF(*bpp); |
2121 | 2120 | ||
2122 | /* | 2121 | /* |
@@ -2168,7 +2167,7 @@ xfs_alloc_read_agf( | |||
2168 | return error; | 2167 | return error; |
2169 | if (!*bpp) | 2168 | if (!*bpp) |
2170 | return 0; | 2169 | return 0; |
2171 | ASSERT(!XFS_BUF_GETERROR(*bpp)); | 2170 | ASSERT(!(*bpp)->b_error); |
2172 | 2171 | ||
2173 | agf = XFS_BUF_TO_AGF(*bpp); | 2172 | agf = XFS_BUF_TO_AGF(*bpp); |
2174 | pag = xfs_perag_get(mp, agno); | 2173 | pag = xfs_perag_get(mp, agno); |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/xfs_aops.c index 63e971e2b837..8c37dde4c521 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/xfs_aops.c | |||
@@ -1300,6 +1300,7 @@ xfs_end_io_direct_write( | |||
1300 | bool is_async) | 1300 | bool is_async) |
1301 | { | 1301 | { |
1302 | struct xfs_ioend *ioend = iocb->private; | 1302 | struct xfs_ioend *ioend = iocb->private; |
1303 | struct inode *inode = ioend->io_inode; | ||
1303 | 1304 | ||
1304 | /* | 1305 | /* |
1305 | * blockdev_direct_IO can return an error even after the I/O | 1306 | * blockdev_direct_IO can return an error even after the I/O |
@@ -1331,7 +1332,7 @@ xfs_end_io_direct_write( | |||
1331 | } | 1332 | } |
1332 | 1333 | ||
1333 | /* XXX: probably should move into the real I/O completion handler */ | 1334 | /* XXX: probably should move into the real I/O completion handler */ |
1334 | inode_dio_done(ioend->io_inode); | 1335 | inode_dio_done(inode); |
1335 | } | 1336 | } |
1336 | 1337 | ||
1337 | STATIC ssize_t | 1338 | STATIC ssize_t |
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/xfs_aops.h index 71f721e1a71f..71f721e1a71f 100644 --- a/fs/xfs/linux-2.6/xfs_aops.h +++ b/fs/xfs/xfs_aops.h | |||
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index cbae424fe1ba..160bcdc34a6e 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -2121,8 +2121,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args) | |||
2121 | 2121 | ||
2122 | bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt, | 2122 | bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt, |
2123 | XBF_LOCK | XBF_DONT_BLOCK); | 2123 | XBF_LOCK | XBF_DONT_BLOCK); |
2124 | ASSERT(bp); | 2124 | ASSERT(!xfs_buf_geterror(bp)); |
2125 | ASSERT(!XFS_BUF_GETERROR(bp)); | ||
2126 | 2125 | ||
2127 | tmp = (valuelen < XFS_BUF_SIZE(bp)) ? valuelen : | 2126 | tmp = (valuelen < XFS_BUF_SIZE(bp)) ? valuelen : |
2128 | XFS_BUF_SIZE(bp); | 2127 | XFS_BUF_SIZE(bp); |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index ab3e5c6c4642..452a291383ab 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -3383,8 +3383,7 @@ xfs_bmap_local_to_extents( | |||
3383 | ASSERT(args.len == 1); | 3383 | ASSERT(args.len == 1); |
3384 | *firstblock = args.fsbno; | 3384 | *firstblock = args.fsbno; |
3385 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); | 3385 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); |
3386 | memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data, | 3386 | memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); |
3387 | ifp->if_bytes); | ||
3388 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); | 3387 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); |
3389 | xfs_bmap_forkoff_reset(args.mp, ip, whichfork); | 3388 | xfs_bmap_forkoff_reset(args.mp, ip, whichfork); |
3390 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); | 3389 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); |
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index cabf4b5604aa..2b9fd385e27d 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
@@ -275,8 +275,7 @@ xfs_btree_dup_cursor( | |||
275 | return error; | 275 | return error; |
276 | } | 276 | } |
277 | new->bc_bufs[i] = bp; | 277 | new->bc_bufs[i] = bp; |
278 | ASSERT(bp); | 278 | ASSERT(!xfs_buf_geterror(bp)); |
279 | ASSERT(!XFS_BUF_GETERROR(bp)); | ||
280 | } else | 279 | } else |
281 | new->bc_bufs[i] = NULL; | 280 | new->bc_bufs[i] = NULL; |
282 | } | 281 | } |
@@ -467,8 +466,7 @@ xfs_btree_get_bufl( | |||
467 | ASSERT(fsbno != NULLFSBLOCK); | 466 | ASSERT(fsbno != NULLFSBLOCK); |
468 | d = XFS_FSB_TO_DADDR(mp, fsbno); | 467 | d = XFS_FSB_TO_DADDR(mp, fsbno); |
469 | bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); | 468 | bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); |
470 | ASSERT(bp); | 469 | ASSERT(!xfs_buf_geterror(bp)); |
471 | ASSERT(!XFS_BUF_GETERROR(bp)); | ||
472 | return bp; | 470 | return bp; |
473 | } | 471 | } |
474 | 472 | ||
@@ -491,8 +489,7 @@ xfs_btree_get_bufs( | |||
491 | ASSERT(agbno != NULLAGBLOCK); | 489 | ASSERT(agbno != NULLAGBLOCK); |
492 | d = XFS_AGB_TO_DADDR(mp, agno, agbno); | 490 | d = XFS_AGB_TO_DADDR(mp, agno, agbno); |
493 | bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); | 491 | bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); |
494 | ASSERT(bp); | 492 | ASSERT(!xfs_buf_geterror(bp)); |
495 | ASSERT(!XFS_BUF_GETERROR(bp)); | ||
496 | return bp; | 493 | return bp; |
497 | } | 494 | } |
498 | 495 | ||
@@ -632,7 +629,7 @@ xfs_btree_read_bufl( | |||
632 | mp->m_bsize, lock, &bp))) { | 629 | mp->m_bsize, lock, &bp))) { |
633 | return error; | 630 | return error; |
634 | } | 631 | } |
635 | ASSERT(!bp || !XFS_BUF_GETERROR(bp)); | 632 | ASSERT(!xfs_buf_geterror(bp)); |
636 | if (bp) | 633 | if (bp) |
637 | XFS_BUF_SET_VTYPE_REF(bp, B_FS_MAP, refval); | 634 | XFS_BUF_SET_VTYPE_REF(bp, B_FS_MAP, refval); |
638 | *bpp = bp; | 635 | *bpp = bp; |
@@ -973,8 +970,7 @@ xfs_btree_get_buf_block( | |||
973 | *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, | 970 | *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, |
974 | mp->m_bsize, flags); | 971 | mp->m_bsize, flags); |
975 | 972 | ||
976 | ASSERT(*bpp); | 973 | ASSERT(!xfs_buf_geterror(*bpp)); |
977 | ASSERT(!XFS_BUF_GETERROR(*bpp)); | ||
978 | 974 | ||
979 | *block = XFS_BUF_TO_BLOCK(*bpp); | 975 | *block = XFS_BUF_TO_BLOCK(*bpp); |
980 | return 0; | 976 | return 0; |
@@ -1006,8 +1002,7 @@ xfs_btree_read_buf_block( | |||
1006 | if (error) | 1002 | if (error) |
1007 | return error; | 1003 | return error; |
1008 | 1004 | ||
1009 | ASSERT(*bpp != NULL); | 1005 | ASSERT(!xfs_buf_geterror(*bpp)); |
1010 | ASSERT(!XFS_BUF_GETERROR(*bpp)); | ||
1011 | 1006 | ||
1012 | xfs_btree_set_refs(cur, *bpp); | 1007 | xfs_btree_set_refs(cur, *bpp); |
1013 | *block = XFS_BUF_TO_BLOCK(*bpp); | 1008 | *block = XFS_BUF_TO_BLOCK(*bpp); |
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index 8d05a6a46ce3..5b240de104c0 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -262,7 +262,7 @@ typedef struct xfs_btree_cur | |||
262 | /* | 262 | /* |
263 | * Convert from buffer to btree block header. | 263 | * Convert from buffer to btree block header. |
264 | */ | 264 | */ |
265 | #define XFS_BUF_TO_BLOCK(bp) ((struct xfs_btree_block *)XFS_BUF_PTR(bp)) | 265 | #define XFS_BUF_TO_BLOCK(bp) ((struct xfs_btree_block *)((bp)->b_addr)) |
266 | 266 | ||
267 | 267 | ||
268 | /* | 268 | /* |
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/xfs_buf.c index d1fe74506c4c..c57836dc778f 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -596,7 +596,7 @@ _xfs_buf_read( | |||
596 | bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD); | 596 | bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD); |
597 | 597 | ||
598 | status = xfs_buf_iorequest(bp); | 598 | status = xfs_buf_iorequest(bp); |
599 | if (status || XFS_BUF_ISERROR(bp) || (flags & XBF_ASYNC)) | 599 | if (status || bp->b_error || (flags & XBF_ASYNC)) |
600 | return status; | 600 | return status; |
601 | return xfs_buf_iowait(bp); | 601 | return xfs_buf_iowait(bp); |
602 | } | 602 | } |
@@ -679,7 +679,6 @@ xfs_buf_read_uncached( | |||
679 | /* set up the buffer for a read IO */ | 679 | /* set up the buffer for a read IO */ |
680 | XFS_BUF_SET_ADDR(bp, daddr); | 680 | XFS_BUF_SET_ADDR(bp, daddr); |
681 | XFS_BUF_READ(bp); | 681 | XFS_BUF_READ(bp); |
682 | XFS_BUF_BUSY(bp); | ||
683 | 682 | ||
684 | xfsbdstrat(mp, bp); | 683 | xfsbdstrat(mp, bp); |
685 | error = xfs_buf_iowait(bp); | 684 | error = xfs_buf_iowait(bp); |
@@ -1069,7 +1068,7 @@ xfs_bioerror( | |||
1069 | /* | 1068 | /* |
1070 | * No need to wait until the buffer is unpinned, we aren't flushing it. | 1069 | * No need to wait until the buffer is unpinned, we aren't flushing it. |
1071 | */ | 1070 | */ |
1072 | XFS_BUF_ERROR(bp, EIO); | 1071 | xfs_buf_ioerror(bp, EIO); |
1073 | 1072 | ||
1074 | /* | 1073 | /* |
1075 | * We're calling xfs_buf_ioend, so delete XBF_DONE flag. | 1074 | * We're calling xfs_buf_ioend, so delete XBF_DONE flag. |
@@ -1094,7 +1093,7 @@ STATIC int | |||
1094 | xfs_bioerror_relse( | 1093 | xfs_bioerror_relse( |
1095 | struct xfs_buf *bp) | 1094 | struct xfs_buf *bp) |
1096 | { | 1095 | { |
1097 | int64_t fl = XFS_BUF_BFLAGS(bp); | 1096 | int64_t fl = bp->b_flags; |
1098 | /* | 1097 | /* |
1099 | * No need to wait until the buffer is unpinned. | 1098 | * No need to wait until the buffer is unpinned. |
1100 | * We aren't flushing it. | 1099 | * We aren't flushing it. |
@@ -1115,7 +1114,7 @@ xfs_bioerror_relse( | |||
1115 | * There's no reason to mark error for | 1114 | * There's no reason to mark error for |
1116 | * ASYNC buffers. | 1115 | * ASYNC buffers. |
1117 | */ | 1116 | */ |
1118 | XFS_BUF_ERROR(bp, EIO); | 1117 | xfs_buf_ioerror(bp, EIO); |
1119 | XFS_BUF_FINISH_IOWAIT(bp); | 1118 | XFS_BUF_FINISH_IOWAIT(bp); |
1120 | } else { | 1119 | } else { |
1121 | xfs_buf_relse(bp); | 1120 | xfs_buf_relse(bp); |
@@ -1324,7 +1323,7 @@ xfs_buf_offset( | |||
1324 | struct page *page; | 1323 | struct page *page; |
1325 | 1324 | ||
1326 | if (bp->b_flags & XBF_MAPPED) | 1325 | if (bp->b_flags & XBF_MAPPED) |
1327 | return XFS_BUF_PTR(bp) + offset; | 1326 | return bp->b_addr + offset; |
1328 | 1327 | ||
1329 | offset += bp->b_offset; | 1328 | offset += bp->b_offset; |
1330 | page = bp->b_pages[offset >> PAGE_SHIFT]; | 1329 | page = bp->b_pages[offset >> PAGE_SHIFT]; |
@@ -1484,7 +1483,7 @@ xfs_setsize_buftarg_flags( | |||
1484 | if (set_blocksize(btp->bt_bdev, sectorsize)) { | 1483 | if (set_blocksize(btp->bt_bdev, sectorsize)) { |
1485 | xfs_warn(btp->bt_mount, | 1484 | xfs_warn(btp->bt_mount, |
1486 | "Cannot set_blocksize to %u on device %s\n", | 1485 | "Cannot set_blocksize to %u on device %s\n", |
1487 | sectorsize, XFS_BUFTARG_NAME(btp)); | 1486 | sectorsize, xfs_buf_target_name(btp)); |
1488 | return EINVAL; | 1487 | return EINVAL; |
1489 | } | 1488 | } |
1490 | 1489 | ||
@@ -1681,7 +1680,7 @@ xfs_buf_delwri_split( | |||
1681 | list_for_each_entry_safe(bp, n, dwq, b_list) { | 1680 | list_for_each_entry_safe(bp, n, dwq, b_list) { |
1682 | ASSERT(bp->b_flags & XBF_DELWRI); | 1681 | ASSERT(bp->b_flags & XBF_DELWRI); |
1683 | 1682 | ||
1684 | if (!XFS_BUF_ISPINNED(bp) && xfs_buf_trylock(bp)) { | 1683 | if (!xfs_buf_ispinned(bp) && xfs_buf_trylock(bp)) { |
1685 | if (!force && | 1684 | if (!force && |
1686 | time_before(jiffies, bp->b_queuetime + age)) { | 1685 | time_before(jiffies, bp->b_queuetime + age)) { |
1687 | xfs_buf_unlock(bp); | 1686 | xfs_buf_unlock(bp); |
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/xfs_buf.h index 6a83b46b4bcf..620972b8094d 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/xfs_buf.h | |||
@@ -228,11 +228,15 @@ extern void xfs_buf_delwri_promote(xfs_buf_t *); | |||
228 | extern int xfs_buf_init(void); | 228 | extern int xfs_buf_init(void); |
229 | extern void xfs_buf_terminate(void); | 229 | extern void xfs_buf_terminate(void); |
230 | 230 | ||
231 | #define xfs_buf_target_name(target) \ | 231 | static inline const char * |
232 | ({ char __b[BDEVNAME_SIZE]; bdevname((target)->bt_bdev, __b); __b; }) | 232 | xfs_buf_target_name(struct xfs_buftarg *target) |
233 | { | ||
234 | static char __b[BDEVNAME_SIZE]; | ||
235 | |||
236 | return bdevname(target->bt_bdev, __b); | ||
237 | } | ||
233 | 238 | ||
234 | 239 | ||
235 | #define XFS_BUF_BFLAGS(bp) ((bp)->b_flags) | ||
236 | #define XFS_BUF_ZEROFLAGS(bp) \ | 240 | #define XFS_BUF_ZEROFLAGS(bp) \ |
237 | ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC|XBF_DELWRI| \ | 241 | ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC|XBF_DELWRI| \ |
238 | XBF_SYNCIO|XBF_FUA|XBF_FLUSH)) | 242 | XBF_SYNCIO|XBF_FUA|XBF_FLUSH)) |
@@ -251,23 +255,14 @@ void xfs_buf_stale(struct xfs_buf *bp); | |||
251 | #define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp) | 255 | #define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp) |
252 | #define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI) | 256 | #define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI) |
253 | 257 | ||
254 | #define XFS_BUF_ERROR(bp,no) xfs_buf_ioerror(bp,no) | ||
255 | #define XFS_BUF_GETERROR(bp) xfs_buf_geterror(bp) | ||
256 | #define XFS_BUF_ISERROR(bp) (xfs_buf_geterror(bp) ? 1 : 0) | ||
257 | |||
258 | #define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE) | 258 | #define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE) |
259 | #define XFS_BUF_UNDONE(bp) ((bp)->b_flags &= ~XBF_DONE) | 259 | #define XFS_BUF_UNDONE(bp) ((bp)->b_flags &= ~XBF_DONE) |
260 | #define XFS_BUF_ISDONE(bp) ((bp)->b_flags & XBF_DONE) | 260 | #define XFS_BUF_ISDONE(bp) ((bp)->b_flags & XBF_DONE) |
261 | 261 | ||
262 | #define XFS_BUF_BUSY(bp) do { } while (0) | ||
263 | #define XFS_BUF_UNBUSY(bp) do { } while (0) | ||
264 | #define XFS_BUF_ISBUSY(bp) (1) | ||
265 | |||
266 | #define XFS_BUF_ASYNC(bp) ((bp)->b_flags |= XBF_ASYNC) | 262 | #define XFS_BUF_ASYNC(bp) ((bp)->b_flags |= XBF_ASYNC) |
267 | #define XFS_BUF_UNASYNC(bp) ((bp)->b_flags &= ~XBF_ASYNC) | 263 | #define XFS_BUF_UNASYNC(bp) ((bp)->b_flags &= ~XBF_ASYNC) |
268 | #define XFS_BUF_ISASYNC(bp) ((bp)->b_flags & XBF_ASYNC) | 264 | #define XFS_BUF_ISASYNC(bp) ((bp)->b_flags & XBF_ASYNC) |
269 | 265 | ||
270 | #define XFS_BUF_HOLD(bp) xfs_buf_hold(bp) | ||
271 | #define XFS_BUF_READ(bp) ((bp)->b_flags |= XBF_READ) | 266 | #define XFS_BUF_READ(bp) ((bp)->b_flags |= XBF_READ) |
272 | #define XFS_BUF_UNREAD(bp) ((bp)->b_flags &= ~XBF_READ) | 267 | #define XFS_BUF_UNREAD(bp) ((bp)->b_flags &= ~XBF_READ) |
273 | #define XFS_BUF_ISREAD(bp) ((bp)->b_flags & XBF_READ) | 268 | #define XFS_BUF_ISREAD(bp) ((bp)->b_flags & XBF_READ) |
@@ -276,10 +271,6 @@ void xfs_buf_stale(struct xfs_buf *bp); | |||
276 | #define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE) | 271 | #define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE) |
277 | #define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE) | 272 | #define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE) |
278 | 273 | ||
279 | #define XFS_BUF_SET_START(bp) do { } while (0) | ||
280 | |||
281 | #define XFS_BUF_PTR(bp) (xfs_caddr_t)((bp)->b_addr) | ||
282 | #define XFS_BUF_SET_PTR(bp, val, cnt) xfs_buf_associate_memory(bp, val, cnt) | ||
283 | #define XFS_BUF_ADDR(bp) ((bp)->b_bn) | 274 | #define XFS_BUF_ADDR(bp) ((bp)->b_bn) |
284 | #define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno)) | 275 | #define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno)) |
285 | #define XFS_BUF_OFFSET(bp) ((bp)->b_file_offset) | 276 | #define XFS_BUF_OFFSET(bp) ((bp)->b_file_offset) |
@@ -299,14 +290,13 @@ xfs_buf_set_ref( | |||
299 | #define XFS_BUF_SET_VTYPE_REF(bp, type, ref) xfs_buf_set_ref(bp, ref) | 290 | #define XFS_BUF_SET_VTYPE_REF(bp, type, ref) xfs_buf_set_ref(bp, ref) |
300 | #define XFS_BUF_SET_VTYPE(bp, type) do { } while (0) | 291 | #define XFS_BUF_SET_VTYPE(bp, type) do { } while (0) |
301 | 292 | ||
302 | #define XFS_BUF_ISPINNED(bp) atomic_read(&((bp)->b_pin_count)) | 293 | static inline int xfs_buf_ispinned(struct xfs_buf *bp) |
294 | { | ||
295 | return atomic_read(&bp->b_pin_count); | ||
296 | } | ||
303 | 297 | ||
304 | #define XFS_BUF_FINISH_IOWAIT(bp) complete(&bp->b_iowait); | 298 | #define XFS_BUF_FINISH_IOWAIT(bp) complete(&bp->b_iowait); |
305 | 299 | ||
306 | #define XFS_BUF_SET_TARGET(bp, target) ((bp)->b_target = (target)) | ||
307 | #define XFS_BUF_TARGET(bp) ((bp)->b_target) | ||
308 | #define XFS_BUFTARG_NAME(target) xfs_buf_target_name(target) | ||
309 | |||
310 | static inline void xfs_buf_relse(xfs_buf_t *bp) | 300 | static inline void xfs_buf_relse(xfs_buf_t *bp) |
311 | { | 301 | { |
312 | xfs_buf_unlock(bp); | 302 | xfs_buf_unlock(bp); |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 88492916c3dc..ef43fce519a1 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -124,9 +124,9 @@ xfs_buf_item_log_check( | |||
124 | 124 | ||
125 | bp = bip->bli_buf; | 125 | bp = bip->bli_buf; |
126 | ASSERT(XFS_BUF_COUNT(bp) > 0); | 126 | ASSERT(XFS_BUF_COUNT(bp) > 0); |
127 | ASSERT(XFS_BUF_PTR(bp) != NULL); | 127 | ASSERT(bp->b_addr != NULL); |
128 | orig = bip->bli_orig; | 128 | orig = bip->bli_orig; |
129 | buffer = XFS_BUF_PTR(bp); | 129 | buffer = bp->b_addr; |
130 | for (x = 0; x < XFS_BUF_COUNT(bp); x++) { | 130 | for (x = 0; x < XFS_BUF_COUNT(bp); x++) { |
131 | if (orig[x] != buffer[x] && !btst(bip->bli_logged, x)) { | 131 | if (orig[x] != buffer[x] && !btst(bip->bli_logged, x)) { |
132 | xfs_emerg(bp->b_mount, | 132 | xfs_emerg(bp->b_mount, |
@@ -371,7 +371,6 @@ xfs_buf_item_pin( | |||
371 | { | 371 | { |
372 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); | 372 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); |
373 | 373 | ||
374 | ASSERT(XFS_BUF_ISBUSY(bip->bli_buf)); | ||
375 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 374 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
376 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || | 375 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || |
377 | (bip->bli_flags & XFS_BLI_STALE)); | 376 | (bip->bli_flags & XFS_BLI_STALE)); |
@@ -479,13 +478,13 @@ xfs_buf_item_trylock( | |||
479 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); | 478 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); |
480 | struct xfs_buf *bp = bip->bli_buf; | 479 | struct xfs_buf *bp = bip->bli_buf; |
481 | 480 | ||
482 | if (XFS_BUF_ISPINNED(bp)) | 481 | if (xfs_buf_ispinned(bp)) |
483 | return XFS_ITEM_PINNED; | 482 | return XFS_ITEM_PINNED; |
484 | if (!xfs_buf_trylock(bp)) | 483 | if (!xfs_buf_trylock(bp)) |
485 | return XFS_ITEM_LOCKED; | 484 | return XFS_ITEM_LOCKED; |
486 | 485 | ||
487 | /* take a reference to the buffer. */ | 486 | /* take a reference to the buffer. */ |
488 | XFS_BUF_HOLD(bp); | 487 | xfs_buf_hold(bp); |
489 | 488 | ||
490 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); | 489 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); |
491 | trace_xfs_buf_item_trylock(bip); | 490 | trace_xfs_buf_item_trylock(bip); |
@@ -630,7 +629,7 @@ xfs_buf_item_push( | |||
630 | * the xfsbufd to get this buffer written. We have to unlock the buffer | 629 | * the xfsbufd to get this buffer written. We have to unlock the buffer |
631 | * to allow the xfsbufd to write it, too. | 630 | * to allow the xfsbufd to write it, too. |
632 | */ | 631 | */ |
633 | STATIC void | 632 | STATIC bool |
634 | xfs_buf_item_pushbuf( | 633 | xfs_buf_item_pushbuf( |
635 | struct xfs_log_item *lip) | 634 | struct xfs_log_item *lip) |
636 | { | 635 | { |
@@ -644,6 +643,7 @@ xfs_buf_item_pushbuf( | |||
644 | 643 | ||
645 | xfs_buf_delwri_promote(bp); | 644 | xfs_buf_delwri_promote(bp); |
646 | xfs_buf_relse(bp); | 645 | xfs_buf_relse(bp); |
646 | return true; | ||
647 | } | 647 | } |
648 | 648 | ||
649 | STATIC void | 649 | STATIC void |
@@ -726,7 +726,7 @@ xfs_buf_item_init( | |||
726 | * to have logged. | 726 | * to have logged. |
727 | */ | 727 | */ |
728 | bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP); | 728 | bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP); |
729 | memcpy(bip->bli_orig, XFS_BUF_PTR(bp), XFS_BUF_COUNT(bp)); | 729 | memcpy(bip->bli_orig, bp->b_addr, XFS_BUF_COUNT(bp)); |
730 | bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP); | 730 | bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP); |
731 | #endif | 731 | #endif |
732 | 732 | ||
@@ -895,7 +895,6 @@ xfs_buf_attach_iodone( | |||
895 | { | 895 | { |
896 | xfs_log_item_t *head_lip; | 896 | xfs_log_item_t *head_lip; |
897 | 897 | ||
898 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
899 | ASSERT(xfs_buf_islocked(bp)); | 898 | ASSERT(xfs_buf_islocked(bp)); |
900 | 899 | ||
901 | lip->li_cb = cb; | 900 | lip->li_cb = cb; |
@@ -960,7 +959,7 @@ xfs_buf_iodone_callbacks( | |||
960 | static ulong lasttime; | 959 | static ulong lasttime; |
961 | static xfs_buftarg_t *lasttarg; | 960 | static xfs_buftarg_t *lasttarg; |
962 | 961 | ||
963 | if (likely(!XFS_BUF_GETERROR(bp))) | 962 | if (likely(!xfs_buf_geterror(bp))) |
964 | goto do_callbacks; | 963 | goto do_callbacks; |
965 | 964 | ||
966 | /* | 965 | /* |
@@ -973,14 +972,14 @@ xfs_buf_iodone_callbacks( | |||
973 | goto do_callbacks; | 972 | goto do_callbacks; |
974 | } | 973 | } |
975 | 974 | ||
976 | if (XFS_BUF_TARGET(bp) != lasttarg || | 975 | if (bp->b_target != lasttarg || |
977 | time_after(jiffies, (lasttime + 5*HZ))) { | 976 | time_after(jiffies, (lasttime + 5*HZ))) { |
978 | lasttime = jiffies; | 977 | lasttime = jiffies; |
979 | xfs_alert(mp, "Device %s: metadata write error block 0x%llx", | 978 | xfs_alert(mp, "Device %s: metadata write error block 0x%llx", |
980 | XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), | 979 | xfs_buf_target_name(bp->b_target), |
981 | (__uint64_t)XFS_BUF_ADDR(bp)); | 980 | (__uint64_t)XFS_BUF_ADDR(bp)); |
982 | } | 981 | } |
983 | lasttarg = XFS_BUF_TARGET(bp); | 982 | lasttarg = bp->b_target; |
984 | 983 | ||
985 | /* | 984 | /* |
986 | * If the write was asynchronous then no one will be looking for the | 985 | * If the write was asynchronous then no one will be looking for the |
@@ -991,12 +990,11 @@ xfs_buf_iodone_callbacks( | |||
991 | * around. | 990 | * around. |
992 | */ | 991 | */ |
993 | if (XFS_BUF_ISASYNC(bp)) { | 992 | if (XFS_BUF_ISASYNC(bp)) { |
994 | XFS_BUF_ERROR(bp, 0); /* errno of 0 unsets the flag */ | 993 | xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */ |
995 | 994 | ||
996 | if (!XFS_BUF_ISSTALE(bp)) { | 995 | if (!XFS_BUF_ISSTALE(bp)) { |
997 | XFS_BUF_DELAYWRITE(bp); | 996 | XFS_BUF_DELAYWRITE(bp); |
998 | XFS_BUF_DONE(bp); | 997 | XFS_BUF_DONE(bp); |
999 | XFS_BUF_SET_START(bp); | ||
1000 | } | 998 | } |
1001 | ASSERT(bp->b_iodone != NULL); | 999 | ASSERT(bp->b_iodone != NULL); |
1002 | trace_xfs_buf_item_iodone_async(bp, _RET_IP_); | 1000 | trace_xfs_buf_item_iodone_async(bp, _RET_IP_); |
@@ -1013,7 +1011,6 @@ xfs_buf_iodone_callbacks( | |||
1013 | XFS_BUF_UNDELAYWRITE(bp); | 1011 | XFS_BUF_UNDELAYWRITE(bp); |
1014 | 1012 | ||
1015 | trace_xfs_buf_error_relse(bp, _RET_IP_); | 1013 | trace_xfs_buf_error_relse(bp, _RET_IP_); |
1016 | xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); | ||
1017 | 1014 | ||
1018 | do_callbacks: | 1015 | do_callbacks: |
1019 | xfs_buf_do_callbacks(bp); | 1016 | xfs_buf_do_callbacks(bp); |
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 5bfcb8779f9f..ee9d5427fcd4 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -2050,7 +2050,7 @@ xfs_da_do_buf( | |||
2050 | case 0: | 2050 | case 0: |
2051 | bp = xfs_trans_get_buf(trans, mp->m_ddev_targp, | 2051 | bp = xfs_trans_get_buf(trans, mp->m_ddev_targp, |
2052 | mappedbno, nmapped, 0); | 2052 | mappedbno, nmapped, 0); |
2053 | error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO); | 2053 | error = bp ? bp->b_error : XFS_ERROR(EIO); |
2054 | break; | 2054 | break; |
2055 | case 1: | 2055 | case 1: |
2056 | case 2: | 2056 | case 2: |
@@ -2268,7 +2268,7 @@ xfs_da_buf_make(int nbuf, xfs_buf_t **bps) | |||
2268 | dabuf->nbuf = 1; | 2268 | dabuf->nbuf = 1; |
2269 | bp = bps[0]; | 2269 | bp = bps[0]; |
2270 | dabuf->bbcount = (short)BTOBB(XFS_BUF_COUNT(bp)); | 2270 | dabuf->bbcount = (short)BTOBB(XFS_BUF_COUNT(bp)); |
2271 | dabuf->data = XFS_BUF_PTR(bp); | 2271 | dabuf->data = bp->b_addr; |
2272 | dabuf->bps[0] = bp; | 2272 | dabuf->bps[0] = bp; |
2273 | } else { | 2273 | } else { |
2274 | dabuf->nbuf = nbuf; | 2274 | dabuf->nbuf = nbuf; |
@@ -2279,7 +2279,7 @@ xfs_da_buf_make(int nbuf, xfs_buf_t **bps) | |||
2279 | dabuf->data = kmem_alloc(BBTOB(dabuf->bbcount), KM_SLEEP); | 2279 | dabuf->data = kmem_alloc(BBTOB(dabuf->bbcount), KM_SLEEP); |
2280 | for (i = off = 0; i < nbuf; i++, off += XFS_BUF_COUNT(bp)) { | 2280 | for (i = off = 0; i < nbuf; i++, off += XFS_BUF_COUNT(bp)) { |
2281 | bp = bps[i]; | 2281 | bp = bps[i]; |
2282 | memcpy((char *)dabuf->data + off, XFS_BUF_PTR(bp), | 2282 | memcpy((char *)dabuf->data + off, bp->b_addr, |
2283 | XFS_BUF_COUNT(bp)); | 2283 | XFS_BUF_COUNT(bp)); |
2284 | } | 2284 | } |
2285 | } | 2285 | } |
@@ -2302,8 +2302,8 @@ xfs_da_buf_clean(xfs_dabuf_t *dabuf) | |||
2302 | for (i = off = 0; i < dabuf->nbuf; | 2302 | for (i = off = 0; i < dabuf->nbuf; |
2303 | i++, off += XFS_BUF_COUNT(bp)) { | 2303 | i++, off += XFS_BUF_COUNT(bp)) { |
2304 | bp = dabuf->bps[i]; | 2304 | bp = dabuf->bps[i]; |
2305 | memcpy(XFS_BUF_PTR(bp), (char *)dabuf->data + off, | 2305 | memcpy(bp->b_addr, dabuf->data + off, |
2306 | XFS_BUF_COUNT(bp)); | 2306 | XFS_BUF_COUNT(bp)); |
2307 | } | 2307 | } |
2308 | } | 2308 | } |
2309 | } | 2309 | } |
@@ -2340,7 +2340,7 @@ xfs_da_log_buf(xfs_trans_t *tp, xfs_dabuf_t *dabuf, uint first, uint last) | |||
2340 | 2340 | ||
2341 | ASSERT(dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0]); | 2341 | ASSERT(dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0]); |
2342 | if (dabuf->nbuf == 1) { | 2342 | if (dabuf->nbuf == 1) { |
2343 | ASSERT(dabuf->data == (void *)XFS_BUF_PTR(dabuf->bps[0])); | 2343 | ASSERT(dabuf->data == dabuf->bps[0]->b_addr); |
2344 | xfs_trans_log_buf(tp, dabuf->bps[0], first, last); | 2344 | xfs_trans_log_buf(tp, dabuf->bps[0], first, last); |
2345 | return; | 2345 | return; |
2346 | } | 2346 | } |
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h index dffba9ba0db6..a3721633abc8 100644 --- a/fs/xfs/xfs_dinode.h +++ b/fs/xfs/xfs_dinode.h | |||
@@ -148,7 +148,7 @@ typedef enum xfs_dinode_fmt { | |||
148 | be32_to_cpu((dip)->di_nextents) : \ | 148 | be32_to_cpu((dip)->di_nextents) : \ |
149 | be16_to_cpu((dip)->di_anextents)) | 149 | be16_to_cpu((dip)->di_anextents)) |
150 | 150 | ||
151 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) | 151 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)((bp)->b_addr)) |
152 | 152 | ||
153 | /* | 153 | /* |
154 | * For block and character special files the 32bit dev_t is stored at the | 154 | * For block and character special files the 32bit dev_t is stored at the |
diff --git a/fs/xfs/linux-2.6/xfs_discard.c b/fs/xfs/xfs_discard.c index 244e797dae32..244e797dae32 100644 --- a/fs/xfs/linux-2.6/xfs_discard.c +++ b/fs/xfs/xfs_discard.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_discard.h b/fs/xfs/xfs_discard.h index 344879aea646..344879aea646 100644 --- a/fs/xfs/linux-2.6/xfs_discard.h +++ b/fs/xfs/xfs_discard.h | |||
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 837f31158d43..db62959bed13 100644 --- a/fs/xfs/quota/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c | |||
@@ -318,10 +318,9 @@ xfs_qm_init_dquot_blk( | |||
318 | int curid, i; | 318 | int curid, i; |
319 | 319 | ||
320 | ASSERT(tp); | 320 | ASSERT(tp); |
321 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
322 | ASSERT(xfs_buf_islocked(bp)); | 321 | ASSERT(xfs_buf_islocked(bp)); |
323 | 322 | ||
324 | d = (xfs_dqblk_t *)XFS_BUF_PTR(bp); | 323 | d = bp->b_addr; |
325 | 324 | ||
326 | /* | 325 | /* |
327 | * ID of the first dquot in the block - id's are zero based. | 326 | * ID of the first dquot in the block - id's are zero based. |
@@ -403,7 +402,7 @@ xfs_qm_dqalloc( | |||
403 | dqp->q_blkno, | 402 | dqp->q_blkno, |
404 | mp->m_quotainfo->qi_dqchunklen, | 403 | mp->m_quotainfo->qi_dqchunklen, |
405 | 0); | 404 | 0); |
406 | if (!bp || (error = XFS_BUF_GETERROR(bp))) | 405 | if (!bp || (error = xfs_buf_geterror(bp))) |
407 | goto error1; | 406 | goto error1; |
408 | /* | 407 | /* |
409 | * Make a chunk of dquots out of this buffer and log | 408 | * Make a chunk of dquots out of this buffer and log |
@@ -534,13 +533,12 @@ xfs_qm_dqtobp( | |||
534 | return XFS_ERROR(error); | 533 | return XFS_ERROR(error); |
535 | } | 534 | } |
536 | 535 | ||
537 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
538 | ASSERT(xfs_buf_islocked(bp)); | 536 | ASSERT(xfs_buf_islocked(bp)); |
539 | 537 | ||
540 | /* | 538 | /* |
541 | * calculate the location of the dquot inside the buffer. | 539 | * calculate the location of the dquot inside the buffer. |
542 | */ | 540 | */ |
543 | ddq = (struct xfs_disk_dquot *)(XFS_BUF_PTR(bp) + dqp->q_bufoffset); | 541 | ddq = bp->b_addr + dqp->q_bufoffset; |
544 | 542 | ||
545 | /* | 543 | /* |
546 | * A simple sanity check in case we got a corrupted dquot... | 544 | * A simple sanity check in case we got a corrupted dquot... |
@@ -553,7 +551,6 @@ xfs_qm_dqtobp( | |||
553 | xfs_trans_brelse(tp, bp); | 551 | xfs_trans_brelse(tp, bp); |
554 | return XFS_ERROR(EIO); | 552 | return XFS_ERROR(EIO); |
555 | } | 553 | } |
556 | XFS_BUF_BUSY(bp); /* We dirtied this */ | ||
557 | } | 554 | } |
558 | 555 | ||
559 | *O_bpp = bp; | 556 | *O_bpp = bp; |
@@ -622,7 +619,6 @@ xfs_qm_dqread( | |||
622 | * this particular dquot was repaired. We still aren't afraid to | 619 | * this particular dquot was repaired. We still aren't afraid to |
623 | * brelse it because we have the changes incore. | 620 | * brelse it because we have the changes incore. |
624 | */ | 621 | */ |
625 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
626 | ASSERT(xfs_buf_islocked(bp)); | 622 | ASSERT(xfs_buf_islocked(bp)); |
627 | xfs_trans_brelse(tp, bp); | 623 | xfs_trans_brelse(tp, bp); |
628 | 624 | ||
@@ -1204,7 +1200,7 @@ xfs_qm_dqflush( | |||
1204 | /* | 1200 | /* |
1205 | * Calculate the location of the dquot inside the buffer. | 1201 | * Calculate the location of the dquot inside the buffer. |
1206 | */ | 1202 | */ |
1207 | ddqp = (struct xfs_disk_dquot *)(XFS_BUF_PTR(bp) + dqp->q_bufoffset); | 1203 | ddqp = bp->b_addr + dqp->q_bufoffset; |
1208 | 1204 | ||
1209 | /* | 1205 | /* |
1210 | * A simple sanity check in case we got a corrupted dquot.. | 1206 | * A simple sanity check in case we got a corrupted dquot.. |
@@ -1240,7 +1236,7 @@ xfs_qm_dqflush( | |||
1240 | * If the buffer is pinned then push on the log so we won't | 1236 | * If the buffer is pinned then push on the log so we won't |
1241 | * get stuck waiting in the write for too long. | 1237 | * get stuck waiting in the write for too long. |
1242 | */ | 1238 | */ |
1243 | if (XFS_BUF_ISPINNED(bp)) { | 1239 | if (xfs_buf_ispinned(bp)) { |
1244 | trace_xfs_dqflush_force(dqp); | 1240 | trace_xfs_dqflush_force(dqp); |
1245 | xfs_log_force(mp, 0); | 1241 | xfs_log_force(mp, 0); |
1246 | } | 1242 | } |
@@ -1447,7 +1443,7 @@ xfs_qm_dqflock_pushbuf_wait( | |||
1447 | goto out_lock; | 1443 | goto out_lock; |
1448 | 1444 | ||
1449 | if (XFS_BUF_ISDELAYWRITE(bp)) { | 1445 | if (XFS_BUF_ISDELAYWRITE(bp)) { |
1450 | if (XFS_BUF_ISPINNED(bp)) | 1446 | if (xfs_buf_ispinned(bp)) |
1451 | xfs_log_force(mp, 0); | 1447 | xfs_log_force(mp, 0); |
1452 | xfs_buf_delwri_promote(bp); | 1448 | xfs_buf_delwri_promote(bp); |
1453 | wake_up_process(bp->b_target->bt_task); | 1449 | wake_up_process(bp->b_target->bt_task); |
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 34b7e945dbfa..34b7e945dbfa 100644 --- a/fs/xfs/quota/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h | |||
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c index 9e0e2fa3f2c8..bb3f71d236d2 100644 --- a/fs/xfs/quota/xfs_dquot_item.c +++ b/fs/xfs/xfs_dquot_item.c | |||
@@ -183,13 +183,14 @@ xfs_qm_dqunpin_wait( | |||
183 | * search the buffer cache can be a time consuming thing, and AIL lock is a | 183 | * search the buffer cache can be a time consuming thing, and AIL lock is a |
184 | * spinlock. | 184 | * spinlock. |
185 | */ | 185 | */ |
186 | STATIC void | 186 | STATIC bool |
187 | xfs_qm_dquot_logitem_pushbuf( | 187 | xfs_qm_dquot_logitem_pushbuf( |
188 | struct xfs_log_item *lip) | 188 | struct xfs_log_item *lip) |
189 | { | 189 | { |
190 | struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip); | 190 | struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip); |
191 | struct xfs_dquot *dqp = qlip->qli_dquot; | 191 | struct xfs_dquot *dqp = qlip->qli_dquot; |
192 | struct xfs_buf *bp; | 192 | struct xfs_buf *bp; |
193 | bool ret = true; | ||
193 | 194 | ||
194 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | 195 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
195 | 196 | ||
@@ -201,17 +202,20 @@ xfs_qm_dquot_logitem_pushbuf( | |||
201 | if (completion_done(&dqp->q_flush) || | 202 | if (completion_done(&dqp->q_flush) || |
202 | !(lip->li_flags & XFS_LI_IN_AIL)) { | 203 | !(lip->li_flags & XFS_LI_IN_AIL)) { |
203 | xfs_dqunlock(dqp); | 204 | xfs_dqunlock(dqp); |
204 | return; | 205 | return true; |
205 | } | 206 | } |
206 | 207 | ||
207 | bp = xfs_incore(dqp->q_mount->m_ddev_targp, qlip->qli_format.qlf_blkno, | 208 | bp = xfs_incore(dqp->q_mount->m_ddev_targp, qlip->qli_format.qlf_blkno, |
208 | dqp->q_mount->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK); | 209 | dqp->q_mount->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK); |
209 | xfs_dqunlock(dqp); | 210 | xfs_dqunlock(dqp); |
210 | if (!bp) | 211 | if (!bp) |
211 | return; | 212 | return true; |
212 | if (XFS_BUF_ISDELAYWRITE(bp)) | 213 | if (XFS_BUF_ISDELAYWRITE(bp)) |
213 | xfs_buf_delwri_promote(bp); | 214 | xfs_buf_delwri_promote(bp); |
215 | if (xfs_buf_ispinned(bp)) | ||
216 | ret = false; | ||
214 | xfs_buf_relse(bp); | 217 | xfs_buf_relse(bp); |
218 | return ret; | ||
215 | } | 219 | } |
216 | 220 | ||
217 | /* | 221 | /* |
diff --git a/fs/xfs/quota/xfs_dquot_item.h b/fs/xfs/xfs_dquot_item.h index 5acae2ada70b..5acae2ada70b 100644 --- a/fs/xfs/quota/xfs_dquot_item.h +++ b/fs/xfs/xfs_dquot_item.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/xfs_export.c index 75e5d322e48f..75e5d322e48f 100644 --- a/fs/xfs/linux-2.6/xfs_export.c +++ b/fs/xfs/xfs_export.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_export.h b/fs/xfs/xfs_export.h index 3272b6ae7a35..3272b6ae7a35 100644 --- a/fs/xfs/linux-2.6/xfs_export.h +++ b/fs/xfs/xfs_export.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/xfs_file.c index 7f7b42469ea7..7f7b42469ea7 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/xfs_fs_subr.c index ed88ed16811c..ed88ed16811c 100644 --- a/fs/xfs/linux-2.6/xfs_fs_subr.c +++ b/fs/xfs/xfs_fs_subr.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_globals.c b/fs/xfs/xfs_globals.c index 76e81cff70b9..76e81cff70b9 100644 --- a/fs/xfs/linux-2.6/xfs_globals.c +++ b/fs/xfs/xfs_globals.c | |||
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index dd5628bd8d0b..9f24ec28283b 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -202,8 +202,7 @@ xfs_ialloc_inode_init( | |||
202 | fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, | 202 | fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, |
203 | mp->m_bsize * blks_per_cluster, | 203 | mp->m_bsize * blks_per_cluster, |
204 | XBF_LOCK); | 204 | XBF_LOCK); |
205 | ASSERT(fbuf); | 205 | ASSERT(!xfs_buf_geterror(fbuf)); |
206 | ASSERT(!XFS_BUF_GETERROR(fbuf)); | ||
207 | 206 | ||
208 | /* | 207 | /* |
209 | * Initialize all inodes in this buffer and then log them. | 208 | * Initialize all inodes in this buffer and then log them. |
@@ -1486,7 +1485,7 @@ xfs_read_agi( | |||
1486 | if (error) | 1485 | if (error) |
1487 | return error; | 1486 | return error; |
1488 | 1487 | ||
1489 | ASSERT(*bpp && !XFS_BUF_GETERROR(*bpp)); | 1488 | ASSERT(!xfs_buf_geterror(*bpp)); |
1490 | agi = XFS_BUF_TO_AGI(*bpp); | 1489 | agi = XFS_BUF_TO_AGI(*bpp); |
1491 | 1490 | ||
1492 | /* | 1491 | /* |
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 2fcca4b03ed3..0239a7c7c886 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -2473,7 +2473,7 @@ cluster_corrupt_out: | |||
2473 | if (bp->b_iodone) { | 2473 | if (bp->b_iodone) { |
2474 | XFS_BUF_UNDONE(bp); | 2474 | XFS_BUF_UNDONE(bp); |
2475 | XFS_BUF_STALE(bp); | 2475 | XFS_BUF_STALE(bp); |
2476 | XFS_BUF_ERROR(bp,EIO); | 2476 | xfs_buf_ioerror(bp, EIO); |
2477 | xfs_buf_ioend(bp, 0); | 2477 | xfs_buf_ioend(bp, 0); |
2478 | } else { | 2478 | } else { |
2479 | XFS_BUF_STALE(bp); | 2479 | XFS_BUF_STALE(bp); |
@@ -2585,7 +2585,7 @@ xfs_iflush( | |||
2585 | * If the buffer is pinned then push on the log now so we won't | 2585 | * If the buffer is pinned then push on the log now so we won't |
2586 | * get stuck waiting in the write for too long. | 2586 | * get stuck waiting in the write for too long. |
2587 | */ | 2587 | */ |
2588 | if (XFS_BUF_ISPINNED(bp)) | 2588 | if (xfs_buf_ispinned(bp)) |
2589 | xfs_log_force(mp, 0); | 2589 | xfs_log_force(mp, 0); |
2590 | 2590 | ||
2591 | /* | 2591 | /* |
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 588406dc6a35..836ad80d4f2b 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c | |||
@@ -708,13 +708,14 @@ xfs_inode_item_committed( | |||
708 | * marked delayed write. If that's the case, we'll promote it and that will | 708 | * marked delayed write. If that's the case, we'll promote it and that will |
709 | * allow the caller to write the buffer by triggering the xfsbufd to run. | 709 | * allow the caller to write the buffer by triggering the xfsbufd to run. |
710 | */ | 710 | */ |
711 | STATIC void | 711 | STATIC bool |
712 | xfs_inode_item_pushbuf( | 712 | xfs_inode_item_pushbuf( |
713 | struct xfs_log_item *lip) | 713 | struct xfs_log_item *lip) |
714 | { | 714 | { |
715 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); | 715 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); |
716 | struct xfs_inode *ip = iip->ili_inode; | 716 | struct xfs_inode *ip = iip->ili_inode; |
717 | struct xfs_buf *bp; | 717 | struct xfs_buf *bp; |
718 | bool ret = true; | ||
718 | 719 | ||
719 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED)); | 720 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED)); |
720 | 721 | ||
@@ -725,7 +726,7 @@ xfs_inode_item_pushbuf( | |||
725 | if (completion_done(&ip->i_flush) || | 726 | if (completion_done(&ip->i_flush) || |
726 | !(lip->li_flags & XFS_LI_IN_AIL)) { | 727 | !(lip->li_flags & XFS_LI_IN_AIL)) { |
727 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 728 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
728 | return; | 729 | return true; |
729 | } | 730 | } |
730 | 731 | ||
731 | bp = xfs_incore(ip->i_mount->m_ddev_targp, iip->ili_format.ilf_blkno, | 732 | bp = xfs_incore(ip->i_mount->m_ddev_targp, iip->ili_format.ilf_blkno, |
@@ -733,10 +734,13 @@ xfs_inode_item_pushbuf( | |||
733 | 734 | ||
734 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 735 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
735 | if (!bp) | 736 | if (!bp) |
736 | return; | 737 | return true; |
737 | if (XFS_BUF_ISDELAYWRITE(bp)) | 738 | if (XFS_BUF_ISDELAYWRITE(bp)) |
738 | xfs_buf_delwri_promote(bp); | 739 | xfs_buf_delwri_promote(bp); |
740 | if (xfs_buf_ispinned(bp)) | ||
741 | ret = false; | ||
739 | xfs_buf_relse(bp); | 742 | xfs_buf_relse(bp); |
743 | return ret; | ||
740 | } | 744 | } |
741 | 745 | ||
742 | /* | 746 | /* |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index f7ce7debe14c..f7ce7debe14c 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h index d56173b34a2a..d56173b34a2a 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.h +++ b/fs/xfs/xfs_ioctl.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 54e623bfbb85..54e623bfbb85 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/xfs_ioctl32.h index 80f4060e8970..80f4060e8970 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl32.h +++ b/fs/xfs/xfs_ioctl32.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/xfs_iops.c index b9c172b3fbbe..28856accb4fa 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -70,9 +70,8 @@ xfs_synchronize_times( | |||
70 | } | 70 | } |
71 | 71 | ||
72 | /* | 72 | /* |
73 | * If the linux inode is valid, mark it dirty. | 73 | * If the linux inode is valid, mark it dirty, else mark the dirty state |
74 | * Used when committing a dirty inode into a transaction so that | 74 | * in the XFS inode to make sure we pick it up when reclaiming the inode. |
75 | * the inode will get written back by the linux code | ||
76 | */ | 75 | */ |
77 | void | 76 | void |
78 | xfs_mark_inode_dirty_sync( | 77 | xfs_mark_inode_dirty_sync( |
@@ -82,6 +81,10 @@ xfs_mark_inode_dirty_sync( | |||
82 | 81 | ||
83 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) | 82 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) |
84 | mark_inode_dirty_sync(inode); | 83 | mark_inode_dirty_sync(inode); |
84 | else { | ||
85 | barrier(); | ||
86 | ip->i_update_core = 1; | ||
87 | } | ||
85 | } | 88 | } |
86 | 89 | ||
87 | void | 90 | void |
@@ -92,6 +95,28 @@ xfs_mark_inode_dirty( | |||
92 | 95 | ||
93 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) | 96 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) |
94 | mark_inode_dirty(inode); | 97 | mark_inode_dirty(inode); |
98 | else { | ||
99 | barrier(); | ||
100 | ip->i_update_core = 1; | ||
101 | } | ||
102 | |||
103 | } | ||
104 | |||
105 | |||
106 | int xfs_initxattrs(struct inode *inode, const struct xattr *xattr_array, | ||
107 | void *fs_info) | ||
108 | { | ||
109 | const struct xattr *xattr; | ||
110 | struct xfs_inode *ip = XFS_I(inode); | ||
111 | int error = 0; | ||
112 | |||
113 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { | ||
114 | error = xfs_attr_set(ip, xattr->name, xattr->value, | ||
115 | xattr->value_len, ATTR_SECURE); | ||
116 | if (error < 0) | ||
117 | break; | ||
118 | } | ||
119 | return error; | ||
95 | } | 120 | } |
96 | 121 | ||
97 | /* | 122 | /* |
@@ -100,31 +125,15 @@ xfs_mark_inode_dirty( | |||
100 | * these attrs can be journalled at inode creation time (along with the | 125 | * these attrs can be journalled at inode creation time (along with the |
101 | * inode, of course, such that log replay can't cause these to be lost). | 126 | * inode, of course, such that log replay can't cause these to be lost). |
102 | */ | 127 | */ |
128 | |||
103 | STATIC int | 129 | STATIC int |
104 | xfs_init_security( | 130 | xfs_init_security( |
105 | struct inode *inode, | 131 | struct inode *inode, |
106 | struct inode *dir, | 132 | struct inode *dir, |
107 | const struct qstr *qstr) | 133 | const struct qstr *qstr) |
108 | { | 134 | { |
109 | struct xfs_inode *ip = XFS_I(inode); | 135 | return security_inode_init_security(inode, dir, qstr, |
110 | size_t length; | 136 | &xfs_initxattrs, NULL); |
111 | void *value; | ||
112 | unsigned char *name; | ||
113 | int error; | ||
114 | |||
115 | error = security_inode_init_security(inode, dir, qstr, (char **)&name, | ||
116 | &value, &length); | ||
117 | if (error) { | ||
118 | if (error == -EOPNOTSUPP) | ||
119 | return 0; | ||
120 | return -error; | ||
121 | } | ||
122 | |||
123 | error = xfs_attr_set(ip, name, value, length, ATTR_SECURE); | ||
124 | |||
125 | kfree(name); | ||
126 | kfree(value); | ||
127 | return error; | ||
128 | } | 137 | } |
129 | 138 | ||
130 | static void | 139 | static void |
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/xfs_iops.h index ef41c92ce66e..ef41c92ce66e 100644 --- a/fs/xfs/linux-2.6/xfs_iops.h +++ b/fs/xfs/xfs_iops.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/xfs_linux.h index d42f814e4d35..828662f70d64 100644 --- a/fs/xfs/linux-2.6/xfs_linux.h +++ b/fs/xfs/xfs_linux.h | |||
@@ -32,13 +32,12 @@ | |||
32 | # define XFS_BIG_INUMS 0 | 32 | # define XFS_BIG_INUMS 0 |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | #include <xfs_types.h> | 35 | #include "xfs_types.h" |
36 | 36 | ||
37 | #include <kmem.h> | 37 | #include "kmem.h" |
38 | #include <mrlock.h> | 38 | #include "mrlock.h" |
39 | #include <time.h> | 39 | #include "time.h" |
40 | 40 | #include "uuid.h" | |
41 | #include <support/uuid.h> | ||
42 | 41 | ||
43 | #include <linux/semaphore.h> | 42 | #include <linux/semaphore.h> |
44 | #include <linux/mm.h> | 43 | #include <linux/mm.h> |
@@ -69,6 +68,8 @@ | |||
69 | #include <linux/ctype.h> | 68 | #include <linux/ctype.h> |
70 | #include <linux/writeback.h> | 69 | #include <linux/writeback.h> |
71 | #include <linux/capability.h> | 70 | #include <linux/capability.h> |
71 | #include <linux/kthread.h> | ||
72 | #include <linux/freezer.h> | ||
72 | #include <linux/list_sort.h> | 73 | #include <linux/list_sort.h> |
73 | 74 | ||
74 | #include <asm/page.h> | 75 | #include <asm/page.h> |
@@ -78,14 +79,14 @@ | |||
78 | #include <asm/byteorder.h> | 79 | #include <asm/byteorder.h> |
79 | #include <asm/unaligned.h> | 80 | #include <asm/unaligned.h> |
80 | 81 | ||
81 | #include <xfs_vnode.h> | 82 | #include "xfs_vnode.h" |
82 | #include <xfs_stats.h> | 83 | #include "xfs_stats.h" |
83 | #include <xfs_sysctl.h> | 84 | #include "xfs_sysctl.h" |
84 | #include <xfs_iops.h> | 85 | #include "xfs_iops.h" |
85 | #include <xfs_aops.h> | 86 | #include "xfs_aops.h" |
86 | #include <xfs_super.h> | 87 | #include "xfs_super.h" |
87 | #include <xfs_buf.h> | 88 | #include "xfs_buf.h" |
88 | #include <xfs_message.h> | 89 | #include "xfs_message.h" |
89 | 90 | ||
90 | #ifdef __BIG_ENDIAN | 91 | #ifdef __BIG_ENDIAN |
91 | #define XFS_NATIVE_HOST 1 | 92 | #define XFS_NATIVE_HOST 1 |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 06ff8437ed8e..3a8d4f66d702 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -878,7 +878,7 @@ xlog_iodone(xfs_buf_t *bp) | |||
878 | /* | 878 | /* |
879 | * Race to shutdown the filesystem if we see an error. | 879 | * Race to shutdown the filesystem if we see an error. |
880 | */ | 880 | */ |
881 | if (XFS_TEST_ERROR((XFS_BUF_GETERROR(bp)), l->l_mp, | 881 | if (XFS_TEST_ERROR((xfs_buf_geterror(bp)), l->l_mp, |
882 | XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) { | 882 | XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) { |
883 | xfs_ioerror_alert("xlog_iodone", l->l_mp, bp, XFS_BUF_ADDR(bp)); | 883 | xfs_ioerror_alert("xlog_iodone", l->l_mp, bp, XFS_BUF_ADDR(bp)); |
884 | XFS_BUF_STALE(bp); | 884 | XFS_BUF_STALE(bp); |
@@ -1051,7 +1051,6 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1051 | if (!bp) | 1051 | if (!bp) |
1052 | goto out_free_log; | 1052 | goto out_free_log; |
1053 | bp->b_iodone = xlog_iodone; | 1053 | bp->b_iodone = xlog_iodone; |
1054 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
1055 | ASSERT(xfs_buf_islocked(bp)); | 1054 | ASSERT(xfs_buf_islocked(bp)); |
1056 | log->l_xbuf = bp; | 1055 | log->l_xbuf = bp; |
1057 | 1056 | ||
@@ -1108,7 +1107,6 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1108 | iclog->ic_callback_tail = &(iclog->ic_callback); | 1107 | iclog->ic_callback_tail = &(iclog->ic_callback); |
1109 | iclog->ic_datap = (char *)iclog->ic_data + log->l_iclog_hsize; | 1108 | iclog->ic_datap = (char *)iclog->ic_data + log->l_iclog_hsize; |
1110 | 1109 | ||
1111 | ASSERT(XFS_BUF_ISBUSY(iclog->ic_bp)); | ||
1112 | ASSERT(xfs_buf_islocked(iclog->ic_bp)); | 1110 | ASSERT(xfs_buf_islocked(iclog->ic_bp)); |
1113 | init_waitqueue_head(&iclog->ic_force_wait); | 1111 | init_waitqueue_head(&iclog->ic_force_wait); |
1114 | init_waitqueue_head(&iclog->ic_write_wait); | 1112 | init_waitqueue_head(&iclog->ic_write_wait); |
@@ -1248,7 +1246,7 @@ xlog_bdstrat( | |||
1248 | struct xlog_in_core *iclog = bp->b_fspriv; | 1246 | struct xlog_in_core *iclog = bp->b_fspriv; |
1249 | 1247 | ||
1250 | if (iclog->ic_state & XLOG_STATE_IOERROR) { | 1248 | if (iclog->ic_state & XLOG_STATE_IOERROR) { |
1251 | XFS_BUF_ERROR(bp, EIO); | 1249 | xfs_buf_ioerror(bp, EIO); |
1252 | XFS_BUF_STALE(bp); | 1250 | XFS_BUF_STALE(bp); |
1253 | xfs_buf_ioend(bp, 0); | 1251 | xfs_buf_ioend(bp, 0); |
1254 | /* | 1252 | /* |
@@ -1355,7 +1353,6 @@ xlog_sync(xlog_t *log, | |||
1355 | XFS_BUF_SET_COUNT(bp, count); | 1353 | XFS_BUF_SET_COUNT(bp, count); |
1356 | bp->b_fspriv = iclog; | 1354 | bp->b_fspriv = iclog; |
1357 | XFS_BUF_ZEROFLAGS(bp); | 1355 | XFS_BUF_ZEROFLAGS(bp); |
1358 | XFS_BUF_BUSY(bp); | ||
1359 | XFS_BUF_ASYNC(bp); | 1356 | XFS_BUF_ASYNC(bp); |
1360 | bp->b_flags |= XBF_SYNCIO; | 1357 | bp->b_flags |= XBF_SYNCIO; |
1361 | 1358 | ||
@@ -1398,16 +1395,15 @@ xlog_sync(xlog_t *log, | |||
1398 | if (split) { | 1395 | if (split) { |
1399 | bp = iclog->ic_log->l_xbuf; | 1396 | bp = iclog->ic_log->l_xbuf; |
1400 | XFS_BUF_SET_ADDR(bp, 0); /* logical 0 */ | 1397 | XFS_BUF_SET_ADDR(bp, 0); /* logical 0 */ |
1401 | XFS_BUF_SET_PTR(bp, (xfs_caddr_t)((__psint_t)&(iclog->ic_header)+ | 1398 | xfs_buf_associate_memory(bp, |
1402 | (__psint_t)count), split); | 1399 | (char *)&iclog->ic_header + count, split); |
1403 | bp->b_fspriv = iclog; | 1400 | bp->b_fspriv = iclog; |
1404 | XFS_BUF_ZEROFLAGS(bp); | 1401 | XFS_BUF_ZEROFLAGS(bp); |
1405 | XFS_BUF_BUSY(bp); | ||
1406 | XFS_BUF_ASYNC(bp); | 1402 | XFS_BUF_ASYNC(bp); |
1407 | bp->b_flags |= XBF_SYNCIO; | 1403 | bp->b_flags |= XBF_SYNCIO; |
1408 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) | 1404 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) |
1409 | bp->b_flags |= XBF_FUA; | 1405 | bp->b_flags |= XBF_FUA; |
1410 | dptr = XFS_BUF_PTR(bp); | 1406 | dptr = bp->b_addr; |
1411 | /* | 1407 | /* |
1412 | * Bump the cycle numbers at the start of each block | 1408 | * Bump the cycle numbers at the start of each block |
1413 | * since this part of the buffer is at the start of | 1409 | * since this part of the buffer is at the start of |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 052a2c0ec5fb..a199dbcee7d8 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -147,7 +147,7 @@ xlog_align( | |||
147 | xfs_daddr_t offset = blk_no & ((xfs_daddr_t)log->l_sectBBsize - 1); | 147 | xfs_daddr_t offset = blk_no & ((xfs_daddr_t)log->l_sectBBsize - 1); |
148 | 148 | ||
149 | ASSERT(BBTOB(offset + nbblks) <= XFS_BUF_SIZE(bp)); | 149 | ASSERT(BBTOB(offset + nbblks) <= XFS_BUF_SIZE(bp)); |
150 | return XFS_BUF_PTR(bp) + BBTOB(offset); | 150 | return bp->b_addr + BBTOB(offset); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
@@ -178,9 +178,7 @@ xlog_bread_noalign( | |||
178 | 178 | ||
179 | XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no); | 179 | XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no); |
180 | XFS_BUF_READ(bp); | 180 | XFS_BUF_READ(bp); |
181 | XFS_BUF_BUSY(bp); | ||
182 | XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); | 181 | XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); |
183 | XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp); | ||
184 | 182 | ||
185 | xfsbdstrat(log->l_mp, bp); | 183 | xfsbdstrat(log->l_mp, bp); |
186 | error = xfs_buf_iowait(bp); | 184 | error = xfs_buf_iowait(bp); |
@@ -220,18 +218,18 @@ xlog_bread_offset( | |||
220 | xfs_buf_t *bp, | 218 | xfs_buf_t *bp, |
221 | xfs_caddr_t offset) | 219 | xfs_caddr_t offset) |
222 | { | 220 | { |
223 | xfs_caddr_t orig_offset = XFS_BUF_PTR(bp); | 221 | xfs_caddr_t orig_offset = bp->b_addr; |
224 | int orig_len = bp->b_buffer_length; | 222 | int orig_len = bp->b_buffer_length; |
225 | int error, error2; | 223 | int error, error2; |
226 | 224 | ||
227 | error = XFS_BUF_SET_PTR(bp, offset, BBTOB(nbblks)); | 225 | error = xfs_buf_associate_memory(bp, offset, BBTOB(nbblks)); |
228 | if (error) | 226 | if (error) |
229 | return error; | 227 | return error; |
230 | 228 | ||
231 | error = xlog_bread_noalign(log, blk_no, nbblks, bp); | 229 | error = xlog_bread_noalign(log, blk_no, nbblks, bp); |
232 | 230 | ||
233 | /* must reset buffer pointer even on error */ | 231 | /* must reset buffer pointer even on error */ |
234 | error2 = XFS_BUF_SET_PTR(bp, orig_offset, orig_len); | 232 | error2 = xfs_buf_associate_memory(bp, orig_offset, orig_len); |
235 | if (error) | 233 | if (error) |
236 | return error; | 234 | return error; |
237 | return error2; | 235 | return error2; |
@@ -266,11 +264,9 @@ xlog_bwrite( | |||
266 | 264 | ||
267 | XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no); | 265 | XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no); |
268 | XFS_BUF_ZEROFLAGS(bp); | 266 | XFS_BUF_ZEROFLAGS(bp); |
269 | XFS_BUF_BUSY(bp); | 267 | xfs_buf_hold(bp); |
270 | XFS_BUF_HOLD(bp); | ||
271 | xfs_buf_lock(bp); | 268 | xfs_buf_lock(bp); |
272 | XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); | 269 | XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); |
273 | XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp); | ||
274 | 270 | ||
275 | if ((error = xfs_bwrite(log->l_mp, bp))) | 271 | if ((error = xfs_bwrite(log->l_mp, bp))) |
276 | xfs_ioerror_alert("xlog_bwrite", log->l_mp, | 272 | xfs_ioerror_alert("xlog_bwrite", log->l_mp, |
@@ -360,7 +356,7 @@ STATIC void | |||
360 | xlog_recover_iodone( | 356 | xlog_recover_iodone( |
361 | struct xfs_buf *bp) | 357 | struct xfs_buf *bp) |
362 | { | 358 | { |
363 | if (XFS_BUF_GETERROR(bp)) { | 359 | if (bp->b_error) { |
364 | /* | 360 | /* |
365 | * We're not going to bother about retrying | 361 | * We're not going to bother about retrying |
366 | * this during recovery. One strike! | 362 | * this during recovery. One strike! |
@@ -1262,7 +1258,7 @@ xlog_write_log_records( | |||
1262 | */ | 1258 | */ |
1263 | ealign = round_down(end_block, sectbb); | 1259 | ealign = round_down(end_block, sectbb); |
1264 | if (j == 0 && (start_block + endcount > ealign)) { | 1260 | if (j == 0 && (start_block + endcount > ealign)) { |
1265 | offset = XFS_BUF_PTR(bp) + BBTOB(ealign - start_block); | 1261 | offset = bp->b_addr + BBTOB(ealign - start_block); |
1266 | error = xlog_bread_offset(log, ealign, sectbb, | 1262 | error = xlog_bread_offset(log, ealign, sectbb, |
1267 | bp, offset); | 1263 | bp, offset); |
1268 | if (error) | 1264 | if (error) |
@@ -2135,15 +2131,16 @@ xlog_recover_buffer_pass2( | |||
2135 | 2131 | ||
2136 | bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, | 2132 | bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, |
2137 | buf_flags); | 2133 | buf_flags); |
2138 | if (XFS_BUF_ISERROR(bp)) { | 2134 | if (!bp) |
2135 | return XFS_ERROR(ENOMEM); | ||
2136 | error = bp->b_error; | ||
2137 | if (error) { | ||
2139 | xfs_ioerror_alert("xlog_recover_do..(read#1)", mp, | 2138 | xfs_ioerror_alert("xlog_recover_do..(read#1)", mp, |
2140 | bp, buf_f->blf_blkno); | 2139 | bp, buf_f->blf_blkno); |
2141 | error = XFS_BUF_GETERROR(bp); | ||
2142 | xfs_buf_relse(bp); | 2140 | xfs_buf_relse(bp); |
2143 | return error; | 2141 | return error; |
2144 | } | 2142 | } |
2145 | 2143 | ||
2146 | error = 0; | ||
2147 | if (buf_f->blf_flags & XFS_BLF_INODE_BUF) { | 2144 | if (buf_f->blf_flags & XFS_BLF_INODE_BUF) { |
2148 | error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f); | 2145 | error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f); |
2149 | } else if (buf_f->blf_flags & | 2146 | } else if (buf_f->blf_flags & |
@@ -2227,14 +2224,17 @@ xlog_recover_inode_pass2( | |||
2227 | 2224 | ||
2228 | bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, | 2225 | bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, |
2229 | XBF_LOCK); | 2226 | XBF_LOCK); |
2230 | if (XFS_BUF_ISERROR(bp)) { | 2227 | if (!bp) { |
2228 | error = ENOMEM; | ||
2229 | goto error; | ||
2230 | } | ||
2231 | error = bp->b_error; | ||
2232 | if (error) { | ||
2231 | xfs_ioerror_alert("xlog_recover_do..(read#2)", mp, | 2233 | xfs_ioerror_alert("xlog_recover_do..(read#2)", mp, |
2232 | bp, in_f->ilf_blkno); | 2234 | bp, in_f->ilf_blkno); |
2233 | error = XFS_BUF_GETERROR(bp); | ||
2234 | xfs_buf_relse(bp); | 2235 | xfs_buf_relse(bp); |
2235 | goto error; | 2236 | goto error; |
2236 | } | 2237 | } |
2237 | error = 0; | ||
2238 | ASSERT(in_f->ilf_fields & XFS_ILOG_CORE); | 2238 | ASSERT(in_f->ilf_fields & XFS_ILOG_CORE); |
2239 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, in_f->ilf_boffset); | 2239 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, in_f->ilf_boffset); |
2240 | 2240 | ||
@@ -3437,7 +3437,7 @@ xlog_do_recovery_pass( | |||
3437 | /* | 3437 | /* |
3438 | * Check for header wrapping around physical end-of-log | 3438 | * Check for header wrapping around physical end-of-log |
3439 | */ | 3439 | */ |
3440 | offset = XFS_BUF_PTR(hbp); | 3440 | offset = hbp->b_addr; |
3441 | split_hblks = 0; | 3441 | split_hblks = 0; |
3442 | wrapped_hblks = 0; | 3442 | wrapped_hblks = 0; |
3443 | if (blk_no + hblks <= log->l_logBBsize) { | 3443 | if (blk_no + hblks <= log->l_logBBsize) { |
@@ -3497,7 +3497,7 @@ xlog_do_recovery_pass( | |||
3497 | } else { | 3497 | } else { |
3498 | /* This log record is split across the | 3498 | /* This log record is split across the |
3499 | * physical end of log */ | 3499 | * physical end of log */ |
3500 | offset = XFS_BUF_PTR(dbp); | 3500 | offset = dbp->b_addr; |
3501 | split_bblks = 0; | 3501 | split_bblks = 0; |
3502 | if (blk_no != log->l_logBBsize) { | 3502 | if (blk_no != log->l_logBBsize) { |
3503 | /* some data is before the physical | 3503 | /* some data is before the physical |
diff --git a/fs/xfs/linux-2.6/xfs_message.c b/fs/xfs/xfs_message.c index bd672def95ac..bd672def95ac 100644 --- a/fs/xfs/linux-2.6/xfs_message.c +++ b/fs/xfs/xfs_message.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_message.h b/fs/xfs/xfs_message.h index 7fb7ea007672..7fb7ea007672 100644 --- a/fs/xfs/linux-2.6/xfs_message.h +++ b/fs/xfs/xfs_message.h | |||
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 092e16ae4d9d..0081657ad985 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -1615,7 +1615,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp) | |||
1615 | XFS_BUF_UNDELAYWRITE(sbp); | 1615 | XFS_BUF_UNDELAYWRITE(sbp); |
1616 | XFS_BUF_WRITE(sbp); | 1616 | XFS_BUF_WRITE(sbp); |
1617 | XFS_BUF_UNASYNC(sbp); | 1617 | XFS_BUF_UNASYNC(sbp); |
1618 | ASSERT(XFS_BUF_TARGET(sbp) == mp->m_ddev_targp); | 1618 | ASSERT(sbp->b_target == mp->m_ddev_targp); |
1619 | xfsbdstrat(mp, sbp); | 1619 | xfsbdstrat(mp, sbp); |
1620 | error = xfs_buf_iowait(sbp); | 1620 | error = xfs_buf_iowait(sbp); |
1621 | if (error) | 1621 | if (error) |
@@ -1938,7 +1938,7 @@ xfs_getsb( | |||
1938 | xfs_buf_lock(bp); | 1938 | xfs_buf_lock(bp); |
1939 | } | 1939 | } |
1940 | 1940 | ||
1941 | XFS_BUF_HOLD(bp); | 1941 | xfs_buf_hold(bp); |
1942 | ASSERT(XFS_BUF_ISDONE(bp)); | 1942 | ASSERT(XFS_BUF_ISDONE(bp)); |
1943 | return bp; | 1943 | return bp; |
1944 | } | 1944 | } |
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/xfs_qm.c index 46e54ad9a2dc..9a0aa76facdf 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/xfs_qm.c | |||
@@ -1240,7 +1240,7 @@ xfs_qm_reset_dqcounts( | |||
1240 | do_div(j, sizeof(xfs_dqblk_t)); | 1240 | do_div(j, sizeof(xfs_dqblk_t)); |
1241 | ASSERT(mp->m_quotainfo->qi_dqperchunk == j); | 1241 | ASSERT(mp->m_quotainfo->qi_dqperchunk == j); |
1242 | #endif | 1242 | #endif |
1243 | ddq = (xfs_disk_dquot_t *)XFS_BUF_PTR(bp); | 1243 | ddq = bp->b_addr; |
1244 | for (j = 0; j < mp->m_quotainfo->qi_dqperchunk; j++) { | 1244 | for (j = 0; j < mp->m_quotainfo->qi_dqperchunk; j++) { |
1245 | /* | 1245 | /* |
1246 | * Do a sanity check, and if needed, repair the dqblk. Don't | 1246 | * Do a sanity check, and if needed, repair the dqblk. Don't |
diff --git a/fs/xfs/quota/xfs_qm.h b/fs/xfs/xfs_qm.h index 43b9abe1052c..43b9abe1052c 100644 --- a/fs/xfs/quota/xfs_qm.h +++ b/fs/xfs/xfs_qm.h | |||
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c index a0a829addca9..a0a829addca9 100644 --- a/fs/xfs/quota/xfs_qm_bhv.c +++ b/fs/xfs/xfs_qm_bhv.c | |||
diff --git a/fs/xfs/quota/xfs_qm_stats.c b/fs/xfs/xfs_qm_stats.c index 8671a0b32644..8671a0b32644 100644 --- a/fs/xfs/quota/xfs_qm_stats.c +++ b/fs/xfs/xfs_qm_stats.c | |||
diff --git a/fs/xfs/quota/xfs_qm_stats.h b/fs/xfs/xfs_qm_stats.h index 5b964fc0dc09..5b964fc0dc09 100644 --- a/fs/xfs/quota/xfs_qm_stats.h +++ b/fs/xfs/xfs_qm_stats.h | |||
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index 609246f42e6c..609246f42e6c 100644 --- a/fs/xfs/quota/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c | |||
diff --git a/fs/xfs/quota/xfs_quota_priv.h b/fs/xfs/xfs_quota_priv.h index 94a3d927d716..94a3d927d716 100644 --- a/fs/xfs/quota/xfs_quota_priv.h +++ b/fs/xfs/xfs_quota_priv.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c index 29b9d642e93d..7e76f537abb7 100644 --- a/fs/xfs/linux-2.6/xfs_quotaops.c +++ b/fs/xfs/xfs_quotaops.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "xfs_trans.h" | 25 | #include "xfs_trans.h" |
26 | #include "xfs_bmap_btree.h" | 26 | #include "xfs_bmap_btree.h" |
27 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
28 | #include "quota/xfs_qm.h" | 28 | #include "xfs_qm.h" |
29 | #include <linux/quota.h> | 29 | #include <linux/quota.h> |
30 | 30 | ||
31 | 31 | ||
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 8f76fdff4f46..35561a511b57 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -168,7 +168,7 @@ error_cancel: | |||
168 | xfs_trans_cancel(tp, cancelflags); | 168 | xfs_trans_cancel(tp, cancelflags); |
169 | goto error; | 169 | goto error; |
170 | } | 170 | } |
171 | memset(XFS_BUF_PTR(bp), 0, mp->m_sb.sb_blocksize); | 171 | memset(bp->b_addr, 0, mp->m_sb.sb_blocksize); |
172 | xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); | 172 | xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); |
173 | /* | 173 | /* |
174 | * Commit the transaction. | 174 | * Commit the transaction. |
@@ -883,7 +883,7 @@ xfs_rtbuf_get( | |||
883 | if (error) { | 883 | if (error) { |
884 | return error; | 884 | return error; |
885 | } | 885 | } |
886 | ASSERT(bp && !XFS_BUF_GETERROR(bp)); | 886 | ASSERT(!xfs_buf_geterror(bp)); |
887 | *bpp = bp; | 887 | *bpp = bp; |
888 | return 0; | 888 | return 0; |
889 | } | 889 | } |
@@ -943,7 +943,7 @@ xfs_rtcheck_range( | |||
943 | if (error) { | 943 | if (error) { |
944 | return error; | 944 | return error; |
945 | } | 945 | } |
946 | bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 946 | bufp = bp->b_addr; |
947 | /* | 947 | /* |
948 | * Compute the starting word's address, and starting bit. | 948 | * Compute the starting word's address, and starting bit. |
949 | */ | 949 | */ |
@@ -994,7 +994,7 @@ xfs_rtcheck_range( | |||
994 | if (error) { | 994 | if (error) { |
995 | return error; | 995 | return error; |
996 | } | 996 | } |
997 | b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 997 | b = bufp = bp->b_addr; |
998 | word = 0; | 998 | word = 0; |
999 | } else { | 999 | } else { |
1000 | /* | 1000 | /* |
@@ -1040,7 +1040,7 @@ xfs_rtcheck_range( | |||
1040 | if (error) { | 1040 | if (error) { |
1041 | return error; | 1041 | return error; |
1042 | } | 1042 | } |
1043 | b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1043 | b = bufp = bp->b_addr; |
1044 | word = 0; | 1044 | word = 0; |
1045 | } else { | 1045 | } else { |
1046 | /* | 1046 | /* |
@@ -1158,7 +1158,7 @@ xfs_rtfind_back( | |||
1158 | if (error) { | 1158 | if (error) { |
1159 | return error; | 1159 | return error; |
1160 | } | 1160 | } |
1161 | bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1161 | bufp = bp->b_addr; |
1162 | /* | 1162 | /* |
1163 | * Get the first word's index & point to it. | 1163 | * Get the first word's index & point to it. |
1164 | */ | 1164 | */ |
@@ -1210,7 +1210,7 @@ xfs_rtfind_back( | |||
1210 | if (error) { | 1210 | if (error) { |
1211 | return error; | 1211 | return error; |
1212 | } | 1212 | } |
1213 | bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1213 | bufp = bp->b_addr; |
1214 | word = XFS_BLOCKWMASK(mp); | 1214 | word = XFS_BLOCKWMASK(mp); |
1215 | b = &bufp[word]; | 1215 | b = &bufp[word]; |
1216 | } else { | 1216 | } else { |
@@ -1256,7 +1256,7 @@ xfs_rtfind_back( | |||
1256 | if (error) { | 1256 | if (error) { |
1257 | return error; | 1257 | return error; |
1258 | } | 1258 | } |
1259 | bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1259 | bufp = bp->b_addr; |
1260 | word = XFS_BLOCKWMASK(mp); | 1260 | word = XFS_BLOCKWMASK(mp); |
1261 | b = &bufp[word]; | 1261 | b = &bufp[word]; |
1262 | } else { | 1262 | } else { |
@@ -1333,7 +1333,7 @@ xfs_rtfind_forw( | |||
1333 | if (error) { | 1333 | if (error) { |
1334 | return error; | 1334 | return error; |
1335 | } | 1335 | } |
1336 | bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1336 | bufp = bp->b_addr; |
1337 | /* | 1337 | /* |
1338 | * Get the first word's index & point to it. | 1338 | * Get the first word's index & point to it. |
1339 | */ | 1339 | */ |
@@ -1384,7 +1384,7 @@ xfs_rtfind_forw( | |||
1384 | if (error) { | 1384 | if (error) { |
1385 | return error; | 1385 | return error; |
1386 | } | 1386 | } |
1387 | b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1387 | b = bufp = bp->b_addr; |
1388 | word = 0; | 1388 | word = 0; |
1389 | } else { | 1389 | } else { |
1390 | /* | 1390 | /* |
@@ -1429,7 +1429,7 @@ xfs_rtfind_forw( | |||
1429 | if (error) { | 1429 | if (error) { |
1430 | return error; | 1430 | return error; |
1431 | } | 1431 | } |
1432 | b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1432 | b = bufp = bp->b_addr; |
1433 | word = 0; | 1433 | word = 0; |
1434 | } else { | 1434 | } else { |
1435 | /* | 1435 | /* |
@@ -1649,7 +1649,7 @@ xfs_rtmodify_range( | |||
1649 | if (error) { | 1649 | if (error) { |
1650 | return error; | 1650 | return error; |
1651 | } | 1651 | } |
1652 | bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1652 | bufp = bp->b_addr; |
1653 | /* | 1653 | /* |
1654 | * Compute the starting word's address, and starting bit. | 1654 | * Compute the starting word's address, and starting bit. |
1655 | */ | 1655 | */ |
@@ -1694,7 +1694,7 @@ xfs_rtmodify_range( | |||
1694 | if (error) { | 1694 | if (error) { |
1695 | return error; | 1695 | return error; |
1696 | } | 1696 | } |
1697 | first = b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1697 | first = b = bufp = bp->b_addr; |
1698 | word = 0; | 1698 | word = 0; |
1699 | } else { | 1699 | } else { |
1700 | /* | 1700 | /* |
@@ -1734,7 +1734,7 @@ xfs_rtmodify_range( | |||
1734 | if (error) { | 1734 | if (error) { |
1735 | return error; | 1735 | return error; |
1736 | } | 1736 | } |
1737 | first = b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); | 1737 | first = b = bufp = bp->b_addr; |
1738 | word = 0; | 1738 | word = 0; |
1739 | } else { | 1739 | } else { |
1740 | /* | 1740 | /* |
@@ -1832,8 +1832,8 @@ xfs_rtmodify_summary( | |||
1832 | */ | 1832 | */ |
1833 | sp = XFS_SUMPTR(mp, bp, so); | 1833 | sp = XFS_SUMPTR(mp, bp, so); |
1834 | *sp += delta; | 1834 | *sp += delta; |
1835 | xfs_trans_log_buf(tp, bp, (uint)((char *)sp - (char *)XFS_BUF_PTR(bp)), | 1835 | xfs_trans_log_buf(tp, bp, (uint)((char *)sp - (char *)bp->b_addr), |
1836 | (uint)((char *)sp - (char *)XFS_BUF_PTR(bp) + sizeof(*sp) - 1)); | 1836 | (uint)((char *)sp - (char *)bp->b_addr + sizeof(*sp) - 1)); |
1837 | return 0; | 1837 | return 0; |
1838 | } | 1838 | } |
1839 | 1839 | ||
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h index 09e1f4f35e97..f7f3a359c1c5 100644 --- a/fs/xfs/xfs_rtalloc.h +++ b/fs/xfs/xfs_rtalloc.h | |||
@@ -47,7 +47,7 @@ struct xfs_trans; | |||
47 | #define XFS_SUMOFFSTOBLOCK(mp,s) \ | 47 | #define XFS_SUMOFFSTOBLOCK(mp,s) \ |
48 | (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog) | 48 | (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog) |
49 | #define XFS_SUMPTR(mp,bp,so) \ | 49 | #define XFS_SUMPTR(mp,bp,so) \ |
50 | ((xfs_suminfo_t *)((char *)XFS_BUF_PTR(bp) + \ | 50 | ((xfs_suminfo_t *)((bp)->b_addr + \ |
51 | (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp)))) | 51 | (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp)))) |
52 | 52 | ||
53 | #define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log) | 53 | #define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log) |
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c index d6d6fdfe9422..c96a8a05ac03 100644 --- a/fs/xfs/xfs_rw.c +++ b/fs/xfs/xfs_rw.c | |||
@@ -104,9 +104,9 @@ xfs_ioerror_alert( | |||
104 | xfs_alert(mp, | 104 | xfs_alert(mp, |
105 | "I/O error occurred: meta-data dev %s block 0x%llx" | 105 | "I/O error occurred: meta-data dev %s block 0x%llx" |
106 | " (\"%s\") error %d buf count %zd", | 106 | " (\"%s\") error %d buf count %zd", |
107 | XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), | 107 | xfs_buf_target_name(bp->b_target), |
108 | (__uint64_t)blkno, func, | 108 | (__uint64_t)blkno, func, |
109 | XFS_BUF_GETERROR(bp), XFS_BUF_COUNT(bp)); | 109 | bp->b_error, XFS_BUF_COUNT(bp)); |
110 | } | 110 | } |
111 | 111 | ||
112 | /* | 112 | /* |
@@ -137,8 +137,8 @@ xfs_read_buf( | |||
137 | bp = xfs_buf_read(target, blkno, len, flags); | 137 | bp = xfs_buf_read(target, blkno, len, flags); |
138 | if (!bp) | 138 | if (!bp) |
139 | return XFS_ERROR(EIO); | 139 | return XFS_ERROR(EIO); |
140 | error = XFS_BUF_GETERROR(bp); | 140 | error = bp->b_error; |
141 | if (bp && !error && !XFS_FORCED_SHUTDOWN(mp)) { | 141 | if (!error && !XFS_FORCED_SHUTDOWN(mp)) { |
142 | *bpp = bp; | 142 | *bpp = bp; |
143 | } else { | 143 | } else { |
144 | *bpp = NULL; | 144 | *bpp = NULL; |
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h index 1eb2ba586814..cb6ae715814a 100644 --- a/fs/xfs/xfs_sb.h +++ b/fs/xfs/xfs_sb.h | |||
@@ -509,7 +509,7 @@ static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp) | |||
509 | 509 | ||
510 | #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ | 510 | #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ |
511 | #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) | 511 | #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) |
512 | #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)XFS_BUF_PTR(bp)) | 512 | #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr)) |
513 | 513 | ||
514 | #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) | 514 | #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) |
515 | #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ | 515 | #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ |
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/xfs_stats.c index 76fdc5861932..76fdc5861932 100644 --- a/fs/xfs/linux-2.6/xfs_stats.c +++ b/fs/xfs/xfs_stats.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_stats.h b/fs/xfs/xfs_stats.h index 736854b1ca1a..736854b1ca1a 100644 --- a/fs/xfs/linux-2.6/xfs_stats.h +++ b/fs/xfs/xfs_stats.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/xfs_super.c index 9a72dda58bd0..5cf06b85fd9d 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -356,6 +356,8 @@ xfs_parseargs( | |||
356 | mp->m_flags |= XFS_MOUNT_DELAYLOG; | 356 | mp->m_flags |= XFS_MOUNT_DELAYLOG; |
357 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { | 357 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { |
358 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; | 358 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; |
359 | xfs_warn(mp, | ||
360 | "nodelaylog is deprecated and will be removed in Linux 3.3"); | ||
359 | } else if (!strcmp(this_char, MNTOPT_DISCARD)) { | 361 | } else if (!strcmp(this_char, MNTOPT_DISCARD)) { |
360 | mp->m_flags |= XFS_MOUNT_DISCARD; | 362 | mp->m_flags |= XFS_MOUNT_DISCARD; |
361 | } else if (!strcmp(this_char, MNTOPT_NODISCARD)) { | 363 | } else if (!strcmp(this_char, MNTOPT_NODISCARD)) { |
@@ -877,33 +879,17 @@ xfs_log_inode( | |||
877 | struct xfs_trans *tp; | 879 | struct xfs_trans *tp; |
878 | int error; | 880 | int error; |
879 | 881 | ||
880 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | ||
881 | tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); | 882 | tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); |
882 | error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0); | 883 | error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0); |
883 | |||
884 | if (error) { | 884 | if (error) { |
885 | xfs_trans_cancel(tp, 0); | 885 | xfs_trans_cancel(tp, 0); |
886 | /* we need to return with the lock hold shared */ | ||
887 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
888 | return error; | 886 | return error; |
889 | } | 887 | } |
890 | 888 | ||
891 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 889 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
892 | 890 | xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); | |
893 | /* | ||
894 | * Note - it's possible that we might have pushed ourselves out of the | ||
895 | * way during trans_reserve which would flush the inode. But there's | ||
896 | * no guarantee that the inode buffer has actually gone out yet (it's | ||
897 | * delwri). Plus the buffer could be pinned anyway if it's part of | ||
898 | * an inode in another recent transaction. So we play it safe and | ||
899 | * fire off the transaction anyway. | ||
900 | */ | ||
901 | xfs_trans_ijoin(tp, ip); | ||
902 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 891 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
903 | error = xfs_trans_commit(tp, 0); | 892 | return xfs_trans_commit(tp, 0); |
904 | xfs_ilock_demote(ip, XFS_ILOCK_EXCL); | ||
905 | |||
906 | return error; | ||
907 | } | 893 | } |
908 | 894 | ||
909 | STATIC int | 895 | STATIC int |
@@ -918,7 +904,9 @@ xfs_fs_write_inode( | |||
918 | trace_xfs_write_inode(ip); | 904 | trace_xfs_write_inode(ip); |
919 | 905 | ||
920 | if (XFS_FORCED_SHUTDOWN(mp)) | 906 | if (XFS_FORCED_SHUTDOWN(mp)) |
921 | return XFS_ERROR(EIO); | 907 | return -XFS_ERROR(EIO); |
908 | if (!ip->i_update_core) | ||
909 | return 0; | ||
922 | 910 | ||
923 | if (wbc->sync_mode == WB_SYNC_ALL) { | 911 | if (wbc->sync_mode == WB_SYNC_ALL) { |
924 | /* | 912 | /* |
@@ -929,12 +917,10 @@ xfs_fs_write_inode( | |||
929 | * of synchronous log foces dramatically. | 917 | * of synchronous log foces dramatically. |
930 | */ | 918 | */ |
931 | xfs_ioend_wait(ip); | 919 | xfs_ioend_wait(ip); |
932 | xfs_ilock(ip, XFS_ILOCK_SHARED); | 920 | error = xfs_log_inode(ip); |
933 | if (ip->i_update_core) { | 921 | if (error) |
934 | error = xfs_log_inode(ip); | 922 | goto out; |
935 | if (error) | 923 | return 0; |
936 | goto out_unlock; | ||
937 | } | ||
938 | } else { | 924 | } else { |
939 | /* | 925 | /* |
940 | * We make this non-blocking if the inode is contended, return | 926 | * We make this non-blocking if the inode is contended, return |
@@ -1666,24 +1652,13 @@ xfs_init_workqueues(void) | |||
1666 | */ | 1652 | */ |
1667 | xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_CPU_INTENSIVE, 8); | 1653 | xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_CPU_INTENSIVE, 8); |
1668 | if (!xfs_syncd_wq) | 1654 | if (!xfs_syncd_wq) |
1669 | goto out; | 1655 | return -ENOMEM; |
1670 | |||
1671 | xfs_ail_wq = alloc_workqueue("xfsail", WQ_CPU_INTENSIVE, 8); | ||
1672 | if (!xfs_ail_wq) | ||
1673 | goto out_destroy_syncd; | ||
1674 | |||
1675 | return 0; | 1656 | return 0; |
1676 | |||
1677 | out_destroy_syncd: | ||
1678 | destroy_workqueue(xfs_syncd_wq); | ||
1679 | out: | ||
1680 | return -ENOMEM; | ||
1681 | } | 1657 | } |
1682 | 1658 | ||
1683 | STATIC void | 1659 | STATIC void |
1684 | xfs_destroy_workqueues(void) | 1660 | xfs_destroy_workqueues(void) |
1685 | { | 1661 | { |
1686 | destroy_workqueue(xfs_ail_wq); | ||
1687 | destroy_workqueue(xfs_syncd_wq); | 1662 | destroy_workqueue(xfs_syncd_wq); |
1688 | } | 1663 | } |
1689 | 1664 | ||
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/xfs_super.h index 50a3266c999e..50a3266c999e 100644 --- a/fs/xfs/linux-2.6/xfs_super.h +++ b/fs/xfs/xfs_super.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/xfs_sync.c index e4c938afb910..4604f90f86a3 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/xfs_sync.c | |||
@@ -332,7 +332,7 @@ xfs_sync_fsdata( | |||
332 | * between there and here. | 332 | * between there and here. |
333 | */ | 333 | */ |
334 | bp = xfs_getsb(mp, 0); | 334 | bp = xfs_getsb(mp, 0); |
335 | if (XFS_BUF_ISPINNED(bp)) | 335 | if (xfs_buf_ispinned(bp)) |
336 | xfs_log_force(mp, 0); | 336 | xfs_log_force(mp, 0); |
337 | 337 | ||
338 | return xfs_bwrite(mp, bp); | 338 | return xfs_bwrite(mp, bp); |
diff --git a/fs/xfs/linux-2.6/xfs_sync.h b/fs/xfs/xfs_sync.h index 941202e7ac6e..941202e7ac6e 100644 --- a/fs/xfs/linux-2.6/xfs_sync.h +++ b/fs/xfs/xfs_sync.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c index ee2d2adaa438..ee2d2adaa438 100644 --- a/fs/xfs/linux-2.6/xfs_sysctl.c +++ b/fs/xfs/xfs_sysctl.c | |||
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h index b9937d450f8e..b9937d450f8e 100644 --- a/fs/xfs/linux-2.6/xfs_sysctl.h +++ b/fs/xfs/xfs_sysctl.h | |||
diff --git a/fs/xfs/linux-2.6/xfs_trace.c b/fs/xfs/xfs_trace.c index 88d25d4aa56e..9010ce885e6a 100644 --- a/fs/xfs/linux-2.6/xfs_trace.c +++ b/fs/xfs/xfs_trace.c | |||
@@ -43,8 +43,8 @@ | |||
43 | #include "xfs_quota.h" | 43 | #include "xfs_quota.h" |
44 | #include "xfs_iomap.h" | 44 | #include "xfs_iomap.h" |
45 | #include "xfs_aops.h" | 45 | #include "xfs_aops.h" |
46 | #include "quota/xfs_dquot_item.h" | 46 | #include "xfs_dquot_item.h" |
47 | #include "quota/xfs_dquot.h" | 47 | #include "xfs_dquot.h" |
48 | #include "xfs_log_recover.h" | 48 | #include "xfs_log_recover.h" |
49 | #include "xfs_inode_item.h" | 49 | #include "xfs_inode_item.h" |
50 | 50 | ||
diff --git a/fs/xfs/linux-2.6/xfs_trace.h b/fs/xfs/xfs_trace.h index 690fc7a7bd72..690fc7a7bd72 100644 --- a/fs/xfs/linux-2.6/xfs_trace.h +++ b/fs/xfs/xfs_trace.h | |||
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 06a9759b6352..53597f4db9b5 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -350,7 +350,7 @@ typedef struct xfs_item_ops { | |||
350 | void (*iop_unlock)(xfs_log_item_t *); | 350 | void (*iop_unlock)(xfs_log_item_t *); |
351 | xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t); | 351 | xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t); |
352 | void (*iop_push)(xfs_log_item_t *); | 352 | void (*iop_push)(xfs_log_item_t *); |
353 | void (*iop_pushbuf)(xfs_log_item_t *); | 353 | bool (*iop_pushbuf)(xfs_log_item_t *); |
354 | void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t); | 354 | void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t); |
355 | } xfs_item_ops_t; | 355 | } xfs_item_ops_t; |
356 | 356 | ||
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 43233e92f0f6..3a1e7ca54c2d 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
@@ -28,8 +28,6 @@ | |||
28 | #include "xfs_trans_priv.h" | 28 | #include "xfs_trans_priv.h" |
29 | #include "xfs_error.h" | 29 | #include "xfs_error.h" |
30 | 30 | ||
31 | struct workqueue_struct *xfs_ail_wq; /* AIL workqueue */ | ||
32 | |||
33 | #ifdef DEBUG | 31 | #ifdef DEBUG |
34 | /* | 32 | /* |
35 | * Check that the list is sorted as it should be. | 33 | * Check that the list is sorted as it should be. |
@@ -299,7 +297,7 @@ xfs_trans_ail_cursor_last( | |||
299 | * Splice the log item list into the AIL at the given LSN. We splice to the | 297 | * Splice the log item list into the AIL at the given LSN. We splice to the |
300 | * tail of the given LSN to maintain insert order for push traversals. The | 298 | * tail of the given LSN to maintain insert order for push traversals. The |
301 | * cursor is optional, allowing repeated updates to the same LSN to avoid | 299 | * cursor is optional, allowing repeated updates to the same LSN to avoid |
302 | * repeated traversals. | 300 | * repeated traversals. This should not be called with an empty list. |
303 | */ | 301 | */ |
304 | static void | 302 | static void |
305 | xfs_ail_splice( | 303 | xfs_ail_splice( |
@@ -308,50 +306,39 @@ xfs_ail_splice( | |||
308 | struct list_head *list, | 306 | struct list_head *list, |
309 | xfs_lsn_t lsn) | 307 | xfs_lsn_t lsn) |
310 | { | 308 | { |
311 | struct xfs_log_item *lip = cur ? cur->item : NULL; | 309 | struct xfs_log_item *lip; |
312 | struct xfs_log_item *next_lip; | 310 | |
311 | ASSERT(!list_empty(list)); | ||
313 | 312 | ||
314 | /* | 313 | /* |
315 | * Get a new cursor if we don't have a placeholder or the existing one | 314 | * Use the cursor to determine the insertion point if one is |
316 | * has been invalidated. | 315 | * provided. If not, or if the one we got is not valid, |
316 | * find the place in the AIL where the items belong. | ||
317 | */ | 317 | */ |
318 | if (!lip || (__psint_t)lip & 1) { | 318 | lip = cur ? cur->item : NULL; |
319 | if (!lip || (__psint_t) lip & 1) | ||
319 | lip = __xfs_trans_ail_cursor_last(ailp, lsn); | 320 | lip = __xfs_trans_ail_cursor_last(ailp, lsn); |
320 | 321 | ||
321 | if (!lip) { | 322 | /* |
322 | /* The list is empty, so just splice and return. */ | 323 | * If a cursor is provided, we know we're processing the AIL |
323 | if (cur) | 324 | * in lsn order, and future items to be spliced in will |
324 | cur->item = NULL; | 325 | * follow the last one being inserted now. Update the |
325 | list_splice(list, &ailp->xa_ail); | 326 | * cursor to point to that last item, now while we have a |
326 | return; | 327 | * reliable pointer to it. |
327 | } | 328 | */ |
328 | } | 329 | if (cur) |
330 | cur->item = list_entry(list->prev, struct xfs_log_item, li_ail); | ||
329 | 331 | ||
330 | /* | 332 | /* |
331 | * Our cursor points to the item we want to insert _after_, so we have | 333 | * Finally perform the splice. Unless the AIL was empty, |
332 | * to update the cursor to point to the end of the list we are splicing | 334 | * lip points to the item in the AIL _after_ which the new |
333 | * in so that it points to the correct location for the next splice. | 335 | * items should go. If lip is null the AIL was empty, so |
334 | * i.e. before the splice | 336 | * the new items go at the head of the AIL. |
335 | * | ||
336 | * lsn -> lsn -> lsn + x -> lsn + x ... | ||
337 | * ^ | ||
338 | * | cursor points here | ||
339 | * | ||
340 | * After the splice we have: | ||
341 | * | ||
342 | * lsn -> lsn -> lsn -> lsn -> .... -> lsn -> lsn + x -> lsn + x ... | ||
343 | * ^ ^ | ||
344 | * | cursor points here | needs to move here | ||
345 | * | ||
346 | * So we set the cursor to the last item in the list to be spliced | ||
347 | * before we execute the splice, resulting in the cursor pointing to | ||
348 | * the correct item after the splice occurs. | ||
349 | */ | 337 | */ |
350 | if (cur) { | 338 | if (lip) |
351 | next_lip = list_entry(list->prev, struct xfs_log_item, li_ail); | 339 | list_splice(list, &lip->li_ail); |
352 | cur->item = next_lip; | 340 | else |
353 | } | 341 | list_splice(list, &ailp->xa_ail); |
354 | list_splice(list, &lip->li_ail); | ||
355 | } | 342 | } |
356 | 343 | ||
357 | /* | 344 | /* |
@@ -367,16 +354,10 @@ xfs_ail_delete( | |||
367 | xfs_trans_ail_cursor_clear(ailp, lip); | 354 | xfs_trans_ail_cursor_clear(ailp, lip); |
368 | } | 355 | } |
369 | 356 | ||
370 | /* | 357 | static long |
371 | * xfs_ail_worker does the work of pushing on the AIL. It will requeue itself | 358 | xfsaild_push( |
372 | * to run at a later time if there is more work to do to complete the push. | 359 | struct xfs_ail *ailp) |
373 | */ | ||
374 | STATIC void | ||
375 | xfs_ail_worker( | ||
376 | struct work_struct *work) | ||
377 | { | 360 | { |
378 | struct xfs_ail *ailp = container_of(to_delayed_work(work), | ||
379 | struct xfs_ail, xa_work); | ||
380 | xfs_mount_t *mp = ailp->xa_mount; | 361 | xfs_mount_t *mp = ailp->xa_mount; |
381 | struct xfs_ail_cursor cur; | 362 | struct xfs_ail_cursor cur; |
382 | xfs_log_item_t *lip; | 363 | xfs_log_item_t *lip; |
@@ -438,8 +419,13 @@ xfs_ail_worker( | |||
438 | 419 | ||
439 | case XFS_ITEM_PUSHBUF: | 420 | case XFS_ITEM_PUSHBUF: |
440 | XFS_STATS_INC(xs_push_ail_pushbuf); | 421 | XFS_STATS_INC(xs_push_ail_pushbuf); |
441 | IOP_PUSHBUF(lip); | 422 | |
442 | ailp->xa_last_pushed_lsn = lsn; | 423 | if (!IOP_PUSHBUF(lip)) { |
424 | stuck++; | ||
425 | flush_log = 1; | ||
426 | } else { | ||
427 | ailp->xa_last_pushed_lsn = lsn; | ||
428 | } | ||
443 | push_xfsbufd = 1; | 429 | push_xfsbufd = 1; |
444 | break; | 430 | break; |
445 | 431 | ||
@@ -451,7 +437,6 @@ xfs_ail_worker( | |||
451 | 437 | ||
452 | case XFS_ITEM_LOCKED: | 438 | case XFS_ITEM_LOCKED: |
453 | XFS_STATS_INC(xs_push_ail_locked); | 439 | XFS_STATS_INC(xs_push_ail_locked); |
454 | ailp->xa_last_pushed_lsn = lsn; | ||
455 | stuck++; | 440 | stuck++; |
456 | break; | 441 | break; |
457 | 442 | ||
@@ -512,20 +497,6 @@ out_done: | |||
512 | /* We're past our target or empty, so idle */ | 497 | /* We're past our target or empty, so idle */ |
513 | ailp->xa_last_pushed_lsn = 0; | 498 | ailp->xa_last_pushed_lsn = 0; |
514 | 499 | ||
515 | /* | ||
516 | * We clear the XFS_AIL_PUSHING_BIT first before checking | ||
517 | * whether the target has changed. If the target has changed, | ||
518 | * this pushes the requeue race directly onto the result of the | ||
519 | * atomic test/set bit, so we are guaranteed that either the | ||
520 | * the pusher that changed the target or ourselves will requeue | ||
521 | * the work (but not both). | ||
522 | */ | ||
523 | clear_bit(XFS_AIL_PUSHING_BIT, &ailp->xa_flags); | ||
524 | smp_rmb(); | ||
525 | if (XFS_LSN_CMP(ailp->xa_target, target) == 0 || | ||
526 | test_and_set_bit(XFS_AIL_PUSHING_BIT, &ailp->xa_flags)) | ||
527 | return; | ||
528 | |||
529 | tout = 50; | 500 | tout = 50; |
530 | } else if (XFS_LSN_CMP(lsn, target) >= 0) { | 501 | } else if (XFS_LSN_CMP(lsn, target) >= 0) { |
531 | /* | 502 | /* |
@@ -548,9 +519,30 @@ out_done: | |||
548 | tout = 20; | 519 | tout = 20; |
549 | } | 520 | } |
550 | 521 | ||
551 | /* There is more to do, requeue us. */ | 522 | return tout; |
552 | queue_delayed_work(xfs_syncd_wq, &ailp->xa_work, | 523 | } |
553 | msecs_to_jiffies(tout)); | 524 | |
525 | static int | ||
526 | xfsaild( | ||
527 | void *data) | ||
528 | { | ||
529 | struct xfs_ail *ailp = data; | ||
530 | long tout = 0; /* milliseconds */ | ||
531 | |||
532 | while (!kthread_should_stop()) { | ||
533 | if (tout && tout <= 20) | ||
534 | __set_current_state(TASK_KILLABLE); | ||
535 | else | ||
536 | __set_current_state(TASK_INTERRUPTIBLE); | ||
537 | schedule_timeout(tout ? | ||
538 | msecs_to_jiffies(tout) : MAX_SCHEDULE_TIMEOUT); | ||
539 | |||
540 | try_to_freeze(); | ||
541 | |||
542 | tout = xfsaild_push(ailp); | ||
543 | } | ||
544 | |||
545 | return 0; | ||
554 | } | 546 | } |
555 | 547 | ||
556 | /* | 548 | /* |
@@ -585,8 +577,9 @@ xfs_ail_push( | |||
585 | */ | 577 | */ |
586 | smp_wmb(); | 578 | smp_wmb(); |
587 | xfs_trans_ail_copy_lsn(ailp, &ailp->xa_target, &threshold_lsn); | 579 | xfs_trans_ail_copy_lsn(ailp, &ailp->xa_target, &threshold_lsn); |
588 | if (!test_and_set_bit(XFS_AIL_PUSHING_BIT, &ailp->xa_flags)) | 580 | smp_wmb(); |
589 | queue_delayed_work(xfs_syncd_wq, &ailp->xa_work, 0); | 581 | |
582 | wake_up_process(ailp->xa_task); | ||
590 | } | 583 | } |
591 | 584 | ||
592 | /* | 585 | /* |
@@ -682,6 +675,7 @@ xfs_trans_ail_update_bulk( | |||
682 | int i; | 675 | int i; |
683 | LIST_HEAD(tmp); | 676 | LIST_HEAD(tmp); |
684 | 677 | ||
678 | ASSERT(nr_items > 0); /* Not required, but true. */ | ||
685 | mlip = xfs_ail_min(ailp); | 679 | mlip = xfs_ail_min(ailp); |
686 | 680 | ||
687 | for (i = 0; i < nr_items; i++) { | 681 | for (i = 0; i < nr_items; i++) { |
@@ -701,7 +695,8 @@ xfs_trans_ail_update_bulk( | |||
701 | list_add(&lip->li_ail, &tmp); | 695 | list_add(&lip->li_ail, &tmp); |
702 | } | 696 | } |
703 | 697 | ||
704 | xfs_ail_splice(ailp, cur, &tmp, lsn); | 698 | if (!list_empty(&tmp)) |
699 | xfs_ail_splice(ailp, cur, &tmp, lsn); | ||
705 | 700 | ||
706 | if (!mlip_changed) { | 701 | if (!mlip_changed) { |
707 | spin_unlock(&ailp->xa_lock); | 702 | spin_unlock(&ailp->xa_lock); |
@@ -822,9 +817,18 @@ xfs_trans_ail_init( | |||
822 | INIT_LIST_HEAD(&ailp->xa_ail); | 817 | INIT_LIST_HEAD(&ailp->xa_ail); |
823 | INIT_LIST_HEAD(&ailp->xa_cursors); | 818 | INIT_LIST_HEAD(&ailp->xa_cursors); |
824 | spin_lock_init(&ailp->xa_lock); | 819 | spin_lock_init(&ailp->xa_lock); |
825 | INIT_DELAYED_WORK(&ailp->xa_work, xfs_ail_worker); | 820 | |
821 | ailp->xa_task = kthread_run(xfsaild, ailp, "xfsaild/%s", | ||
822 | ailp->xa_mount->m_fsname); | ||
823 | if (IS_ERR(ailp->xa_task)) | ||
824 | goto out_free_ailp; | ||
825 | |||
826 | mp->m_ail = ailp; | 826 | mp->m_ail = ailp; |
827 | return 0; | 827 | return 0; |
828 | |||
829 | out_free_ailp: | ||
830 | kmem_free(ailp); | ||
831 | return ENOMEM; | ||
828 | } | 832 | } |
829 | 833 | ||
830 | void | 834 | void |
@@ -833,6 +837,6 @@ xfs_trans_ail_destroy( | |||
833 | { | 837 | { |
834 | struct xfs_ail *ailp = mp->m_ail; | 838 | struct xfs_ail *ailp = mp->m_ail; |
835 | 839 | ||
836 | cancel_delayed_work_sync(&ailp->xa_work); | 840 | kthread_stop(ailp->xa_task); |
837 | kmem_free(ailp); | 841 | kmem_free(ailp); |
838 | } | 842 | } |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 15584fc3ed7d..137e2b9e2948 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -54,7 +54,7 @@ xfs_trans_buf_item_match( | |||
54 | list_for_each_entry(lidp, &tp->t_items, lid_trans) { | 54 | list_for_each_entry(lidp, &tp->t_items, lid_trans) { |
55 | blip = (struct xfs_buf_log_item *)lidp->lid_item; | 55 | blip = (struct xfs_buf_log_item *)lidp->lid_item; |
56 | if (blip->bli_item.li_type == XFS_LI_BUF && | 56 | if (blip->bli_item.li_type == XFS_LI_BUF && |
57 | XFS_BUF_TARGET(blip->bli_buf) == target && | 57 | blip->bli_buf->b_target == target && |
58 | XFS_BUF_ADDR(blip->bli_buf) == blkno && | 58 | XFS_BUF_ADDR(blip->bli_buf) == blkno && |
59 | XFS_BUF_COUNT(blip->bli_buf) == len) | 59 | XFS_BUF_COUNT(blip->bli_buf) == len) |
60 | return blip->bli_buf; | 60 | return blip->bli_buf; |
@@ -80,7 +80,6 @@ _xfs_trans_bjoin( | |||
80 | { | 80 | { |
81 | struct xfs_buf_log_item *bip; | 81 | struct xfs_buf_log_item *bip; |
82 | 82 | ||
83 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
84 | ASSERT(bp->b_transp == NULL); | 83 | ASSERT(bp->b_transp == NULL); |
85 | 84 | ||
86 | /* | 85 | /* |
@@ -194,7 +193,7 @@ xfs_trans_get_buf(xfs_trans_t *tp, | |||
194 | return NULL; | 193 | return NULL; |
195 | } | 194 | } |
196 | 195 | ||
197 | ASSERT(!XFS_BUF_GETERROR(bp)); | 196 | ASSERT(!bp->b_error); |
198 | 197 | ||
199 | _xfs_trans_bjoin(tp, bp, 1); | 198 | _xfs_trans_bjoin(tp, bp, 1); |
200 | trace_xfs_trans_get_buf(bp->b_fspriv); | 199 | trace_xfs_trans_get_buf(bp->b_fspriv); |
@@ -293,10 +292,10 @@ xfs_trans_read_buf( | |||
293 | return (flags & XBF_TRYLOCK) ? | 292 | return (flags & XBF_TRYLOCK) ? |
294 | EAGAIN : XFS_ERROR(ENOMEM); | 293 | EAGAIN : XFS_ERROR(ENOMEM); |
295 | 294 | ||
296 | if (XFS_BUF_GETERROR(bp) != 0) { | 295 | if (bp->b_error) { |
296 | error = bp->b_error; | ||
297 | xfs_ioerror_alert("xfs_trans_read_buf", mp, | 297 | xfs_ioerror_alert("xfs_trans_read_buf", mp, |
298 | bp, blkno); | 298 | bp, blkno); |
299 | error = XFS_BUF_GETERROR(bp); | ||
300 | xfs_buf_relse(bp); | 299 | xfs_buf_relse(bp); |
301 | return error; | 300 | return error; |
302 | } | 301 | } |
@@ -330,7 +329,7 @@ xfs_trans_read_buf( | |||
330 | ASSERT(xfs_buf_islocked(bp)); | 329 | ASSERT(xfs_buf_islocked(bp)); |
331 | ASSERT(bp->b_transp == tp); | 330 | ASSERT(bp->b_transp == tp); |
332 | ASSERT(bp->b_fspriv != NULL); | 331 | ASSERT(bp->b_fspriv != NULL); |
333 | ASSERT((XFS_BUF_ISERROR(bp)) == 0); | 332 | ASSERT(!bp->b_error); |
334 | if (!(XFS_BUF_ISDONE(bp))) { | 333 | if (!(XFS_BUF_ISDONE(bp))) { |
335 | trace_xfs_trans_read_buf_io(bp, _RET_IP_); | 334 | trace_xfs_trans_read_buf_io(bp, _RET_IP_); |
336 | ASSERT(!XFS_BUF_ISASYNC(bp)); | 335 | ASSERT(!XFS_BUF_ISASYNC(bp)); |
@@ -386,10 +385,9 @@ xfs_trans_read_buf( | |||
386 | return (flags & XBF_TRYLOCK) ? | 385 | return (flags & XBF_TRYLOCK) ? |
387 | 0 : XFS_ERROR(ENOMEM); | 386 | 0 : XFS_ERROR(ENOMEM); |
388 | } | 387 | } |
389 | if (XFS_BUF_GETERROR(bp) != 0) { | 388 | if (bp->b_error) { |
390 | XFS_BUF_SUPER_STALE(bp); | 389 | error = bp->b_error; |
391 | error = XFS_BUF_GETERROR(bp); | 390 | XFS_BUF_SUPER_STALE(bp); |
392 | |||
393 | xfs_ioerror_alert("xfs_trans_read_buf", mp, | 391 | xfs_ioerror_alert("xfs_trans_read_buf", mp, |
394 | bp, blkno); | 392 | bp, blkno); |
395 | if (tp->t_flags & XFS_TRANS_DIRTY) | 393 | if (tp->t_flags & XFS_TRANS_DIRTY) |
@@ -430,7 +428,7 @@ shutdown_abort: | |||
430 | if (XFS_BUF_ISSTALE(bp) && XFS_BUF_ISDELAYWRITE(bp)) | 428 | if (XFS_BUF_ISSTALE(bp) && XFS_BUF_ISDELAYWRITE(bp)) |
431 | xfs_notice(mp, "about to pop assert, bp == 0x%p", bp); | 429 | xfs_notice(mp, "about to pop assert, bp == 0x%p", bp); |
432 | #endif | 430 | #endif |
433 | ASSERT((XFS_BUF_BFLAGS(bp) & (XBF_STALE|XBF_DELWRI)) != | 431 | ASSERT((bp->b_flags & (XBF_STALE|XBF_DELWRI)) != |
434 | (XBF_STALE|XBF_DELWRI)); | 432 | (XBF_STALE|XBF_DELWRI)); |
435 | 433 | ||
436 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); | 434 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); |
@@ -581,7 +579,6 @@ xfs_trans_bhold(xfs_trans_t *tp, | |||
581 | { | 579 | { |
582 | xfs_buf_log_item_t *bip = bp->b_fspriv; | 580 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
583 | 581 | ||
584 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
585 | ASSERT(bp->b_transp == tp); | 582 | ASSERT(bp->b_transp == tp); |
586 | ASSERT(bip != NULL); | 583 | ASSERT(bip != NULL); |
587 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); | 584 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); |
@@ -602,7 +599,6 @@ xfs_trans_bhold_release(xfs_trans_t *tp, | |||
602 | { | 599 | { |
603 | xfs_buf_log_item_t *bip = bp->b_fspriv; | 600 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
604 | 601 | ||
605 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
606 | ASSERT(bp->b_transp == tp); | 602 | ASSERT(bp->b_transp == tp); |
607 | ASSERT(bip != NULL); | 603 | ASSERT(bip != NULL); |
608 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); | 604 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); |
@@ -631,7 +627,6 @@ xfs_trans_log_buf(xfs_trans_t *tp, | |||
631 | { | 627 | { |
632 | xfs_buf_log_item_t *bip = bp->b_fspriv; | 628 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
633 | 629 | ||
634 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
635 | ASSERT(bp->b_transp == tp); | 630 | ASSERT(bp->b_transp == tp); |
636 | ASSERT(bip != NULL); | 631 | ASSERT(bip != NULL); |
637 | ASSERT((first <= last) && (last < XFS_BUF_COUNT(bp))); | 632 | ASSERT((first <= last) && (last < XFS_BUF_COUNT(bp))); |
@@ -702,7 +697,6 @@ xfs_trans_binval( | |||
702 | { | 697 | { |
703 | xfs_buf_log_item_t *bip = bp->b_fspriv; | 698 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
704 | 699 | ||
705 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
706 | ASSERT(bp->b_transp == tp); | 700 | ASSERT(bp->b_transp == tp); |
707 | ASSERT(bip != NULL); | 701 | ASSERT(bip != NULL); |
708 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 702 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
@@ -774,7 +768,6 @@ xfs_trans_inode_buf( | |||
774 | { | 768 | { |
775 | xfs_buf_log_item_t *bip = bp->b_fspriv; | 769 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
776 | 770 | ||
777 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
778 | ASSERT(bp->b_transp == tp); | 771 | ASSERT(bp->b_transp == tp); |
779 | ASSERT(bip != NULL); | 772 | ASSERT(bip != NULL); |
780 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 773 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
@@ -798,7 +791,6 @@ xfs_trans_stale_inode_buf( | |||
798 | { | 791 | { |
799 | xfs_buf_log_item_t *bip = bp->b_fspriv; | 792 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
800 | 793 | ||
801 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
802 | ASSERT(bp->b_transp == tp); | 794 | ASSERT(bp->b_transp == tp); |
803 | ASSERT(bip != NULL); | 795 | ASSERT(bip != NULL); |
804 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 796 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
@@ -823,7 +815,6 @@ xfs_trans_inode_alloc_buf( | |||
823 | { | 815 | { |
824 | xfs_buf_log_item_t *bip = bp->b_fspriv; | 816 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
825 | 817 | ||
826 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
827 | ASSERT(bp->b_transp == tp); | 818 | ASSERT(bp->b_transp == tp); |
828 | ASSERT(bip != NULL); | 819 | ASSERT(bip != NULL); |
829 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 820 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
@@ -851,7 +842,6 @@ xfs_trans_dquot_buf( | |||
851 | { | 842 | { |
852 | xfs_buf_log_item_t *bip = bp->b_fspriv; | 843 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
853 | 844 | ||
854 | ASSERT(XFS_BUF_ISBUSY(bp)); | ||
855 | ASSERT(bp->b_transp == tp); | 845 | ASSERT(bp->b_transp == tp); |
856 | ASSERT(bip != NULL); | 846 | ASSERT(bip != NULL); |
857 | ASSERT(type == XFS_BLF_UDQUOT_BUF || | 847 | ASSERT(type == XFS_BLF_UDQUOT_BUF || |
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index 4d00ee67792d..4d00ee67792d 100644 --- a/fs/xfs/quota/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c | |||
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h index 212946b97239..22750b5e4a8f 100644 --- a/fs/xfs/xfs_trans_priv.h +++ b/fs/xfs/xfs_trans_priv.h | |||
@@ -64,23 +64,17 @@ struct xfs_ail_cursor { | |||
64 | */ | 64 | */ |
65 | struct xfs_ail { | 65 | struct xfs_ail { |
66 | struct xfs_mount *xa_mount; | 66 | struct xfs_mount *xa_mount; |
67 | struct task_struct *xa_task; | ||
67 | struct list_head xa_ail; | 68 | struct list_head xa_ail; |
68 | xfs_lsn_t xa_target; | 69 | xfs_lsn_t xa_target; |
69 | struct list_head xa_cursors; | 70 | struct list_head xa_cursors; |
70 | spinlock_t xa_lock; | 71 | spinlock_t xa_lock; |
71 | struct delayed_work xa_work; | ||
72 | xfs_lsn_t xa_last_pushed_lsn; | 72 | xfs_lsn_t xa_last_pushed_lsn; |
73 | unsigned long xa_flags; | ||
74 | }; | 73 | }; |
75 | 74 | ||
76 | #define XFS_AIL_PUSHING_BIT 0 | ||
77 | |||
78 | /* | 75 | /* |
79 | * From xfs_trans_ail.c | 76 | * From xfs_trans_ail.c |
80 | */ | 77 | */ |
81 | |||
82 | extern struct workqueue_struct *xfs_ail_wq; /* AIL workqueue */ | ||
83 | |||
84 | void xfs_trans_ail_update_bulk(struct xfs_ail *ailp, | 78 | void xfs_trans_ail_update_bulk(struct xfs_ail *ailp, |
85 | struct xfs_ail_cursor *cur, | 79 | struct xfs_ail_cursor *cur, |
86 | struct xfs_log_item **log_items, int nr_items, | 80 | struct xfs_log_item **log_items, int nr_items, |
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/xfs_vnode.h index 7c220b4227bc..7c220b4227bc 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.h +++ b/fs/xfs/xfs_vnode.h | |||
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 9322e13f0c63..51fc429527bc 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -83,7 +83,9 @@ xfs_readlink_bmap( | |||
83 | 83 | ||
84 | bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), | 84 | bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), |
85 | XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK); | 85 | XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK); |
86 | error = XFS_BUF_GETERROR(bp); | 86 | if (!bp) |
87 | return XFS_ERROR(ENOMEM); | ||
88 | error = bp->b_error; | ||
87 | if (error) { | 89 | if (error) { |
88 | xfs_ioerror_alert("xfs_readlink", | 90 | xfs_ioerror_alert("xfs_readlink", |
89 | ip->i_mount, bp, XFS_BUF_ADDR(bp)); | 91 | ip->i_mount, bp, XFS_BUF_ADDR(bp)); |
@@ -94,7 +96,7 @@ xfs_readlink_bmap( | |||
94 | byte_cnt = pathlen; | 96 | byte_cnt = pathlen; |
95 | pathlen -= byte_cnt; | 97 | pathlen -= byte_cnt; |
96 | 98 | ||
97 | memcpy(link, XFS_BUF_PTR(bp), byte_cnt); | 99 | memcpy(link, bp->b_addr, byte_cnt); |
98 | xfs_buf_relse(bp); | 100 | xfs_buf_relse(bp); |
99 | } | 101 | } |
100 | 102 | ||
@@ -1648,13 +1650,13 @@ xfs_symlink( | |||
1648 | byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); | 1650 | byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); |
1649 | bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, | 1651 | bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, |
1650 | BTOBB(byte_cnt), 0); | 1652 | BTOBB(byte_cnt), 0); |
1651 | ASSERT(bp && !XFS_BUF_GETERROR(bp)); | 1653 | ASSERT(!xfs_buf_geterror(bp)); |
1652 | if (pathlen < byte_cnt) { | 1654 | if (pathlen < byte_cnt) { |
1653 | byte_cnt = pathlen; | 1655 | byte_cnt = pathlen; |
1654 | } | 1656 | } |
1655 | pathlen -= byte_cnt; | 1657 | pathlen -= byte_cnt; |
1656 | 1658 | ||
1657 | memcpy(XFS_BUF_PTR(bp), cur_chunk, byte_cnt); | 1659 | memcpy(bp->b_addr, cur_chunk, byte_cnt); |
1658 | cur_chunk += byte_cnt; | 1660 | cur_chunk += byte_cnt; |
1659 | 1661 | ||
1660 | xfs_trans_log_buf(tp, bp, 0, byte_cnt - 1); | 1662 | xfs_trans_log_buf(tp, bp, 0, byte_cnt - 1); |
@@ -1999,7 +2001,7 @@ xfs_zero_remaining_bytes( | |||
1999 | mp, bp, XFS_BUF_ADDR(bp)); | 2001 | mp, bp, XFS_BUF_ADDR(bp)); |
2000 | break; | 2002 | break; |
2001 | } | 2003 | } |
2002 | memset(XFS_BUF_PTR(bp) + | 2004 | memset(bp->b_addr + |
2003 | (offset - XFS_FSB_TO_B(mp, imap.br_startoff)), | 2005 | (offset - XFS_FSB_TO_B(mp, imap.br_startoff)), |
2004 | 0, lastoffset - offset + 1); | 2006 | 0, lastoffset - offset + 1); |
2005 | XFS_BUF_UNDONE(bp); | 2007 | XFS_BUF_UNDONE(bp); |
diff --git a/fs/xfs/linux-2.6/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 87d3e03878c8..87d3e03878c8 100644 --- a/fs/xfs/linux-2.6/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c | |||