aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/Makefile1
-rw-r--r--fs/9p/vfs_addr.c10
-rw-r--r--fs/Makefile1
-rw-r--r--fs/adfs/adfs.h1
-rw-r--r--fs/adfs/file.c1
-rw-r--r--fs/affs/affs.h1
-rw-r--r--fs/affs/amigaffs.c1
-rw-r--r--fs/affs/amigaffs.h1
-rw-r--r--fs/affs/bitmap.c1
-rw-r--r--fs/affs/dir.c1
-rw-r--r--fs/affs/file.c1
-rw-r--r--fs/affs/inode.c1
-rw-r--r--fs/affs/namei.c1
-rw-r--r--fs/affs/symlink.c1
-rw-r--r--fs/afs/Makefile1
-rw-r--r--fs/afs/netdevices.c1
-rw-r--r--fs/attr.c1
-rw-r--r--fs/bad_inode.c1
-rw-r--r--fs/befs/befs.h1
-rw-r--r--fs/befs/befs_fs_types.h1
-rw-r--r--fs/befs/btree.h1
-rw-r--r--fs/befs/datastream.c1
-rw-r--r--fs/befs/datastream.h1
-rw-r--r--fs/befs/debug.c1
-rw-r--r--fs/befs/endian.h1
-rw-r--r--fs/befs/inode.c1
-rw-r--r--fs/befs/io.c1
-rw-r--r--fs/bfs/bfs.h1
-rw-r--r--fs/bfs/dir.c1
-rw-r--r--fs/bfs/file.c1
-rw-r--r--fs/binfmt_flat.c1
-rw-r--r--fs/binfmt_misc.c56
-rw-r--r--fs/binfmt_script.c17
-rw-r--r--fs/block_dev.c6
-rw-r--r--fs/btrfs/Makefile1
-rw-r--r--fs/btrfs/compression.c18
-rw-r--r--fs/btrfs/ctree.h3
-rw-r--r--fs/btrfs/disk-io.c9
-rw-r--r--fs/btrfs/export.c1
-rw-r--r--fs/btrfs/export.h1
-rw-r--r--fs/btrfs/extent_io.c11
-rw-r--r--fs/btrfs/extent_io.h1
-rw-r--r--fs/btrfs/extent_map.c1
-rw-r--r--fs/btrfs/extent_map.h1
-rw-r--r--fs/btrfs/inode-map.h1
-rw-r--r--fs/btrfs/inode.c27
-rw-r--r--fs/btrfs/ioctl.c12
-rw-r--r--fs/btrfs/qgroup.c6
-rw-r--r--fs/btrfs/relocation.c2
-rw-r--r--fs/btrfs/send.c2
-rw-r--r--fs/btrfs/super.c2
-rw-r--r--fs/btrfs/sysfs.h1
-rw-r--r--fs/btrfs/tree-log.c12
-rw-r--r--fs/btrfs/volumes.c2
-rw-r--r--fs/cachefiles/Makefile1
-rw-r--r--fs/ceph/Makefile1
-rw-r--r--fs/ceph/addr.c1
-rw-r--r--fs/ceph/caps.c6
-rw-r--r--fs/ceph/ceph_frag.c1
-rw-r--r--fs/ceph/debugfs.c1
-rw-r--r--fs/ceph/dir.c1
-rw-r--r--fs/ceph/export.c1
-rw-r--r--fs/ceph/file.c1
-rw-r--r--fs/ceph/inode.c1
-rw-r--r--fs/ceph/ioctl.c1
-rw-r--r--fs/ceph/ioctl.h1
-rw-r--r--fs/ceph/locks.c1
-rw-r--r--fs/ceph/mds_client.c19
-rw-r--r--fs/ceph/mds_client.h4
-rw-r--r--fs/ceph/mdsmap.c1
-rw-r--r--fs/ceph/snap.c9
-rw-r--r--fs/ceph/strings.c1
-rw-r--r--fs/ceph/super.h1
-rw-r--r--fs/ceph/xattr.c1
-rw-r--r--fs/char_dev.c1
-rw-r--r--fs/cifs/Kconfig5
-rw-r--r--fs/cifs/Makefile1
-rw-r--r--fs/cifs/cifs_debug.c9
-rw-r--r--fs/cifs/cifsfs.c4
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/cifsglob.h14
-rw-r--r--fs/cifs/connect.c32
-rw-r--r--fs/cifs/dir.c5
-rw-r--r--fs/cifs/file.c19
-rw-r--r--fs/cifs/inode.c15
-rw-r--r--fs/cifs/smb2maperror.c2
-rw-r--r--fs/cifs/smb2ops.c73
-rw-r--r--fs/cifs/smb2pdu.c144
-rw-r--r--fs/cifs/smb2pdu.h7
-rw-r--r--fs/cifs/smb2proto.h1
-rw-r--r--fs/cifs/smb2transport.c26
-rw-r--r--fs/coda/cache.c1
-rw-r--r--fs/coda/cnode.c1
-rw-r--r--fs/coda/coda_cache.h1
-rw-r--r--fs/coda/coda_fs_i.h1
-rw-r--r--fs/coda/coda_int.h1
-rw-r--r--fs/coda/coda_linux.c1
-rw-r--r--fs/coda/coda_linux.h1
-rw-r--r--fs/coda/dir.c1
-rw-r--r--fs/coda/file.c1
-rw-r--r--fs/coda/inode.c1
-rw-r--r--fs/coda/pioctl.c1
-rw-r--r--fs/coda/symlink.c1
-rw-r--r--fs/coda/sysctl.c1
-rw-r--r--fs/coda/upcall.c1
-rw-r--r--fs/compat_ioctl.c1
-rw-r--r--fs/coredump.c1
-rw-r--r--fs/cramfs/uncompress.c1
-rw-r--r--fs/crypto/bio.c1
-rw-r--r--fs/crypto/fname.c1
-rw-r--r--fs/crypto/fscrypt_private.h1
-rw-r--r--fs/crypto/keyinfo.c6
-rw-r--r--fs/crypto/policy.c1
-rw-r--r--fs/direct-io.c75
-rw-r--r--fs/dlm/Makefile1
-rw-r--r--fs/drop_caches.c1
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h24
-rw-r--r--fs/ecryptfs/keystore.c9
-rw-r--r--fs/efs/dir.c1
-rw-r--r--fs/efs/efs.h1
-rw-r--r--fs/efs/file.c1
-rw-r--r--fs/efs/namei.c1
-rw-r--r--fs/efs/super.c1
-rw-r--r--fs/efs/symlink.c1
-rw-r--r--fs/exec.c3
-rw-r--r--fs/ext2/Makefile1
-rw-r--r--fs/ext2/acl.c1
-rw-r--r--fs/ext2/acl.h1
-rw-r--r--fs/ext2/balloc.c1
-rw-r--r--fs/ext2/dir.c1
-rw-r--r--fs/ext2/ext2.h1
-rw-r--r--fs/ext2/file.c1
-rw-r--r--fs/ext2/ialloc.c1
-rw-r--r--fs/ext2/inode.c1
-rw-r--r--fs/ext2/ioctl.c1
-rw-r--r--fs/ext2/namei.c1
-rw-r--r--fs/ext2/symlink.c1
-rw-r--r--fs/ext2/xattr.c1
-rw-r--r--fs/ext2/xattr.h1
-rw-r--r--fs/ext2/xattr_security.c1
-rw-r--r--fs/ext2/xattr_trusted.c1
-rw-r--r--fs/ext2/xattr_user.c1
-rw-r--r--fs/ext4/Makefile1
-rw-r--r--fs/ext4/acl.c1
-rw-r--r--fs/ext4/acl.h1
-rw-r--r--fs/ext4/balloc.c1
-rw-r--r--fs/ext4/bitmap.c1
-rw-r--r--fs/ext4/block_validity.c1
-rw-r--r--fs/ext4/dir.c1
-rw-r--r--fs/ext4/ext4.h1
-rw-r--r--fs/ext4/ext4_jbd2.c1
-rw-r--r--fs/ext4/extents_status.c1
-rw-r--r--fs/ext4/extents_status.h1
-rw-r--r--fs/ext4/file.c1
-rw-r--r--fs/ext4/fsync.c1
-rw-r--r--fs/ext4/ialloc.c1
-rw-r--r--fs/ext4/indirect.c1
-rw-r--r--fs/ext4/inode.c1
-rw-r--r--fs/ext4/ioctl.c1
-rw-r--r--fs/ext4/mballoc.h1
-rw-r--r--fs/ext4/mmp.c1
-rw-r--r--fs/ext4/namei.c1
-rw-r--r--fs/ext4/page-io.c1
-rw-r--r--fs/ext4/readpage.c1
-rw-r--r--fs/ext4/resize.c1
-rw-r--r--fs/ext4/super.c4
-rw-r--r--fs/ext4/symlink.c1
-rw-r--r--fs/ext4/sysfs.c1
-rw-r--r--fs/ext4/truncate.h1
-rw-r--r--fs/ext4/xattr.c1
-rw-r--r--fs/ext4/xattr.h1
-rw-r--r--fs/ext4/xattr_security.c1
-rw-r--r--fs/ext4/xattr_trusted.c1
-rw-r--r--fs/ext4/xattr_user.c1
-rw-r--r--fs/f2fs/Makefile1
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/segment.c6
-rw-r--r--fs/f2fs/super.c2
-rw-r--r--fs/fat/Makefile1
-rw-r--r--fs/fat/cache.c1
-rw-r--r--fs/fat/fat.h1
-rw-r--r--fs/fcntl.c3
-rw-r--r--fs/fhandle.c1
-rw-r--r--fs/file.c1
-rw-r--r--fs/filesystems.c1
-rw-r--r--fs/fs_pin.c1
-rw-r--r--fs/fscache/Makefile1
-rw-r--r--fs/fscache/object-list.c7
-rw-r--r--fs/fuse/dir.c3
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/gfs2/Makefile1
-rw-r--r--fs/gfs2/glock.c14
-rw-r--r--fs/gfs2/trace_gfs2.h1
-rw-r--r--fs/hfs/attr.c1
-rw-r--r--fs/hfs/bfind.c1
-rw-r--r--fs/hfs/bnode.c1
-rw-r--r--fs/hfs/brec.c1
-rw-r--r--fs/hfs/btree.c1
-rw-r--r--fs/hfs/btree.h1
-rw-r--r--fs/hfsplus/Makefile1
-rw-r--r--fs/hfsplus/acl.h1
-rw-r--r--fs/hfsplus/attributes.c1
-rw-r--r--fs/hfsplus/bfind.c1
-rw-r--r--fs/hfsplus/bitmap.c1
-rw-r--r--fs/hfsplus/bnode.c1
-rw-r--r--fs/hfsplus/brec.c1
-rw-r--r--fs/hfsplus/btree.c1
-rw-r--r--fs/hfsplus/catalog.c1
-rw-r--r--fs/hfsplus/dir.c1
-rw-r--r--fs/hfsplus/extents.c1
-rw-r--r--fs/hfsplus/hfsplus_fs.h1
-rw-r--r--fs/hfsplus/hfsplus_raw.h1
-rw-r--r--fs/hfsplus/inode.c1
-rw-r--r--fs/hfsplus/ioctl.c1
-rw-r--r--fs/hfsplus/options.c1
-rw-r--r--fs/hfsplus/posix_acl.c1
-rw-r--r--fs/hfsplus/tables.c1
-rw-r--r--fs/hfsplus/unicode.c1
-rw-r--r--fs/hfsplus/wrapper.c1
-rw-r--r--fs/hfsplus/xattr.c1
-rw-r--r--fs/hfsplus/xattr.h1
-rw-r--r--fs/hfsplus/xattr_security.c1
-rw-r--r--fs/hfsplus/xattr_trusted.c1
-rw-r--r--fs/hfsplus/xattr_user.c1
-rw-r--r--fs/hostfs/hostfs.h1
-rw-r--r--fs/hpfs/alloc.c1
-rw-r--r--fs/hpfs/anode.c1
-rw-r--r--fs/hpfs/buffer.c1
-rw-r--r--fs/hpfs/dentry.c1
-rw-r--r--fs/hpfs/dir.c1
-rw-r--r--fs/hpfs/dnode.c1
-rw-r--r--fs/hpfs/ea.c1
-rw-r--r--fs/hpfs/file.c1
-rw-r--r--fs/hpfs/hpfs.h1
-rw-r--r--fs/hpfs/hpfs_fn.h1
-rw-r--r--fs/hpfs/inode.c1
-rw-r--r--fs/hpfs/map.c1
-rw-r--r--fs/hpfs/name.c1
-rw-r--r--fs/hpfs/namei.c1
-rw-r--r--fs/hugetlbfs/inode.c5
-rw-r--r--fs/ioctl.c1
-rw-r--r--fs/iomap.c54
-rw-r--r--fs/isofs/Makefile1
-rw-r--r--fs/isofs/dir.c1
-rw-r--r--fs/isofs/export.c1
-rw-r--r--fs/isofs/inode.c2
-rw-r--r--fs/isofs/isofs.h1
-rw-r--r--fs/isofs/joliet.c1
-rw-r--r--fs/isofs/namei.c1
-rw-r--r--fs/isofs/rock.c1
-rw-r--r--fs/isofs/rock.h1
-rw-r--r--fs/isofs/util.c1
-rw-r--r--fs/jffs2/Makefile1
-rw-r--r--fs/jfs/Makefile1
-rw-r--r--fs/jfs/ioctl.c1
-rw-r--r--fs/lockd/Makefile1
-rw-r--r--fs/lockd/clnt4xdr.c1
-rw-r--r--fs/lockd/clntxdr.c1
-rw-r--r--fs/lockd/host.c1
-rw-r--r--fs/lockd/mon.c1
-rw-r--r--fs/lockd/netns.h1
-rw-r--r--fs/lockd/procfs.c1
-rw-r--r--fs/lockd/procfs.h1
-rw-r--r--fs/lockd/svc4proc.c1
-rw-r--r--fs/lockd/svclock.c1
-rw-r--r--fs/lockd/svcproc.c1
-rw-r--r--fs/lockd/svcshare.c1
-rw-r--r--fs/lockd/xdr.c1
-rw-r--r--fs/lockd/xdr4.c1
-rw-r--r--fs/minix/bitmap.c1
-rw-r--r--fs/minix/dir.c1
-rw-r--r--fs/minix/file.c1
-rw-r--r--fs/minix/itree_common.c1
-rw-r--r--fs/minix/itree_v1.c1
-rw-r--r--fs/minix/itree_v2.c1
-rw-r--r--fs/minix/minix.h1
-rw-r--r--fs/minix/namei.c1
-rw-r--r--fs/mount.h1
-rw-r--r--fs/mpage.c15
-rw-r--r--fs/namei.c1
-rw-r--r--fs/namespace.c7
-rw-r--r--fs/ncpfs/Makefile1
-rw-r--r--fs/ncpfs/dir.c1
-rw-r--r--fs/ncpfs/file.c1
-rw-r--r--fs/ncpfs/getopt.c1
-rw-r--r--fs/ncpfs/getopt.h1
-rw-r--r--fs/ncpfs/ioctl.c1
-rw-r--r--fs/ncpfs/mmap.c1
-rw-r--r--fs/ncpfs/ncp_fs.h1
-rw-r--r--fs/ncpfs/ncp_fs_i.h1
-rw-r--r--fs/ncpfs/ncp_fs_sb.h1
-rw-r--r--fs/ncpfs/ncplib_kernel.c1
-rw-r--r--fs/ncpfs/ncplib_kernel.h1
-rw-r--r--fs/ncpfs/ncpsign_kernel.c1
-rw-r--r--fs/ncpfs/ncpsign_kernel.h1
-rw-r--r--fs/ncpfs/sock.c1
-rw-r--r--fs/ncpfs/symlink.c1
-rw-r--r--fs/nfs/Makefile1
-rw-r--r--fs/nfs/blocklayout/dev.c1
-rw-r--r--fs/nfs/blocklayout/extent_tree.c1
-rw-r--r--fs/nfs/cache_lib.c1
-rw-r--r--fs/nfs/cache_lib.h1
-rw-r--r--fs/nfs/callback.c1
-rw-r--r--fs/nfs/callback.h1
-rw-r--r--fs/nfs/callback_proc.c1
-rw-r--r--fs/nfs/callback_xdr.c1
-rw-r--r--fs/nfs/client.c2
-rw-r--r--fs/nfs/delegation.h1
-rw-r--r--fs/nfs/dns_resolve.c1
-rw-r--r--fs/nfs/dns_resolve.h1
-rw-r--r--fs/nfs/export.c1
-rw-r--r--fs/nfs/filelayout/filelayout.c3
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.h1
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayoutdev.c1
-rw-r--r--fs/nfs/internal.h1
-rw-r--r--fs/nfs/io.c1
-rw-r--r--fs/nfs/iostat.h1
-rw-r--r--fs/nfs/mount_clnt.c1
-rw-r--r--fs/nfs/netns.h1
-rw-r--r--fs/nfs/nfs.h1
-rw-r--r--fs/nfs/nfs2xdr.c1
-rw-r--r--fs/nfs/nfs3_fs.h1
-rw-r--r--fs/nfs/nfs3acl.c1
-rw-r--r--fs/nfs/nfs3proc.c1
-rw-r--r--fs/nfs/nfs3xdr.c1
-rw-r--r--fs/nfs/nfs42.h1
-rw-r--r--fs/nfs/nfs42proc.c1
-rw-r--r--fs/nfs/nfs42xdr.c1
-rw-r--r--fs/nfs/nfs4_fs.h1
-rw-r--r--fs/nfs/nfs4file.c1
-rw-r--r--fs/nfs/nfs4getroot.c1
-rw-r--r--fs/nfs/nfs4idmap.c2
-rw-r--r--fs/nfs/nfs4namespace.c1
-rw-r--r--fs/nfs/nfs4proc.c3
-rw-r--r--fs/nfs/nfs4session.h1
-rw-r--r--fs/nfs/nfs4sysctl.c1
-rw-r--r--fs/nfs/nfs4trace.c1
-rw-r--r--fs/nfs/nfs4trace.h1
-rw-r--r--fs/nfs/nfs4xdr.c4
-rw-r--r--fs/nfs/nfsroot.c1
-rw-r--r--fs/nfs/nfstrace.c1
-rw-r--r--fs/nfs/nfstrace.h1
-rw-r--r--fs/nfs/proc.c1
-rw-r--r--fs/nfs/symlink.c1
-rw-r--r--fs/nfs/sysctl.c1
-rw-r--r--fs/nfs/unlink.c1
-rw-r--r--fs/nfsd/Makefile1
-rw-r--r--fs/nfsd/auth.c1
-rw-r--r--fs/nfsd/auth.h1
-rw-r--r--fs/nfsd/blocklayout.c1
-rw-r--r--fs/nfsd/blocklayoutxdr.c1
-rw-r--r--fs/nfsd/blocklayoutxdr.h1
-rw-r--r--fs/nfsd/cache.h1
-rw-r--r--fs/nfsd/current_stateid.h1
-rw-r--r--fs/nfsd/export.c1
-rw-r--r--fs/nfsd/export.h1
-rw-r--r--fs/nfsd/fault_inject.c1
-rw-r--r--fs/nfsd/flexfilelayout.c1
-rw-r--r--fs/nfsd/flexfilelayoutxdr.c1
-rw-r--r--fs/nfsd/flexfilelayoutxdr.h1
-rw-r--r--fs/nfsd/lockd.c1
-rw-r--r--fs/nfsd/nfs2acl.c1
-rw-r--r--fs/nfsd/nfs3acl.c1
-rw-r--r--fs/nfsd/nfs3proc.c1
-rw-r--r--fs/nfsd/nfs3xdr.c1
-rw-r--r--fs/nfsd/nfs4layouts.c1
-rw-r--r--fs/nfsd/nfs4proc.c9
-rw-r--r--fs/nfsd/nfscache.c1
-rw-r--r--fs/nfsd/nfsd.h1
-rw-r--r--fs/nfsd/nfsfh.c1
-rw-r--r--fs/nfsd/nfsfh.h1
-rw-r--r--fs/nfsd/nfsproc.c1
-rw-r--r--fs/nfsd/nfssvc.c1
-rw-r--r--fs/nfsd/nfsxdr.c1
-rw-r--r--fs/nfsd/pnfs.h1
-rw-r--r--fs/nfsd/stats.c1
-rw-r--r--fs/nfsd/stats.h1
-rw-r--r--fs/nfsd/trace.h1
-rw-r--r--fs/nfsd/vfs.c1
-rw-r--r--fs/nfsd/vfs.h1
-rw-r--r--fs/nfsd/xdr.h1
-rw-r--r--fs/nfsd/xdr3.h1
-rw-r--r--fs/nfsd/xdr4cb.h1
-rw-r--r--fs/nilfs2/Makefile1
-rw-r--r--fs/nilfs2/export.h1
-rw-r--r--fs/nls/Makefile1
-rw-r--r--fs/notify/Makefile1
-rw-r--r--fs/notify/fanotify/fanotify.c1
-rw-r--r--fs/notify/fanotify/fanotify.h1
-rw-r--r--fs/notify/fanotify/fanotify_user.c1
-rw-r--r--fs/notify/fdinfo.c1
-rw-r--r--fs/notify/fdinfo.h1
-rw-r--r--fs/notify/fsnotify.h1
-rw-r--r--fs/notify/inotify/inotify.h1
-rw-r--r--fs/nsfs.c1
-rw-r--r--fs/ntfs/Makefile1
-rw-r--r--fs/ocfs2/Makefile1
-rw-r--r--fs/ocfs2/alloc.c24
-rw-r--r--fs/ocfs2/ioctl.c1
-rw-r--r--fs/ocfs2/ioctl.h1
-rw-r--r--fs/ocfs2/mmap.h1
-rw-r--r--fs/ocfs2/ocfs2_trace.h1
-rw-r--r--fs/ocfs2/quota.h1
-rw-r--r--fs/ocfs2/quota_global.c1
-rw-r--r--fs/ocfs2/quota_local.c1
-rw-r--r--fs/omfs/bitmap.c1
-rw-r--r--fs/omfs/omfs.h1
-rw-r--r--fs/omfs/omfs_fs.h1
-rw-r--r--fs/orangefs/Makefile1
-rw-r--r--fs/orangefs/acl.c1
-rw-r--r--fs/orangefs/dcache.c1
-rw-r--r--fs/orangefs/devorangefs-req.c1
-rw-r--r--fs/orangefs/dir.c1
-rw-r--r--fs/orangefs/downcall.h1
-rw-r--r--fs/orangefs/file.c1
-rw-r--r--fs/orangefs/inode.c1
-rw-r--r--fs/orangefs/namei.c1
-rw-r--r--fs/orangefs/orangefs-bufmap.c1
-rw-r--r--fs/orangefs/orangefs-bufmap.h1
-rw-r--r--fs/orangefs/orangefs-cache.c1
-rw-r--r--fs/orangefs/orangefs-debug.h1
-rw-r--r--fs/orangefs/orangefs-debugfs.c1
-rw-r--r--fs/orangefs/orangefs-debugfs.h1
-rw-r--r--fs/orangefs/orangefs-dev-proto.h1
-rw-r--r--fs/orangefs/orangefs-kernel.h1
-rw-r--r--fs/orangefs/orangefs-sysfs.c1
-rw-r--r--fs/orangefs/orangefs-utils.c1
-rw-r--r--fs/orangefs/protocol.h1
-rw-r--r--fs/orangefs/super.c1
-rw-r--r--fs/orangefs/symlink.c1
-rw-r--r--fs/orangefs/upcall.h1
-rw-r--r--fs/orangefs/waitqueue.c1
-rw-r--r--fs/orangefs/xattr.c1
-rw-r--r--fs/overlayfs/copy_up.c6
-rw-r--r--fs/overlayfs/dir.c20
-rw-r--r--fs/overlayfs/inode.c20
-rw-r--r--fs/overlayfs/namei.c33
-rw-r--r--fs/overlayfs/overlayfs.h4
-rw-r--r--fs/overlayfs/ovl_entry.h3
-rw-r--r--fs/overlayfs/readdir.c17
-rw-r--r--fs/overlayfs/super.c30
-rw-r--r--fs/overlayfs/util.c24
-rw-r--r--fs/pipe.c1
-rw-r--r--fs/proc/Makefile1
-rw-r--r--fs/proc/array.c45
-rw-r--r--fs/proc/base.c1
-rw-r--r--fs/proc/cmdline.c1
-rw-r--r--fs/proc/cpuinfo.c1
-rw-r--r--fs/proc/devices.c1
-rw-r--r--fs/proc/fd.c1
-rw-r--r--fs/proc/fd.h1
-rw-r--r--fs/proc/inode.c1
-rw-r--r--fs/proc/interrupts.c1
-rw-r--r--fs/proc/kcore.c1
-rw-r--r--fs/proc/kmsg.c1
-rw-r--r--fs/proc/loadavg.c1
-rw-r--r--fs/proc/meminfo.c1
-rw-r--r--fs/proc/namespaces.c1
-rw-r--r--fs/proc/page.c1
-rw-r--r--fs/proc/proc_sysctl.c1
-rw-r--r--fs/proc/proc_tty.c1
-rw-r--r--fs/proc/root.c1
-rw-r--r--fs/proc/self.c1
-rw-r--r--fs/proc/softirqs.c1
-rw-r--r--fs/proc/stat.c1
-rw-r--r--fs/proc/task_mmu.c7
-rw-r--r--fs/proc/task_nommu.c1
-rw-r--r--fs/proc/thread_self.c1
-rw-r--r--fs/proc/uptime.c1
-rw-r--r--fs/proc/version.c1
-rw-r--r--fs/proc_namespace.c1
-rw-r--r--fs/pstore/Makefile1
-rw-r--r--fs/pstore/internal.h1
-rw-r--r--fs/qnx4/bitmap.c1
-rw-r--r--fs/qnx4/dir.c1
-rw-r--r--fs/qnx4/namei.c1
-rw-r--r--fs/qnx4/qnx4.h1
-rw-r--r--fs/qnx6/dir.c1
-rw-r--r--fs/qnx6/namei.c1
-rw-r--r--fs/qnx6/qnx6.h1
-rw-r--r--fs/qnx6/super_mmi.c1
-rw-r--r--fs/quota/Makefile1
-rw-r--r--fs/quota/compat.c1
-rw-r--r--fs/quota/dquot.c30
-rw-r--r--fs/quota/kqid.c1
-rw-r--r--fs/quota/netlink.c1
-rw-r--r--fs/quota/quota.c1
-rw-r--r--fs/quota/quota_tree.h1
-rw-r--r--fs/quota/quota_v2.c4
-rw-r--r--fs/quota/quotaio_v1.h1
-rw-r--r--fs/quota/quotaio_v2.h1
-rw-r--r--fs/read_write.c5
-rw-r--r--fs/readdir.c1
-rw-r--r--fs/reiserfs/Makefile1
-rw-r--r--fs/reiserfs/acl.h1
-rw-r--r--fs/reiserfs/journal.c1
-rw-r--r--fs/reiserfs/lock.c1
-rw-r--r--fs/reiserfs/reiserfs.h1
-rw-r--r--fs/reiserfs/tail_conversion.c1
-rw-r--r--fs/reiserfs/xattr.c1
-rw-r--r--fs/reiserfs/xattr.h1
-rw-r--r--fs/reiserfs/xattr_acl.c1
-rw-r--r--fs/reiserfs/xattr_security.c1
-rw-r--r--fs/reiserfs/xattr_trusted.c1
-rw-r--r--fs/reiserfs/xattr_user.c1
-rw-r--r--fs/romfs/Makefile1
-rw-r--r--fs/select.c1
-rw-r--r--fs/seq_file.c1
-rw-r--r--fs/signalfd.c1
-rw-r--r--fs/squashfs/Makefile1
-rw-r--r--fs/stat.c1
-rw-r--r--fs/statfs.c1
-rw-r--r--fs/super.c1
-rw-r--r--fs/sync.c1
-rw-r--r--fs/sysv/balloc.c1
-rw-r--r--fs/sysv/dir.c1
-rw-r--r--fs/sysv/file.c1
-rw-r--r--fs/sysv/ialloc.c1
-rw-r--r--fs/sysv/inode.c1
-rw-r--r--fs/sysv/itree.c1
-rw-r--r--fs/sysv/namei.c1
-rw-r--r--fs/sysv/sysv.h1
-rw-r--r--fs/timerfd.c1
-rw-r--r--fs/ubifs/Makefile1
-rw-r--r--fs/ubifs/crypto.c1
-rw-r--r--fs/ubifs/misc.c1
-rw-r--r--fs/udf/udf_i.h1
-rw-r--r--fs/udf/udf_sb.h1
-rw-r--r--fs/udf/udfdecl.h1
-rw-r--r--fs/udf/udfend.h1
-rw-r--r--fs/ufs/balloc.c1
-rw-r--r--fs/ufs/cylinder.c1
-rw-r--r--fs/ufs/dir.c1
-rw-r--r--fs/ufs/file.c1
-rw-r--r--fs/ufs/ialloc.c1
-rw-r--r--fs/ufs/inode.c1
-rw-r--r--fs/ufs/namei.c1
-rw-r--r--fs/ufs/swab.h1
-rw-r--r--fs/ufs/ufs.h1
-rw-r--r--fs/ufs/ufs_fs.h1
-rw-r--r--fs/ufs/util.c1
-rw-r--r--fs/ufs/util.h1
-rw-r--r--fs/userfaultfd.c66
-rw-r--r--fs/utimes.c1
-rw-r--r--fs/xattr.c2
-rw-r--r--fs/xfs/libxfs/xfs_ag_resv.c12
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c8
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c32
-rw-r--r--fs/xfs/libxfs/xfs_bmap.h1
-rw-r--r--fs/xfs/libxfs/xfs_cksum.h1
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c4
-rw-r--r--fs/xfs/libxfs/xfs_log_format.h27
-rw-r--r--fs/xfs/xfs_acl.c22
-rw-r--r--fs/xfs/xfs_aops.c50
-rw-r--r--fs/xfs/xfs_attr_inactive.c2
-rw-r--r--fs/xfs/xfs_bmap_util.c40
-rw-r--r--fs/xfs/xfs_bmap_util.h13
-rw-r--r--fs/xfs/xfs_buf.c2
-rw-r--r--fs/xfs/xfs_discard.h1
-rw-r--r--fs/xfs/xfs_error.c2
-rw-r--r--fs/xfs/xfs_file.c64
-rw-r--r--fs/xfs/xfs_fsmap.c58
-rw-r--r--fs/xfs/xfs_inode.c8
-rw-r--r--fs/xfs/xfs_inode_item.c81
-rw-r--r--fs/xfs/xfs_ioctl.c3
-rw-r--r--fs/xfs/xfs_iomap.c7
-rw-r--r--fs/xfs/xfs_iomap.h2
-rw-r--r--fs/xfs/xfs_log.c2
-rw-r--r--fs/xfs/xfs_message.h1
-rw-r--r--fs/xfs/xfs_mount.c2
-rw-r--r--fs/xfs/xfs_ondisk.h2
-rw-r--r--fs/xfs/xfs_pnfs.c3
-rw-r--r--fs/xfs/xfs_pnfs.h1
-rw-r--r--fs/xfs/xfs_reflink.c9
-rw-r--r--fs/xfs/xfs_super.c12
575 files changed, 1622 insertions, 515 deletions
diff --git a/fs/9p/Makefile b/fs/9p/Makefile
index 9619ccadd2fc..e7800a5c7395 100644
--- a/fs/9p/Makefile
+++ b/fs/9p/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_9P_FS) := 9p.o 2obj-$(CONFIG_9P_FS) := 9p.o
2 3
39p-objs := \ 49p-objs := \
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index adaf6f6dd858..e1cbdfdb7c68 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -310,9 +310,13 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
310 310
311 p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping); 311 p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
312 312
313 if (unlikely(copied < len && !PageUptodate(page))) { 313 if (!PageUptodate(page)) {
314 copied = 0; 314 if (unlikely(copied < len)) {
315 goto out; 315 copied = 0;
316 goto out;
317 } else if (len == PAGE_SIZE) {
318 SetPageUptodate(page);
319 }
316 } 320 }
317 /* 321 /*
318 * No need to use i_size_read() here, the i_size 322 * No need to use i_size_read() here, the i_size
diff --git a/fs/Makefile b/fs/Makefile
index 7bbaca9c67b1..ef772f1eaff8 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the Linux filesystems. 3# Makefile for the Linux filesystems.
3# 4#
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
index fadf408bdd46..c76db75f02aa 100644
--- a/fs/adfs/adfs.h
+++ b/fs/adfs/adfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/adfs_fs.h> 3#include <linux/adfs_fs.h>
3 4
diff --git a/fs/adfs/file.c b/fs/adfs/file.c
index 46c0d5671cd5..754afb14a6ff 100644
--- a/fs/adfs/file.c
+++ b/fs/adfs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/adfs/file.c 3 * linux/fs/adfs/file.c
3 * 4 *
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 773749be8290..a92eb6ae2ae2 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifdef pr_fmt 2#ifdef pr_fmt
2#undef pr_fmt 3#undef pr_fmt
3#endif 4#endif
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 8cf941c3b511..185d5ab7e986 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/affs/amigaffs.c 3 * linux/fs/affs/amigaffs.c
3 * 4 *
diff --git a/fs/affs/amigaffs.h b/fs/affs/amigaffs.h
index 43b41c06aa37..f9bef9056659 100644
--- a/fs/affs/amigaffs.h
+++ b/fs/affs/amigaffs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef AMIGAFFS_H 2#ifndef AMIGAFFS_H
2#define AMIGAFFS_H 3#define AMIGAFFS_H
3 4
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c
index 2b2112475ec2..2b1399611d9e 100644
--- a/fs/affs/bitmap.c
+++ b/fs/affs/bitmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/affs/bitmap.c 3 * linux/fs/affs/bitmap.c
3 * 4 *
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index 591ecd7f3063..a105e77df2c1 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/affs/dir.c 3 * linux/fs/affs/dir.c
3 * 4 *
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 00331810f690..a85817f54483 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/affs/file.c 3 * linux/fs/affs/file.c
3 * 4 *
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index fd4ef3c40e40..73598bff8506 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/affs/inode.c 3 * linux/fs/affs/inode.c
3 * 4 *
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 46d3ace6761d..d8aa0ae3d037 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/affs/namei.c 3 * linux/fs/affs/namei.c
3 * 4 *
diff --git a/fs/affs/symlink.c b/fs/affs/symlink.c
index ae622cdce142..a7531b26e8f0 100644
--- a/fs/affs/symlink.c
+++ b/fs/affs/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/affs/symlink.c 3 * linux/fs/affs/symlink.c
3 * 4 *
diff --git a/fs/afs/Makefile b/fs/afs/Makefile
index 095c54165dfd..641148208e90 100644
--- a/fs/afs/Makefile
+++ b/fs/afs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for Red Hat Linux AFS client. 3# Makefile for Red Hat Linux AFS client.
3# 4#
diff --git a/fs/afs/netdevices.c b/fs/afs/netdevices.c
index 40b2bab3e401..50bd5bb1c4fb 100644
--- a/fs/afs/netdevices.c
+++ b/fs/afs/netdevices.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* AFS network device helpers 2/* AFS network device helpers
2 * 3 *
3 * Copyright (c) 2007 Patrick McHardy <kaber@trash.net> 4 * Copyright (c) 2007 Patrick McHardy <kaber@trash.net>
diff --git a/fs/attr.c b/fs/attr.c
index 135304146120..12ffdb6fb63c 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/attr.c 3 * linux/fs/attr.c
3 * 4 *
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index bb53728c7a31..213b51dbbb60 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/bad_inode.c 3 * linux/fs/bad_inode.c
3 * 4 *
diff --git a/fs/befs/befs.h b/fs/befs/befs.h
index b914cfb03820..7cd47245694d 100644
--- a/fs/befs/befs.h
+++ b/fs/befs/befs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * befs.h 3 * befs.h
3 * 4 *
diff --git a/fs/befs/befs_fs_types.h b/fs/befs/befs_fs_types.h
index 69c9d8cde955..8019fde814b7 100644
--- a/fs/befs/befs_fs_types.h
+++ b/fs/befs/befs_fs_types.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * fs/befs/befs_fs_types.h 3 * fs/befs/befs_fs_types.h
3 * 4 *
diff --git a/fs/befs/btree.h b/fs/befs/btree.h
index 60c6c728e64e..a253a6276d8e 100644
--- a/fs/befs/btree.h
+++ b/fs/befs/btree.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * btree.h 3 * btree.h
3 * 4 *
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index 720b3bc5c16a..97719a7c7e40 100644
--- a/fs/befs/datastream.c
+++ b/fs/befs/datastream.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/befs/datastream.c 3 * linux/fs/befs/datastream.c
3 * 4 *
diff --git a/fs/befs/datastream.h b/fs/befs/datastream.h
index 7ff9ff09ec6e..39b1d4766ccf 100644
--- a/fs/befs/datastream.h
+++ b/fs/befs/datastream.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * datastream.h 3 * datastream.h
3 * 4 *
diff --git a/fs/befs/debug.c b/fs/befs/debug.c
index 36656c86f50e..eb7bd6c692c7 100644
--- a/fs/befs/debug.c
+++ b/fs/befs/debug.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/befs/debug.c 3 * linux/fs/befs/debug.c
3 * 4 *
diff --git a/fs/befs/endian.h b/fs/befs/endian.h
index 27223878ba9f..bb55a54c24c0 100644
--- a/fs/befs/endian.h
+++ b/fs/befs/endian.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/befs/endian.h 3 * linux/fs/befs/endian.h
3 * 4 *
diff --git a/fs/befs/inode.c b/fs/befs/inode.c
index 5367a6470a69..791b46a6f2f9 100644
--- a/fs/befs/inode.c
+++ b/fs/befs/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * inode.c 3 * inode.c
3 * 4 *
diff --git a/fs/befs/io.c b/fs/befs/io.c
index 227cb86e07fe..2caf50a4abbe 100644
--- a/fs/befs/io.c
+++ b/fs/befs/io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/befs/io.c 3 * linux/fs/befs/io.c
3 * 4 *
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h
index f40006db36df..67aef3bb89e4 100644
--- a/fs/bfs/bfs.h
+++ b/fs/bfs/bfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * fs/bfs/bfs.h 3 * fs/bfs/bfs.h
3 * Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com> 4 * Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com>
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 3e5ac30e8b6f..ee832ca5f734 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/bfs/dir.c 3 * fs/bfs/dir.c
3 * BFS directory operations. 4 * BFS directory operations.
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index 97f1b5160155..1476cdd90cfb 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/bfs/file.c 3 * fs/bfs/file.c
3 * BFS file operations. 4 * BFS file operations.
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 475d083f8088..5d6b94475f27 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/****************************************************************************/ 2/****************************************************************************/
2/* 3/*
3 * linux/fs/binfmt_flat.c 4 * linux/fs/binfmt_flat.c
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index ce7181ea60fa..a7c5a9861bef 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -54,7 +54,7 @@ typedef struct {
54 int size; /* size of magic/mask */ 54 int size; /* size of magic/mask */
55 char *magic; /* magic or filename extension */ 55 char *magic; /* magic or filename extension */
56 char *mask; /* mask, NULL for exact match */ 56 char *mask; /* mask, NULL for exact match */
57 char *interpreter; /* filename of interpreter */ 57 const char *interpreter; /* filename of interpreter */
58 char *name; 58 char *name;
59 struct dentry *dentry; 59 struct dentry *dentry;
60 struct file *interp_file; 60 struct file *interp_file;
@@ -131,27 +131,26 @@ static int load_misc_binary(struct linux_binprm *bprm)
131{ 131{
132 Node *fmt; 132 Node *fmt;
133 struct file *interp_file = NULL; 133 struct file *interp_file = NULL;
134 char iname[BINPRM_BUF_SIZE];
135 const char *iname_addr = iname;
136 int retval; 134 int retval;
137 int fd_binary = -1; 135 int fd_binary = -1;
138 136
139 retval = -ENOEXEC; 137 retval = -ENOEXEC;
140 if (!enabled) 138 if (!enabled)
141 goto ret; 139 return retval;
142 140
143 /* to keep locking time low, we copy the interpreter string */ 141 /* to keep locking time low, we copy the interpreter string */
144 read_lock(&entries_lock); 142 read_lock(&entries_lock);
145 fmt = check_file(bprm); 143 fmt = check_file(bprm);
146 if (fmt) 144 if (fmt)
147 strlcpy(iname, fmt->interpreter, BINPRM_BUF_SIZE); 145 dget(fmt->dentry);
148 read_unlock(&entries_lock); 146 read_unlock(&entries_lock);
149 if (!fmt) 147 if (!fmt)
150 goto ret; 148 return retval;
151 149
152 /* Need to be able to load the file after exec */ 150 /* Need to be able to load the file after exec */
151 retval = -ENOENT;
153 if (bprm->interp_flags & BINPRM_FLAGS_PATH_INACCESSIBLE) 152 if (bprm->interp_flags & BINPRM_FLAGS_PATH_INACCESSIBLE)
154 return -ENOENT; 153 goto ret;
155 154
156 if (!(fmt->flags & MISC_FMT_PRESERVE_ARGV0)) { 155 if (!(fmt->flags & MISC_FMT_PRESERVE_ARGV0)) {
157 retval = remove_arg_zero(bprm); 156 retval = remove_arg_zero(bprm);
@@ -195,22 +194,22 @@ static int load_misc_binary(struct linux_binprm *bprm)
195 bprm->argc++; 194 bprm->argc++;
196 195
197 /* add the interp as argv[0] */ 196 /* add the interp as argv[0] */
198 retval = copy_strings_kernel(1, &iname_addr, bprm); 197 retval = copy_strings_kernel(1, &fmt->interpreter, bprm);
199 if (retval < 0) 198 if (retval < 0)
200 goto error; 199 goto error;
201 bprm->argc++; 200 bprm->argc++;
202 201
203 /* Update interp in case binfmt_script needs it. */ 202 /* Update interp in case binfmt_script needs it. */
204 retval = bprm_change_interp(iname, bprm); 203 retval = bprm_change_interp(fmt->interpreter, bprm);
205 if (retval < 0) 204 if (retval < 0)
206 goto error; 205 goto error;
207 206
208 if (fmt->flags & MISC_FMT_OPEN_FILE && fmt->interp_file) { 207 if (fmt->flags & MISC_FMT_OPEN_FILE) {
209 interp_file = filp_clone_open(fmt->interp_file); 208 interp_file = filp_clone_open(fmt->interp_file);
210 if (!IS_ERR(interp_file)) 209 if (!IS_ERR(interp_file))
211 deny_write_access(interp_file); 210 deny_write_access(interp_file);
212 } else { 211 } else {
213 interp_file = open_exec(iname); 212 interp_file = open_exec(fmt->interpreter);
214 } 213 }
215 retval = PTR_ERR(interp_file); 214 retval = PTR_ERR(interp_file);
216 if (IS_ERR(interp_file)) 215 if (IS_ERR(interp_file))
@@ -238,6 +237,7 @@ static int load_misc_binary(struct linux_binprm *bprm)
238 goto error; 237 goto error;
239 238
240ret: 239ret:
240 dput(fmt->dentry);
241 return retval; 241 return retval;
242error: 242error:
243 if (fd_binary > 0) 243 if (fd_binary > 0)
@@ -594,8 +594,13 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
594 594
595static void bm_evict_inode(struct inode *inode) 595static void bm_evict_inode(struct inode *inode)
596{ 596{
597 Node *e = inode->i_private;
598
599 if (e && e->flags & MISC_FMT_OPEN_FILE)
600 filp_close(e->interp_file, NULL);
601
597 clear_inode(inode); 602 clear_inode(inode);
598 kfree(inode->i_private); 603 kfree(e);
599} 604}
600 605
601static void kill_node(Node *e) 606static void kill_node(Node *e)
@@ -603,24 +608,14 @@ static void kill_node(Node *e)
603 struct dentry *dentry; 608 struct dentry *dentry;
604 609
605 write_lock(&entries_lock); 610 write_lock(&entries_lock);
606 dentry = e->dentry; 611 list_del_init(&e->list);
607 if (dentry) {
608 list_del_init(&e->list);
609 e->dentry = NULL;
610 }
611 write_unlock(&entries_lock); 612 write_unlock(&entries_lock);
612 613
613 if ((e->flags & MISC_FMT_OPEN_FILE) && e->interp_file) { 614 dentry = e->dentry;
614 filp_close(e->interp_file, NULL); 615 drop_nlink(d_inode(dentry));
615 e->interp_file = NULL; 616 d_drop(dentry);
616 } 617 dput(dentry);
617 618 simple_release_fs(&bm_mnt, &entry_count);
618 if (dentry) {
619 drop_nlink(d_inode(dentry));
620 d_drop(dentry);
621 dput(dentry);
622 simple_release_fs(&bm_mnt, &entry_count);
623 }
624} 619}
625 620
626/* /<entry> */ 621/* /<entry> */
@@ -665,7 +660,8 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
665 root = file_inode(file)->i_sb->s_root; 660 root = file_inode(file)->i_sb->s_root;
666 inode_lock(d_inode(root)); 661 inode_lock(d_inode(root));
667 662
668 kill_node(e); 663 if (!list_empty(&e->list))
664 kill_node(e);
669 665
670 inode_unlock(d_inode(root)); 666 inode_unlock(d_inode(root));
671 break; 667 break;
@@ -794,7 +790,7 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer,
794 inode_lock(d_inode(root)); 790 inode_lock(d_inode(root));
795 791
796 while (!list_empty(&entries)) 792 while (!list_empty(&entries))
797 kill_node(list_entry(entries.next, Node, list)); 793 kill_node(list_first_entry(&entries, Node, list));
798 794
799 inode_unlock(d_inode(root)); 795 inode_unlock(d_inode(root));
800 break; 796 break;
diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
index afdf4e3cafc2..7cde3f46ad26 100644
--- a/fs/binfmt_script.c
+++ b/fs/binfmt_script.c
@@ -19,7 +19,6 @@ static int load_script(struct linux_binprm *bprm)
19 const char *i_arg, *i_name; 19 const char *i_arg, *i_name;
20 char *cp; 20 char *cp;
21 struct file *file; 21 struct file *file;
22 char interp[BINPRM_BUF_SIZE];
23 int retval; 22 int retval;
24 23
25 if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!')) 24 if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!'))
@@ -55,7 +54,7 @@ static int load_script(struct linux_binprm *bprm)
55 break; 54 break;
56 } 55 }
57 for (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\t'); cp++); 56 for (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\t'); cp++);
58 if (*cp == '\0') 57 if (*cp == '\0')
59 return -ENOEXEC; /* No interpreter name found */ 58 return -ENOEXEC; /* No interpreter name found */
60 i_name = cp; 59 i_name = cp;
61 i_arg = NULL; 60 i_arg = NULL;
@@ -65,7 +64,6 @@ static int load_script(struct linux_binprm *bprm)
65 *cp++ = '\0'; 64 *cp++ = '\0';
66 if (*cp) 65 if (*cp)
67 i_arg = cp; 66 i_arg = cp;
68 strcpy (interp, i_name);
69 /* 67 /*
70 * OK, we've parsed out the interpreter name and 68 * OK, we've parsed out the interpreter name and
71 * (optional) argument. 69 * (optional) argument.
@@ -80,24 +78,27 @@ static int load_script(struct linux_binprm *bprm)
80 if (retval) 78 if (retval)
81 return retval; 79 return retval;
82 retval = copy_strings_kernel(1, &bprm->interp, bprm); 80 retval = copy_strings_kernel(1, &bprm->interp, bprm);
83 if (retval < 0) return retval; 81 if (retval < 0)
82 return retval;
84 bprm->argc++; 83 bprm->argc++;
85 if (i_arg) { 84 if (i_arg) {
86 retval = copy_strings_kernel(1, &i_arg, bprm); 85 retval = copy_strings_kernel(1, &i_arg, bprm);
87 if (retval < 0) return retval; 86 if (retval < 0)
87 return retval;
88 bprm->argc++; 88 bprm->argc++;
89 } 89 }
90 retval = copy_strings_kernel(1, &i_name, bprm); 90 retval = copy_strings_kernel(1, &i_name, bprm);
91 if (retval) return retval; 91 if (retval)
92 return retval;
92 bprm->argc++; 93 bprm->argc++;
93 retval = bprm_change_interp(interp, bprm); 94 retval = bprm_change_interp(i_name, bprm);
94 if (retval < 0) 95 if (retval < 0)
95 return retval; 96 return retval;
96 97
97 /* 98 /*
98 * OK, now restart the process with the interpreter's dentry. 99 * OK, now restart the process with the interpreter's dentry.
99 */ 100 */
100 file = open_exec(interp); 101 file = open_exec(i_name);
101 if (IS_ERR(file)) 102 if (IS_ERR(file))
102 return PTR_ERR(file); 103 return PTR_ERR(file);
103 104
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 93d088ffc05c..789f55e851ae 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -716,10 +716,12 @@ int bdev_write_page(struct block_device *bdev, sector_t sector,
716 716
717 set_page_writeback(page); 717 set_page_writeback(page);
718 result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, true); 718 result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, true);
719 if (result) 719 if (result) {
720 end_page_writeback(page); 720 end_page_writeback(page);
721 else 721 } else {
722 clean_page_buffers(page);
722 unlock_page(page); 723 unlock_page(page);
724 }
723 blk_queue_exit(bdev->bd_queue); 725 blk_queue_exit(bdev->bd_queue);
724 return result; 726 return result;
725} 727}
diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
index 962a95aefb81..f2cd9dedb037 100644
--- a/fs/btrfs/Makefile
+++ b/fs/btrfs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1 2
2obj-$(CONFIG_BTRFS_FS) := btrfs.o 3obj-$(CONFIG_BTRFS_FS) := btrfs.o
3 4
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index b51d23f5cafa..280384bf34f1 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -107,7 +107,8 @@ static void end_compressed_bio_read(struct bio *bio)
107 struct inode *inode; 107 struct inode *inode;
108 struct page *page; 108 struct page *page;
109 unsigned long index; 109 unsigned long index;
110 int ret; 110 unsigned int mirror = btrfs_io_bio(bio)->mirror_num;
111 int ret = 0;
111 112
112 if (bio->bi_status) 113 if (bio->bi_status)
113 cb->errors = 1; 114 cb->errors = 1;
@@ -118,6 +119,21 @@ static void end_compressed_bio_read(struct bio *bio)
118 if (!refcount_dec_and_test(&cb->pending_bios)) 119 if (!refcount_dec_and_test(&cb->pending_bios))
119 goto out; 120 goto out;
120 121
122 /*
123 * Record the correct mirror_num in cb->orig_bio so that
124 * read-repair can work properly.
125 */
126 ASSERT(btrfs_io_bio(cb->orig_bio));
127 btrfs_io_bio(cb->orig_bio)->mirror_num = mirror;
128 cb->mirror_num = mirror;
129
130 /*
131 * Some IO in this cb have failed, just skip checksum as there
132 * is no way it could be correct.
133 */
134 if (cb->errors == 1)
135 goto csum_failed;
136
121 inode = cb->inode; 137 inode = cb->inode;
122 ret = check_compressed_csum(BTRFS_I(inode), cb, 138 ret = check_compressed_csum(BTRFS_I(inode), cb,
123 (u64)bio->bi_iter.bi_sector << 9); 139 (u64)bio->bi_iter.bi_sector << 9);
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 5a8933da39a7..8fc690384c58 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -709,7 +709,6 @@ struct btrfs_delayed_root;
709#define BTRFS_FS_OPEN 5 709#define BTRFS_FS_OPEN 5
710#define BTRFS_FS_QUOTA_ENABLED 6 710#define BTRFS_FS_QUOTA_ENABLED 6
711#define BTRFS_FS_QUOTA_ENABLING 7 711#define BTRFS_FS_QUOTA_ENABLING 7
712#define BTRFS_FS_QUOTA_DISABLING 8
713#define BTRFS_FS_UPDATE_UUID_TREE_GEN 9 712#define BTRFS_FS_UPDATE_UUID_TREE_GEN 9
714#define BTRFS_FS_CREATING_FREE_SPACE_TREE 10 713#define BTRFS_FS_CREATING_FREE_SPACE_TREE 10
715#define BTRFS_FS_BTREE_ERR 11 714#define BTRFS_FS_BTREE_ERR 11
@@ -723,7 +722,7 @@ struct btrfs_delayed_root;
723 * Indicate that a whole-filesystem exclusive operation is running 722 * Indicate that a whole-filesystem exclusive operation is running
724 * (device replace, resize, device add/delete, balance) 723 * (device replace, resize, device add/delete, balance)
725 */ 724 */
726#define BTRFS_FS_EXCL_OP 14 725#define BTRFS_FS_EXCL_OP 16
727 726
728struct btrfs_fs_info { 727struct btrfs_fs_info {
729 u8 fsid[BTRFS_FSID_SIZE]; 728 u8 fsid[BTRFS_FSID_SIZE];
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 487bbe4fb3c6..dfdab849037b 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3643,7 +3643,14 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
3643 u64 flags; 3643 u64 flags;
3644 3644
3645 do_barriers = !btrfs_test_opt(fs_info, NOBARRIER); 3645 do_barriers = !btrfs_test_opt(fs_info, NOBARRIER);
3646 backup_super_roots(fs_info); 3646
3647 /*
3648 * max_mirrors == 0 indicates we're from commit_transaction,
3649 * not from fsync where the tree roots in fs_info have not
3650 * been consistent on disk.
3651 */
3652 if (max_mirrors == 0)
3653 backup_super_roots(fs_info);
3647 3654
3648 sb = fs_info->super_for_commit; 3655 sb = fs_info->super_for_commit;
3649 dev_item = &sb->dev_item; 3656 dev_item = &sb->dev_item;
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index fa66980726c9..3aeb5770f896 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/types.h> 3#include <linux/types.h>
3#include "ctree.h" 4#include "ctree.h"
diff --git a/fs/btrfs/export.h b/fs/btrfs/export.h
index 074348a95841..91b3908e7c54 100644
--- a/fs/btrfs/export.h
+++ b/fs/btrfs/export.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef BTRFS_EXPORT_H 2#ifndef BTRFS_EXPORT_H
2#define BTRFS_EXPORT_H 3#define BTRFS_EXPORT_H
3 4
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 3e5bb0cdd3cd..7fa50e12f18e 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/bitops.h> 2#include <linux/bitops.h>
2#include <linux/slab.h> 3#include <linux/slab.h>
3#include <linux/bio.h> 4#include <linux/bio.h>
@@ -2801,7 +2802,7 @@ static int submit_extent_page(unsigned int opf, struct extent_io_tree *tree,
2801 } 2802 }
2802 } 2803 }
2803 2804
2804 bio = btrfs_bio_alloc(bdev, sector << 9); 2805 bio = btrfs_bio_alloc(bdev, (u64)sector << 9);
2805 bio_add_page(bio, page, page_size, offset); 2806 bio_add_page(bio, page, page_size, offset);
2806 bio->bi_end_io = end_io_func; 2807 bio->bi_end_io = end_io_func;
2807 bio->bi_private = tree; 2808 bio->bi_private = tree;
@@ -3471,8 +3472,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
3471 unsigned int write_flags = 0; 3472 unsigned int write_flags = 0;
3472 unsigned long nr_written = 0; 3473 unsigned long nr_written = 0;
3473 3474
3474 if (wbc->sync_mode == WB_SYNC_ALL) 3475 write_flags = wbc_to_write_flags(wbc);
3475 write_flags = REQ_SYNC;
3476 3476
3477 trace___extent_writepage(page, inode, wbc); 3477 trace___extent_writepage(page, inode, wbc);
3478 3478
@@ -3718,7 +3718,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb,
3718 unsigned long i, num_pages; 3718 unsigned long i, num_pages;
3719 unsigned long bio_flags = 0; 3719 unsigned long bio_flags = 0;
3720 unsigned long start, end; 3720 unsigned long start, end;
3721 unsigned int write_flags = (epd->sync_io ? REQ_SYNC : 0) | REQ_META; 3721 unsigned int write_flags = wbc_to_write_flags(wbc) | REQ_META;
3722 int ret = 0; 3722 int ret = 0;
3723 3723
3724 clear_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags); 3724 clear_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags);
@@ -4063,9 +4063,6 @@ static void flush_epd_write_bio(struct extent_page_data *epd)
4063 if (epd->bio) { 4063 if (epd->bio) {
4064 int ret; 4064 int ret;
4065 4065
4066 bio_set_op_attrs(epd->bio, REQ_OP_WRITE,
4067 epd->sync_io ? REQ_SYNC : 0);
4068
4069 ret = submit_one_bio(epd->bio, 0, epd->bio_flags); 4066 ret = submit_one_bio(epd->bio, 0, epd->bio_flags);
4070 BUG_ON(ret < 0); /* -ENOMEM */ 4067 BUG_ON(ret < 0); /* -ENOMEM */
4071 epd->bio = NULL; 4068 epd->bio = NULL;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index faffa28ba707..e5535bbe6953 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __EXTENTIO__ 2#ifndef __EXTENTIO__
2#define __EXTENTIO__ 3#define __EXTENTIO__
3 4
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 69850155870c..2e348fb0b280 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/err.h> 2#include <linux/err.h>
2#include <linux/slab.h> 3#include <linux/slab.h>
3#include <linux/spinlock.h> 4#include <linux/spinlock.h>
diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
index a67b2def5413..64365bbc9b16 100644
--- a/fs/btrfs/extent_map.h
+++ b/fs/btrfs/extent_map.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __EXTENTMAP__ 2#ifndef __EXTENTMAP__
2#define __EXTENTMAP__ 3#define __EXTENTMAP__
3 4
diff --git a/fs/btrfs/inode-map.h b/fs/btrfs/inode-map.h
index c8e864b2d530..6734ec92a1e9 100644
--- a/fs/btrfs/inode-map.h
+++ b/fs/btrfs/inode-map.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __BTRFS_INODE_MAP 2#ifndef __BTRFS_INODE_MAP
2#define __BTRFS_INODE_MAP 3#define __BTRFS_INODE_MAP
3 4
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 128f3e58634f..d94e3f68b9b1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -135,6 +135,18 @@ static inline void btrfs_cleanup_ordered_extents(struct inode *inode,
135 const u64 offset, 135 const u64 offset,
136 const u64 bytes) 136 const u64 bytes)
137{ 137{
138 unsigned long index = offset >> PAGE_SHIFT;
139 unsigned long end_index = (offset + bytes - 1) >> PAGE_SHIFT;
140 struct page *page;
141
142 while (index <= end_index) {
143 page = find_get_page(inode->i_mapping, index);
144 index++;
145 if (!page)
146 continue;
147 ClearPagePrivate2(page);
148 put_page(page);
149 }
138 return __endio_write_update_ordered(inode, offset + PAGE_SIZE, 150 return __endio_write_update_ordered(inode, offset + PAGE_SIZE,
139 bytes - PAGE_SIZE, false); 151 bytes - PAGE_SIZE, false);
140} 152}
@@ -8357,11 +8369,8 @@ static void btrfs_endio_direct_read(struct bio *bio)
8357 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); 8369 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
8358 blk_status_t err = bio->bi_status; 8370 blk_status_t err = bio->bi_status;
8359 8371
8360 if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) { 8372 if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED)
8361 err = btrfs_subio_endio_read(inode, io_bio, err); 8373 err = btrfs_subio_endio_read(inode, io_bio, err);
8362 if (!err)
8363 bio->bi_status = 0;
8364 }
8365 8374
8366 unlock_extent(&BTRFS_I(inode)->io_tree, dip->logical_offset, 8375 unlock_extent(&BTRFS_I(inode)->io_tree, dip->logical_offset,
8367 dip->logical_offset + dip->bytes - 1); 8376 dip->logical_offset + dip->bytes - 1);
@@ -8369,7 +8378,7 @@ static void btrfs_endio_direct_read(struct bio *bio)
8369 8378
8370 kfree(dip); 8379 kfree(dip);
8371 8380
8372 dio_bio->bi_status = bio->bi_status; 8381 dio_bio->bi_status = err;
8373 dio_end_io(dio_bio); 8382 dio_end_io(dio_bio);
8374 8383
8375 if (io_bio->end_io) 8384 if (io_bio->end_io)
@@ -8387,6 +8396,7 @@ static void __endio_write_update_ordered(struct inode *inode,
8387 btrfs_work_func_t func; 8396 btrfs_work_func_t func;
8388 u64 ordered_offset = offset; 8397 u64 ordered_offset = offset;
8389 u64 ordered_bytes = bytes; 8398 u64 ordered_bytes = bytes;
8399 u64 last_offset;
8390 int ret; 8400 int ret;
8391 8401
8392 if (btrfs_is_free_space_inode(BTRFS_I(inode))) { 8402 if (btrfs_is_free_space_inode(BTRFS_I(inode))) {
@@ -8398,6 +8408,7 @@ static void __endio_write_update_ordered(struct inode *inode,
8398 } 8408 }
8399 8409
8400again: 8410again:
8411 last_offset = ordered_offset;
8401 ret = btrfs_dec_test_first_ordered_pending(inode, &ordered, 8412 ret = btrfs_dec_test_first_ordered_pending(inode, &ordered,
8402 &ordered_offset, 8413 &ordered_offset,
8403 ordered_bytes, 8414 ordered_bytes,
@@ -8409,6 +8420,12 @@ again:
8409 btrfs_queue_work(wq, &ordered->work); 8420 btrfs_queue_work(wq, &ordered->work);
8410out_test: 8421out_test:
8411 /* 8422 /*
8423 * If btrfs_dec_test_ordered_pending does not find any ordered extent
8424 * in the range, we can exit.
8425 */
8426 if (ordered_offset == last_offset)
8427 return;
8428 /*
8412 * our bio might span multiple ordered extents. If we haven't 8429 * our bio might span multiple ordered extents. If we haven't
8413 * completed the accounting for the whole dio, go back and try again 8430 * completed the accounting for the whole dio, go back and try again
8414 */ 8431 */
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index d6715c2bcdc4..6c7a49faf4e0 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2773,9 +2773,9 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
2773 } 2773 }
2774 mutex_unlock(&fs_devices->device_list_mutex); 2774 mutex_unlock(&fs_devices->device_list_mutex);
2775 2775
2776 fi_args->nodesize = fs_info->super_copy->nodesize; 2776 fi_args->nodesize = fs_info->nodesize;
2777 fi_args->sectorsize = fs_info->super_copy->sectorsize; 2777 fi_args->sectorsize = fs_info->sectorsize;
2778 fi_args->clone_alignment = fs_info->super_copy->sectorsize; 2778 fi_args->clone_alignment = fs_info->sectorsize;
2779 2779
2780 if (copy_to_user(arg, fi_args, sizeof(*fi_args))) 2780 if (copy_to_user(arg, fi_args, sizeof(*fi_args)))
2781 ret = -EFAULT; 2781 ret = -EFAULT;
@@ -3032,7 +3032,7 @@ static int btrfs_cmp_data_prepare(struct inode *src, u64 loff,
3032out: 3032out:
3033 if (ret) 3033 if (ret)
3034 btrfs_cmp_data_free(cmp); 3034 btrfs_cmp_data_free(cmp);
3035 return 0; 3035 return ret;
3036} 3036}
3037 3037
3038static int btrfs_cmp_data(u64 len, struct cmp_pages *cmp) 3038static int btrfs_cmp_data(u64 len, struct cmp_pages *cmp)
@@ -4061,6 +4061,10 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
4061 ret = PTR_ERR(new_root); 4061 ret = PTR_ERR(new_root);
4062 goto out; 4062 goto out;
4063 } 4063 }
4064 if (!is_fstree(new_root->objectid)) {
4065 ret = -ENOENT;
4066 goto out;
4067 }
4064 4068
4065 path = btrfs_alloc_path(); 4069 path = btrfs_alloc_path();
4066 if (!path) { 4070 if (!path) {
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 5c8b61c86e61..e172d4843eae 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -807,7 +807,6 @@ static int btrfs_clean_quota_tree(struct btrfs_trans_handle *trans,
807 } 807 }
808 ret = 0; 808 ret = 0;
809out: 809out:
810 set_bit(BTRFS_FS_QUOTA_DISABLING, &root->fs_info->flags);
811 btrfs_free_path(path); 810 btrfs_free_path(path);
812 return ret; 811 return ret;
813} 812}
@@ -953,7 +952,6 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans,
953 if (!fs_info->quota_root) 952 if (!fs_info->quota_root)
954 goto out; 953 goto out;
955 clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); 954 clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);
956 set_bit(BTRFS_FS_QUOTA_DISABLING, &fs_info->flags);
957 btrfs_qgroup_wait_for_completion(fs_info, false); 955 btrfs_qgroup_wait_for_completion(fs_info, false);
958 spin_lock(&fs_info->qgroup_lock); 956 spin_lock(&fs_info->qgroup_lock);
959 quota_root = fs_info->quota_root; 957 quota_root = fs_info->quota_root;
@@ -1307,6 +1305,8 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans,
1307 } 1305 }
1308 } 1306 }
1309 ret = del_qgroup_item(trans, quota_root, qgroupid); 1307 ret = del_qgroup_item(trans, quota_root, qgroupid);
1308 if (ret && ret != -ENOENT)
1309 goto out;
1310 1310
1311 while (!list_empty(&qgroup->groups)) { 1311 while (!list_empty(&qgroup->groups)) {
1312 list = list_first_entry(&qgroup->groups, 1312 list = list_first_entry(&qgroup->groups,
@@ -2086,8 +2086,6 @@ int btrfs_run_qgroups(struct btrfs_trans_handle *trans,
2086 2086
2087 if (test_and_clear_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags)) 2087 if (test_and_clear_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags))
2088 set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); 2088 set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);
2089 if (test_and_clear_bit(BTRFS_FS_QUOTA_DISABLING, &fs_info->flags))
2090 clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);
2091 2089
2092 spin_lock(&fs_info->qgroup_lock); 2090 spin_lock(&fs_info->qgroup_lock);
2093 while (!list_empty(&fs_info->dirty_qgroups)) { 2091 while (!list_empty(&fs_info->dirty_qgroups)) {
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 3a49a3c2fca4..9841faef08ea 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2400,11 +2400,11 @@ void free_reloc_roots(struct list_head *list)
2400 while (!list_empty(list)) { 2400 while (!list_empty(list)) {
2401 reloc_root = list_entry(list->next, struct btrfs_root, 2401 reloc_root = list_entry(list->next, struct btrfs_root,
2402 root_list); 2402 root_list);
2403 __del_reloc_root(reloc_root);
2403 free_extent_buffer(reloc_root->node); 2404 free_extent_buffer(reloc_root->node);
2404 free_extent_buffer(reloc_root->commit_root); 2405 free_extent_buffer(reloc_root->commit_root);
2405 reloc_root->node = NULL; 2406 reloc_root->node = NULL;
2406 reloc_root->commit_root = NULL; 2407 reloc_root->commit_root = NULL;
2407 __del_reloc_root(reloc_root);
2408 } 2408 }
2409} 2409}
2410 2410
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 32b043ef8ac9..8fd195cfe81b 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -2630,7 +2630,7 @@ static int send_create_inode(struct send_ctx *sctx, u64 ino)
2630 } else { 2630 } else {
2631 btrfs_warn(sctx->send_root->fs_info, "unexpected inode type %o", 2631 btrfs_warn(sctx->send_root->fs_info, "unexpected inode type %o",
2632 (int)(mode & S_IFMT)); 2632 (int)(mode & S_IFMT));
2633 ret = -ENOTSUPP; 2633 ret = -EOPNOTSUPP;
2634 goto out; 2634 goto out;
2635 } 2635 }
2636 2636
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 35a128acfbd1..161694b66038 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1135,7 +1135,7 @@ static int btrfs_fill_super(struct super_block *sb,
1135#ifdef CONFIG_BTRFS_FS_POSIX_ACL 1135#ifdef CONFIG_BTRFS_FS_POSIX_ACL
1136 sb->s_flags |= MS_POSIXACL; 1136 sb->s_flags |= MS_POSIXACL;
1137#endif 1137#endif
1138 sb->s_flags |= MS_I_VERSION; 1138 sb->s_flags |= SB_I_VERSION;
1139 sb->s_iflags |= SB_I_CGROUPWB; 1139 sb->s_iflags |= SB_I_CGROUPWB;
1140 1140
1141 err = super_setup_bdi(sb); 1141 err = super_setup_bdi(sb);
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index d7da1a4c2f6c..4cb908305e5d 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _BTRFS_SYSFS_H_ 2#ifndef _BTRFS_SYSFS_H_
2#define _BTRFS_SYSFS_H_ 3#define _BTRFS_SYSFS_H_
3 4
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index ad7f4bab640b..c800d067fcbf 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -4181,6 +4181,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
4181 struct extent_map *em, *n; 4181 struct extent_map *em, *n;
4182 struct list_head extents; 4182 struct list_head extents;
4183 struct extent_map_tree *tree = &inode->extent_tree; 4183 struct extent_map_tree *tree = &inode->extent_tree;
4184 u64 logged_start, logged_end;
4184 u64 test_gen; 4185 u64 test_gen;
4185 int ret = 0; 4186 int ret = 0;
4186 int num = 0; 4187 int num = 0;
@@ -4190,10 +4191,11 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
4190 down_write(&inode->dio_sem); 4191 down_write(&inode->dio_sem);
4191 write_lock(&tree->lock); 4192 write_lock(&tree->lock);
4192 test_gen = root->fs_info->last_trans_committed; 4193 test_gen = root->fs_info->last_trans_committed;
4194 logged_start = start;
4195 logged_end = end;
4193 4196
4194 list_for_each_entry_safe(em, n, &tree->modified_extents, list) { 4197 list_for_each_entry_safe(em, n, &tree->modified_extents, list) {
4195 list_del_init(&em->list); 4198 list_del_init(&em->list);
4196
4197 /* 4199 /*
4198 * Just an arbitrary number, this can be really CPU intensive 4200 * Just an arbitrary number, this can be really CPU intensive
4199 * once we start getting a lot of extents, and really once we 4201 * once we start getting a lot of extents, and really once we
@@ -4208,6 +4210,12 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
4208 4210
4209 if (em->generation <= test_gen) 4211 if (em->generation <= test_gen)
4210 continue; 4212 continue;
4213
4214 if (em->start < logged_start)
4215 logged_start = em->start;
4216 if ((em->start + em->len - 1) > logged_end)
4217 logged_end = em->start + em->len - 1;
4218
4211 /* Need a ref to keep it from getting evicted from cache */ 4219 /* Need a ref to keep it from getting evicted from cache */
4212 refcount_inc(&em->refs); 4220 refcount_inc(&em->refs);
4213 set_bit(EXTENT_FLAG_LOGGING, &em->flags); 4221 set_bit(EXTENT_FLAG_LOGGING, &em->flags);
@@ -4216,7 +4224,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
4216 } 4224 }
4217 4225
4218 list_sort(NULL, &extents, extent_cmp); 4226 list_sort(NULL, &extents, extent_cmp);
4219 btrfs_get_logged_extents(inode, logged_list, start, end); 4227 btrfs_get_logged_extents(inode, logged_list, logged_start, logged_end);
4220 /* 4228 /*
4221 * Some ordered extents started by fsync might have completed 4229 * Some ordered extents started by fsync might have completed
4222 * before we could collect them into the list logged_list, which 4230 * before we could collect them into the list logged_list, which
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0e8f16c305df..b39737568c22 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6166,7 +6166,7 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
6166 map_length = length; 6166 map_length = length;
6167 6167
6168 btrfs_bio_counter_inc_blocked(fs_info); 6168 btrfs_bio_counter_inc_blocked(fs_info);
6169 ret = __btrfs_map_block(fs_info, bio_op(bio), logical, 6169 ret = __btrfs_map_block(fs_info, btrfs_op(bio), logical,
6170 &map_length, &bbio, mirror_num, 1); 6170 &map_length, &bbio, mirror_num, 1);
6171 if (ret) { 6171 if (ret) {
6172 btrfs_bio_counter_dec(fs_info); 6172 btrfs_bio_counter_dec(fs_info);
diff --git a/fs/cachefiles/Makefile b/fs/cachefiles/Makefile
index 32cbab0ffce3..891dedda5905 100644
--- a/fs/cachefiles/Makefile
+++ b/fs/cachefiles/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for caching in a mounted filesystem 3# Makefile for caching in a mounted filesystem
3# 4#
diff --git a/fs/ceph/Makefile b/fs/ceph/Makefile
index 85a4230b9bff..174f5709e508 100644
--- a/fs/ceph/Makefile
+++ b/fs/ceph/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for CEPH filesystem. 3# Makefile for CEPH filesystem.
3# 4#
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index b3e3edc09d80..4d622654bfbc 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/backing-dev.h> 4#include <linux/backing-dev.h>
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 157fe59fbabe..ff5d32cf9578 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/fs.h> 4#include <linux/fs.h>
@@ -1991,6 +1992,7 @@ static int try_flush_caps(struct inode *inode, u64 *ptid)
1991retry: 1992retry:
1992 spin_lock(&ci->i_ceph_lock); 1993 spin_lock(&ci->i_ceph_lock);
1993 if (ci->i_ceph_flags & CEPH_I_NOFLUSH) { 1994 if (ci->i_ceph_flags & CEPH_I_NOFLUSH) {
1995 spin_unlock(&ci->i_ceph_lock);
1994 dout("try_flush_caps skipping %p I_NOFLUSH set\n", inode); 1996 dout("try_flush_caps skipping %p I_NOFLUSH set\n", inode);
1995 goto out; 1997 goto out;
1996 } 1998 }
@@ -2008,8 +2010,10 @@ retry:
2008 mutex_lock(&session->s_mutex); 2010 mutex_lock(&session->s_mutex);
2009 goto retry; 2011 goto retry;
2010 } 2012 }
2011 if (cap->session->s_state < CEPH_MDS_SESSION_OPEN) 2013 if (cap->session->s_state < CEPH_MDS_SESSION_OPEN) {
2014 spin_unlock(&ci->i_ceph_lock);
2012 goto out; 2015 goto out;
2016 }
2013 2017
2014 flushing = __mark_caps_flushing(inode, session, true, 2018 flushing = __mark_caps_flushing(inode, session, true,
2015 &flush_tid, &oldest_flush_tid); 2019 &flush_tid, &oldest_flush_tid);
diff --git a/fs/ceph/ceph_frag.c b/fs/ceph/ceph_frag.c
index bdce8b1fbd06..6f67d5b884a0 100644
--- a/fs/ceph/ceph_frag.c
+++ b/fs/ceph/ceph_frag.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Ceph 'frag' type 3 * Ceph 'frag' type
3 */ 4 */
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
index d635496ea189..644def813754 100644
--- a/fs/ceph/debugfs.c
+++ b/fs/ceph/debugfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/device.h> 4#include <linux/device.h>
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 019c2036d36f..8a5266699b67 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/spinlock.h> 4#include <linux/spinlock.h>
diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index 7df550c13d7f..3c59ad180ef0 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/exportfs.h> 4#include <linux/exportfs.h>
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 65a6fa12c857..5c17125f45c7 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/module.h> 4#include <linux/module.h>
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 373dab5173ca..f2550a076edc 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/module.h> 4#include <linux/module.h>
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 4c9c72f26eb9..851aa69ec8f0 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2#include <linux/in.h> 3#include <linux/in.h>
3 4
diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
index c77028afb1e1..51f7f1d39a94 100644
--- a/fs/ceph/ioctl.h
+++ b/fs/ceph/ioctl.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef FS_CEPH_IOCTL_H 2#ifndef FS_CEPH_IOCTL_H
2#define FS_CEPH_IOCTL_H 3#define FS_CEPH_IOCTL_H
3 4
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 8cd63e8123d8..e7cce412f2cf 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/file.h> 4#include <linux/file.h>
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 9dd6b836ac9e..0687ab3c3267 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/fs.h> 4#include <linux/fs.h>
@@ -7,7 +8,6 @@
7#include <linux/sched.h> 8#include <linux/sched.h>
8#include <linux/debugfs.h> 9#include <linux/debugfs.h>
9#include <linux/seq_file.h> 10#include <linux/seq_file.h>
10#include <linux/utsname.h>
11#include <linux/ratelimit.h> 11#include <linux/ratelimit.h>
12 12
13#include "super.h" 13#include "super.h"
@@ -735,12 +735,13 @@ static int __choose_mds(struct ceph_mds_client *mdsc,
735 inode = req->r_inode; 735 inode = req->r_inode;
736 ihold(inode); 736 ihold(inode);
737 } else { 737 } else {
738 /* req->r_dentry is non-null for LSSNAP request. 738 /* req->r_dentry is non-null for LSSNAP request */
739 * fall-thru */ 739 rcu_read_lock();
740 WARN_ON_ONCE(!req->r_dentry); 740 inode = get_nonsnap_parent(req->r_dentry);
741 rcu_read_unlock();
742 dout("__choose_mds using snapdir's parent %p\n", inode);
741 } 743 }
742 } 744 } else if (req->r_dentry) {
743 if (!inode && req->r_dentry) {
744 /* ignore race with rename; old or new d_parent is okay */ 745 /* ignore race with rename; old or new d_parent is okay */
745 struct dentry *parent; 746 struct dentry *parent;
746 struct inode *dir; 747 struct inode *dir;
@@ -884,8 +885,8 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6
884 void *p; 885 void *p;
885 886
886 const char* metadata[][2] = { 887 const char* metadata[][2] = {
887 {"hostname", utsname()->nodename}, 888 {"hostname", mdsc->nodename},
888 {"kernel_version", utsname()->release}, 889 {"kernel_version", init_utsname()->release},
889 {"entity_id", opt->name ? : ""}, 890 {"entity_id", opt->name ? : ""},
890 {"root", fsopt->server_path ? : "/"}, 891 {"root", fsopt->server_path ? : "/"},
891 {NULL, NULL} 892 {NULL, NULL}
@@ -3539,6 +3540,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
3539 init_rwsem(&mdsc->pool_perm_rwsem); 3540 init_rwsem(&mdsc->pool_perm_rwsem);
3540 mdsc->pool_perm_tree = RB_ROOT; 3541 mdsc->pool_perm_tree = RB_ROOT;
3541 3542
3543 strncpy(mdsc->nodename, utsname()->nodename,
3544 sizeof(mdsc->nodename) - 1);
3542 return 0; 3545 return 0;
3543} 3546}
3544 3547
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index db57ae98ed34..837ac4b087a0 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _FS_CEPH_MDS_CLIENT_H 2#ifndef _FS_CEPH_MDS_CLIENT_H
2#define _FS_CEPH_MDS_CLIENT_H 3#define _FS_CEPH_MDS_CLIENT_H
3 4
@@ -8,6 +9,7 @@
8#include <linux/rbtree.h> 9#include <linux/rbtree.h>
9#include <linux/spinlock.h> 10#include <linux/spinlock.h>
10#include <linux/refcount.h> 11#include <linux/refcount.h>
12#include <linux/utsname.h>
11 13
12#include <linux/ceph/types.h> 14#include <linux/ceph/types.h>
13#include <linux/ceph/messenger.h> 15#include <linux/ceph/messenger.h>
@@ -368,6 +370,8 @@ struct ceph_mds_client {
368 370
369 struct rw_semaphore pool_perm_rwsem; 371 struct rw_semaphore pool_perm_rwsem;
370 struct rb_root pool_perm_tree; 372 struct rb_root pool_perm_tree;
373
374 char nodename[__NEW_UTS_LEN + 1];
371}; 375};
372 376
373extern const char *ceph_mds_op_name(int op); 377extern const char *ceph_mds_op_name(int op);
diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c
index 33ced4c22732..44e53abeb32a 100644
--- a/fs/ceph/mdsmap.c
+++ b/fs/ceph/mdsmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/bug.h> 4#include <linux/bug.h>
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index 1ffc8b426c1c..8a2ca41e4b97 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2 3
3#include <linux/sort.h> 4#include <linux/sort.h>
@@ -374,12 +375,10 @@ static int build_snap_context(struct ceph_snap_realm *realm,
374 realm->ino, realm, snapc, snapc->seq, 375 realm->ino, realm, snapc, snapc->seq,
375 (unsigned int) snapc->num_snaps); 376 (unsigned int) snapc->num_snaps);
376 377
377 if (realm->cached_context) { 378 ceph_put_snap_context(realm->cached_context);
378 ceph_put_snap_context(realm->cached_context);
379 /* queue realm for cap_snap creation */
380 list_add_tail(&realm->dirty_item, dirty_realms);
381 }
382 realm->cached_context = snapc; 379 realm->cached_context = snapc;
380 /* queue realm for cap_snap creation */
381 list_add_tail(&realm->dirty_item, dirty_realms);
383 return 0; 382 return 0;
384 383
385fail: 384fail:
diff --git a/fs/ceph/strings.c b/fs/ceph/strings.c
index 913dea163d5c..4a79f3632260 100644
--- a/fs/ceph/strings.c
+++ b/fs/ceph/strings.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Ceph fs string constants 3 * Ceph fs string constants
3 */ 4 */
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 279a2f401cf5..3e27a28aa44a 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _FS_CEPH_SUPER_H 2#ifndef _FS_CEPH_SUPER_H
2#define _FS_CEPH_SUPER_H 3#define _FS_CEPH_SUPER_H
3 4
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 3542b2c364cf..e1c4e0b12b4c 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/ceph/ceph_debug.h> 2#include <linux/ceph/ceph_debug.h>
2#include <linux/ceph/pagelist.h> 3#include <linux/ceph/pagelist.h>
3 4
diff --git a/fs/char_dev.c b/fs/char_dev.c
index ebcc8fb3fa66..a65e4a56318c 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/char_dev.c 3 * linux/fs/char_dev.c
3 * 4 *
diff --git a/fs/cifs/Kconfig b/fs/cifs/Kconfig
index f7243617316c..d5b2e12b5d02 100644
--- a/fs/cifs/Kconfig
+++ b/fs/cifs/Kconfig
@@ -5,9 +5,14 @@ config CIFS
5 select CRYPTO 5 select CRYPTO
6 select CRYPTO_MD4 6 select CRYPTO_MD4
7 select CRYPTO_MD5 7 select CRYPTO_MD5
8 select CRYPTO_SHA256
9 select CRYPTO_CMAC
8 select CRYPTO_HMAC 10 select CRYPTO_HMAC
9 select CRYPTO_ARC4 11 select CRYPTO_ARC4
12 select CRYPTO_AEAD2
13 select CRYPTO_CCM
10 select CRYPTO_ECB 14 select CRYPTO_ECB
15 select CRYPTO_AES
11 select CRYPTO_DES 16 select CRYPTO_DES
12 help 17 help
13 This is the client VFS module for the SMB3 family of NAS protocols, 18 This is the client VFS module for the SMB3 family of NAS protocols,
diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile
index 5e853a395b92..7134f182720b 100644
--- a/fs/cifs/Makefile
+++ b/fs/cifs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for Linux CIFS VFS client 3# Makefile for Linux CIFS VFS client
3# 4#
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 9727e1dcacd5..cbb9534b89b4 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -160,8 +160,13 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
160 if ((ses->serverDomain == NULL) || 160 if ((ses->serverDomain == NULL) ||
161 (ses->serverOS == NULL) || 161 (ses->serverOS == NULL) ||
162 (ses->serverNOS == NULL)) { 162 (ses->serverNOS == NULL)) {
163 seq_printf(m, "\n%d) entry for %s not fully " 163 seq_printf(m, "\n%d) Name: %s Uses: %d Capability: 0x%x\tSession Status: %d\t",
164 "displayed\n\t", i, ses->serverName); 164 i, ses->serverName, ses->ses_count,
165 ses->capabilities, ses->status);
166 if (ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST)
167 seq_printf(m, "Guest\t");
168 else if (ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
169 seq_printf(m, "Anonymous\t");
165 } else { 170 } else {
166 seq_printf(m, 171 seq_printf(m,
167 "\n%d) Name: %s Domain: %s Uses: %d OS:" 172 "\n%d) Name: %s Domain: %s Uses: %d OS:"
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 180b3356ff86..8c8b75d33f31 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -461,6 +461,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
461 seq_puts(s, ",nocase"); 461 seq_puts(s, ",nocase");
462 if (tcon->retry) 462 if (tcon->retry)
463 seq_puts(s, ",hard"); 463 seq_puts(s, ",hard");
464 else
465 seq_puts(s, ",soft");
464 if (tcon->use_persistent) 466 if (tcon->use_persistent)
465 seq_puts(s, ",persistenthandles"); 467 seq_puts(s, ",persistenthandles");
466 else if (tcon->use_resilient) 468 else if (tcon->use_resilient)
@@ -1447,7 +1449,7 @@ exit_cifs(void)
1447 exit_cifs_idmap(); 1449 exit_cifs_idmap();
1448#endif 1450#endif
1449#ifdef CONFIG_CIFS_UPCALL 1451#ifdef CONFIG_CIFS_UPCALL
1450 unregister_key_type(&cifs_spnego_key_type); 1452 exit_cifs_spnego();
1451#endif 1453#endif
1452 cifs_destroy_request_bufs(); 1454 cifs_destroy_request_bufs();
1453 cifs_destroy_mids(); 1455 cifs_destroy_mids();
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 30bf89b1fd9a..5a10e566f0e6 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -149,5 +149,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
149extern const struct export_operations cifs_export_ops; 149extern const struct export_operations cifs_export_ops;
150#endif /* CONFIG_CIFS_NFSD_EXPORT */ 150#endif /* CONFIG_CIFS_NFSD_EXPORT */
151 151
152#define CIFS_VERSION "2.09" 152#define CIFS_VERSION "2.10"
153#endif /* _CIFSFS_H */ 153#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 808486c29f0d..e185b2853eab 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -188,6 +188,8 @@ enum smb_version {
188#ifdef CONFIG_CIFS_SMB311 188#ifdef CONFIG_CIFS_SMB311
189 Smb_311, 189 Smb_311,
190#endif /* SMB311 */ 190#endif /* SMB311 */
191 Smb_3any,
192 Smb_default,
191 Smb_version_err 193 Smb_version_err
192}; 194};
193 195
@@ -659,7 +661,9 @@ struct TCP_Server_Info {
659#endif 661#endif
660 unsigned int max_read; 662 unsigned int max_read;
661 unsigned int max_write; 663 unsigned int max_write;
662 __u8 preauth_hash[512]; 664#ifdef CONFIG_CIFS_SMB311
665 __u8 preauth_sha_hash[64]; /* save initital negprot hash */
666#endif /* 3.1.1 */
663 struct delayed_work reconnect; /* reconnect workqueue job */ 667 struct delayed_work reconnect; /* reconnect workqueue job */
664 struct mutex reconnect_mutex; /* prevent simultaneous reconnects */ 668 struct mutex reconnect_mutex; /* prevent simultaneous reconnects */
665 unsigned long echo_interval; 669 unsigned long echo_interval;
@@ -847,7 +851,9 @@ struct cifs_ses {
847 __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE]; 851 __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];
848 __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE]; 852 __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE];
849 __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE]; 853 __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE];
850 __u8 preauth_hash[512]; 854#ifdef CONFIG_CIFS_SMB311
855 __u8 preauth_sha_hash[64];
856#endif /* 3.1.1 */
851}; 857};
852 858
853static inline bool 859static inline bool
@@ -1701,6 +1707,10 @@ extern struct smb_version_values smb20_values;
1701#define SMB21_VERSION_STRING "2.1" 1707#define SMB21_VERSION_STRING "2.1"
1702extern struct smb_version_operations smb21_operations; 1708extern struct smb_version_operations smb21_operations;
1703extern struct smb_version_values smb21_values; 1709extern struct smb_version_values smb21_values;
1710#define SMBDEFAULT_VERSION_STRING "default"
1711extern struct smb_version_values smbdefault_values;
1712#define SMB3ANY_VERSION_STRING "3"
1713extern struct smb_version_values smb3any_values;
1704#define SMB30_VERSION_STRING "3.0" 1714#define SMB30_VERSION_STRING "3.0"
1705extern struct smb_version_operations smb30_operations; 1715extern struct smb_version_operations smb30_operations;
1706extern struct smb_version_values smb30_values; 1716extern struct smb_version_values smb30_values;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 5aa2d278ca84..0bfc2280436d 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -301,6 +301,8 @@ static const match_table_t cifs_smb_version_tokens = {
301 { Smb_311, SMB311_VERSION_STRING }, 301 { Smb_311, SMB311_VERSION_STRING },
302 { Smb_311, ALT_SMB311_VERSION_STRING }, 302 { Smb_311, ALT_SMB311_VERSION_STRING },
303#endif /* SMB311 */ 303#endif /* SMB311 */
304 { Smb_3any, SMB3ANY_VERSION_STRING },
305 { Smb_default, SMBDEFAULT_VERSION_STRING },
304 { Smb_version_err, NULL } 306 { Smb_version_err, NULL }
305}; 307};
306 308
@@ -1148,6 +1150,14 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol)
1148 vol->vals = &smb311_values; 1150 vol->vals = &smb311_values;
1149 break; 1151 break;
1150#endif /* SMB311 */ 1152#endif /* SMB311 */
1153 case Smb_3any:
1154 vol->ops = &smb30_operations; /* currently identical with 3.0 */
1155 vol->vals = &smb3any_values;
1156 break;
1157 case Smb_default:
1158 vol->ops = &smb30_operations; /* currently identical with 3.0 */
1159 vol->vals = &smbdefault_values;
1160 break;
1151 default: 1161 default:
1152 cifs_dbg(VFS, "Unknown vers= option specified: %s\n", value); 1162 cifs_dbg(VFS, "Unknown vers= option specified: %s\n", value);
1153 return 1; 1163 return 1;
@@ -1274,9 +1284,9 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1274 1284
1275 vol->actimeo = CIFS_DEF_ACTIMEO; 1285 vol->actimeo = CIFS_DEF_ACTIMEO;
1276 1286
1277 /* FIXME: add autonegotiation for SMB3 or later rather than just SMB3 */ 1287 /* offer SMB2.1 and later (SMB3 etc). Secure and widely accepted */
1278 vol->ops = &smb30_operations; /* both secure and accepted widely */ 1288 vol->ops = &smb30_operations;
1279 vol->vals = &smb30_values; 1289 vol->vals = &smbdefault_values;
1280 1290
1281 vol->echo_interval = SMB_ECHO_INTERVAL_DEFAULT; 1291 vol->echo_interval = SMB_ECHO_INTERVAL_DEFAULT;
1282 1292
@@ -1988,11 +1998,10 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1988 1998
1989 if (got_version == false) 1999 if (got_version == false)
1990 pr_warn("No dialect specified on mount. Default has changed to " 2000 pr_warn("No dialect specified on mount. Default has changed to "
1991 "a more secure dialect, SMB3 (vers=3.0), from CIFS " 2001 "a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS "
1992 "(SMB1). To use the less secure SMB1 dialect to access " 2002 "(SMB1). To use the less secure SMB1 dialect to access "
1993 "old servers which do not support SMB3 specify vers=1.0" 2003 "old servers which do not support SMB3 (or SMB2.1) specify vers=1.0"
1994 " on mount. For somewhat newer servers such as Windows " 2004 " on mount.\n");
1995 "7 try vers=2.1.\n");
1996 2005
1997 kfree(mountdata_copy); 2006 kfree(mountdata_copy);
1998 return 0; 2007 return 0;
@@ -2133,6 +2142,7 @@ static int match_server(struct TCP_Server_Info *server, struct smb_vol *vol)
2133 if (vol->nosharesock) 2142 if (vol->nosharesock)
2134 return 0; 2143 return 0;
2135 2144
2145 /* BB update this for smb3any and default case */
2136 if ((server->vals != vol->vals) || (server->ops != vol->ops)) 2146 if ((server->vals != vol->vals) || (server->ops != vol->ops))
2137 return 0; 2147 return 0;
2138 2148
@@ -4144,6 +4154,14 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
4144 cifs_dbg(FYI, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d\n", 4154 cifs_dbg(FYI, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d\n",
4145 server->sec_mode, server->capabilities, server->timeAdj); 4155 server->sec_mode, server->capabilities, server->timeAdj);
4146 4156
4157 if (ses->auth_key.response) {
4158 cifs_dbg(VFS, "Free previous auth_key.response = %p\n",
4159 ses->auth_key.response);
4160 kfree(ses->auth_key.response);
4161 ses->auth_key.response = NULL;
4162 ses->auth_key.len = 0;
4163 }
4164
4147 if (server->ops->sess_setup) 4165 if (server->ops->sess_setup)
4148 rc = server->ops->sess_setup(xid, ses, nls_info); 4166 rc = server->ops->sess_setup(xid, ses, nls_info);
4149 4167
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index e702d48bd023..81ba6e0d88d8 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -204,7 +204,8 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon)
204 struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); 204 struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
205 int i; 205 int i;
206 206
207 if (unlikely(direntry->d_name.len > 207 if (unlikely(tcon->fsAttrInfo.MaxPathNameComponentLength &&
208 direntry->d_name.len >
208 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength))) 209 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength)))
209 return -ENAMETOOLONG; 210 return -ENAMETOOLONG;
210 211
@@ -520,7 +521,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
520 521
521 rc = check_name(direntry, tcon); 522 rc = check_name(direntry, tcon);
522 if (rc) 523 if (rc)
523 goto out_free_xid; 524 goto out;
524 525
525 server = tcon->ses->server; 526 server = tcon->ses->server;
526 527
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 0786f19d288f..92fdf9c35de2 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -224,6 +224,13 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
224 if (backup_cred(cifs_sb)) 224 if (backup_cred(cifs_sb))
225 create_options |= CREATE_OPEN_BACKUP_INTENT; 225 create_options |= CREATE_OPEN_BACKUP_INTENT;
226 226
227 /* O_SYNC also has bit for O_DSYNC so following check picks up either */
228 if (f_flags & O_SYNC)
229 create_options |= CREATE_WRITE_THROUGH;
230
231 if (f_flags & O_DIRECT)
232 create_options |= CREATE_NO_BUFFER;
233
227 oparms.tcon = tcon; 234 oparms.tcon = tcon;
228 oparms.cifs_sb = cifs_sb; 235 oparms.cifs_sb = cifs_sb;
229 oparms.desired_access = desired_access; 236 oparms.desired_access = desired_access;
@@ -1102,8 +1109,10 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
1102 struct cifs_tcon *tcon; 1109 struct cifs_tcon *tcon;
1103 unsigned int num, max_num, max_buf; 1110 unsigned int num, max_num, max_buf;
1104 LOCKING_ANDX_RANGE *buf, *cur; 1111 LOCKING_ANDX_RANGE *buf, *cur;
1105 int types[] = {LOCKING_ANDX_LARGE_FILES, 1112 static const int types[] = {
1106 LOCKING_ANDX_SHARED_LOCK | LOCKING_ANDX_LARGE_FILES}; 1113 LOCKING_ANDX_LARGE_FILES,
1114 LOCKING_ANDX_SHARED_LOCK | LOCKING_ANDX_LARGE_FILES
1115 };
1107 int i; 1116 int i;
1108 1117
1109 xid = get_xid(); 1118 xid = get_xid();
@@ -1434,8 +1443,10 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
1434 unsigned int xid) 1443 unsigned int xid)
1435{ 1444{
1436 int rc = 0, stored_rc; 1445 int rc = 0, stored_rc;
1437 int types[] = {LOCKING_ANDX_LARGE_FILES, 1446 static const int types[] = {
1438 LOCKING_ANDX_SHARED_LOCK | LOCKING_ANDX_LARGE_FILES}; 1447 LOCKING_ANDX_LARGE_FILES,
1448 LOCKING_ANDX_SHARED_LOCK | LOCKING_ANDX_LARGE_FILES
1449 };
1439 unsigned int i; 1450 unsigned int i;
1440 unsigned int max_num, num, max_buf; 1451 unsigned int max_num, num, max_buf;
1441 LOCKING_ANDX_RANGE *buf, *cur; 1452 LOCKING_ANDX_RANGE *buf, *cur;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index a8693632235f..7c732cb44164 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -234,6 +234,8 @@ cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,
234 fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); 234 fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
235 fattr->cf_mtime = cifs_NTtimeToUnix(info->LastModificationTime); 235 fattr->cf_mtime = cifs_NTtimeToUnix(info->LastModificationTime);
236 fattr->cf_ctime = cifs_NTtimeToUnix(info->LastStatusChange); 236 fattr->cf_ctime = cifs_NTtimeToUnix(info->LastStatusChange);
237 /* old POSIX extensions don't get create time */
238
237 fattr->cf_mode = le64_to_cpu(info->Permissions); 239 fattr->cf_mode = le64_to_cpu(info->Permissions);
238 240
239 /* 241 /*
@@ -2024,6 +2026,19 @@ int cifs_getattr(const struct path *path, struct kstat *stat,
2024 stat->blksize = CIFS_MAX_MSGSIZE; 2026 stat->blksize = CIFS_MAX_MSGSIZE;
2025 stat->ino = CIFS_I(inode)->uniqueid; 2027 stat->ino = CIFS_I(inode)->uniqueid;
2026 2028
2029 /* old CIFS Unix Extensions doesn't return create time */
2030 if (CIFS_I(inode)->createtime) {
2031 stat->result_mask |= STATX_BTIME;
2032 stat->btime =
2033 cifs_NTtimeToUnix(cpu_to_le64(CIFS_I(inode)->createtime));
2034 }
2035
2036 stat->attributes_mask |= (STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED);
2037 if (CIFS_I(inode)->cifsAttrs & FILE_ATTRIBUTE_COMPRESSED)
2038 stat->attributes |= STATX_ATTR_COMPRESSED;
2039 if (CIFS_I(inode)->cifsAttrs & FILE_ATTRIBUTE_ENCRYPTED)
2040 stat->attributes |= STATX_ATTR_ENCRYPTED;
2041
2027 /* 2042 /*
2028 * If on a multiuser mount without unix extensions or cifsacl being 2043 * If on a multiuser mount without unix extensions or cifsacl being
2029 * enabled, and the admin hasn't overridden them, set the ownership 2044 * enabled, and the admin hasn't overridden them, set the ownership
diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c
index 7ca9808a0daa..62c88dfed57b 100644
--- a/fs/cifs/smb2maperror.c
+++ b/fs/cifs/smb2maperror.c
@@ -214,7 +214,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
214 {STATUS_DATATYPE_MISALIGNMENT, -EIO, "STATUS_DATATYPE_MISALIGNMENT"}, 214 {STATUS_DATATYPE_MISALIGNMENT, -EIO, "STATUS_DATATYPE_MISALIGNMENT"},
215 {STATUS_BREAKPOINT, -EIO, "STATUS_BREAKPOINT"}, 215 {STATUS_BREAKPOINT, -EIO, "STATUS_BREAKPOINT"},
216 {STATUS_SINGLE_STEP, -EIO, "STATUS_SINGLE_STEP"}, 216 {STATUS_SINGLE_STEP, -EIO, "STATUS_SINGLE_STEP"},
217 {STATUS_BUFFER_OVERFLOW, -EIO, "STATUS_BUFFER_OVERFLOW"}, 217 {STATUS_BUFFER_OVERFLOW, -E2BIG, "STATUS_BUFFER_OVERFLOW"},
218 {STATUS_NO_MORE_FILES, -ENODATA, "STATUS_NO_MORE_FILES"}, 218 {STATUS_NO_MORE_FILES, -ENODATA, "STATUS_NO_MORE_FILES"},
219 {STATUS_WAKE_SYSTEM_DEBUGGER, -EIO, "STATUS_WAKE_SYSTEM_DEBUGGER"}, 219 {STATUS_WAKE_SYSTEM_DEBUGGER, -EIO, "STATUS_WAKE_SYSTEM_DEBUGGER"},
220 {STATUS_HANDLES_CLOSED, -EIO, "STATUS_HANDLES_CLOSED"}, 220 {STATUS_HANDLES_CLOSED, -EIO, "STATUS_HANDLES_CLOSED"},
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index fb2934b9b97c..bdb963d0ba32 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -426,6 +426,7 @@ smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
426 return rc; 426 return rc;
427} 427}
428 428
429#ifdef CONFIG_CIFS_XATTR
429static ssize_t 430static ssize_t
430move_smb2_ea_to_cifs(char *dst, size_t dst_size, 431move_smb2_ea_to_cifs(char *dst, size_t dst_size,
431 struct smb2_file_full_ea_info *src, size_t src_size, 432 struct smb2_file_full_ea_info *src, size_t src_size,
@@ -521,6 +522,7 @@ smb2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
521 struct cifs_open_parms oparms; 522 struct cifs_open_parms oparms;
522 struct cifs_fid fid; 523 struct cifs_fid fid;
523 struct smb2_file_full_ea_info *smb2_data; 524 struct smb2_file_full_ea_info *smb2_data;
525 int ea_buf_size = SMB2_MIN_EA_BUF;
524 526
525 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); 527 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
526 if (!utf16_path) 528 if (!utf16_path)
@@ -540,14 +542,32 @@ smb2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
540 return rc; 542 return rc;
541 } 543 }
542 544
543 smb2_data = kzalloc(SMB2_MAX_EA_BUF, GFP_KERNEL); 545 while (1) {
544 if (smb2_data == NULL) { 546 smb2_data = kzalloc(ea_buf_size, GFP_KERNEL);
545 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); 547 if (smb2_data == NULL) {
546 return -ENOMEM; 548 SMB2_close(xid, tcon, fid.persistent_fid,
549 fid.volatile_fid);
550 return -ENOMEM;
551 }
552
553 rc = SMB2_query_eas(xid, tcon, fid.persistent_fid,
554 fid.volatile_fid,
555 ea_buf_size, smb2_data);
556
557 if (rc != -E2BIG)
558 break;
559
560 kfree(smb2_data);
561 ea_buf_size <<= 1;
562
563 if (ea_buf_size > SMB2_MAX_EA_BUF) {
564 cifs_dbg(VFS, "EA size is too large\n");
565 SMB2_close(xid, tcon, fid.persistent_fid,
566 fid.volatile_fid);
567 return -ENOMEM;
568 }
547 } 569 }
548 570
549 rc = SMB2_query_eas(xid, tcon, fid.persistent_fid, fid.volatile_fid,
550 smb2_data);
551 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); 571 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
552 572
553 if (!rc) 573 if (!rc)
@@ -613,6 +633,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
613 633
614 return rc; 634 return rc;
615} 635}
636#endif
616 637
617static bool 638static bool
618smb2_can_echo(struct TCP_Server_Info *server) 639smb2_can_echo(struct TCP_Server_Info *server)
@@ -3110,6 +3131,46 @@ struct smb_version_values smb21_values = {
3110 .create_lease_size = sizeof(struct create_lease), 3131 .create_lease_size = sizeof(struct create_lease),
3111}; 3132};
3112 3133
3134struct smb_version_values smb3any_values = {
3135 .version_string = SMB3ANY_VERSION_STRING,
3136 .protocol_id = SMB302_PROT_ID, /* doesn't matter, send protocol array */
3137 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION,
3138 .large_lock_type = 0,
3139 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
3140 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
3141 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
3142 .header_size = sizeof(struct smb2_hdr),
3143 .max_header_size = MAX_SMB2_HDR_SIZE,
3144 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
3145 .lock_cmd = SMB2_LOCK,
3146 .cap_unix = 0,
3147 .cap_nt_find = SMB2_NT_FIND,
3148 .cap_large_files = SMB2_LARGE_FILES,
3149 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
3150 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
3151 .create_lease_size = sizeof(struct create_lease_v2),
3152};
3153
3154struct smb_version_values smbdefault_values = {
3155 .version_string = SMBDEFAULT_VERSION_STRING,
3156 .protocol_id = SMB302_PROT_ID, /* doesn't matter, send protocol array */
3157 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION,
3158 .large_lock_type = 0,
3159 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
3160 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
3161 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
3162 .header_size = sizeof(struct smb2_hdr),
3163 .max_header_size = MAX_SMB2_HDR_SIZE,
3164 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
3165 .lock_cmd = SMB2_LOCK,
3166 .cap_unix = 0,
3167 .cap_nt_find = SMB2_NT_FIND,
3168 .cap_large_files = SMB2_LARGE_FILES,
3169 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
3170 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
3171 .create_lease_size = sizeof(struct create_lease_v2),
3172};
3173
3113struct smb_version_values smb30_values = { 3174struct smb_version_values smb30_values = {
3114 .version_string = SMB30_VERSION_STRING, 3175 .version_string = SMB30_VERSION_STRING,
3115 .protocol_id = SMB30_PROT_ID, 3176 .protocol_id = SMB30_PROT_ID,
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 5531e7ee1210..5331631386a2 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -439,7 +439,7 @@ assemble_neg_contexts(struct smb2_negotiate_req *req)
439 build_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt); 439 build_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt);
440 req->NegotiateContextOffset = cpu_to_le32(OFFSET_OF_NEG_CONTEXT); 440 req->NegotiateContextOffset = cpu_to_le32(OFFSET_OF_NEG_CONTEXT);
441 req->NegotiateContextCount = cpu_to_le16(2); 441 req->NegotiateContextCount = cpu_to_le16(2);
442 inc_rfc1001_len(req, 4 + sizeof(struct smb2_preauth_neg_context) + 2 442 inc_rfc1001_len(req, 4 + sizeof(struct smb2_preauth_neg_context)
443 + sizeof(struct smb2_encryption_neg_context)); /* calculate hash */ 443 + sizeof(struct smb2_encryption_neg_context)); /* calculate hash */
444} 444}
445#else 445#else
@@ -491,10 +491,25 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
491 491
492 req->hdr.sync_hdr.SessionId = 0; 492 req->hdr.sync_hdr.SessionId = 0;
493 493
494 req->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id); 494 if (strcmp(ses->server->vals->version_string,
495 495 SMB3ANY_VERSION_STRING) == 0) {
496 req->DialectCount = cpu_to_le16(1); /* One vers= at a time for now */ 496 req->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
497 inc_rfc1001_len(req, 2); 497 req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
498 req->DialectCount = cpu_to_le16(2);
499 inc_rfc1001_len(req, 4);
500 } else if (strcmp(ses->server->vals->version_string,
501 SMBDEFAULT_VERSION_STRING) == 0) {
502 req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
503 req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
504 req->Dialects[2] = cpu_to_le16(SMB302_PROT_ID);
505 req->DialectCount = cpu_to_le16(3);
506 inc_rfc1001_len(req, 6);
507 } else {
508 /* otherwise send specific dialect */
509 req->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id);
510 req->DialectCount = cpu_to_le16(1);
511 inc_rfc1001_len(req, 2);
512 }
498 513
499 /* only one of SMB2 signing flags may be set in SMB2 request */ 514 /* only one of SMB2 signing flags may be set in SMB2 request */
500 if (ses->sign) 515 if (ses->sign)
@@ -528,16 +543,43 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
528 */ 543 */
529 if (rc == -EOPNOTSUPP) { 544 if (rc == -EOPNOTSUPP) {
530 cifs_dbg(VFS, "Dialect not supported by server. Consider " 545 cifs_dbg(VFS, "Dialect not supported by server. Consider "
531 "specifying vers=1.0 or vers=2.1 on mount for accessing" 546 "specifying vers=1.0 or vers=2.0 on mount for accessing"
532 " older servers\n"); 547 " older servers\n");
533 goto neg_exit; 548 goto neg_exit;
534 } else if (rc != 0) 549 } else if (rc != 0)
535 goto neg_exit; 550 goto neg_exit;
536 551
552 if (strcmp(ses->server->vals->version_string,
553 SMB3ANY_VERSION_STRING) == 0) {
554 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
555 cifs_dbg(VFS,
556 "SMB2 dialect returned but not requested\n");
557 return -EIO;
558 } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
559 cifs_dbg(VFS,
560 "SMB2.1 dialect returned but not requested\n");
561 return -EIO;
562 }
563 } else if (strcmp(ses->server->vals->version_string,
564 SMBDEFAULT_VERSION_STRING) == 0) {
565 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
566 cifs_dbg(VFS,
567 "SMB2 dialect returned but not requested\n");
568 return -EIO;
569 } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
570 /* ops set to 3.0 by default for default so update */
571 ses->server->ops = &smb21_operations;
572 }
573 } else if (le16_to_cpu(rsp->DialectRevision) !=
574 ses->server->vals->protocol_id) {
575 /* if requested single dialect ensure returned dialect matched */
576 cifs_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n",
577 le16_to_cpu(rsp->DialectRevision));
578 return -EIO;
579 }
580
537 cifs_dbg(FYI, "mode 0x%x\n", rsp->SecurityMode); 581 cifs_dbg(FYI, "mode 0x%x\n", rsp->SecurityMode);
538 582
539 /* BB we may eventually want to match the negotiated vs. requested
540 dialect, even though we are only requesting one at a time */
541 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) 583 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID))
542 cifs_dbg(FYI, "negotiated smb2.0 dialect\n"); 584 cifs_dbg(FYI, "negotiated smb2.0 dialect\n");
543 else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) 585 else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID))
@@ -558,6 +600,8 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
558 } 600 }
559 server->dialect = le16_to_cpu(rsp->DialectRevision); 601 server->dialect = le16_to_cpu(rsp->DialectRevision);
560 602
603 /* BB: add check that dialect was valid given dialect(s) we asked for */
604
561 /* SMB2 only has an extended negflavor */ 605 /* SMB2 only has an extended negflavor */
562 server->negflavor = CIFS_NEGFLAVOR_EXTENDED; 606 server->negflavor = CIFS_NEGFLAVOR_EXTENDED;
563 /* set it to the maximum buffer size value we can send with 1 credit */ 607 /* set it to the maximum buffer size value we can send with 1 credit */
@@ -604,22 +648,30 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
604{ 648{
605 int rc = 0; 649 int rc = 0;
606 struct validate_negotiate_info_req vneg_inbuf; 650 struct validate_negotiate_info_req vneg_inbuf;
607 struct validate_negotiate_info_rsp *pneg_rsp; 651 struct validate_negotiate_info_rsp *pneg_rsp = NULL;
608 u32 rsplen; 652 u32 rsplen;
653 u32 inbuflen; /* max of 4 dialects */
609 654
610 cifs_dbg(FYI, "validate negotiate\n"); 655 cifs_dbg(FYI, "validate negotiate\n");
611 656
612 /* 657 /*
613 * validation ioctl must be signed, so no point sending this if we 658 * validation ioctl must be signed, so no point sending this if we
614 * can not sign it. We could eventually change this to selectively 659 * can not sign it (ie are not known user). Even if signing is not
660 * required (enabled but not negotiated), in those cases we selectively
615 * sign just this, the first and only signed request on a connection. 661 * sign just this, the first and only signed request on a connection.
616 * This is good enough for now since a user who wants better security 662 * Having validation of negotiate info helps reduce attack vectors.
617 * would also enable signing on the mount. Having validation of
618 * negotiate info for signed connections helps reduce attack vectors
619 */ 663 */
620 if (tcon->ses->server->sign == false) 664 if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST)
621 return 0; /* validation requires signing */ 665 return 0; /* validation requires signing */
622 666
667 if (tcon->ses->user_name == NULL) {
668 cifs_dbg(FYI, "Can't validate negotiate: null user mount\n");
669 return 0; /* validation requires signing */
670 }
671
672 if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
673 cifs_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
674
623 vneg_inbuf.Capabilities = 675 vneg_inbuf.Capabilities =
624 cpu_to_le32(tcon->ses->server->vals->req_capabilities); 676 cpu_to_le32(tcon->ses->server->vals->req_capabilities);
625 memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid, 677 memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,
@@ -634,9 +686,30 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
634 else 686 else
635 vneg_inbuf.SecurityMode = 0; 687 vneg_inbuf.SecurityMode = 0;
636 688
637 vneg_inbuf.DialectCount = cpu_to_le16(1); 689
638 vneg_inbuf.Dialects[0] = 690 if (strcmp(tcon->ses->server->vals->version_string,
639 cpu_to_le16(tcon->ses->server->vals->protocol_id); 691 SMB3ANY_VERSION_STRING) == 0) {
692 vneg_inbuf.Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
693 vneg_inbuf.Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
694 vneg_inbuf.DialectCount = cpu_to_le16(2);
695 /* structure is big enough for 3 dialects, sending only 2 */
696 inbuflen = sizeof(struct validate_negotiate_info_req) - 2;
697 } else if (strcmp(tcon->ses->server->vals->version_string,
698 SMBDEFAULT_VERSION_STRING) == 0) {
699 vneg_inbuf.Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
700 vneg_inbuf.Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
701 vneg_inbuf.Dialects[2] = cpu_to_le16(SMB302_PROT_ID);
702 vneg_inbuf.DialectCount = cpu_to_le16(3);
703 /* structure is big enough for 3 dialects */
704 inbuflen = sizeof(struct validate_negotiate_info_req);
705 } else {
706 /* otherwise specific dialect was requested */
707 vneg_inbuf.Dialects[0] =
708 cpu_to_le16(tcon->ses->server->vals->protocol_id);
709 vneg_inbuf.DialectCount = cpu_to_le16(1);
710 /* structure is big enough for 3 dialects, sending only 1 */
711 inbuflen = sizeof(struct validate_negotiate_info_req) - 4;
712 }
640 713
641 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, 714 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
642 FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */, 715 FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */,
@@ -654,8 +727,9 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
654 rsplen); 727 rsplen);
655 728
656 /* relax check since Mac returns max bufsize allowed on ioctl */ 729 /* relax check since Mac returns max bufsize allowed on ioctl */
657 if (rsplen > CIFSMaxBufSize) 730 if ((rsplen > CIFSMaxBufSize)
658 return -EIO; 731 || (rsplen < sizeof(struct validate_negotiate_info_rsp)))
732 goto err_rsp_free;
659 } 733 }
660 734
661 /* check validate negotiate info response matches what we got earlier */ 735 /* check validate negotiate info response matches what we got earlier */
@@ -674,10 +748,13 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
674 748
675 /* validate negotiate successful */ 749 /* validate negotiate successful */
676 cifs_dbg(FYI, "validate negotiate info successful\n"); 750 cifs_dbg(FYI, "validate negotiate info successful\n");
751 kfree(pneg_rsp);
677 return 0; 752 return 0;
678 753
679vneg_out: 754vneg_out:
680 cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n"); 755 cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n");
756err_rsp_free:
757 kfree(pneg_rsp);
681 return -EIO; 758 return -EIO;
682} 759}
683 760
@@ -1110,6 +1187,8 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
1110 while (sess_data->func) 1187 while (sess_data->func)
1111 sess_data->func(sess_data); 1188 sess_data->func(sess_data);
1112 1189
1190 if ((ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST) && (ses->sign))
1191 cifs_dbg(VFS, "signing requested but authenticated as guest\n");
1113 rc = sess_data->result; 1192 rc = sess_data->result;
1114out: 1193out:
1115 kfree(sess_data); 1194 kfree(sess_data);
@@ -1180,7 +1259,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
1180 struct smb2_tree_connect_req *req; 1259 struct smb2_tree_connect_req *req;
1181 struct smb2_tree_connect_rsp *rsp = NULL; 1260 struct smb2_tree_connect_rsp *rsp = NULL;
1182 struct kvec iov[2]; 1261 struct kvec iov[2];
1183 struct kvec rsp_iov; 1262 struct kvec rsp_iov = { NULL, 0 };
1184 int rc = 0; 1263 int rc = 0;
1185 int resp_buftype; 1264 int resp_buftype;
1186 int unc_path_len; 1265 int unc_path_len;
@@ -1297,7 +1376,7 @@ tcon_exit:
1297 return rc; 1376 return rc;
1298 1377
1299tcon_error_exit: 1378tcon_error_exit:
1300 if (rsp->hdr.sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { 1379 if (rsp && rsp->hdr.sync_hdr.Status == STATUS_BAD_NETWORK_NAME) {
1301 cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); 1380 cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree);
1302 } 1381 }
1303 goto tcon_exit; 1382 goto tcon_exit;
@@ -1634,7 +1713,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
1634 struct cifs_tcon *tcon = oparms->tcon; 1713 struct cifs_tcon *tcon = oparms->tcon;
1635 struct cifs_ses *ses = tcon->ses; 1714 struct cifs_ses *ses = tcon->ses;
1636 struct kvec iov[4]; 1715 struct kvec iov[4];
1637 struct kvec rsp_iov; 1716 struct kvec rsp_iov = {NULL, 0};
1638 int resp_buftype; 1717 int resp_buftype;
1639 int uni_path_len; 1718 int uni_path_len;
1640 __le16 *copy_path = NULL; 1719 __le16 *copy_path = NULL;
@@ -1763,7 +1842,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
1763 1842
1764 if (rc != 0) { 1843 if (rc != 0) {
1765 cifs_stats_fail_inc(tcon, SMB2_CREATE_HE); 1844 cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
1766 if (err_buf) 1845 if (err_buf && rsp)
1767 *err_buf = kmemdup(rsp, get_rfc1002_length(rsp) + 4, 1846 *err_buf = kmemdup(rsp, get_rfc1002_length(rsp) + 4,
1768 GFP_KERNEL); 1847 GFP_KERNEL);
1769 goto creat_exit; 1848 goto creat_exit;
@@ -1900,6 +1979,9 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
1900 } else 1979 } else
1901 iov[0].iov_len = get_rfc1002_length(req) + 4; 1980 iov[0].iov_len = get_rfc1002_length(req) + 4;
1902 1981
1982 /* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */
1983 if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO)
1984 req->hdr.sync_hdr.Flags |= SMB2_FLAGS_SIGNED;
1903 1985
1904 rc = SendReceive2(xid, ses, iov, n_iov, &resp_buftype, flags, &rsp_iov); 1986 rc = SendReceive2(xid, ses, iov, n_iov, &resp_buftype, flags, &rsp_iov);
1905 cifs_small_buf_release(req); 1987 cifs_small_buf_release(req);
@@ -2116,9 +2198,13 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
2116 req->PersistentFileId = persistent_fid; 2198 req->PersistentFileId = persistent_fid;
2117 req->VolatileFileId = volatile_fid; 2199 req->VolatileFileId = volatile_fid;
2118 req->AdditionalInformation = cpu_to_le32(additional_info); 2200 req->AdditionalInformation = cpu_to_le32(additional_info);
2119 /* 4 for rfc1002 length field and 1 for Buffer */ 2201
2120 req->InputBufferOffset = 2202 /*
2121 cpu_to_le16(sizeof(struct smb2_query_info_req) - 1 - 4); 2203 * We do not use the input buffer (do not send extra byte)
2204 */
2205 req->InputBufferOffset = 0;
2206 inc_rfc1001_len(req, -1);
2207
2122 req->OutputBufferLength = cpu_to_le32(output_len); 2208 req->OutputBufferLength = cpu_to_le32(output_len);
2123 2209
2124 iov[0].iov_base = (char *)req; 2210 iov[0].iov_base = (char *)req;
@@ -2158,12 +2244,12 @@ qinf_exit:
2158} 2244}
2159 2245
2160int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, 2246int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
2161 u64 persistent_fid, u64 volatile_fid, 2247 u64 persistent_fid, u64 volatile_fid,
2162 struct smb2_file_full_ea_info *data) 2248 int ea_buf_size, struct smb2_file_full_ea_info *data)
2163{ 2249{
2164 return query_info(xid, tcon, persistent_fid, volatile_fid, 2250 return query_info(xid, tcon, persistent_fid, volatile_fid,
2165 FILE_FULL_EA_INFORMATION, SMB2_O_INFO_FILE, 0, 2251 FILE_FULL_EA_INFORMATION, SMB2_O_INFO_FILE, 0,
2166 SMB2_MAX_EA_BUF, 2252 ea_buf_size,
2167 sizeof(struct smb2_file_full_ea_info), 2253 sizeof(struct smb2_file_full_ea_info),
2168 (void **)&data, 2254 (void **)&data,
2169 NULL); 2255 NULL);
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index 393ed5f4e1b6..c2ec934be968 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -716,7 +716,7 @@ struct validate_negotiate_info_req {
716 __u8 Guid[SMB2_CLIENT_GUID_SIZE]; 716 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
717 __le16 SecurityMode; 717 __le16 SecurityMode;
718 __le16 DialectCount; 718 __le16 DialectCount;
719 __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */ 719 __le16 Dialects[3]; /* BB expand this if autonegotiate > 3 dialects */
720} __packed; 720} __packed;
721 721
722struct validate_negotiate_info_rsp { 722struct validate_negotiate_info_rsp {
@@ -832,7 +832,7 @@ struct smb2_flush_rsp {
832/* Channel field for read and write: exactly one of following flags can be set*/ 832/* Channel field for read and write: exactly one of following flags can be set*/
833#define SMB2_CHANNEL_NONE 0x00000000 833#define SMB2_CHANNEL_NONE 0x00000000
834#define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */ 834#define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */
835#define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */ 835#define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000002 /* SMB3.02 or later */
836 836
837/* SMB2 read request without RFC1001 length at the beginning */ 837/* SMB2 read request without RFC1001 length at the beginning */
838struct smb2_read_plain_req { 838struct smb2_read_plain_req {
@@ -1178,7 +1178,8 @@ struct smb2_file_link_info { /* encoding of request for level 11 */
1178 char FileName[0]; /* Name to be assigned to new link */ 1178 char FileName[0]; /* Name to be assigned to new link */
1179} __packed; /* level 11 Set */ 1179} __packed; /* level 11 Set */
1180 1180
1181#define SMB2_MAX_EA_BUF 2048 1181#define SMB2_MIN_EA_BUF 2048
1182#define SMB2_MAX_EA_BUF 65536
1182 1183
1183struct smb2_file_full_ea_info { /* encoding of response for level 15 */ 1184struct smb2_file_full_ea_info { /* encoding of response for level 15 */
1184 __le32 next_entry_offset; 1185 __le32 next_entry_offset;
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
index 003217099ef3..e9ab5227e7a8 100644
--- a/fs/cifs/smb2proto.h
+++ b/fs/cifs/smb2proto.h
@@ -134,6 +134,7 @@ extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
134 u64 persistent_file_id, u64 volatile_file_id); 134 u64 persistent_file_id, u64 volatile_file_id);
135extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, 135extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
136 u64 persistent_file_id, u64 volatile_file_id, 136 u64 persistent_file_id, u64 volatile_file_id,
137 int ea_buf_size,
137 struct smb2_file_full_ea_info *data); 138 struct smb2_file_full_ea_info *data);
138extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon, 139extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
139 u64 persistent_file_id, u64 volatile_file_id, 140 u64 persistent_file_id, u64 volatile_file_id,
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index 67367cf1f8cd..99493946e2f9 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -390,6 +390,7 @@ generate_smb30signingkey(struct cifs_ses *ses)
390 return generate_smb3signingkey(ses, &triplet); 390 return generate_smb3signingkey(ses, &triplet);
391} 391}
392 392
393#ifdef CONFIG_CIFS_SMB311
393int 394int
394generate_smb311signingkey(struct cifs_ses *ses) 395generate_smb311signingkey(struct cifs_ses *ses)
395 396
@@ -398,25 +399,26 @@ generate_smb311signingkey(struct cifs_ses *ses)
398 struct derivation *d; 399 struct derivation *d;
399 400
400 d = &triplet.signing; 401 d = &triplet.signing;
401 d->label.iov_base = "SMB2AESCMAC"; 402 d->label.iov_base = "SMBSigningKey";
402 d->label.iov_len = 12; 403 d->label.iov_len = 14;
403 d->context.iov_base = "SmbSign"; 404 d->context.iov_base = ses->preauth_sha_hash;
404 d->context.iov_len = 8; 405 d->context.iov_len = 64;
405 406
406 d = &triplet.encryption; 407 d = &triplet.encryption;
407 d->label.iov_base = "SMB2AESCCM"; 408 d->label.iov_base = "SMBC2SCipherKey";
408 d->label.iov_len = 11; 409 d->label.iov_len = 16;
409 d->context.iov_base = "ServerIn "; 410 d->context.iov_base = ses->preauth_sha_hash;
410 d->context.iov_len = 10; 411 d->context.iov_len = 64;
411 412
412 d = &triplet.decryption; 413 d = &triplet.decryption;
413 d->label.iov_base = "SMB2AESCCM"; 414 d->label.iov_base = "SMBS2CCipherKey";
414 d->label.iov_len = 11; 415 d->label.iov_len = 16;
415 d->context.iov_base = "ServerOut"; 416 d->context.iov_base = ses->preauth_sha_hash;
416 d->context.iov_len = 10; 417 d->context.iov_len = 64;
417 418
418 return generate_smb3signingkey(ses, &triplet); 419 return generate_smb3signingkey(ses, &triplet);
419} 420}
421#endif /* 311 */
420 422
421int 423int
422smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) 424smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
diff --git a/fs/coda/cache.c b/fs/coda/cache.c
index 5bb630a769e0..201fc08a8b4f 100644
--- a/fs/coda/cache.c
+++ b/fs/coda/cache.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Cache operations for Coda. 3 * Cache operations for Coda.
3 * For Linux 2.1: (C) 1997 Carnegie Mellon University 4 * For Linux 2.1: (C) 1997 Carnegie Mellon University
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index f13e09057c6b..845b5a66952a 100644
--- a/fs/coda/cnode.c
+++ b/fs/coda/cnode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* cnode related routines for the coda kernel code 2/* cnode related routines for the coda kernel code
2 (C) 1996 Peter Braam 3 (C) 1996 Peter Braam
3 */ 4 */
diff --git a/fs/coda/coda_cache.h b/fs/coda/coda_cache.h
index c910b5eb1ceb..c9f7a77c013e 100644
--- a/fs/coda/coda_cache.h
+++ b/fs/coda/coda_cache.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* Coda filesystem -- Linux Minicache 2/* Coda filesystem -- Linux Minicache
2 * 3 *
3 * Copyright (C) 1989 - 1997 Carnegie Mellon University 4 * Copyright (C) 1989 - 1997 Carnegie Mellon University
diff --git a/fs/coda/coda_fs_i.h b/fs/coda/coda_fs_i.h
index c64075213218..d702ba1a2bf9 100644
--- a/fs/coda/coda_fs_i.h
+++ b/fs/coda/coda_fs_i.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * coda_fs_i.h 3 * coda_fs_i.h
3 * 4 *
diff --git a/fs/coda/coda_int.h b/fs/coda/coda_int.h
index 381c993b1427..bb0b3e0ed6c2 100644
--- a/fs/coda/coda_int.h
+++ b/fs/coda/coda_int.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _CODA_INT_ 2#ifndef _CODA_INT_
2#define _CODA_INT_ 3#define _CODA_INT_
3 4
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index f1714cfb589c..ca599df0dcb1 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Inode operations for Coda filesystem 3 * Inode operations for Coda filesystem
3 * Original version: (C) 1996 P. Braam and M. Callahan 4 * Original version: (C) 1996 P. Braam and M. Callahan
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index d3c361883c28..126155cadfa9 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Coda File System, Linux Kernel module 3 * Coda File System, Linux Kernel module
3 * 4 *
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 274ab5586dd0..00876ddadb43 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1 2
2/* 3/*
3 * Directory operations for Coda filesystem 4 * Directory operations for Coda filesystem
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 363402fcb3ed..1cbc1f2298ee 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * File operations for Coda. 3 * File operations for Coda.
3 * Original version: (C) 1996 Peter Braam 4 * Original version: (C) 1996 Peter Braam
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 6058df380cc0..6f0a6a4d5faa 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Super block/filesystem wide operations 3 * Super block/filesystem wide operations
3 * 4 *
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index b0b9cda41928..e0c17b7dccce 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Pioctl operations for Coda. 3 * Pioctl operations for Coda.
3 * Original version: (C) 1996 Peter Braam 4 * Original version: (C) 1996 Peter Braam
diff --git a/fs/coda/symlink.c b/fs/coda/symlink.c
index 03736e20d720..202297d156df 100644
--- a/fs/coda/symlink.c
+++ b/fs/coda/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Symlink inode operations for Coda filesystem 3 * Symlink inode operations for Coda filesystem
3 * Original version: (C) 1996 P. Braam and M. Callahan 4 * Original version: (C) 1996 P. Braam and M. Callahan
diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
index 34218a8a28cd..0301d45000a8 100644
--- a/fs/coda/sysctl.c
+++ b/fs/coda/sysctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Sysctl operations for Coda filesystem 3 * Sysctl operations for Coda filesystem
3 * Original version: (C) 1996 P. Braam and M. Callahan 4 * Original version: (C) 1996 P. Braam and M. Callahan
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index e82357c89979..a37f003530d7 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Mostly platform independent upcall operations to Venus: 3 * Mostly platform independent upcall operations to Venus:
3 * -- upcalls 4 * -- upcalls
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index d27b326d96f4..bd5d91e119ca 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls. 3 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 * 4 *
diff --git a/fs/coredump.c b/fs/coredump.c
index 0eec03696707..52c63d6c9143 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/slab.h> 2#include <linux/slab.h>
2#include <linux/file.h> 3#include <linux/file.h>
3#include <linux/fdtable.h> 4#include <linux/fdtable.h>
diff --git a/fs/cramfs/uncompress.c b/fs/cramfs/uncompress.c
index ec4f1d4fdad0..975d98fc26b5 100644
--- a/fs/cramfs/uncompress.c
+++ b/fs/cramfs/uncompress.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * uncompress.c 3 * uncompress.c
3 * 4 *
diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c
index 483784d5eb73..0d5e6a569d58 100644
--- a/fs/crypto/bio.c
+++ b/fs/crypto/bio.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This contains encryption functions for per-file encryption. 3 * This contains encryption functions for per-file encryption.
3 * 4 *
diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
index ad9f814fdead..8606da1df0aa 100644
--- a/fs/crypto/fname.c
+++ b/fs/crypto/fname.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This contains functions for filename crypto management 3 * This contains functions for filename crypto management
3 * 4 *
diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h
index a1d5021c31ef..092e9dad1414 100644
--- a/fs/crypto/fscrypt_private.h
+++ b/fs/crypto/fscrypt_private.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * fscrypt_private.h 3 * fscrypt_private.h
3 * 4 *
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 018c588c7ac3..a38630214058 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * key management facility for FS encryption support. 3 * key management facility for FS encryption support.
3 * 4 *
@@ -109,6 +110,11 @@ static int validate_user_key(struct fscrypt_info *crypt_info,
109 goto out; 110 goto out;
110 } 111 }
111 ukp = user_key_payload_locked(keyring_key); 112 ukp = user_key_payload_locked(keyring_key);
113 if (!ukp) {
114 /* key was revoked before we acquired its semaphore */
115 res = -EKEYREVOKED;
116 goto out;
117 }
112 if (ukp->datalen != sizeof(struct fscrypt_key)) { 118 if (ukp->datalen != sizeof(struct fscrypt_key)) {
113 res = -EINVAL; 119 res = -EINVAL;
114 goto out; 120 goto out;
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index ce07a86200f3..a120649beeca 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Encryption policy functions for per-file encryption support. 3 * Encryption policy functions for per-file encryption support.
3 * 4 *
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 5fa2211e49ae..b53e66d9abd7 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -45,6 +45,12 @@
45#define DIO_PAGES 64 45#define DIO_PAGES 64
46 46
47/* 47/*
48 * Flags for dio_complete()
49 */
50#define DIO_COMPLETE_ASYNC 0x01 /* This is async IO */
51#define DIO_COMPLETE_INVALIDATE 0x02 /* Can invalidate pages */
52
53/*
48 * This code generally works in units of "dio_blocks". A dio_block is 54 * This code generally works in units of "dio_blocks". A dio_block is
49 * somewhere between the hard sector size and the filesystem block size. it 55 * somewhere between the hard sector size and the filesystem block size. it
50 * is determined on a per-invocation basis. When talking to the filesystem 56 * is determined on a per-invocation basis. When talking to the filesystem
@@ -225,10 +231,11 @@ static inline struct page *dio_get_page(struct dio *dio,
225 * filesystems can use it to hold additional state between get_block calls and 231 * filesystems can use it to hold additional state between get_block calls and
226 * dio_complete. 232 * dio_complete.
227 */ 233 */
228static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async) 234static ssize_t dio_complete(struct dio *dio, ssize_t ret, unsigned int flags)
229{ 235{
230 loff_t offset = dio->iocb->ki_pos; 236 loff_t offset = dio->iocb->ki_pos;
231 ssize_t transferred = 0; 237 ssize_t transferred = 0;
238 int err;
232 239
233 /* 240 /*
234 * AIO submission can race with bio completion to get here while 241 * AIO submission can race with bio completion to get here while
@@ -259,18 +266,37 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
259 ret = transferred; 266 ret = transferred;
260 267
261 if (dio->end_io) { 268 if (dio->end_io) {
262 int err;
263
264 // XXX: ki_pos?? 269 // XXX: ki_pos??
265 err = dio->end_io(dio->iocb, offset, ret, dio->private); 270 err = dio->end_io(dio->iocb, offset, ret, dio->private);
266 if (err) 271 if (err)
267 ret = err; 272 ret = err;
268 } 273 }
269 274
275 /*
276 * Try again to invalidate clean pages which might have been cached by
277 * non-direct readahead, or faulted in by get_user_pages() if the source
278 * of the write was an mmap'ed region of the file we're writing. Either
279 * one is a pretty crazy thing to do, so we don't support it 100%. If
280 * this invalidation fails, tough, the write still worked...
281 *
282 * And this page cache invalidation has to be after dio->end_io(), as
283 * some filesystems convert unwritten extents to real allocations in
284 * end_io() when necessary, otherwise a racing buffer read would cache
285 * zeros from unwritten extents.
286 */
287 if (flags & DIO_COMPLETE_INVALIDATE &&
288 ret > 0 && dio->op == REQ_OP_WRITE &&
289 dio->inode->i_mapping->nrpages) {
290 err = invalidate_inode_pages2_range(dio->inode->i_mapping,
291 offset >> PAGE_SHIFT,
292 (offset + ret - 1) >> PAGE_SHIFT);
293 WARN_ON_ONCE(err);
294 }
295
270 if (!(dio->flags & DIO_SKIP_DIO_COUNT)) 296 if (!(dio->flags & DIO_SKIP_DIO_COUNT))
271 inode_dio_end(dio->inode); 297 inode_dio_end(dio->inode);
272 298
273 if (is_async) { 299 if (flags & DIO_COMPLETE_ASYNC) {
274 /* 300 /*
275 * generic_write_sync expects ki_pos to have been updated 301 * generic_write_sync expects ki_pos to have been updated
276 * already, but the submission path only does this for 302 * already, but the submission path only does this for
@@ -291,7 +317,7 @@ static void dio_aio_complete_work(struct work_struct *work)
291{ 317{
292 struct dio *dio = container_of(work, struct dio, complete_work); 318 struct dio *dio = container_of(work, struct dio, complete_work);
293 319
294 dio_complete(dio, 0, true); 320 dio_complete(dio, 0, DIO_COMPLETE_ASYNC | DIO_COMPLETE_INVALIDATE);
295} 321}
296 322
297static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio); 323static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio);
@@ -304,6 +330,7 @@ static void dio_bio_end_aio(struct bio *bio)
304 struct dio *dio = bio->bi_private; 330 struct dio *dio = bio->bi_private;
305 unsigned long remaining; 331 unsigned long remaining;
306 unsigned long flags; 332 unsigned long flags;
333 bool defer_completion = false;
307 334
308 /* cleanup the bio */ 335 /* cleanup the bio */
309 dio_bio_complete(dio, bio); 336 dio_bio_complete(dio, bio);
@@ -315,12 +342,24 @@ static void dio_bio_end_aio(struct bio *bio)
315 spin_unlock_irqrestore(&dio->bio_lock, flags); 342 spin_unlock_irqrestore(&dio->bio_lock, flags);
316 343
317 if (remaining == 0) { 344 if (remaining == 0) {
318 if (dio->result && dio->defer_completion) { 345 /*
346 * Defer completion when defer_completion is set or
347 * when the inode has pages mapped and this is AIO write.
348 * We need to invalidate those pages because there is a
349 * chance they contain stale data in the case buffered IO
350 * went in between AIO submission and completion into the
351 * same region.
352 */
353 if (dio->result)
354 defer_completion = dio->defer_completion ||
355 (dio->op == REQ_OP_WRITE &&
356 dio->inode->i_mapping->nrpages);
357 if (defer_completion) {
319 INIT_WORK(&dio->complete_work, dio_aio_complete_work); 358 INIT_WORK(&dio->complete_work, dio_aio_complete_work);
320 queue_work(dio->inode->i_sb->s_dio_done_wq, 359 queue_work(dio->inode->i_sb->s_dio_done_wq,
321 &dio->complete_work); 360 &dio->complete_work);
322 } else { 361 } else {
323 dio_complete(dio, 0, true); 362 dio_complete(dio, 0, DIO_COMPLETE_ASYNC);
324 } 363 }
325 } 364 }
326} 365}
@@ -838,7 +877,8 @@ out:
838 */ 877 */
839 if (sdio->boundary) { 878 if (sdio->boundary) {
840 ret = dio_send_cur_page(dio, sdio, map_bh); 879 ret = dio_send_cur_page(dio, sdio, map_bh);
841 dio_bio_submit(dio, sdio); 880 if (sdio->bio)
881 dio_bio_submit(dio, sdio);
842 put_page(sdio->cur_page); 882 put_page(sdio->cur_page);
843 sdio->cur_page = NULL; 883 sdio->cur_page = NULL;
844 } 884 }
@@ -1210,10 +1250,19 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
1210 * For AIO O_(D)SYNC writes we need to defer completions to a workqueue 1250 * For AIO O_(D)SYNC writes we need to defer completions to a workqueue
1211 * so that we can call ->fsync. 1251 * so that we can call ->fsync.
1212 */ 1252 */
1213 if (dio->is_async && iov_iter_rw(iter) == WRITE && 1253 if (dio->is_async && iov_iter_rw(iter) == WRITE) {
1214 ((iocb->ki_filp->f_flags & O_DSYNC) || 1254 retval = 0;
1215 IS_SYNC(iocb->ki_filp->f_mapping->host))) { 1255 if ((iocb->ki_filp->f_flags & O_DSYNC) ||
1216 retval = dio_set_defer_completion(dio); 1256 IS_SYNC(iocb->ki_filp->f_mapping->host))
1257 retval = dio_set_defer_completion(dio);
1258 else if (!dio->inode->i_sb->s_dio_done_wq) {
1259 /*
1260 * In case of AIO write racing with buffered read we
1261 * need to defer completion. We can't decide this now,
1262 * however the workqueue needs to be initialized here.
1263 */
1264 retval = sb_init_dio_done_wq(dio->inode->i_sb);
1265 }
1217 if (retval) { 1266 if (retval) {
1218 /* 1267 /*
1219 * We grab i_mutex only for reads so we don't have 1268 * We grab i_mutex only for reads so we don't have
@@ -1322,7 +1371,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
1322 dio_await_completion(dio); 1371 dio_await_completion(dio);
1323 1372
1324 if (drop_refcount(dio) == 0) { 1373 if (drop_refcount(dio) == 0) {
1325 retval = dio_complete(dio, retval, false); 1374 retval = dio_complete(dio, retval, DIO_COMPLETE_INVALIDATE);
1326 } else 1375 } else
1327 BUG_ON(retval != -EIOCBQUEUED); 1376 BUG_ON(retval != -EIOCBQUEUED);
1328 1377
diff --git a/fs/dlm/Makefile b/fs/dlm/Makefile
index ca1c9124c8ce..3545fdafc6fb 100644
--- a/fs/dlm/Makefile
+++ b/fs/dlm/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_DLM) += dlm.o 2obj-$(CONFIG_DLM) += dlm.o
2dlm-y := ast.o \ 3dlm-y := ast.o \
3 config.o \ 4 config.o \
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d72d52b90433..82377017130f 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Implement the manual drop-all-pagecache function 3 * Implement the manual drop-all-pagecache function
3 */ 4 */
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 9c351bf757b2..3fbc0ff79699 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -84,11 +84,16 @@ struct ecryptfs_page_crypt_context {
84static inline struct ecryptfs_auth_tok * 84static inline struct ecryptfs_auth_tok *
85ecryptfs_get_encrypted_key_payload_data(struct key *key) 85ecryptfs_get_encrypted_key_payload_data(struct key *key)
86{ 86{
87 if (key->type == &key_type_encrypted) 87 struct encrypted_key_payload *payload;
88 return (struct ecryptfs_auth_tok *) 88
89 (&((struct encrypted_key_payload *)key->payload.data[0])->payload_data); 89 if (key->type != &key_type_encrypted)
90 else
91 return NULL; 90 return NULL;
91
92 payload = key->payload.data[0];
93 if (!payload)
94 return ERR_PTR(-EKEYREVOKED);
95
96 return (struct ecryptfs_auth_tok *)payload->payload_data;
92} 97}
93 98
94static inline struct key *ecryptfs_get_encrypted_key(char *sig) 99static inline struct key *ecryptfs_get_encrypted_key(char *sig)
@@ -114,12 +119,17 @@ static inline struct ecryptfs_auth_tok *
114ecryptfs_get_key_payload_data(struct key *key) 119ecryptfs_get_key_payload_data(struct key *key)
115{ 120{
116 struct ecryptfs_auth_tok *auth_tok; 121 struct ecryptfs_auth_tok *auth_tok;
122 struct user_key_payload *ukp;
117 123
118 auth_tok = ecryptfs_get_encrypted_key_payload_data(key); 124 auth_tok = ecryptfs_get_encrypted_key_payload_data(key);
119 if (!auth_tok) 125 if (auth_tok)
120 return (struct ecryptfs_auth_tok *)user_key_payload_locked(key)->data;
121 else
122 return auth_tok; 126 return auth_tok;
127
128 ukp = user_key_payload_locked(key);
129 if (!ukp)
130 return ERR_PTR(-EKEYREVOKED);
131
132 return (struct ecryptfs_auth_tok *)ukp->data;
123} 133}
124 134
125#define ECRYPTFS_MAX_KEYSET_SIZE 1024 135#define ECRYPTFS_MAX_KEYSET_SIZE 1024
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 3cf1546dca82..fa218cd64f74 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -459,7 +459,8 @@ out:
459 * @auth_tok_key: key containing the authentication token 459 * @auth_tok_key: key containing the authentication token
460 * @auth_tok: authentication token 460 * @auth_tok: authentication token
461 * 461 *
462 * Returns zero on valid auth tok; -EINVAL otherwise 462 * Returns zero on valid auth tok; -EINVAL if the payload is invalid; or
463 * -EKEYREVOKED if the key was revoked before we acquired its semaphore.
463 */ 464 */
464static int 465static int
465ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key, 466ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
@@ -468,6 +469,12 @@ ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
468 int rc = 0; 469 int rc = 0;
469 470
470 (*auth_tok) = ecryptfs_get_key_payload_data(auth_tok_key); 471 (*auth_tok) = ecryptfs_get_key_payload_data(auth_tok_key);
472 if (IS_ERR(*auth_tok)) {
473 rc = PTR_ERR(*auth_tok);
474 *auth_tok = NULL;
475 goto out;
476 }
477
471 if (ecryptfs_verify_version((*auth_tok)->version)) { 478 if (ecryptfs_verify_version((*auth_tok)->version)) {
472 printk(KERN_ERR "Data structure version mismatch. Userspace " 479 printk(KERN_ERR "Data structure version mismatch. Userspace "
473 "tools must match eCryptfs kernel module with major " 480 "tools must match eCryptfs kernel module with major "
diff --git a/fs/efs/dir.c b/fs/efs/dir.c
index a7be96e5f1cb..f892ac7c2a35 100644
--- a/fs/efs/dir.c
+++ b/fs/efs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * dir.c 3 * dir.c
3 * 4 *
diff --git a/fs/efs/efs.h b/fs/efs/efs.h
index 70f5d4f9a945..13a4d9622633 100644
--- a/fs/efs/efs.h
+++ b/fs/efs/efs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (c) 1999 Al Smith 3 * Copyright (c) 1999 Al Smith
3 * 4 *
diff --git a/fs/efs/file.c b/fs/efs/file.c
index a37dcee46866..9e641da6fab2 100644
--- a/fs/efs/file.c
+++ b/fs/efs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * file.c 3 * file.c
3 * 4 *
diff --git a/fs/efs/namei.c b/fs/efs/namei.c
index d34a40edcdb2..38961ee1d1af 100644
--- a/fs/efs/namei.c
+++ b/fs/efs/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * namei.c 3 * namei.c
3 * 4 *
diff --git a/fs/efs/super.c b/fs/efs/super.c
index 5c42f1e34a2f..65b59009555b 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * super.c 3 * super.c
3 * 4 *
diff --git a/fs/efs/symlink.c b/fs/efs/symlink.c
index 4870cc82deb0..923eb91654d5 100644
--- a/fs/efs/symlink.c
+++ b/fs/efs/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * symlink.c 3 * symlink.c
3 * 4 *
diff --git a/fs/exec.c b/fs/exec.c
index ac34d9724684..3e14ba25f678 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1410,7 +1410,7 @@ static void free_bprm(struct linux_binprm *bprm)
1410 kfree(bprm); 1410 kfree(bprm);
1411} 1411}
1412 1412
1413int bprm_change_interp(char *interp, struct linux_binprm *bprm) 1413int bprm_change_interp(const char *interp, struct linux_binprm *bprm)
1414{ 1414{
1415 /* If a binfmt changed the interp, free it first. */ 1415 /* If a binfmt changed the interp, free it first. */
1416 if (bprm->interp != bprm->filename) 1416 if (bprm->interp != bprm->filename)
@@ -1802,6 +1802,7 @@ static int do_execveat_common(int fd, struct filename *filename,
1802 /* execve succeeded */ 1802 /* execve succeeded */
1803 current->fs->in_exec = 0; 1803 current->fs->in_exec = 0;
1804 current->in_execve = 0; 1804 current->in_execve = 0;
1805 membarrier_execve(current);
1805 acct_update_integrals(current); 1806 acct_update_integrals(current);
1806 task_numa_free(current); 1807 task_numa_free(current);
1807 free_bprm(bprm); 1808 free_bprm(bprm);
diff --git a/fs/ext2/Makefile b/fs/ext2/Makefile
index 445b0e996a12..311479d864a7 100644
--- a/fs/ext2/Makefile
+++ b/fs/ext2/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the linux ext2-filesystem routines. 3# Makefile for the linux ext2-filesystem routines.
3# 4#
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 51f0aea70cb4..224c04abb2e5 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/acl.c 3 * linux/fs/ext2/acl.c
3 * 4 *
diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
index 44937f9fcf32..0f01c759daac 100644
--- a/fs/ext2/acl.h
+++ b/fs/ext2/acl.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 File: fs/ext2/acl.h 3 File: fs/ext2/acl.h
3 4
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index d0bdb74f0e15..e1b3724bebf2 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/balloc.c 3 * linux/fs/ext2/balloc.c
3 * 4 *
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index e2709695b177..987647986f47 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/dir.c 3 * linux/fs/ext2/dir.c
3 * 4 *
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 28de3edd4f4d..032295e1d386 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (C) 1992, 1993, 1994, 1995 3 * Copyright (C) 1992, 1993, 1994, 1995
3 * Remy Card (card@masi.ibp.fr) 4 * Remy Card (card@masi.ibp.fr)
diff --git a/fs/ext2/file.c b/fs/ext2/file.c
index ff3a3636a5ca..c67b486488fd 100644
--- a/fs/ext2/file.c
+++ b/fs/ext2/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/file.c 3 * linux/fs/ext2/file.c
3 * 4 *
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index 395fc074c0db..a1fc3dabca41 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/ialloc.c 3 * linux/fs/ext2/ialloc.c
3 * 4 *
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 4dca6f348714..1442a4c734c8 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/inode.c 3 * linux/fs/ext2/inode.c
3 * 4 *
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 087f122cca42..0367c0039e68 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/ioctl.c 3 * linux/fs/ext2/ioctl.c
3 * 4 *
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 814e405a2da6..e078075dc66f 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/namei.c 3 * linux/fs/ext2/namei.c
3 * 4 *
diff --git a/fs/ext2/symlink.c b/fs/ext2/symlink.c
index eeffb0138a17..d5589ddcc281 100644
--- a/fs/ext2/symlink.c
+++ b/fs/ext2/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/symlink.c 3 * linux/fs/ext2/symlink.c
3 * 4 *
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 1b9b1268d418..62d9a659a8ff 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/xattr.c 3 * linux/fs/ext2/xattr.c
3 * 4 *
diff --git a/fs/ext2/xattr.h b/fs/ext2/xattr.h
index 6f82ab1b00ca..cee888cdc235 100644
--- a/fs/ext2/xattr.h
+++ b/fs/ext2/xattr.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 File: linux/ext2_xattr.h 3 File: linux/ext2_xattr.h
3 4
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c
index 7b9e9c1842d5..9a682e440acb 100644
--- a/fs/ext2/xattr_security.c
+++ b/fs/ext2/xattr_security.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/xattr_security.c 3 * linux/fs/ext2/xattr_security.c
3 * Handler for storing security labels as extended attributes. 4 * Handler for storing security labels as extended attributes.
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c
index 65049b71af13..49add1107850 100644
--- a/fs/ext2/xattr_trusted.c
+++ b/fs/ext2/xattr_trusted.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/xattr_trusted.c 3 * linux/fs/ext2/xattr_trusted.c
3 * Handler for trusted extended attributes. 4 * Handler for trusted extended attributes.
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c
index fb2f992ae763..c243a3b4d69d 100644
--- a/fs/ext2/xattr_user.c
+++ b/fs/ext2/xattr_user.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext2/xattr_user.c 3 * linux/fs/ext2/xattr_user.c
3 * Handler for extended user attributes. 4 * Handler for extended user attributes.
diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile
index d9beca1653c5..8fdfcd3c3e04 100644
--- a/fs/ext4/Makefile
+++ b/fs/ext4/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the linux ext4-filesystem routines. 3# Makefile for the linux ext4-filesystem routines.
3# 4#
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 46ff2229ff5e..fb50f9aa6ead 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/acl.c 3 * linux/fs/ext4/acl.c
3 * 4 *
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
index da2c79577d72..a48fc5ae2701 100644
--- a/fs/ext4/acl.h
+++ b/fs/ext4/acl.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 File: fs/ext4/acl.h 3 File: fs/ext4/acl.h
3 4
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index e04ec868e37e..d5ddfb96c83c 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/balloc.c 3 * linux/fs/ext4/balloc.c
3 * 4 *
diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
index 4a606afb171f..f63e028c638c 100644
--- a/fs/ext4/bitmap.c
+++ b/fs/ext4/bitmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/bitmap.c 3 * linux/fs/ext4/bitmap.c
3 * 4 *
diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index fdb19543af1e..bee888e0e2db 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/block_validity.c 3 * linux/fs/ext4/block_validity.c
3 * 4 *
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index b04e882179c6..d5babc9f222b 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/dir.c 3 * linux/fs/ext4/dir.c
3 * 4 *
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index e2abe01c8c6b..58a0304566db 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * ext4.h 3 * ext4.h
3 * 4 *
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index 5b342ac67d2e..2d593201cf7a 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Interface between ext4 and JBD 3 * Interface between ext4 and JBD
3 */ 4 */
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index e7f12a204cbc..763ef185dd17 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/ext4/extents_status.c 3 * fs/ext4/extents_status.c
3 * 4 *
diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h
index f7aa24f4642d..ca90fc96f47e 100644
--- a/fs/ext4/extents_status.h
+++ b/fs/ext4/extents_status.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * fs/ext4/extents_status.h 3 * fs/ext4/extents_status.h
3 * 4 *
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index b1da660ac3bc..5cb9aa3ad249 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/file.c 3 * linux/fs/ext4/file.c
3 * 4 *
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index f9230580a84b..26a7fe5c4fd3 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/fsync.c 3 * linux/fs/ext4/fsync.c
3 * 4 *
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index ee823022aa34..c5f697a3fad4 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/ialloc.c 3 * linux/fs/ext4/ialloc.c
3 * 4 *
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 7ffa290cbb8e..c32802c956d5 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/indirect.c 3 * linux/fs/ext4/indirect.c
3 * 4 *
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 31db875bc7a1..90afeb7293a6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/inode.c 3 * linux/fs/ext4/inode.c
3 * 4 *
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index afb66d4ab5cf..75d83471f65c 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/ioctl.c 3 * linux/fs/ext4/ioctl.c
3 * 4 *
diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h
index 009300ee1561..dcf52540f379 100644
--- a/fs/ext4/mballoc.h
+++ b/fs/ext4/mballoc.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * fs/ext4/mballoc.h 3 * fs/ext4/mballoc.h
3 * 4 *
diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index 84c54f15f1dd..27b9a76a0dfa 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/random.h> 3#include <linux/random.h>
3#include <linux/buffer_head.h> 4#include <linux/buffer_head.h>
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index c1cf020d1889..bd48a8d83961 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/namei.c 3 * linux/fs/ext4/namei.c
3 * 4 *
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 55ad7dd149d0..db7590178dfc 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/page-io.c 3 * linux/fs/ext4/page-io.c
3 * 4 *
diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
index 04c90643af7a..9ffa6fad18db 100644
--- a/fs/ext4/readpage.c
+++ b/fs/ext4/readpage.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/readpage.c 3 * linux/fs/ext4/readpage.c
3 * 4 *
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 035cd3f4785e..1dac59c24792 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/resize.c 3 * linux/fs/ext4/resize.c
3 * 4 *
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b104096fce9e..b0915b734a38 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1677,7 +1677,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1677 sbi->s_mount_flags |= EXT4_MF_FS_ABORTED; 1677 sbi->s_mount_flags |= EXT4_MF_FS_ABORTED;
1678 return 1; 1678 return 1;
1679 case Opt_i_version: 1679 case Opt_i_version:
1680 sb->s_flags |= MS_I_VERSION; 1680 sb->s_flags |= SB_I_VERSION;
1681 return 1; 1681 return 1;
1682 case Opt_lazytime: 1682 case Opt_lazytime:
1683 sb->s_flags |= MS_LAZYTIME; 1683 sb->s_flags |= MS_LAZYTIME;
@@ -2060,7 +2060,7 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
2060 SEQ_OPTS_PRINT("min_batch_time=%u", sbi->s_min_batch_time); 2060 SEQ_OPTS_PRINT("min_batch_time=%u", sbi->s_min_batch_time);
2061 if (nodefs || sbi->s_max_batch_time != EXT4_DEF_MAX_BATCH_TIME) 2061 if (nodefs || sbi->s_max_batch_time != EXT4_DEF_MAX_BATCH_TIME)
2062 SEQ_OPTS_PRINT("max_batch_time=%u", sbi->s_max_batch_time); 2062 SEQ_OPTS_PRINT("max_batch_time=%u", sbi->s_max_batch_time);
2063 if (sb->s_flags & MS_I_VERSION) 2063 if (sb->s_flags & SB_I_VERSION)
2064 SEQ_OPTS_PUTS("i_version"); 2064 SEQ_OPTS_PUTS("i_version");
2065 if (nodefs || sbi->s_stripe) 2065 if (nodefs || sbi->s_stripe)
2066 SEQ_OPTS_PRINT("stripe=%lu", sbi->s_stripe); 2066 SEQ_OPTS_PRINT("stripe=%lu", sbi->s_stripe);
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
index 5c8fc53cb0e5..a2006c9af1d9 100644
--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/symlink.c 3 * linux/fs/ext4/symlink.c
3 * 4 *
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 48c7a7d55ed3..e21afd52e7d7 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/sysfs.c 3 * linux/fs/ext4/sysfs.c
3 * 4 *
diff --git a/fs/ext4/truncate.h b/fs/ext4/truncate.h
index c70d06a383e2..b64a9fa0ff41 100644
--- a/fs/ext4/truncate.h
+++ b/fs/ext4/truncate.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/ext4/truncate.h 3 * linux/fs/ext4/truncate.h
3 * 4 *
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 3b69330a4250..218a7ba57819 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/xattr.c 3 * linux/fs/ext4/xattr.c
3 * 4 *
diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h
index 0d2dde1fa87a..f8cc07588ac9 100644
--- a/fs/ext4/xattr.h
+++ b/fs/ext4/xattr.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 File: fs/ext4/xattr.h 3 File: fs/ext4/xattr.h
3 4
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c
index a8921112030d..629001b28632 100644
--- a/fs/ext4/xattr_security.c
+++ b/fs/ext4/xattr_security.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/xattr_security.c 3 * linux/fs/ext4/xattr_security.c
3 * Handler for storing security labels as extended attributes. 4 * Handler for storing security labels as extended attributes.
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c
index c7765c735714..e9389e5d75c3 100644
--- a/fs/ext4/xattr_trusted.c
+++ b/fs/ext4/xattr_trusted.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/xattr_trusted.c 3 * linux/fs/ext4/xattr_trusted.c
3 * Handler for trusted extended attributes. 4 * Handler for trusted extended attributes.
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c
index ca20e423034b..d4546184b34b 100644
--- a/fs/ext4/xattr_user.c
+++ b/fs/ext4/xattr_user.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ext4/xattr_user.c 3 * linux/fs/ext4/xattr_user.c
3 * Handler for extended user attributes. 4 * Handler for extended user attributes.
diff --git a/fs/f2fs/Makefile b/fs/f2fs/Makefile
index a0dc559b1b47..776c4b936504 100644
--- a/fs/f2fs/Makefile
+++ b/fs/f2fs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_F2FS_FS) += f2fs.o 2obj-$(CONFIG_F2FS_FS) += f2fs.o
2 3
3f2fs-y := dir.o file.o inode.o namei.o hash.o super.o inline.o 4f2fs-y := dir.o file.o inode.o namei.o hash.o super.o inline.o
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9a7c90386947..4b4a72f392be 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2525,7 +2525,7 @@ void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr);
2525bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr); 2525bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr);
2526void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new); 2526void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new);
2527void stop_discard_thread(struct f2fs_sb_info *sbi); 2527void stop_discard_thread(struct f2fs_sb_info *sbi);
2528void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi); 2528void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi, bool umount);
2529void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc); 2529void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc);
2530void release_discard_addrs(struct f2fs_sb_info *sbi); 2530void release_discard_addrs(struct f2fs_sb_info *sbi);
2531int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra); 2531int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 621b9b3d320b..c695ff462ee6 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1210,11 +1210,11 @@ void stop_discard_thread(struct f2fs_sb_info *sbi)
1210} 1210}
1211 1211
1212/* This comes from f2fs_put_super and f2fs_trim_fs */ 1212/* This comes from f2fs_put_super and f2fs_trim_fs */
1213void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi) 1213void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi, bool umount)
1214{ 1214{
1215 __issue_discard_cmd(sbi, false); 1215 __issue_discard_cmd(sbi, false);
1216 __drop_discard_cmd(sbi); 1216 __drop_discard_cmd(sbi);
1217 __wait_discard_cmd(sbi, false); 1217 __wait_discard_cmd(sbi, !umount);
1218} 1218}
1219 1219
1220static void mark_discard_range_all(struct f2fs_sb_info *sbi) 1220static void mark_discard_range_all(struct f2fs_sb_info *sbi)
@@ -2244,7 +2244,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
2244 } 2244 }
2245 /* It's time to issue all the filed discards */ 2245 /* It's time to issue all the filed discards */
2246 mark_discard_range_all(sbi); 2246 mark_discard_range_all(sbi);
2247 f2fs_wait_discard_bios(sbi); 2247 f2fs_wait_discard_bios(sbi, false);
2248out: 2248out:
2249 range->len = F2FS_BLK_TO_BYTES(cpc.trimmed); 2249 range->len = F2FS_BLK_TO_BYTES(cpc.trimmed);
2250 return err; 2250 return err;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 89f61eb3d167..933c3d529e65 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -801,7 +801,7 @@ static void f2fs_put_super(struct super_block *sb)
801 } 801 }
802 802
803 /* be sure to wait for any on-going discard commands */ 803 /* be sure to wait for any on-going discard commands */
804 f2fs_wait_discard_bios(sbi); 804 f2fs_wait_discard_bios(sbi, true);
805 805
806 if (f2fs_discard_en(sbi) && !sbi->discard_blks) { 806 if (f2fs_discard_en(sbi) && !sbi->discard_blks) {
807 struct cp_control cpc = { 807 struct cp_control cpc = {
diff --git a/fs/fat/Makefile b/fs/fat/Makefile
index 964b634f6667..70645ce2f7fc 100644
--- a/fs/fat/Makefile
+++ b/fs/fat/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the Linux fat filesystem support. 3# Makefile for the Linux fat filesystem support.
3# 4#
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 5d384921524d..e9bed49df6b7 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/fat/cache.c 3 * linux/fs/fat/cache.c
3 * 4 *
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 051dac1ce3be..8fc1093da47d 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _FAT_H 2#ifndef _FAT_H
2#define _FAT_H 3#define _FAT_H
3 4
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 0491da3b28c3..8d78ffd7b399 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/fcntl.c 3 * linux/fs/fcntl.c
3 * 4 *
@@ -749,7 +750,7 @@ static void send_sigio_to_task(struct task_struct *p,
749 * specific si_codes. In that case use SI_SIGIO instead 750 * specific si_codes. In that case use SI_SIGIO instead
750 * to remove the ambiguity. 751 * to remove the ambiguity.
751 */ 752 */
752 if (sig_specific_sicodes(signum)) 753 if ((signum != SIGPOLL) && sig_specific_sicodes(signum))
753 si.si_code = SI_SIGIO; 754 si.si_code = SI_SIGIO;
754 755
755 /* Make sure we are called with one of the POLL_* 756 /* Make sure we are called with one of the POLL_*
diff --git a/fs/fhandle.c b/fs/fhandle.c
index 58a61f55e0d0..474adc8d2a3a 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/syscalls.h> 2#include <linux/syscalls.h>
2#include <linux/slab.h> 3#include <linux/slab.h>
3#include <linux/fs.h> 4#include <linux/fs.h>
diff --git a/fs/file.c b/fs/file.c
index 1fc7fbbb4510..4eecbf4244a5 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/file.c 3 * linux/fs/file.c
3 * 4 *
diff --git a/fs/filesystems.c b/fs/filesystems.c
index a920ad2629ac..f2728a4a03a1 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/filesystems.c 3 * linux/fs/filesystems.c
3 * 4 *
diff --git a/fs/fs_pin.c b/fs/fs_pin.c
index e747b3d720ee..0d285fd5b44a 100644
--- a/fs/fs_pin.c
+++ b/fs/fs_pin.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/sched.h> 3#include <linux/sched.h>
3#include <linux/slab.h> 4#include <linux/slab.h>
diff --git a/fs/fscache/Makefile b/fs/fscache/Makefile
index 6d561531cb36..79e08e05ef84 100644
--- a/fs/fscache/Makefile
+++ b/fs/fscache/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for general filesystem caching code 3# Makefile for general filesystem caching code
3# 4#
diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c
index b5ab06fabc60..0438d4cd91ef 100644
--- a/fs/fscache/object-list.c
+++ b/fs/fscache/object-list.c
@@ -331,6 +331,13 @@ static void fscache_objlist_config(struct fscache_objlist_data *data)
331 rcu_read_lock(); 331 rcu_read_lock();
332 332
333 confkey = user_key_payload_rcu(key); 333 confkey = user_key_payload_rcu(key);
334 if (!confkey) {
335 /* key was revoked */
336 rcu_read_unlock();
337 key_put(key);
338 goto no_config;
339 }
340
334 buf = confkey->data; 341 buf = confkey->data;
335 342
336 for (len = confkey->datalen - 1; len >= 0; len--) { 343 for (len = confkey->datalen - 1; len >= 0; len--) {
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 622081b97426..24967382a7b1 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1308,7 +1308,8 @@ static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file,
1308 */ 1308 */
1309 over = !dir_emit(ctx, dirent->name, dirent->namelen, 1309 over = !dir_emit(ctx, dirent->name, dirent->namelen,
1310 dirent->ino, dirent->type); 1310 dirent->ino, dirent->type);
1311 ctx->pos = dirent->off; 1311 if (!over)
1312 ctx->pos = dirent->off;
1312 } 1313 }
1313 1314
1314 buf += reclen; 1315 buf += reclen;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 65c88379a3a1..94a745acaef8 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1059,7 +1059,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
1059 if (sb->s_flags & MS_MANDLOCK) 1059 if (sb->s_flags & MS_MANDLOCK)
1060 goto err; 1060 goto err;
1061 1061
1062 sb->s_flags &= ~(MS_NOSEC | MS_I_VERSION); 1062 sb->s_flags &= ~(MS_NOSEC | SB_I_VERSION);
1063 1063
1064 if (!parse_fuse_opt(data, &d, is_bdev)) 1064 if (!parse_fuse_opt(data, &d, is_bdev))
1065 goto err; 1065 goto err;
diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile
index 86128202384f..41b2aa4bc3bf 100644
--- a/fs/gfs2/Makefile
+++ b/fs/gfs2/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1ccflags-y := -I$(src) 2ccflags-y := -I$(src)
2obj-$(CONFIG_GFS2_FS) += gfs2.o 3obj-$(CONFIG_GFS2_FS) += gfs2.o
3gfs2-y := acl.o bmap.o dir.o xattr.o glock.o \ 4gfs2-y := acl.o bmap.o dir.o xattr.o glock.o \
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 98e845b7841b..11066d8647d2 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1945,13 +1945,9 @@ static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos)
1945{ 1945{
1946 struct gfs2_glock_iter *gi = seq->private; 1946 struct gfs2_glock_iter *gi = seq->private;
1947 loff_t n = *pos; 1947 loff_t n = *pos;
1948 int ret;
1949
1950 if (gi->last_pos <= *pos)
1951 n = (*pos - gi->last_pos);
1952 1948
1953 ret = rhashtable_walk_start(&gi->hti); 1949 rhashtable_walk_enter(&gl_hash_table, &gi->hti);
1954 if (ret) 1950 if (rhashtable_walk_start(&gi->hti) != 0)
1955 return NULL; 1951 return NULL;
1956 1952
1957 do { 1953 do {
@@ -1959,6 +1955,7 @@ static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos)
1959 } while (gi->gl && n--); 1955 } while (gi->gl && n--);
1960 1956
1961 gi->last_pos = *pos; 1957 gi->last_pos = *pos;
1958
1962 return gi->gl; 1959 return gi->gl;
1963} 1960}
1964 1961
@@ -1970,6 +1967,7 @@ static void *gfs2_glock_seq_next(struct seq_file *seq, void *iter_ptr,
1970 (*pos)++; 1967 (*pos)++;
1971 gi->last_pos = *pos; 1968 gi->last_pos = *pos;
1972 gfs2_glock_iter_next(gi); 1969 gfs2_glock_iter_next(gi);
1970
1973 return gi->gl; 1971 return gi->gl;
1974} 1972}
1975 1973
@@ -1980,6 +1978,7 @@ static void gfs2_glock_seq_stop(struct seq_file *seq, void *iter_ptr)
1980 1978
1981 gi->gl = NULL; 1979 gi->gl = NULL;
1982 rhashtable_walk_stop(&gi->hti); 1980 rhashtable_walk_stop(&gi->hti);
1981 rhashtable_walk_exit(&gi->hti);
1983} 1982}
1984 1983
1985static int gfs2_glock_seq_show(struct seq_file *seq, void *iter_ptr) 1984static int gfs2_glock_seq_show(struct seq_file *seq, void *iter_ptr)
@@ -2042,12 +2041,10 @@ static int __gfs2_glocks_open(struct inode *inode, struct file *file,
2042 struct gfs2_glock_iter *gi = seq->private; 2041 struct gfs2_glock_iter *gi = seq->private;
2043 2042
2044 gi->sdp = inode->i_private; 2043 gi->sdp = inode->i_private;
2045 gi->last_pos = 0;
2046 seq->buf = kmalloc(GFS2_SEQ_GOODSIZE, GFP_KERNEL | __GFP_NOWARN); 2044 seq->buf = kmalloc(GFS2_SEQ_GOODSIZE, GFP_KERNEL | __GFP_NOWARN);
2047 if (seq->buf) 2045 if (seq->buf)
2048 seq->size = GFS2_SEQ_GOODSIZE; 2046 seq->size = GFS2_SEQ_GOODSIZE;
2049 gi->gl = NULL; 2047 gi->gl = NULL;
2050 rhashtable_walk_enter(&gl_hash_table, &gi->hti);
2051 } 2048 }
2052 return ret; 2049 return ret;
2053} 2050}
@@ -2063,7 +2060,6 @@ static int gfs2_glocks_release(struct inode *inode, struct file *file)
2063 struct gfs2_glock_iter *gi = seq->private; 2060 struct gfs2_glock_iter *gi = seq->private;
2064 2061
2065 gi->gl = NULL; 2062 gi->gl = NULL;
2066 rhashtable_walk_exit(&gi->hti);
2067 return seq_release_private(inode, file); 2063 return seq_release_private(inode, file);
2068} 2064}
2069 2065
diff --git a/fs/gfs2/trace_gfs2.h b/fs/gfs2/trace_gfs2.h
index 49ac55da4e33..2f159265693b 100644
--- a/fs/gfs2/trace_gfs2.h
+++ b/fs/gfs2/trace_gfs2.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#undef TRACE_SYSTEM 2#undef TRACE_SYSTEM
2#define TRACE_SYSTEM gfs2 3#define TRACE_SYSTEM gfs2
3 4
diff --git a/fs/hfs/attr.c b/fs/hfs/attr.c
index 0933600e11c8..74fa62643136 100644
--- a/fs/hfs/attr.c
+++ b/fs/hfs/attr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfs/attr.c 3 * linux/fs/hfs/attr.c
3 * 4 *
diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index de69d8a24f6d..4af318fbda77 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfs/bfind.c 3 * linux/fs/hfs/bfind.c
3 * 4 *
diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index d77d844b668b..8aec5e732abf 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfs/bnode.c 3 * linux/fs/hfs/bnode.c
3 * 4 *
diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 6fc766df0461..ad04a5741016 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfs/brec.c 3 * linux/fs/hfs/brec.c
3 * 4 *
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
index 37cdd955eceb..374b5688e29e 100644
--- a/fs/hfs/btree.c
+++ b/fs/hfs/btree.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfs/btree.c 3 * linux/fs/hfs/btree.c
3 * 4 *
diff --git a/fs/hfs/btree.h b/fs/hfs/btree.h
index f6bd266d70b5..c8b252dbb26c 100644
--- a/fs/hfs/btree.h
+++ b/fs/hfs/btree.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/hfs/btree.h 3 * linux/fs/hfs/btree.h
3 * 4 *
diff --git a/fs/hfsplus/Makefile b/fs/hfsplus/Makefile
index 683fca2e5e65..f6a56542f8d7 100644
--- a/fs/hfsplus/Makefile
+++ b/fs/hfsplus/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2## Makefile for the linux hfsplus filesystem routines. 3## Makefile for the linux hfsplus filesystem routines.
3# 4#
diff --git a/fs/hfsplus/acl.h b/fs/hfsplus/acl.h
index 95c8ed9ec17f..488c2b75cf41 100644
--- a/fs/hfsplus/acl.h
+++ b/fs/hfsplus/acl.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/hfsplus/acl.h 3 * linux/fs/hfsplus/acl.h
3 * 4 *
diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
index e5b221de7de6..2bab6b3cdba4 100644
--- a/fs/hfsplus/attributes.c
+++ b/fs/hfsplus/attributes.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/attributes.c 3 * linux/fs/hfsplus/attributes.c
3 * 4 *
diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index 528e38b5af7f..ca2ba8c9f82e 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/bfind.c 3 * linux/fs/hfsplus/bfind.c
3 * 4 *
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
index c0ae274c0a22..cebce0cfe340 100644
--- a/fs/hfsplus/bitmap.c
+++ b/fs/hfsplus/bitmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/bitmap.c 3 * linux/fs/hfsplus/bitmap.c
3 * 4 *
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index ce014ceb89ef..d77015c3f22c 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/bnode.c 3 * linux/fs/hfsplus/bnode.c
3 * 4 *
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 754fdf8c6356..808f4d8c859c 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/brec.c 3 * linux/fs/hfsplus/brec.c
3 * 4 *
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index d9d1a36ba826..de14b2b6881b 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/btree.c 3 * linux/fs/hfsplus/btree.c
3 * 4 *
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index a5e00f7a4c14..a196369ba779 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/catalog.c 3 * linux/fs/hfsplus/catalog.c
3 * 4 *
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 31d5e3f1fe17..e8120a282435 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/dir.c 3 * linux/fs/hfsplus/dir.c
3 * 4 *
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index a3eb640b4f8f..e8770935ce6d 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/extents.c 3 * linux/fs/hfsplus/extents.c
3 * 4 *
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index a3f03b247463..a015044daa05 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/include/linux/hfsplus_fs.h 3 * linux/include/linux/hfsplus_fs.h
3 * 4 *
diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h
index 8298d0985f81..456e87aec7fd 100644
--- a/fs/hfsplus/hfsplus_raw.h
+++ b/fs/hfsplus/hfsplus_raw.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/include/linux/hfsplus_raw.h 3 * linux/include/linux/hfsplus_raw.h
3 * 4 *
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 4f26b6877130..190c60efbc99 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/inode.c 3 * linux/fs/hfsplus/inode.c
3 * 4 *
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index 0a156d84e67d..5e6502ef7415 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/ioctl.c 3 * linux/fs/hfsplus/ioctl.c
3 * 4 *
diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
index bb806e58c977..047e05c57560 100644
--- a/fs/hfsplus/options.c
+++ b/fs/hfsplus/options.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/options.c 3 * linux/fs/hfsplus/options.c
3 * 4 *
diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c
index 6bb5d7c42888..066114dcc3a2 100644
--- a/fs/hfsplus/posix_acl.c
+++ b/fs/hfsplus/posix_acl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/posix_acl.c 3 * linux/fs/hfsplus/posix_acl.c
3 * 4 *
diff --git a/fs/hfsplus/tables.c b/fs/hfsplus/tables.c
index 1b911730a0c1..a5fb8ee7d019 100644
--- a/fs/hfsplus/tables.c
+++ b/fs/hfsplus/tables.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/tables.c 3 * linux/fs/hfsplus/tables.c
3 * 4 *
diff --git a/fs/hfsplus/unicode.c b/fs/hfsplus/unicode.c
index e563939882f3..dfa90c21948f 100644
--- a/fs/hfsplus/unicode.c
+++ b/fs/hfsplus/unicode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/unicode.c 3 * linux/fs/hfsplus/unicode.c
3 * 4 *
diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c
index 10032b919a85..08c1580bdf7a 100644
--- a/fs/hfsplus/wrapper.c
+++ b/fs/hfsplus/wrapper.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/wrapper.c 3 * linux/fs/hfsplus/wrapper.c
3 * 4 *
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index d37bb88dc746..e538b758c448 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/xattr.c 3 * linux/fs/hfsplus/xattr.c
3 * 4 *
diff --git a/fs/hfsplus/xattr.h b/fs/hfsplus/xattr.h
index 68f6b539371f..a4e611d69710 100644
--- a/fs/hfsplus/xattr.h
+++ b/fs/hfsplus/xattr.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/hfsplus/xattr.h 3 * linux/fs/hfsplus/xattr.h
3 * 4 *
diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c
index 37b3efa733ef..f5550b006e88 100644
--- a/fs/hfsplus/xattr_security.c
+++ b/fs/hfsplus/xattr_security.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/xattr_trusted.c 3 * linux/fs/hfsplus/xattr_trusted.c
3 * 4 *
diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c
index 94519d6c627d..fbad91e1dada 100644
--- a/fs/hfsplus/xattr_trusted.c
+++ b/fs/hfsplus/xattr_trusted.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/xattr_trusted.c 3 * linux/fs/hfsplus/xattr_trusted.c
3 * 4 *
diff --git a/fs/hfsplus/xattr_user.c b/fs/hfsplus/xattr_user.c
index fae6c0ea0030..74d19faf255e 100644
--- a/fs/hfsplus/xattr_user.c
+++ b/fs/hfsplus/xattr_user.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hfsplus/xattr_user.c 3 * linux/fs/hfsplus/xattr_user.c
3 * 4 *
diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h
index 91e19f9dffe5..ffaec2e7526c 100644
--- a/fs/hostfs/hostfs.h
+++ b/fs/hostfs/hostfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __UM_FS_HOSTFS 2#ifndef __UM_FS_HOSTFS
2#define __UM_FS_HOSTFS 3#define __UM_FS_HOSTFS
3 4
diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c
index 098bf0f4f386..66617b1557c6 100644
--- a/fs/hpfs/alloc.c
+++ b/fs/hpfs/alloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/alloc.c 3 * linux/fs/hpfs/alloc.c
3 * 4 *
diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c
index 2d5b254ad9e2..c14c9a035ee0 100644
--- a/fs/hpfs/anode.c
+++ b/fs/hpfs/anode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/anode.c 3 * linux/fs/hpfs/anode.c
3 * 4 *
diff --git a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c
index f626114449e4..e285d6b3bba4 100644
--- a/fs/hpfs/buffer.c
+++ b/fs/hpfs/buffer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/buffer.c 3 * linux/fs/hpfs/buffer.c
3 * 4 *
diff --git a/fs/hpfs/dentry.c b/fs/hpfs/dentry.c
index bb87d65f0d97..89a36fdc68cb 100644
--- a/fs/hpfs/dentry.c
+++ b/fs/hpfs/dentry.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/dentry.c 3 * linux/fs/hpfs/dentry.c
3 * 4 *
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index fa6bbb4f509f..8d6b7e35faf9 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/dir.c 3 * linux/fs/hpfs/dir.c
3 * 4 *
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
index 86ab7e790b4e..3b834563b1f1 100644
--- a/fs/hpfs/dnode.c
+++ b/fs/hpfs/dnode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/dnode.c 3 * linux/fs/hpfs/dnode.c
3 * 4 *
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index ce3f98ba993a..102ba18e561f 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/ea.c 3 * linux/fs/hpfs/ea.c
3 * 4 *
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index f26138425b16..1ecec124e76f 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/file.c 3 * linux/fs/hpfs/file.c
3 * 4 *
diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h
index cce025aff1b1..823a328791c0 100644
--- a/fs/hpfs/hpfs.h
+++ b/fs/hpfs/hpfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/hpfs/hpfs.h 3 * linux/fs/hpfs/hpfs.h
3 * 4 *
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index d352f3a6af7f..2577ef1034ef 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/hpfs/hpfs_fn.h 3 * linux/fs/hpfs/hpfs_fn.h
3 * 4 *
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index b9c724ed1e7e..eb8b4baf0f2e 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/inode.c 3 * linux/fs/hpfs/inode.c
3 * 4 *
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c
index a136929189f0..e0e60b148400 100644
--- a/fs/hpfs/map.c
+++ b/fs/hpfs/map.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/map.c 3 * linux/fs/hpfs/map.c
3 * 4 *
diff --git a/fs/hpfs/name.c b/fs/hpfs/name.c
index b00d396d22c6..ef7ba77f36b8 100644
--- a/fs/hpfs/name.c
+++ b/fs/hpfs/name.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/name.c 3 * linux/fs/hpfs/name.c
3 * 4 *
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index f30c14414518..a3615e4c730d 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/hpfs/namei.c 3 * linux/fs/hpfs/namei.c
3 * 4 *
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 59073e9f01a4..ed113ea17aff 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -842,9 +842,12 @@ static int hugetlbfs_error_remove_page(struct address_space *mapping,
842 struct page *page) 842 struct page *page)
843{ 843{
844 struct inode *inode = mapping->host; 844 struct inode *inode = mapping->host;
845 pgoff_t index = page->index;
845 846
846 remove_huge_page(page); 847 remove_huge_page(page);
847 hugetlb_fix_reserve_counts(inode); 848 if (unlikely(hugetlb_unreserve_pages(inode, index, index + 1, 1)))
849 hugetlb_fix_reserve_counts(inode);
850
848 return 0; 851 return 0;
849} 852}
850 853
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 569db68d02b3..5ace7efb0d04 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ioctl.c 3 * linux/fs/ioctl.c
3 * 4 *
diff --git a/fs/iomap.c b/fs/iomap.c
index 269b24a01f32..d4801f8dd4fd 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -713,6 +713,8 @@ struct iomap_dio {
713static ssize_t iomap_dio_complete(struct iomap_dio *dio) 713static ssize_t iomap_dio_complete(struct iomap_dio *dio)
714{ 714{
715 struct kiocb *iocb = dio->iocb; 715 struct kiocb *iocb = dio->iocb;
716 struct inode *inode = file_inode(iocb->ki_filp);
717 loff_t offset = iocb->ki_pos;
716 ssize_t ret; 718 ssize_t ret;
717 719
718 if (dio->end_io) { 720 if (dio->end_io) {
@@ -726,12 +728,33 @@ static ssize_t iomap_dio_complete(struct iomap_dio *dio)
726 if (likely(!ret)) { 728 if (likely(!ret)) {
727 ret = dio->size; 729 ret = dio->size;
728 /* check for short read */ 730 /* check for short read */
729 if (iocb->ki_pos + ret > dio->i_size && 731 if (offset + ret > dio->i_size &&
730 !(dio->flags & IOMAP_DIO_WRITE)) 732 !(dio->flags & IOMAP_DIO_WRITE))
731 ret = dio->i_size - iocb->ki_pos; 733 ret = dio->i_size - offset;
732 iocb->ki_pos += ret; 734 iocb->ki_pos += ret;
733 } 735 }
734 736
737 /*
738 * Try again to invalidate clean pages which might have been cached by
739 * non-direct readahead, or faulted in by get_user_pages() if the source
740 * of the write was an mmap'ed region of the file we're writing. Either
741 * one is a pretty crazy thing to do, so we don't support it 100%. If
742 * this invalidation fails, tough, the write still worked...
743 *
744 * And this page cache invalidation has to be after dio->end_io(), as
745 * some filesystems convert unwritten extents to real allocations in
746 * end_io() when necessary, otherwise a racing buffer read would cache
747 * zeros from unwritten extents.
748 */
749 if (!dio->error &&
750 (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages) {
751 int err;
752 err = invalidate_inode_pages2_range(inode->i_mapping,
753 offset >> PAGE_SHIFT,
754 (offset + dio->size - 1) >> PAGE_SHIFT);
755 WARN_ON_ONCE(err);
756 }
757
735 inode_dio_end(file_inode(iocb->ki_filp)); 758 inode_dio_end(file_inode(iocb->ki_filp));
736 kfree(dio); 759 kfree(dio);
737 760
@@ -993,6 +1016,13 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
993 WARN_ON_ONCE(ret); 1016 WARN_ON_ONCE(ret);
994 ret = 0; 1017 ret = 0;
995 1018
1019 if (iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) &&
1020 !inode->i_sb->s_dio_done_wq) {
1021 ret = sb_init_dio_done_wq(inode->i_sb);
1022 if (ret < 0)
1023 goto out_free_dio;
1024 }
1025
996 inode_dio_begin(inode); 1026 inode_dio_begin(inode);
997 1027
998 blk_start_plug(&plug); 1028 blk_start_plug(&plug);
@@ -1015,13 +1045,6 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
1015 if (ret < 0) 1045 if (ret < 0)
1016 iomap_dio_set_error(dio, ret); 1046 iomap_dio_set_error(dio, ret);
1017 1047
1018 if (ret >= 0 && iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) &&
1019 !inode->i_sb->s_dio_done_wq) {
1020 ret = sb_init_dio_done_wq(inode->i_sb);
1021 if (ret < 0)
1022 iomap_dio_set_error(dio, ret);
1023 }
1024
1025 if (!atomic_dec_and_test(&dio->ref)) { 1048 if (!atomic_dec_and_test(&dio->ref)) {
1026 if (!is_sync_kiocb(iocb)) 1049 if (!is_sync_kiocb(iocb))
1027 return -EIOCBQUEUED; 1050 return -EIOCBQUEUED;
@@ -1042,19 +1065,6 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
1042 1065
1043 ret = iomap_dio_complete(dio); 1066 ret = iomap_dio_complete(dio);
1044 1067
1045 /*
1046 * Try again to invalidate clean pages which might have been cached by
1047 * non-direct readahead, or faulted in by get_user_pages() if the source
1048 * of the write was an mmap'ed region of the file we're writing. Either
1049 * one is a pretty crazy thing to do, so we don't support it 100%. If
1050 * this invalidation fails, tough, the write still worked...
1051 */
1052 if (iov_iter_rw(iter) == WRITE) {
1053 int err = invalidate_inode_pages2_range(mapping,
1054 start >> PAGE_SHIFT, end >> PAGE_SHIFT);
1055 WARN_ON_ONCE(err);
1056 }
1057
1058 return ret; 1068 return ret;
1059 1069
1060out_free_dio: 1070out_free_dio:
diff --git a/fs/isofs/Makefile b/fs/isofs/Makefile
index bf162f0942d5..6498fd2b0f60 100644
--- a/fs/isofs/Makefile
+++ b/fs/isofs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the Linux isofs filesystem routines. 3# Makefile for the Linux isofs filesystem routines.
3# 4#
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index e7599615e4e0..947ce22f5b3c 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/isofs/dir.c 3 * linux/fs/isofs/dir.c
3 * 4 *
diff --git a/fs/isofs/export.c b/fs/isofs/export.c
index 0c5f721b4e91..85a9093769a9 100644
--- a/fs/isofs/export.c
+++ b/fs/isofs/export.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/isofs/export.c 3 * fs/isofs/export.c
3 * 4 *
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index db692f554158..447a24d77b89 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -514,9 +514,11 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root)
514 if (sbi->s_fmode != ISOFS_INVALID_MODE) 514 if (sbi->s_fmode != ISOFS_INVALID_MODE)
515 seq_printf(m, ",fmode=%o", sbi->s_fmode); 515 seq_printf(m, ",fmode=%o", sbi->s_fmode);
516 516
517#ifdef CONFIG_JOLIET
517 if (sbi->s_nls_iocharset && 518 if (sbi->s_nls_iocharset &&
518 strcmp(sbi->s_nls_iocharset->charset, CONFIG_NLS_DEFAULT) != 0) 519 strcmp(sbi->s_nls_iocharset->charset, CONFIG_NLS_DEFAULT) != 0)
519 seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset); 520 seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset);
521#endif
520 return 0; 522 return 0;
521} 523}
522 524
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index 133a456b0425..57d4c3e2e94a 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/buffer_head.h> 3#include <linux/buffer_head.h>
3#include <linux/exportfs.h> 4#include <linux/exportfs.h>
diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c
index a048de81c093..be8b6a9d0b92 100644
--- a/fs/isofs/joliet.c
+++ b/fs/isofs/joliet.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/isofs/joliet.c 3 * linux/fs/isofs/joliet.c
3 * 4 *
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index aee592767f1d..cac468f04820 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/isofs/namei.c 3 * linux/fs/isofs/namei.c
3 * 4 *
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 0ec137310320..94ef92fe806c 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/isofs/rock.c 3 * linux/fs/isofs/rock.c
3 * 4 *
diff --git a/fs/isofs/rock.h b/fs/isofs/rock.h
index ed09e2b08637..ef03625431bb 100644
--- a/fs/isofs/rock.h
+++ b/fs/isofs/rock.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * These structs are used by the system-use-sharing protocol, in which the 3 * These structs are used by the system-use-sharing protocol, in which the
3 * Rock Ridge extensions are embedded. It is quite possible that other 4 * Rock Ridge extensions are embedded. It is quite possible that other
diff --git a/fs/isofs/util.c b/fs/isofs/util.c
index 005a15cfd30a..42544bf0e222 100644
--- a/fs/isofs/util.c
+++ b/fs/isofs/util.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/isofs/util.c 3 * linux/fs/isofs/util.c
3 */ 4 */
diff --git a/fs/jffs2/Makefile b/fs/jffs2/Makefile
index 60e5d49ca03e..5294969d5bf9 100644
--- a/fs/jffs2/Makefile
+++ b/fs/jffs2/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the Linux Journalling Flash File System v2 (JFFS2) 3# Makefile for the Linux Journalling Flash File System v2 (JFFS2)
3# 4#
diff --git a/fs/jfs/Makefile b/fs/jfs/Makefile
index d20d4737b3ef..285ec189ed5c 100644
--- a/fs/jfs/Makefile
+++ b/fs/jfs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the Linux JFS filesystem routines. 3# Makefile for the Linux JFS filesystem routines.
3# 4#
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index 5c5ac5b3aec3..ba34dae8bd9f 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/jfs/ioctl.c 3 * linux/fs/jfs/ioctl.c
3 * 4 *
diff --git a/fs/lockd/Makefile b/fs/lockd/Makefile
index 9b320cc2a8cf..6d5e83ed4476 100644
--- a/fs/lockd/Makefile
+++ b/fs/lockd/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the linux lock manager stuff 3# Makefile for the linux lock manager stuff
3# 4#
diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c
index c349fc0f9b80..00d5ef5f99f7 100644
--- a/fs/lockd/clnt4xdr.c
+++ b/fs/lockd/clnt4xdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/clnt4xdr.c 3 * linux/fs/lockd/clnt4xdr.c
3 * 4 *
diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c
index 3b4724a6c4ee..2c6176387143 100644
--- a/fs/lockd/clntxdr.c
+++ b/fs/lockd/clntxdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/clntxdr.c 3 * linux/fs/lockd/clntxdr.c
3 * 4 *
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index d716c9993a26..0d4e590e0549 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/host.c 3 * linux/fs/lockd/host.c
3 * 4 *
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 9d8166c39c54..9fbbd11f9ecb 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/mon.c 3 * linux/fs/lockd/mon.c
3 * 4 *
diff --git a/fs/lockd/netns.h b/fs/lockd/netns.h
index fb8cac88251a..5bec78c8e431 100644
--- a/fs/lockd/netns.h
+++ b/fs/lockd/netns.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __LOCKD_NETNS_H__ 2#ifndef __LOCKD_NETNS_H__
2#define __LOCKD_NETNS_H__ 3#define __LOCKD_NETNS_H__
3 4
diff --git a/fs/lockd/procfs.c b/fs/lockd/procfs.c
index 8f72cb237ef3..ca9228a56d65 100644
--- a/fs/lockd/procfs.c
+++ b/fs/lockd/procfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Procfs support for lockd 3 * Procfs support for lockd
3 * 4 *
diff --git a/fs/lockd/procfs.h b/fs/lockd/procfs.h
index 184a15edd18d..ba9a82f4ce28 100644
--- a/fs/lockd/procfs.h
+++ b/fs/lockd/procfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Procfs support for lockd 3 * Procfs support for lockd
3 * 4 *
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index 82925f17ec45..1bddf70d9656 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/svc4proc.c 3 * linux/fs/lockd/svc4proc.c
3 * 4 *
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 3507c80d1d4b..3701bccab478 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/svclock.c 3 * linux/fs/lockd/svclock.c
3 * 4 *
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 07915162581d..0d670c5c378f 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/svcproc.c 3 * linux/fs/lockd/svcproc.c
3 * 4 *
diff --git a/fs/lockd/svcshare.c b/fs/lockd/svcshare.c
index b0ae07008700..ade4931b2da2 100644
--- a/fs/lockd/svcshare.c
+++ b/fs/lockd/svcshare.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/svcshare.c 3 * linux/fs/lockd/svcshare.c
3 * 4 *
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 442bbd0b0b29..7147e4aebecc 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/xdr.c 3 * linux/fs/lockd/xdr.c
3 * 4 *
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index 2a0cd5679c49..7ed9edf9aed4 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/lockd/xdr4.c 3 * linux/fs/lockd/xdr4.c
3 * 4 *
diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index c2c3fd3277b5..f4e5e5181a14 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/minix/bitmap.c 3 * linux/fs/minix/bitmap.c
3 * 4 *
diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index baa9721f1299..dcfe5b25378b 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/minix/dir.c 3 * linux/fs/minix/dir.c
3 * 4 *
diff --git a/fs/minix/file.c b/fs/minix/file.c
index a6a4797aa0d4..c50b0a20fcd9 100644
--- a/fs/minix/file.c
+++ b/fs/minix/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/minix/file.c 3 * linux/fs/minix/file.c
3 * 4 *
diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
index 2d1ca08870f7..043c3fdbc8e7 100644
--- a/fs/minix/itree_common.c
+++ b/fs/minix/itree_common.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* Generic part */ 2/* Generic part */
2 3
3typedef struct { 4typedef struct {
diff --git a/fs/minix/itree_v1.c b/fs/minix/itree_v1.c
index 46ca39d6c735..046cc96ee7ad 100644
--- a/fs/minix/itree_v1.c
+++ b/fs/minix/itree_v1.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/buffer_head.h> 2#include <linux/buffer_head.h>
2#include <linux/slab.h> 3#include <linux/slab.h>
3#include "minix.h" 4#include "minix.h"
diff --git a/fs/minix/itree_v2.c b/fs/minix/itree_v2.c
index 1ee101352586..f7fc7ecccccc 100644
--- a/fs/minix/itree_v2.c
+++ b/fs/minix/itree_v2.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/buffer_head.h> 2#include <linux/buffer_head.h>
2#include "minix.h" 3#include "minix.h"
3 4
diff --git a/fs/minix/minix.h b/fs/minix/minix.h
index 663d66138d06..df081e8afcc3 100644
--- a/fs/minix/minix.h
+++ b/fs/minix/minix.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef FS_MINIX_H 2#ifndef FS_MINIX_H
2#define FS_MINIX_H 3#define FS_MINIX_H
3 4
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 1e0f11f5dac9..ccf0f00030bf 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/minix/namei.c 3 * linux/fs/minix/namei.c
3 * 4 *
diff --git a/fs/mount.h b/fs/mount.h
index 6790767d1883..f39bc9da4d73 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/mount.h> 2#include <linux/mount.h>
2#include <linux/seq_file.h> 3#include <linux/seq_file.h>
3#include <linux/poll.h> 4#include <linux/poll.h>
diff --git a/fs/mpage.c b/fs/mpage.c
index 37bb77c1302c..b7e7f570733a 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/mpage.c 3 * fs/mpage.c
3 * 4 *
@@ -468,6 +469,16 @@ static void clean_buffers(struct page *page, unsigned first_unmapped)
468 try_to_free_buffers(page); 469 try_to_free_buffers(page);
469} 470}
470 471
472/*
473 * For situations where we want to clean all buffers attached to a page.
474 * We don't need to calculate how many buffers are attached to the page,
475 * we just need to specify a number larger than the maximum number of buffers.
476 */
477void clean_page_buffers(struct page *page)
478{
479 clean_buffers(page, ~0U);
480}
481
471static int __mpage_writepage(struct page *page, struct writeback_control *wbc, 482static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
472 void *data) 483 void *data)
473{ 484{
@@ -605,10 +616,8 @@ alloc_new:
605 if (bio == NULL) { 616 if (bio == NULL) {
606 if (first_unmapped == blocks_per_page) { 617 if (first_unmapped == blocks_per_page) {
607 if (!bdev_write_page(bdev, blocks[0] << (blkbits - 9), 618 if (!bdev_write_page(bdev, blocks[0] << (blkbits - 9),
608 page, wbc)) { 619 page, wbc))
609 clean_buffers(page, first_unmapped);
610 goto out; 620 goto out;
611 }
612 } 621 }
613 bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), 622 bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
614 BIO_MAX_PAGES, GFP_NOFS|__GFP_HIGH); 623 BIO_MAX_PAGES, GFP_NOFS|__GFP_HIGH);
diff --git a/fs/namei.c b/fs/namei.c
index c75ea03ca147..ed8b9488a890 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/namei.c 3 * linux/fs/namei.c
3 * 4 *
diff --git a/fs/namespace.c b/fs/namespace.c
index 54059b142d6b..d18deb4c410b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -468,7 +468,9 @@ static inline int may_write_real(struct file *file)
468 468
469 /* File refers to upper, writable layer? */ 469 /* File refers to upper, writable layer? */
470 upperdentry = d_real(dentry, NULL, 0, D_REAL_UPPER); 470 upperdentry = d_real(dentry, NULL, 0, D_REAL_UPPER);
471 if (upperdentry && file_inode(file) == d_inode(upperdentry)) 471 if (upperdentry &&
472 (file_inode(file) == d_inode(upperdentry) ||
473 file_inode(file) == d_inode(dentry)))
472 return 0; 474 return 0;
473 475
474 /* Lower layer: can't write to real file, sorry... */ 476 /* Lower layer: can't write to real file, sorry... */
@@ -2823,7 +2825,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2823 SB_MANDLOCK | 2825 SB_MANDLOCK |
2824 SB_DIRSYNC | 2826 SB_DIRSYNC |
2825 SB_SILENT | 2827 SB_SILENT |
2826 SB_POSIXACL); 2828 SB_POSIXACL |
2829 SB_I_VERSION);
2827 2830
2828 if (flags & MS_REMOUNT) 2831 if (flags & MS_REMOUNT)
2829 retval = do_remount(&path, flags, sb_flags, mnt_flags, 2832 retval = do_remount(&path, flags, sb_flags, mnt_flags,
diff --git a/fs/ncpfs/Makefile b/fs/ncpfs/Makefile
index c66af563f2ce..66fe5f878817 100644
--- a/fs/ncpfs/Makefile
+++ b/fs/ncpfs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the linux ncp filesystem routines. 3# Makefile for the linux ncp filesystem routines.
3# 4#
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 088f52484d6e..b5ec1d980dc9 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * dir.c 3 * dir.c
3 * 4 *
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index a06c07619ee6..8f8cc0334ddd 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * file.c 3 * file.c
3 * 4 *
diff --git a/fs/ncpfs/getopt.c b/fs/ncpfs/getopt.c
index 344889cd120e..5c941bef14c4 100644
--- a/fs/ncpfs/getopt.c
+++ b/fs/ncpfs/getopt.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * getopt.c 3 * getopt.c
3 */ 4 */
diff --git a/fs/ncpfs/getopt.h b/fs/ncpfs/getopt.h
index cccc007dcaf9..30f0da317670 100644
--- a/fs/ncpfs/getopt.h
+++ b/fs/ncpfs/getopt.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _LINUX_GETOPT_H 2#ifndef _LINUX_GETOPT_H
2#define _LINUX_GETOPT_H 3#define _LINUX_GETOPT_H
3 4
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index 12550c2320cc..d378b98cd7b6 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ioctl.c 3 * ioctl.c
3 * 4 *
diff --git a/fs/ncpfs/mmap.c b/fs/ncpfs/mmap.c
index 6719c0be674d..a5c5cf2ff007 100644
--- a/fs/ncpfs/mmap.c
+++ b/fs/ncpfs/mmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mmap.c 3 * mmap.c
3 * 4 *
diff --git a/fs/ncpfs/ncp_fs.h b/fs/ncpfs/ncp_fs.h
index b9f69e1b1f43..bdd262b6c198 100644
--- a/fs/ncpfs/ncp_fs.h
+++ b/fs/ncpfs/ncp_fs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/ncp_fs.h> 2#include <linux/ncp_fs.h>
2#include "ncp_fs_i.h" 3#include "ncp_fs_i.h"
3#include "ncp_fs_sb.h" 4#include "ncp_fs_sb.h"
diff --git a/fs/ncpfs/ncp_fs_i.h b/fs/ncpfs/ncp_fs_i.h
index c4794504f843..3432bafb53a5 100644
--- a/fs/ncpfs/ncp_fs_i.h
+++ b/fs/ncpfs/ncp_fs_i.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * ncp_fs_i.h 3 * ncp_fs_i.h
3 * 4 *
diff --git a/fs/ncpfs/ncp_fs_sb.h b/fs/ncpfs/ncp_fs_sb.h
index 366fd63cc506..89031d7e3ae1 100644
--- a/fs/ncpfs/ncp_fs_sb.h
+++ b/fs/ncpfs/ncp_fs_sb.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * ncp_fs_sb.h 3 * ncp_fs_sb.h
3 * 4 *
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
index 88dbbc9fcf4d..804adfebba2f 100644
--- a/fs/ncpfs/ncplib_kernel.c
+++ b/fs/ncpfs/ncplib_kernel.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ncplib_kernel.c 3 * ncplib_kernel.c
3 * 4 *
diff --git a/fs/ncpfs/ncplib_kernel.h b/fs/ncpfs/ncplib_kernel.h
index b4c87cfcee95..aaae8aa9bf7d 100644
--- a/fs/ncpfs/ncplib_kernel.h
+++ b/fs/ncpfs/ncplib_kernel.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * ncplib_kernel.h 3 * ncplib_kernel.h
3 * 4 *
diff --git a/fs/ncpfs/ncpsign_kernel.c b/fs/ncpfs/ncpsign_kernel.c
index 08907599dcd2..8085b1a3ba47 100644
--- a/fs/ncpfs/ncpsign_kernel.c
+++ b/fs/ncpfs/ncpsign_kernel.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ncpsign_kernel.c 3 * ncpsign_kernel.c
3 * 4 *
diff --git a/fs/ncpfs/ncpsign_kernel.h b/fs/ncpfs/ncpsign_kernel.h
index d9a1438bb1f6..57ff0a0650b8 100644
--- a/fs/ncpfs/ncpsign_kernel.h
+++ b/fs/ncpfs/ncpsign_kernel.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * ncpsign_kernel.h 3 * ncpsign_kernel.h
3 * 4 *
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 98b6db0ed63e..7dd7170d6cdf 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ncpfs/sock.c 3 * linux/fs/ncpfs/sock.c
3 * 4 *
diff --git a/fs/ncpfs/symlink.c b/fs/ncpfs/symlink.c
index a6d26b46fc05..b6e16da4837a 100644
--- a/fs/ncpfs/symlink.c
+++ b/fs/ncpfs/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ncpfs/symlink.c 3 * linux/fs/ncpfs/symlink.c
3 * 4 *
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index 1fb118902d57..c587e3c4c6a6 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the Linux nfs filesystem routines. 3# Makefile for the Linux nfs filesystem routines.
3# 4#
diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c
index a69ef4e9c24c..95f74bd2c067 100644
--- a/fs/nfs/blocklayout/dev.c
+++ b/fs/nfs/blocklayout/dev.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2014-2016 Christoph Hellwig. 3 * Copyright (c) 2014-2016 Christoph Hellwig.
3 */ 4 */
diff --git a/fs/nfs/blocklayout/extent_tree.c b/fs/nfs/blocklayout/extent_tree.c
index c85fbfd2d0d9..7a57ff2528af 100644
--- a/fs/nfs/blocklayout/extent_tree.c
+++ b/fs/nfs/blocklayout/extent_tree.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2014-2016 Christoph Hellwig. 3 * Copyright (c) 2014-2016 Christoph Hellwig.
3 */ 4 */
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c
index 2ae676f93e6b..b60627bcfc62 100644
--- a/fs/nfs/cache_lib.c
+++ b/fs/nfs/cache_lib.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/cache_lib.c 3 * linux/fs/nfs/cache_lib.c
3 * 4 *
diff --git a/fs/nfs/cache_lib.h b/fs/nfs/cache_lib.h
index 4116d2c3f52f..4e6236a86cf7 100644
--- a/fs/nfs/cache_lib.h
+++ b/fs/nfs/cache_lib.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Helper routines for the NFS client caches 3 * Helper routines for the NFS client caches
3 * 4 *
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 2cddf7f437e6..cd9d992feb2e 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/callback.c 3 * linux/fs/nfs/callback.c
3 * 4 *
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index 3dc54d7cb19c..a20a0bce40a4 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/nfs/callback.h 3 * linux/fs/nfs/callback.h
3 * 4 *
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 14358de173fb..19151f6c0e97 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/callback_proc.c 3 * linux/fs/nfs/callback_proc.c
3 * 4 *
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 681dd642f119..123c069429a7 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/callback_xdr.c 3 * linux/fs/nfs/callback_xdr.c
3 * 4 *
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index efebe6cf4378..22880ef6d8dd 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -218,7 +218,6 @@ static void nfs_cb_idr_remove_locked(struct nfs_client *clp)
218static void pnfs_init_server(struct nfs_server *server) 218static void pnfs_init_server(struct nfs_server *server)
219{ 219{
220 rpc_init_wait_queue(&server->roc_rpcwaitq, "pNFS ROC"); 220 rpc_init_wait_queue(&server->roc_rpcwaitq, "pNFS ROC");
221 rpc_init_wait_queue(&server->uoc_rpcwaitq, "NFS UOC");
222} 221}
223 222
224#else 223#else
@@ -888,6 +887,7 @@ struct nfs_server *nfs_alloc_server(void)
888 ida_init(&server->openowner_id); 887 ida_init(&server->openowner_id);
889 ida_init(&server->lockowner_id); 888 ida_init(&server->lockowner_id);
890 pnfs_init_server(server); 889 pnfs_init_server(server);
890 rpc_init_wait_queue(&server->uoc_rpcwaitq, "NFS UOC");
891 891
892 return server; 892 return server;
893} 893}
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index e9d555796873..ddaf2644cf13 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/nfs/delegation.h 3 * linux/fs/nfs/delegation.h
3 * 4 *
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index d25f10fb4926..060c658eab66 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/dns_resolve.c 3 * linux/fs/nfs/dns_resolve.c
3 * 4 *
diff --git a/fs/nfs/dns_resolve.h b/fs/nfs/dns_resolve.h
index 2e4f596d2923..576ff4b54c82 100644
--- a/fs/nfs/dns_resolve.h
+++ b/fs/nfs/dns_resolve.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Resolve DNS hostnames into valid ip addresses 3 * Resolve DNS hostnames into valid ip addresses
3 */ 4 */
diff --git a/fs/nfs/export.c b/fs/nfs/export.c
index 249cb96cc5b5..83fd09fc8f77 100644
--- a/fs/nfs/export.c
+++ b/fs/nfs/export.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2015, Primary Data, Inc. All rights reserved. 3 * Copyright (c) 2015, Primary Data, Inc. All rights reserved.
3 * 4 *
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 44c638b7876c..508126eb49f9 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -745,7 +745,8 @@ filelayout_free_lseg(struct pnfs_layout_segment *lseg)
745 struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); 745 struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
746 746
747 dprintk("--> %s\n", __func__); 747 dprintk("--> %s\n", __func__);
748 nfs4_fl_put_deviceid(fl->dsaddr); 748 if (fl->dsaddr != NULL)
749 nfs4_fl_put_deviceid(fl->dsaddr);
749 /* This assumes a single RW lseg */ 750 /* This assumes a single RW lseg */
750 if (lseg->pls_range.iomode == IOMODE_RW) { 751 if (lseg->pls_range.iomode == IOMODE_RW) {
751 struct nfs4_filelayout *flo; 752 struct nfs4_filelayout *flo;
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h
index 98b34c9b0564..679cb087ef3f 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.h
+++ b/fs/nfs/flexfilelayout/flexfilelayout.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * NFSv4 flexfile layout driver data structures. 3 * NFSv4 flexfile layout driver data structures.
3 * 4 *
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index f32c58bbe556..d62279d3fc5d 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Device operations for the pnfs nfs4 file layout driver. 3 * Device operations for the pnfs nfs4 file layout driver.
3 * 4 *
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 5bdf952f414b..f9a4a5524bd5 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * NFS internal definitions 3 * NFS internal definitions
3 */ 4 */
diff --git a/fs/nfs/io.c b/fs/nfs/io.c
index 1fc5d1ce327e..20fef85d2bb1 100644
--- a/fs/nfs/io.c
+++ b/fs/nfs/io.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2016 Trond Myklebust 3 * Copyright (c) 2016 Trond Myklebust
3 * 4 *
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h
index 0cb806fbd4c4..2ddaab1ac653 100644
--- a/fs/nfs/iostat.h
+++ b/fs/nfs/iostat.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/nfs/iostat.h 3 * linux/fs/nfs/iostat.h
3 * 4 *
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index 60bad882c123..d979ff4fee7e 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * In-kernel MOUNT protocol client 3 * In-kernel MOUNT protocol client
3 * 4 *
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index 5fbd2bde91ba..fc9978c58265 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * NFS-private data for each "struct net". Accessed with net_generic(). 3 * NFS-private data for each "struct net". Accessed with net_generic().
3 */ 4 */
diff --git a/fs/nfs/nfs.h b/fs/nfs/nfs.h
index 43679df56cd0..5ba00610aede 100644
--- a/fs/nfs/nfs.h
+++ b/fs/nfs/nfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (c) 2012 Netapp, Inc. All rights reserved. 3 * Copyright (c) 2012 Netapp, Inc. All rights reserved.
3 * 4 *
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index fe68dabfbde6..85e4b4a233f9 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/nfs2xdr.c 3 * linux/fs/nfs/nfs2xdr.c
3 * 4 *
diff --git a/fs/nfs/nfs3_fs.h b/fs/nfs/nfs3_fs.h
index e134d6548ab7..f82e11c4cb56 100644
--- a/fs/nfs/nfs3_fs.h
+++ b/fs/nfs/nfs3_fs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (C) 2014 Anna Schumaker. 3 * Copyright (C) 2014 Anna Schumaker.
3 * 4 *
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index 720d92f5abfb..7173a4ee862c 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/gfp.h> 3#include <linux/gfp.h>
3#include <linux/nfs.h> 4#include <linux/nfs.h>
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index d1e87ec0df84..bc673fb47fb3 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/nfs3proc.c 3 * linux/fs/nfs/nfs3proc.c
3 * 4 *
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index e82c9e553224..6cd33bd5da87 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/nfs3xdr.c 3 * linux/fs/nfs/nfs3xdr.c
3 * 4 *
diff --git a/fs/nfs/nfs42.h b/fs/nfs/nfs42.h
index b6cd15314bab..19ec38f85ce0 100644
--- a/fs/nfs/nfs42.h
+++ b/fs/nfs/nfs42.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com> 3 * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
3 */ 4 */
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 6c2db51e67a7..9c374441f660 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com> 3 * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
3 */ 4 */
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index 5ee1b0f0d904..5966e1e7b1f5 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com> 3 * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
3 */ 4 */
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index ac4f10b7f6c1..dcfcf7fd7438 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/nfs/nfs4_fs.h 3 * linux/fs/nfs/nfs4_fs.h
3 * 4 *
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 0efba77789b9..626d1382002e 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/file.c 3 * linux/fs/nfs/file.c
3 * 4 *
diff --git a/fs/nfs/nfs4getroot.c b/fs/nfs/nfs4getroot.c
index ac8406018962..1a69479a3a59 100644
--- a/fs/nfs/nfs4getroot.c
+++ b/fs/nfs/nfs4getroot.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2* Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. 3* Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
3* Written by David Howells (dhowells@redhat.com) 4* Written by David Howells (dhowells@redhat.com)
diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
index dd5d27da8c0c..30426c1a1bbd 100644
--- a/fs/nfs/nfs4idmap.c
+++ b/fs/nfs/nfs4idmap.c
@@ -274,7 +274,7 @@ static struct key *nfs_idmap_request_key(const char *name, size_t namelen,
274 ssize_t ret; 274 ssize_t ret;
275 275
276 ret = nfs_idmap_get_desc(name, namelen, type, strlen(type), &desc); 276 ret = nfs_idmap_get_desc(name, namelen, type, strlen(type), &desc);
277 if (ret <= 0) 277 if (ret < 0)
278 return ERR_PTR(ret); 278 return ERR_PTR(ret);
279 279
280 rkey = request_key(&key_type_id_resolver, desc, ""); 280 rkey = request_key(&key_type_id_resolver, desc, "");
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 7d531da1bae3..8c3f327d858d 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/nfs4namespace.c 3 * linux/fs/nfs/nfs4namespace.c
3 * 4 *
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6c61e2b99635..f90090e8c959 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -8399,8 +8399,7 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
8399 lo = NFS_I(inode)->layout; 8399 lo = NFS_I(inode)->layout;
8400 /* If the open stateid was bad, then recover it. */ 8400 /* If the open stateid was bad, then recover it. */
8401 if (!lo || test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags) || 8401 if (!lo || test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags) ||
8402 nfs4_stateid_match_other(&lgp->args.stateid, 8402 !nfs4_stateid_match_other(&lgp->args.stateid, &lo->plh_stateid)) {
8403 &lgp->args.ctx->state->stateid)) {
8404 spin_unlock(&inode->i_lock); 8403 spin_unlock(&inode->i_lock);
8405 exception->state = lgp->args.ctx->state; 8404 exception->state = lgp->args.ctx->state;
8406 exception->stateid = &lgp->args.stateid; 8405 exception->stateid = &lgp->args.stateid;
diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h
index dfae4880eacb..3c550f297561 100644
--- a/fs/nfs/nfs4session.h
+++ b/fs/nfs/nfs4session.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * fs/nfs/nfs4session.h 3 * fs/nfs/nfs4session.h
3 * 4 *
diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c
index 8693d77c45ea..0d91d84e5822 100644
--- a/fs/nfs/nfs4sysctl.c
+++ b/fs/nfs/nfs4sysctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/nfs4sysctl.c 3 * linux/fs/nfs/nfs4sysctl.c
3 * 4 *
diff --git a/fs/nfs/nfs4trace.c b/fs/nfs/nfs4trace.c
index 2850bce19244..e9fb3e50a999 100644
--- a/fs/nfs/nfs4trace.c
+++ b/fs/nfs/nfs4trace.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com> 3 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
3 */ 4 */
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index be1da19c65d6..e7c6275519b0 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com> 3 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
3 */ 4 */
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 37c8af003275..14ed9791ec9c 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1842,8 +1842,8 @@ static void encode_create_session(struct xdr_stream *xdr,
1842 * Assumes OPEN is the biggest non-idempotent compound. 1842 * Assumes OPEN is the biggest non-idempotent compound.
1843 * 2 is the verifier. 1843 * 2 is the verifier.
1844 */ 1844 */
1845 max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 1845 max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 2)
1846 RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; 1846 * XDR_UNIT + RPC_MAX_AUTH_SIZE;
1847 1847
1848 encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); 1848 encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr);
1849 p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); 1849 p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12);
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index 89a15dbe5efc..effaa4247b91 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 1995, 1996 Gero Kuhlmann <gero@gkminix.han.de> 3 * Copyright (C) 1995, 1996 Gero Kuhlmann <gero@gkminix.han.de>
3 * 4 *
diff --git a/fs/nfs/nfstrace.c b/fs/nfs/nfstrace.c
index c74f7af23d77..b60d5fbd7727 100644
--- a/fs/nfs/nfstrace.c
+++ b/fs/nfs/nfstrace.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com> 3 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
3 */ 4 */
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 551711042ba4..093290c42d7c 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com> 3 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
3 */ 4 */
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 7962e49097c3..f7fd9192d4bc 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/proc.c 3 * linux/fs/nfs/proc.c
3 * 4 *
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c
index 5a1d0ded8979..06eb44b47885 100644
--- a/fs/nfs/symlink.c
+++ b/fs/nfs/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/symlink.c 3 * linux/fs/nfs/symlink.c
3 * 4 *
diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c
index bb6ed810fa6f..7aea195ddb35 100644
--- a/fs/nfs/sysctl.c
+++ b/fs/nfs/sysctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/sysctl.c 3 * linux/fs/nfs/sysctl.c
3 * 4 *
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index e3949d93085c..630b4a3c1a93 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/nfs/unlink.c 3 * linux/fs/nfs/unlink.c
3 * 4 *
diff --git a/fs/nfsd/Makefile b/fs/nfsd/Makefile
index 5f5d3a76980c..2bfb58eefad1 100644
--- a/fs/nfsd/Makefile
+++ b/fs/nfsd/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the Linux nfs server 3# Makefile for the Linux nfs server
3# 4#
diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c
index 62469c60be23..697f8ae7792d 100644
--- a/fs/nfsd/auth.c
+++ b/fs/nfsd/auth.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */ 2/* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
2 3
3#include <linux/sched.h> 4#include <linux/sched.h>
diff --git a/fs/nfsd/auth.h b/fs/nfsd/auth.h
index 53325a12ba62..dbd66424f600 100644
--- a/fs/nfsd/auth.h
+++ b/fs/nfsd/auth.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * nfsd-specific authentication stuff. 3 * nfsd-specific authentication stuff.
3 * 4 *
diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index c862c2489df0..3f880ae0966b 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2014-2016 Christoph Hellwig. 3 * Copyright (c) 2014-2016 Christoph Hellwig.
3 */ 4 */
diff --git a/fs/nfsd/blocklayoutxdr.c b/fs/nfsd/blocklayoutxdr.c
index ac6f54546fdd..442543304930 100644
--- a/fs/nfsd/blocklayoutxdr.c
+++ b/fs/nfsd/blocklayoutxdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2014-2016 Christoph Hellwig. 3 * Copyright (c) 2014-2016 Christoph Hellwig.
3 */ 4 */
diff --git a/fs/nfsd/blocklayoutxdr.h b/fs/nfsd/blocklayoutxdr.h
index 397bc7563a49..bc5166bfe46b 100644
--- a/fs/nfsd/blocklayoutxdr.h
+++ b/fs/nfsd/blocklayoutxdr.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _NFSD_BLOCKLAYOUTXDR_H 2#ifndef _NFSD_BLOCKLAYOUTXDR_H
2#define _NFSD_BLOCKLAYOUTXDR_H 1 3#define _NFSD_BLOCKLAYOUTXDR_H 1
3 4
diff --git a/fs/nfsd/cache.h b/fs/nfsd/cache.h
index dd96a3830004..046b3f048757 100644
--- a/fs/nfsd/cache.h
+++ b/fs/nfsd/cache.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Request reply cache. This was heavily inspired by the 3 * Request reply cache. This was heavily inspired by the
3 * implementation in 4.3BSD/4.4BSD. 4 * implementation in 4.3BSD/4.4BSD.
diff --git a/fs/nfsd/current_stateid.h b/fs/nfsd/current_stateid.h
index 34075cee573a..c28540d86742 100644
--- a/fs/nfsd/current_stateid.h
+++ b/fs/nfsd/current_stateid.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _NFSD4_CURRENT_STATE_H 2#ifndef _NFSD4_CURRENT_STATE_H
2#define _NFSD4_CURRENT_STATE_H 3#define _NFSD4_CURRENT_STATE_H
3 4
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 3bc08c394a3f..46b48dbbdd32 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * NFS exporting and validation. 3 * NFS exporting and validation.
3 * 4 *
diff --git a/fs/nfsd/export.h b/fs/nfsd/export.h
index 730f15eeb7ed..c8b74126ddaa 100644
--- a/fs/nfsd/export.h
+++ b/fs/nfsd/export.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> 3 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
3 */ 4 */
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index 34c1c449fddf..6dfede6d172a 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2011 Bryan Schumaker <bjschuma@netapp.com> 3 * Copyright (c) 2011 Bryan Schumaker <bjschuma@netapp.com>
3 * 4 *
diff --git a/fs/nfsd/flexfilelayout.c b/fs/nfsd/flexfilelayout.c
index b67287383010..db7ef07ae50c 100644
--- a/fs/nfsd/flexfilelayout.c
+++ b/fs/nfsd/flexfilelayout.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2016 Tom Haynes <loghyr@primarydata.com> 3 * Copyright (c) 2016 Tom Haynes <loghyr@primarydata.com>
3 * 4 *
diff --git a/fs/nfsd/flexfilelayoutxdr.c b/fs/nfsd/flexfilelayoutxdr.c
index 5e3fd7fc1a9f..e81d2a5cf381 100644
--- a/fs/nfsd/flexfilelayoutxdr.c
+++ b/fs/nfsd/flexfilelayoutxdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2016 Tom Haynes <loghyr@primarydata.com> 3 * Copyright (c) 2016 Tom Haynes <loghyr@primarydata.com>
3 */ 4 */
diff --git a/fs/nfsd/flexfilelayoutxdr.h b/fs/nfsd/flexfilelayoutxdr.h
index 467defd4e563..8e195aeca023 100644
--- a/fs/nfsd/flexfilelayoutxdr.h
+++ b/fs/nfsd/flexfilelayoutxdr.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (c) 2016 Tom Haynes <loghyr@primarydata.com> 3 * Copyright (c) 2016 Tom Haynes <loghyr@primarydata.com>
3 */ 4 */
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
index 1a03bc3059e8..3f5b3d7b62b7 100644
--- a/fs/nfsd/lockd.c
+++ b/fs/nfsd/lockd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This file contains all the stubs needed when communicating with lockd. 3 * This file contains all the stubs needed when communicating with lockd.
3 * This level of indirection is necessary so we can run nfsd+lockd without 4 * This level of indirection is necessary so we can run nfsd+lockd without
diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c
index 6276ec8608b0..cbab1d2d8a75 100644
--- a/fs/nfsd/nfs2acl.c
+++ b/fs/nfsd/nfs2acl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Process version 2 NFSACL requests. 3 * Process version 2 NFSACL requests.
3 * 4 *
diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c
index 01976529f042..13bca4a2f89d 100644
--- a/fs/nfsd/nfs3acl.c
+++ b/fs/nfsd/nfs3acl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Process version 3 NFSACL requests. 3 * Process version 3 NFSACL requests.
3 * 4 *
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index 2cb56a0d6625..1d0ce3c57d93 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Process version 3 NFS requests. 3 * Process version 3 NFS requests.
3 * 4 *
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index bf444b664011..f38acd905441 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * XDR support for nfsd/protocol version 3. 3 * XDR support for nfsd/protocol version 3.
3 * 4 *
diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
index e122da696f1b..ea45d954e8d7 100644
--- a/fs/nfsd/nfs4layouts.c
+++ b/fs/nfsd/nfs4layouts.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2014 Christoph Hellwig. 3 * Copyright (c) 2014 Christoph Hellwig.
3 */ 4 */
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 3c69db7d4905..8487486ec496 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -927,6 +927,13 @@ nfsd4_secinfo_release(union nfsd4_op_u *u)
927 exp_put(u->secinfo.si_exp); 927 exp_put(u->secinfo.si_exp);
928} 928}
929 929
930static void
931nfsd4_secinfo_no_name_release(union nfsd4_op_u *u)
932{
933 if (u->secinfo_no_name.sin_exp)
934 exp_put(u->secinfo_no_name.sin_exp);
935}
936
930static __be32 937static __be32
931nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, 938nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
932 union nfsd4_op_u *u) 939 union nfsd4_op_u *u)
@@ -2375,7 +2382,7 @@ static const struct nfsd4_operation nfsd4_ops[] = {
2375 }, 2382 },
2376 [OP_SECINFO_NO_NAME] = { 2383 [OP_SECINFO_NO_NAME] = {
2377 .op_func = nfsd4_secinfo_no_name, 2384 .op_func = nfsd4_secinfo_no_name,
2378 .op_release = nfsd4_secinfo_release, 2385 .op_release = nfsd4_secinfo_no_name_release,
2379 .op_flags = OP_HANDLES_WRONGSEC, 2386 .op_flags = OP_HANDLES_WRONGSEC,
2380 .op_name = "OP_SECINFO_NO_NAME", 2387 .op_name = "OP_SECINFO_NO_NAME",
2381 .op_rsize_bop = nfsd4_secinfo_rsize, 2388 .op_rsize_bop = nfsd4_secinfo_rsize,
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 96fd15979cbd..334f2ad60704 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Request reply cache. This is currently a global cache, but this may 3 * Request reply cache. This is currently a global cache, but this may
3 * change in the future and be a per-client cache. 4 * change in the future and be a per-client cache.
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index b9c538ab7a59..3fce905d0365 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Hodge-podge collection of knfsd-related stuff. 3 * Hodge-podge collection of knfsd-related stuff.
3 * I will sort this out later. 4 * I will sort this out later.
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index cfe7500d5847..8aa011820c4a 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * NFS server file handle treatment. 3 * NFS server file handle treatment.
3 * 4 *
diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h
index e47cf6c2ac28..43f31cf49bae 100644
--- a/fs/nfsd/nfsfh.h
+++ b/fs/nfsd/nfsfh.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> 3 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
3 * 4 *
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index 5076ae2b8258..43c0419b8ddb 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Process version 2 NFS requests. 3 * Process version 2 NFS requests.
3 * 4 *
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 7e3af3ef0917..e02bd2783124 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Central processing for nfsd. 3 * Central processing for nfsd.
3 * 4 *
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index e4da2717982d..644a0342f0e0 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * XDR support for nfsd 3 * XDR support for nfsd
3 * 4 *
diff --git a/fs/nfsd/pnfs.h b/fs/nfsd/pnfs.h
index d27a5aa60022..4f4282d4eeca 100644
--- a/fs/nfsd/pnfs.h
+++ b/fs/nfsd/pnfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _FS_NFSD_PNFS_H 2#ifndef _FS_NFSD_PNFS_H
2#define _FS_NFSD_PNFS_H 1 3#define _FS_NFSD_PNFS_H 1
3 4
diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
index d97338bb6a39..9bce3b913189 100644
--- a/fs/nfsd/stats.c
+++ b/fs/nfsd/stats.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * procfs-based user access to knfsd statistics 3 * procfs-based user access to knfsd statistics
3 * 4 *
diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h
index a5c944b771c6..b23fdac69820 100644
--- a/fs/nfsd/stats.h
+++ b/fs/nfsd/stats.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Statistics for NFS server. 3 * Statistics for NFS server.
3 * 4 *
diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index 3287041905da..8b2f1d92c579 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (c) 2014 Christoph Hellwig. 3 * Copyright (c) 2014 Christoph Hellwig.
3 */ 4 */
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index bc69d40c4e8b..a3c9bfa77def 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * File operations used by nfsd. Some of these have been ripped from 3 * File operations used by nfsd. Some of these have been ripped from
3 * other parts of the kernel because they weren't exported, others 4 * other parts of the kernel because they weren't exported, others
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 1bbdccecbf3d..be6d8e00453f 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> 3 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
3 */ 4 */
diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h
index 457ce45e5084..2f4f22e6b8cb 100644
--- a/fs/nfsd/xdr.h
+++ b/fs/nfsd/xdr.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* XDR types for nfsd. This is mainly a typing exercise. */ 2/* XDR types for nfsd. This is mainly a typing exercise. */
2 3
3#ifndef LINUX_NFSD_H 4#ifndef LINUX_NFSD_H
diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h
index 80d7da620e91..056bf8a7364e 100644
--- a/fs/nfsd/xdr3.h
+++ b/fs/nfsd/xdr3.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * XDR types for NFSv3 in nfsd. 3 * XDR types for NFSv3 in nfsd.
3 * 4 *
diff --git a/fs/nfsd/xdr4cb.h b/fs/nfsd/xdr4cb.h
index 49b719dfef95..517239af0302 100644
--- a/fs/nfsd/xdr4cb.h
+++ b/fs/nfsd/xdr4cb.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#define NFS4_MAXTAGLEN 20 2#define NFS4_MAXTAGLEN 20
2 3
3#define NFS4_enc_cb_null_sz 0 4#define NFS4_enc_cb_null_sz 0
diff --git a/fs/nilfs2/Makefile b/fs/nilfs2/Makefile
index fc603e0431bb..43b60b8a4d07 100644
--- a/fs/nilfs2/Makefile
+++ b/fs/nilfs2/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_NILFS2_FS) += nilfs2.o 2obj-$(CONFIG_NILFS2_FS) += nilfs2.o
2nilfs2-y := inode.o file.o dir.o super.o namei.o page.o mdt.o \ 3nilfs2-y := inode.o file.o dir.o super.o namei.o page.o mdt.o \
3 btnode.o bmap.o btree.o direct.o dat.o recovery.o \ 4 btnode.o bmap.o btree.o direct.o dat.o recovery.o \
diff --git a/fs/nilfs2/export.h b/fs/nilfs2/export.h
index 00107fdb9343..d29fd837c42c 100644
--- a/fs/nilfs2/export.h
+++ b/fs/nilfs2/export.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef NILFS_EXPORT_H 2#ifndef NILFS_EXPORT_H
2#define NILFS_EXPORT_H 3#define NILFS_EXPORT_H
3 4
diff --git a/fs/nls/Makefile b/fs/nls/Makefile
index 8ae37c1b5249..ac54db297128 100644
--- a/fs/nls/Makefile
+++ b/fs/nls/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for native language support 3# Makefile for native language support
3# 4#
diff --git a/fs/notify/Makefile b/fs/notify/Makefile
index 3e969ae91b60..63a4b8828df4 100644
--- a/fs/notify/Makefile
+++ b/fs/notify/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_FSNOTIFY) += fsnotify.o notification.o group.o mark.o \ 2obj-$(CONFIG_FSNOTIFY) += fsnotify.o notification.o group.o mark.o \
2 fdinfo.o 3 fdinfo.o
3 4
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 2fa99aeaa095..09640b546363 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fanotify.h> 2#include <linux/fanotify.h>
2#include <linux/fdtable.h> 3#include <linux/fdtable.h>
3#include <linux/fsnotify_backend.h> 4#include <linux/fsnotify_backend.h>
diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h
index 4eb6f5efa282..7dacb7d80727 100644
--- a/fs/notify/fanotify/fanotify.h
+++ b/fs/notify/fanotify/fanotify.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/fsnotify_backend.h> 2#include <linux/fsnotify_backend.h>
2#include <linux/path.h> 3#include <linux/path.h>
3#include <linux/slab.h> 4#include <linux/slab.h>
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 907a481ac781..9752e7270e61 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fanotify.h> 2#include <linux/fanotify.h>
2#include <linux/fcntl.h> 3#include <linux/fcntl.h>
3#include <linux/file.h> 4#include <linux/file.h>
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
index dd63aa9a6f9a..517f88c1dbe5 100644
--- a/fs/notify/fdinfo.c
+++ b/fs/notify/fdinfo.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/file.h> 2#include <linux/file.h>
2#include <linux/fs.h> 3#include <linux/fs.h>
3#include <linux/fsnotify_backend.h> 4#include <linux/fsnotify_backend.h>
diff --git a/fs/notify/fdinfo.h b/fs/notify/fdinfo.h
index 9664c4904d6b..5c9937e02e21 100644
--- a/fs/notify/fdinfo.h
+++ b/fs/notify/fdinfo.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __FSNOTIFY_FDINFO_H__ 2#ifndef __FSNOTIFY_FDINFO_H__
2#define __FSNOTIFY_FDINFO_H__ 3#define __FSNOTIFY_FDINFO_H__
3 4
diff --git a/fs/notify/fsnotify.h b/fs/notify/fsnotify.h
index bf012e8ecd14..60f365dc1408 100644
--- a/fs/notify/fsnotify.h
+++ b/fs/notify/fsnotify.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __FS_NOTIFY_FSNOTIFY_H_ 2#ifndef __FS_NOTIFY_FSNOTIFY_H_
2#define __FS_NOTIFY_FSNOTIFY_H_ 3#define __FS_NOTIFY_FSNOTIFY_H_
3 4
diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h
index 9ff67b61da8a..c00d2caca894 100644
--- a/fs/notify/inotify/inotify.h
+++ b/fs/notify/inotify/inotify.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/fsnotify_backend.h> 2#include <linux/fsnotify_backend.h>
2#include <linux/inotify.h> 3#include <linux/inotify.h>
3#include <linux/slab.h> /* struct kmem_cache */ 4#include <linux/slab.h> /* struct kmem_cache */
diff --git a/fs/nsfs.c b/fs/nsfs.c
index 08127a2b8559..ef243e14b6eb 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/mount.h> 2#include <linux/mount.h>
2#include <linux/file.h> 3#include <linux/file.h>
3#include <linux/fs.h> 4#include <linux/fs.h>
diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile
index 2ff263e6d363..3e736572ed00 100644
--- a/fs/ntfs/Makefile
+++ b/fs/ntfs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# Rules for making the NTFS driver. 2# Rules for making the NTFS driver.
2 3
3obj-$(CONFIG_NTFS_FS) += ntfs.o 4obj-$(CONFIG_NTFS_FS) += ntfs.o
diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
index 4342c7ee7d20..99ee093182cb 100644
--- a/fs/ocfs2/Makefile
+++ b/fs/ocfs2/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1ccflags-y := -Ifs/ocfs2 2ccflags-y := -Ifs/ocfs2
2 3
3obj-$(CONFIG_OCFS2_FS) += \ 4obj-$(CONFIG_OCFS2_FS) += \
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index a177eae3aa1a..addd7c5f2d3e 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -7304,13 +7304,24 @@ out:
7304 7304
7305static int ocfs2_trim_extent(struct super_block *sb, 7305static int ocfs2_trim_extent(struct super_block *sb,
7306 struct ocfs2_group_desc *gd, 7306 struct ocfs2_group_desc *gd,
7307 u32 start, u32 count) 7307 u64 group, u32 start, u32 count)
7308{ 7308{
7309 u64 discard, bcount; 7309 u64 discard, bcount;
7310 struct ocfs2_super *osb = OCFS2_SB(sb);
7310 7311
7311 bcount = ocfs2_clusters_to_blocks(sb, count); 7312 bcount = ocfs2_clusters_to_blocks(sb, count);
7312 discard = le64_to_cpu(gd->bg_blkno) + 7313 discard = ocfs2_clusters_to_blocks(sb, start);
7313 ocfs2_clusters_to_blocks(sb, start); 7314
7315 /*
7316 * For the first cluster group, the gd->bg_blkno is not at the start
7317 * of the group, but at an offset from the start. If we add it while
7318 * calculating discard for first group, we will wrongly start fstrim a
7319 * few blocks after the desried start block and the range can cross
7320 * over into the next cluster group. So, add it only if this is not
7321 * the first cluster group.
7322 */
7323 if (group != osb->first_cluster_group_blkno)
7324 discard += le64_to_cpu(gd->bg_blkno);
7314 7325
7315 trace_ocfs2_trim_extent(sb, (unsigned long long)discard, bcount); 7326 trace_ocfs2_trim_extent(sb, (unsigned long long)discard, bcount);
7316 7327
@@ -7318,7 +7329,7 @@ static int ocfs2_trim_extent(struct super_block *sb,
7318} 7329}
7319 7330
7320static int ocfs2_trim_group(struct super_block *sb, 7331static int ocfs2_trim_group(struct super_block *sb,
7321 struct ocfs2_group_desc *gd, 7332 struct ocfs2_group_desc *gd, u64 group,
7322 u32 start, u32 max, u32 minbits) 7333 u32 start, u32 max, u32 minbits)
7323{ 7334{
7324 int ret = 0, count = 0, next; 7335 int ret = 0, count = 0, next;
@@ -7337,7 +7348,7 @@ static int ocfs2_trim_group(struct super_block *sb,
7337 next = ocfs2_find_next_bit(bitmap, max, start); 7348 next = ocfs2_find_next_bit(bitmap, max, start);
7338 7349
7339 if ((next - start) >= minbits) { 7350 if ((next - start) >= minbits) {
7340 ret = ocfs2_trim_extent(sb, gd, 7351 ret = ocfs2_trim_extent(sb, gd, group,
7341 start, next - start); 7352 start, next - start);
7342 if (ret < 0) { 7353 if (ret < 0) {
7343 mlog_errno(ret); 7354 mlog_errno(ret);
@@ -7435,7 +7446,8 @@ int ocfs2_trim_fs(struct super_block *sb, struct fstrim_range *range)
7435 } 7446 }
7436 7447
7437 gd = (struct ocfs2_group_desc *)gd_bh->b_data; 7448 gd = (struct ocfs2_group_desc *)gd_bh->b_data;
7438 cnt = ocfs2_trim_group(sb, gd, first_bit, last_bit, minlen); 7449 cnt = ocfs2_trim_group(sb, gd, group,
7450 first_bit, last_bit, minlen);
7439 brelse(gd_bh); 7451 brelse(gd_bh);
7440 gd_bh = NULL; 7452 gd_bh = NULL;
7441 if (cnt < 0) { 7453 if (cnt < 0) {
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 4506ec5ec2ea..ab30c005cc4b 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ocfs2/ioctl.c 3 * linux/fs/ocfs2/ioctl.c
3 * 4 *
diff --git a/fs/ocfs2/ioctl.h b/fs/ocfs2/ioctl.h
index 0cd5323bd3f0..9f5e4d95e37f 100644
--- a/fs/ocfs2/ioctl.h
+++ b/fs/ocfs2/ioctl.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * ioctl.h 3 * ioctl.h
3 * 4 *
diff --git a/fs/ocfs2/mmap.h b/fs/ocfs2/mmap.h
index 1274ee0f1fe2..1051507cc684 100644
--- a/fs/ocfs2/mmap.h
+++ b/fs/ocfs2/mmap.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef OCFS2_MMAP_H 2#ifndef OCFS2_MMAP_H
2#define OCFS2_MMAP_H 3#define OCFS2_MMAP_H
3 4
diff --git a/fs/ocfs2/ocfs2_trace.h b/fs/ocfs2/ocfs2_trace.h
index 0b58abcf1c6d..a0b5d00ef0a9 100644
--- a/fs/ocfs2/ocfs2_trace.h
+++ b/fs/ocfs2/ocfs2_trace.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#undef TRACE_SYSTEM 2#undef TRACE_SYSTEM
2#define TRACE_SYSTEM ocfs2 3#define TRACE_SYSTEM ocfs2
3 4
diff --git a/fs/ocfs2/quota.h b/fs/ocfs2/quota.h
index d153e6e31529..ebb5c99f490e 100644
--- a/fs/ocfs2/quota.h
+++ b/fs/ocfs2/quota.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * quota.h for OCFS2 3 * quota.h for OCFS2
3 * 4 *
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index c94b6baaa551..b39d14cbfa34 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Implementation of operations over global quota file 3 * Implementation of operations over global quota file
3 */ 4 */
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index aa700fd10610..16c42ed0dca8 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Implementation of operations over local quota file 3 * Implementation of operations over local quota file
3 */ 4 */
diff --git a/fs/omfs/bitmap.c b/fs/omfs/bitmap.c
index 83f4e76511c2..7147ba6a6afc 100644
--- a/fs/omfs/bitmap.c
+++ b/fs/omfs/bitmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/kernel.h> 2#include <linux/kernel.h>
2#include <linux/fs.h> 3#include <linux/fs.h>
3#include <linux/buffer_head.h> 4#include <linux/buffer_head.h>
diff --git a/fs/omfs/omfs.h b/fs/omfs/omfs.h
index f0f8bc75e609..4008be73de54 100644
--- a/fs/omfs/omfs.h
+++ b/fs/omfs/omfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _OMFS_H 2#ifndef _OMFS_H
2#define _OMFS_H 3#define _OMFS_H
3 4
diff --git a/fs/omfs/omfs_fs.h b/fs/omfs/omfs_fs.h
index 83a98330ed66..caecb3d5a344 100644
--- a/fs/omfs/omfs_fs.h
+++ b/fs/omfs/omfs_fs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _OMFS_FS_H 2#ifndef _OMFS_FS_H
2#define _OMFS_FS_H 3#define _OMFS_FS_H
3 4
diff --git a/fs/orangefs/Makefile b/fs/orangefs/Makefile
index a9d6a968fe6d..9b6c50bb173b 100644
--- a/fs/orangefs/Makefile
+++ b/fs/orangefs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the ORANGEFS filesystem. 3# Makefile for the ORANGEFS filesystem.
3# 4#
diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
index 9108ef433e6d..c2d8233b1e82 100644
--- a/fs/orangefs/acl.c
+++ b/fs/orangefs/acl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/dcache.c b/fs/orangefs/dcache.c
index 5355efba4bc8..ae782df5c063 100644
--- a/fs/orangefs/dcache.c
+++ b/fs/orangefs/dcache.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c
index 2826859bdc2c..ded456f17de6 100644
--- a/fs/orangefs/devorangefs-req.c
+++ b/fs/orangefs/devorangefs-req.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/dir.c b/fs/orangefs/dir.c
index d327cbd17756..a8cc588d6224 100644
--- a/fs/orangefs/dir.c
+++ b/fs/orangefs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 2017 Omnibond Systems, L.L.C. 3 * Copyright 2017 Omnibond Systems, L.L.C.
3 */ 4 */
diff --git a/fs/orangefs/downcall.h b/fs/orangefs/downcall.h
index 163001c95501..ea2332e16af9 100644
--- a/fs/orangefs/downcall.h
+++ b/fs/orangefs/downcall.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c
index 336ecbf8c268..e4a8e6a7eb17 100644
--- a/fs/orangefs/file.c
+++ b/fs/orangefs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 9428ea0aac16..28825a5b6d09 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 478e88bd7f9d..7e9e5d0ea3bc 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index 7ef473f3d642..59f444dced9b 100644
--- a/fs/orangefs/orangefs-bufmap.c
+++ b/fs/orangefs/orangefs-bufmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/orangefs-bufmap.h b/fs/orangefs/orangefs-bufmap.h
index 71f64f4057b5..c2c3c5a0eeab 100644
--- a/fs/orangefs/orangefs-bufmap.h
+++ b/fs/orangefs/orangefs-bufmap.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/orangefs-cache.c b/fs/orangefs/orangefs-cache.c
index aa3830b741c7..3b6982bf6bcf 100644
--- a/fs/orangefs/orangefs-cache.c
+++ b/fs/orangefs/orangefs-cache.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/orangefs-debug.h b/fs/orangefs/orangefs-debug.h
index 387db17cde2b..b6001bb28f5a 100644
--- a/fs/orangefs/orangefs-debug.h
+++ b/fs/orangefs/orangefs-debug.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 5f59917fd631..1c59dff530de 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * What: /sys/kernel/debug/orangefs/debug-help 3 * What: /sys/kernel/debug/orangefs/debug-help
3 * Date: June 2015 4 * Date: June 2015
diff --git a/fs/orangefs/orangefs-debugfs.h b/fs/orangefs/orangefs-debugfs.h
index 803517269ba6..b5fd9cd4960f 100644
--- a/fs/orangefs/orangefs-debugfs.h
+++ b/fs/orangefs/orangefs-debugfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1int orangefs_debugfs_init(int); 2int orangefs_debugfs_init(int);
2void orangefs_debugfs_cleanup(void); 3void orangefs_debugfs_cleanup(void);
3int orangefs_client_debug_init(void); 4int orangefs_client_debug_init(void);
diff --git a/fs/orangefs/orangefs-dev-proto.h b/fs/orangefs/orangefs-dev-proto.h
index efe08c763e56..dc6609824965 100644
--- a/fs/orangefs/orangefs-dev-proto.h
+++ b/fs/orangefs/orangefs-dev-proto.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index ea0ce507a6ab..004af348fb80 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/orangefs-sysfs.c b/fs/orangefs/orangefs-sysfs.c
index afd2f523b283..079a465796f3 100644
--- a/fs/orangefs/orangefs-sysfs.c
+++ b/fs/orangefs/orangefs-sysfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Documentation/ABI/stable/orangefs-sysfs: 3 * Documentation/ABI/stable/orangefs-sysfs:
3 * 4 *
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
index aab6f1842963..f82336496311 100644
--- a/fs/orangefs/orangefs-utils.c
+++ b/fs/orangefs/orangefs-utils.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/protocol.h b/fs/orangefs/protocol.h
index 48bcc1bbe415..e0bf5e4dce0d 100644
--- a/fs/orangefs/protocol.h
+++ b/fs/orangefs/protocol.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/kernel.h> 2#include <linux/kernel.h>
2#include <linux/types.h> 3#include <linux/types.h>
3#include <linux/spinlock_types.h> 4#include <linux/spinlock_types.h>
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index 47f3fb9cbec4..47ebd9bfd1a1 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/symlink.c b/fs/orangefs/symlink.c
index 02b1bbdbcc42..d856cdf91763 100644
--- a/fs/orangefs/symlink.c
+++ b/fs/orangefs/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/upcall.h b/fs/orangefs/upcall.h
index b8249f8fdd80..16118452aa12 100644
--- a/fs/orangefs/upcall.h
+++ b/fs/orangefs/upcall.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/orangefs/waitqueue.c b/fs/orangefs/waitqueue.c
index 61e2ca7fec55..835c6e148afc 100644
--- a/fs/orangefs/waitqueue.c
+++ b/fs/orangefs/waitqueue.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * (C) 2011 Omnibond Systems 4 * (C) 2011 Omnibond Systems
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c
index 81ac88bb91ff..03bcb871544d 100644
--- a/fs/orangefs/xattr.c
+++ b/fs/orangefs/xattr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * (C) 2001 Clemson University and The University of Chicago 3 * (C) 2001 Clemson University and The University of Chicago
3 * 4 *
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index aad97b30d5e6..c441f9387a1b 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -561,10 +561,8 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
561 c->tmpfile = true; 561 c->tmpfile = true;
562 err = ovl_copy_up_locked(c); 562 err = ovl_copy_up_locked(c);
563 } else { 563 } else {
564 err = -EIO; 564 err = ovl_lock_rename_workdir(c->workdir, c->destdir);
565 if (lock_rename(c->workdir, c->destdir) != NULL) { 565 if (!err) {
566 pr_err("overlayfs: failed to lock workdir+upperdir\n");
567 } else {
568 err = ovl_copy_up_locked(c); 566 err = ovl_copy_up_locked(c);
569 unlock_rename(c->workdir, c->destdir); 567 unlock_rename(c->workdir, c->destdir);
570 } 568 }
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 3309b1912241..cc961a3bd3bd 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -216,26 +216,6 @@ out_unlock:
216 return err; 216 return err;
217} 217}
218 218
219static int ovl_lock_rename_workdir(struct dentry *workdir,
220 struct dentry *upperdir)
221{
222 /* Workdir should not be the same as upperdir */
223 if (workdir == upperdir)
224 goto err;
225
226 /* Workdir should not be subdir of upperdir and vice versa */
227 if (lock_rename(workdir, upperdir) != NULL)
228 goto err_unlock;
229
230 return 0;
231
232err_unlock:
233 unlock_rename(workdir, upperdir);
234err:
235 pr_err("overlayfs: failed to lock workdir+upperdir\n");
236 return -EIO;
237}
238
239static struct dentry *ovl_clear_empty(struct dentry *dentry, 219static struct dentry *ovl_clear_empty(struct dentry *dentry,
240 struct list_head *list) 220 struct list_head *list)
241{ 221{
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index a619addecafc..321511ed8c42 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -598,18 +598,30 @@ static bool ovl_verify_inode(struct inode *inode, struct dentry *lowerdentry,
598 return true; 598 return true;
599} 599}
600 600
601struct inode *ovl_get_inode(struct dentry *dentry, struct dentry *upperdentry) 601struct inode *ovl_get_inode(struct dentry *dentry, struct dentry *upperdentry,
602 struct dentry *index)
602{ 603{
603 struct dentry *lowerdentry = ovl_dentry_lower(dentry); 604 struct dentry *lowerdentry = ovl_dentry_lower(dentry);
604 struct inode *realinode = upperdentry ? d_inode(upperdentry) : NULL; 605 struct inode *realinode = upperdentry ? d_inode(upperdentry) : NULL;
605 struct inode *inode; 606 struct inode *inode;
607 /* Already indexed or could be indexed on copy up? */
608 bool indexed = (index || (ovl_indexdir(dentry->d_sb) && !upperdentry));
609
610 if (WARN_ON(upperdentry && indexed && !lowerdentry))
611 return ERR_PTR(-EIO);
606 612
607 if (!realinode) 613 if (!realinode)
608 realinode = d_inode(lowerdentry); 614 realinode = d_inode(lowerdentry);
609 615
610 if (!S_ISDIR(realinode->i_mode) && 616 /*
611 (upperdentry || (lowerdentry && ovl_indexdir(dentry->d_sb)))) { 617 * Copy up origin (lower) may exist for non-indexed upper, but we must
612 struct inode *key = d_inode(lowerdentry ?: upperdentry); 618 * not use lower as hash key in that case.
619 * Hash inodes that are or could be indexed by origin inode and
620 * non-indexed upper inodes that could be hard linked by upper inode.
621 */
622 if (!S_ISDIR(realinode->i_mode) && (upperdentry || indexed)) {
623 struct inode *key = d_inode(indexed ? lowerdentry :
624 upperdentry);
613 unsigned int nlink; 625 unsigned int nlink;
614 626
615 inode = iget5_locked(dentry->d_sb, (unsigned long) key, 627 inode = iget5_locked(dentry->d_sb, (unsigned long) key,
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index c3addd1114f1..a12dc10bf726 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -405,14 +405,13 @@ int ovl_verify_index(struct dentry *index, struct path *lowerstack,
405 * be treated as stale (i.e. after unlink of the overlay inode). 405 * be treated as stale (i.e. after unlink of the overlay inode).
406 * We don't know the verification rules for directory and whiteout 406 * We don't know the verification rules for directory and whiteout
407 * index entries, because they have not been implemented yet, so return 407 * index entries, because they have not been implemented yet, so return
408 * EROFS if those entries are found to avoid corrupting an index that 408 * EINVAL if those entries are found to abort the mount to avoid
409 * was created by a newer kernel. 409 * corrupting an index that was created by a newer kernel.
410 */ 410 */
411 err = -EROFS; 411 err = -EINVAL;
412 if (d_is_dir(index) || ovl_is_whiteout(index)) 412 if (d_is_dir(index) || ovl_is_whiteout(index))
413 goto fail; 413 goto fail;
414 414
415 err = -EINVAL;
416 if (index->d_name.len < sizeof(struct ovl_fh)*2) 415 if (index->d_name.len < sizeof(struct ovl_fh)*2)
417 goto fail; 416 goto fail;
418 417
@@ -506,6 +505,11 @@ static struct dentry *ovl_lookup_index(struct dentry *dentry,
506 505
507 index = lookup_one_len_unlocked(name.name, ofs->indexdir, name.len); 506 index = lookup_one_len_unlocked(name.name, ofs->indexdir, name.len);
508 if (IS_ERR(index)) { 507 if (IS_ERR(index)) {
508 err = PTR_ERR(index);
509 if (err == -ENOENT) {
510 index = NULL;
511 goto out;
512 }
509 pr_warn_ratelimited("overlayfs: failed inode index lookup (ino=%lu, key=%*s, err=%i);\n" 513 pr_warn_ratelimited("overlayfs: failed inode index lookup (ino=%lu, key=%*s, err=%i);\n"
510 "overlayfs: mount with '-o index=off' to disable inodes index.\n", 514 "overlayfs: mount with '-o index=off' to disable inodes index.\n",
511 d_inode(origin)->i_ino, name.len, name.name, 515 d_inode(origin)->i_ino, name.len, name.name,
@@ -515,18 +519,9 @@ static struct dentry *ovl_lookup_index(struct dentry *dentry,
515 519
516 inode = d_inode(index); 520 inode = d_inode(index);
517 if (d_is_negative(index)) { 521 if (d_is_negative(index)) {
518 if (upper && d_inode(origin)->i_nlink > 1) { 522 goto out_dput;
519 pr_warn_ratelimited("overlayfs: hard link with origin but no index (ino=%lu).\n",
520 d_inode(origin)->i_ino);
521 goto fail;
522 }
523
524 dput(index);
525 index = NULL;
526 } else if (upper && d_inode(upper) != inode) { 523 } else if (upper && d_inode(upper) != inode) {
527 pr_warn_ratelimited("overlayfs: wrong index found (index=%pd2, ino=%lu, upper ino=%lu).\n", 524 goto out_dput;
528 index, inode->i_ino, d_inode(upper)->i_ino);
529 goto fail;
530 } else if (ovl_dentry_weird(index) || ovl_is_whiteout(index) || 525 } else if (ovl_dentry_weird(index) || ovl_is_whiteout(index) ||
531 ((inode->i_mode ^ d_inode(origin)->i_mode) & S_IFMT)) { 526 ((inode->i_mode ^ d_inode(origin)->i_mode) & S_IFMT)) {
532 /* 527 /*
@@ -546,6 +541,11 @@ out:
546 kfree(name.name); 541 kfree(name.name);
547 return index; 542 return index;
548 543
544out_dput:
545 dput(index);
546 index = NULL;
547 goto out;
548
549fail: 549fail:
550 dput(index); 550 dput(index);
551 index = ERR_PTR(-EIO); 551 index = ERR_PTR(-EIO);
@@ -634,6 +634,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
634 } 634 }
635 635
636 if (d.redirect) { 636 if (d.redirect) {
637 err = -ENOMEM;
637 upperredirect = kstrdup(d.redirect, GFP_KERNEL); 638 upperredirect = kstrdup(d.redirect, GFP_KERNEL);
638 if (!upperredirect) 639 if (!upperredirect)
639 goto out_put_upper; 640 goto out_put_upper;
@@ -708,7 +709,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
708 upperdentry = dget(index); 709 upperdentry = dget(index);
709 710
710 if (upperdentry || ctr) { 711 if (upperdentry || ctr) {
711 inode = ovl_get_inode(dentry, upperdentry); 712 inode = ovl_get_inode(dentry, upperdentry, index);
712 err = PTR_ERR(inode); 713 err = PTR_ERR(inode);
713 if (IS_ERR(inode)) 714 if (IS_ERR(inode))
714 goto out_free_oe; 715 goto out_free_oe;
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index d4e8c1a08fb0..d9a0edd4e57e 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -235,6 +235,7 @@ bool ovl_inuse_trylock(struct dentry *dentry);
235void ovl_inuse_unlock(struct dentry *dentry); 235void ovl_inuse_unlock(struct dentry *dentry);
236int ovl_nlink_start(struct dentry *dentry, bool *locked); 236int ovl_nlink_start(struct dentry *dentry, bool *locked);
237void ovl_nlink_end(struct dentry *dentry, bool locked); 237void ovl_nlink_end(struct dentry *dentry, bool locked);
238int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir);
238 239
239static inline bool ovl_is_impuredir(struct dentry *dentry) 240static inline bool ovl_is_impuredir(struct dentry *dentry)
240{ 241{
@@ -285,7 +286,8 @@ int ovl_update_time(struct inode *inode, struct timespec *ts, int flags);
285bool ovl_is_private_xattr(const char *name); 286bool ovl_is_private_xattr(const char *name);
286 287
287struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, dev_t rdev); 288struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, dev_t rdev);
288struct inode *ovl_get_inode(struct dentry *dentry, struct dentry *upperdentry); 289struct inode *ovl_get_inode(struct dentry *dentry, struct dentry *upperdentry,
290 struct dentry *index);
289static inline void ovl_copyattr(struct inode *from, struct inode *to) 291static inline void ovl_copyattr(struct inode *from, struct inode *to)
290{ 292{
291 to->i_uid = from->i_uid; 293 to->i_uid = from->i_uid;
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index 878a750986dd..25d9b5adcd42 100644
--- a/fs/overlayfs/ovl_entry.h
+++ b/fs/overlayfs/ovl_entry.h
@@ -37,6 +37,9 @@ struct ovl_fs {
37 bool noxattr; 37 bool noxattr;
38 /* sb common to all layers */ 38 /* sb common to all layers */
39 struct super_block *same_sb; 39 struct super_block *same_sb;
40 /* Did we take the inuse lock? */
41 bool upperdir_locked;
42 bool workdir_locked;
40}; 43};
41 44
42/* private information held for every overlayfs dentry */ 45/* private information held for every overlayfs dentry */
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 62e9b22a2077..698b74dd750e 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -988,6 +988,7 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
988 struct path *lowerstack, unsigned int numlower) 988 struct path *lowerstack, unsigned int numlower)
989{ 989{
990 int err; 990 int err;
991 struct dentry *index = NULL;
991 struct inode *dir = dentry->d_inode; 992 struct inode *dir = dentry->d_inode;
992 struct path path = { .mnt = mnt, .dentry = dentry }; 993 struct path path = { .mnt = mnt, .dentry = dentry };
993 LIST_HEAD(list); 994 LIST_HEAD(list);
@@ -1007,8 +1008,6 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
1007 1008
1008 inode_lock_nested(dir, I_MUTEX_PARENT); 1009 inode_lock_nested(dir, I_MUTEX_PARENT);
1009 list_for_each_entry(p, &list, l_node) { 1010 list_for_each_entry(p, &list, l_node) {
1010 struct dentry *index;
1011
1012 if (p->name[0] == '.') { 1011 if (p->name[0] == '.') {
1013 if (p->len == 1) 1012 if (p->len == 1)
1014 continue; 1013 continue;
@@ -1018,18 +1017,20 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
1018 index = lookup_one_len(p->name, dentry, p->len); 1017 index = lookup_one_len(p->name, dentry, p->len);
1019 if (IS_ERR(index)) { 1018 if (IS_ERR(index)) {
1020 err = PTR_ERR(index); 1019 err = PTR_ERR(index);
1020 index = NULL;
1021 break; 1021 break;
1022 } 1022 }
1023 err = ovl_verify_index(index, lowerstack, numlower); 1023 err = ovl_verify_index(index, lowerstack, numlower);
1024 if (err) { 1024 /* Cleanup stale and orphan index entries */
1025 if (err == -EROFS) 1025 if (err && (err == -ESTALE || err == -ENOENT))
1026 break;
1027 err = ovl_cleanup(dir, index); 1026 err = ovl_cleanup(dir, index);
1028 if (err) 1027 if (err)
1029 break; 1028 break;
1030 } 1029
1031 dput(index); 1030 dput(index);
1031 index = NULL;
1032 } 1032 }
1033 dput(index);
1033 inode_unlock(dir); 1034 inode_unlock(dir);
1034out: 1035out:
1035 ovl_cache_free(&list); 1036 ovl_cache_free(&list);
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index fd5ea4facc62..f5738e96a052 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -174,6 +174,9 @@ static struct inode *ovl_alloc_inode(struct super_block *sb)
174{ 174{
175 struct ovl_inode *oi = kmem_cache_alloc(ovl_inode_cachep, GFP_KERNEL); 175 struct ovl_inode *oi = kmem_cache_alloc(ovl_inode_cachep, GFP_KERNEL);
176 176
177 if (!oi)
178 return NULL;
179
177 oi->cache = NULL; 180 oi->cache = NULL;
178 oi->redirect = NULL; 181 oi->redirect = NULL;
179 oi->version = 0; 182 oi->version = 0;
@@ -211,9 +214,10 @@ static void ovl_put_super(struct super_block *sb)
211 214
212 dput(ufs->indexdir); 215 dput(ufs->indexdir);
213 dput(ufs->workdir); 216 dput(ufs->workdir);
214 ovl_inuse_unlock(ufs->workbasedir); 217 if (ufs->workdir_locked)
218 ovl_inuse_unlock(ufs->workbasedir);
215 dput(ufs->workbasedir); 219 dput(ufs->workbasedir);
216 if (ufs->upper_mnt) 220 if (ufs->upper_mnt && ufs->upperdir_locked)
217 ovl_inuse_unlock(ufs->upper_mnt->mnt_root); 221 ovl_inuse_unlock(ufs->upper_mnt->mnt_root);
218 mntput(ufs->upper_mnt); 222 mntput(ufs->upper_mnt);
219 for (i = 0; i < ufs->numlower; i++) 223 for (i = 0; i < ufs->numlower; i++)
@@ -881,9 +885,13 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
881 goto out_put_upperpath; 885 goto out_put_upperpath;
882 886
883 err = -EBUSY; 887 err = -EBUSY;
884 if (!ovl_inuse_trylock(upperpath.dentry)) { 888 if (ovl_inuse_trylock(upperpath.dentry)) {
885 pr_err("overlayfs: upperdir is in-use by another mount\n"); 889 ufs->upperdir_locked = true;
890 } else if (ufs->config.index) {
891 pr_err("overlayfs: upperdir is in-use by another mount, mount with '-o index=off' to override exclusive upperdir protection.\n");
886 goto out_put_upperpath; 892 goto out_put_upperpath;
893 } else {
894 pr_warn("overlayfs: upperdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
887 } 895 }
888 896
889 err = ovl_mount_dir(ufs->config.workdir, &workpath); 897 err = ovl_mount_dir(ufs->config.workdir, &workpath);
@@ -901,9 +909,13 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
901 } 909 }
902 910
903 err = -EBUSY; 911 err = -EBUSY;
904 if (!ovl_inuse_trylock(workpath.dentry)) { 912 if (ovl_inuse_trylock(workpath.dentry)) {
905 pr_err("overlayfs: workdir is in-use by another mount\n"); 913 ufs->workdir_locked = true;
914 } else if (ufs->config.index) {
915 pr_err("overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.\n");
906 goto out_put_workpath; 916 goto out_put_workpath;
917 } else {
918 pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
907 } 919 }
908 920
909 ufs->workbasedir = workpath.dentry; 921 ufs->workbasedir = workpath.dentry;
@@ -1156,11 +1168,13 @@ out_put_lowerpath:
1156out_free_lowertmp: 1168out_free_lowertmp:
1157 kfree(lowertmp); 1169 kfree(lowertmp);
1158out_unlock_workdentry: 1170out_unlock_workdentry:
1159 ovl_inuse_unlock(workpath.dentry); 1171 if (ufs->workdir_locked)
1172 ovl_inuse_unlock(workpath.dentry);
1160out_put_workpath: 1173out_put_workpath:
1161 path_put(&workpath); 1174 path_put(&workpath);
1162out_unlock_upperdentry: 1175out_unlock_upperdentry:
1163 ovl_inuse_unlock(upperpath.dentry); 1176 if (ufs->upperdir_locked)
1177 ovl_inuse_unlock(upperpath.dentry);
1164out_put_upperpath: 1178out_put_upperpath:
1165 path_put(&upperpath); 1179 path_put(&upperpath);
1166out_free_config: 1180out_free_config:
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 117794582f9f..b9b239fa5cfd 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -430,7 +430,7 @@ void ovl_inuse_unlock(struct dentry *dentry)
430 } 430 }
431} 431}
432 432
433/* Called must hold OVL_I(inode)->oi_lock */ 433/* Caller must hold OVL_I(inode)->lock */
434static void ovl_cleanup_index(struct dentry *dentry) 434static void ovl_cleanup_index(struct dentry *dentry)
435{ 435{
436 struct inode *dir = ovl_indexdir(dentry->d_sb)->d_inode; 436 struct inode *dir = ovl_indexdir(dentry->d_sb)->d_inode;
@@ -469,6 +469,9 @@ static void ovl_cleanup_index(struct dentry *dentry)
469 err = PTR_ERR(index); 469 err = PTR_ERR(index);
470 if (!IS_ERR(index)) 470 if (!IS_ERR(index))
471 err = ovl_cleanup(dir, index); 471 err = ovl_cleanup(dir, index);
472 else
473 index = NULL;
474
472 inode_unlock(dir); 475 inode_unlock(dir);
473 if (err) 476 if (err)
474 goto fail; 477 goto fail;
@@ -557,3 +560,22 @@ void ovl_nlink_end(struct dentry *dentry, bool locked)
557 mutex_unlock(&OVL_I(d_inode(dentry))->lock); 560 mutex_unlock(&OVL_I(d_inode(dentry))->lock);
558 } 561 }
559} 562}
563
564int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir)
565{
566 /* Workdir should not be the same as upperdir */
567 if (workdir == upperdir)
568 goto err;
569
570 /* Workdir should not be subdir of upperdir and vice versa */
571 if (lock_rename(workdir, upperdir) != NULL)
572 goto err_unlock;
573
574 return 0;
575
576err_unlock:
577 unlock_rename(workdir, upperdir);
578err:
579 pr_err("overlayfs: failed to lock workdir+upperdir\n");
580 return -EIO;
581}
diff --git a/fs/pipe.c b/fs/pipe.c
index 97e5be897753..349c9d56d4b3 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/pipe.c 3 * linux/fs/pipe.c
3 * 4 *
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index 12c6922c913c..f7456c4e7d0f 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the Linux proc filesystem routines. 3# Makefile for the Linux proc filesystem routines.
3# 4#
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 88c355574aa0..9390032a11e1 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/proc/array.c 3 * linux/fs/proc/array.c
3 * 4 *
@@ -62,6 +63,7 @@
62#include <linux/mman.h> 63#include <linux/mman.h>
63#include <linux/sched/mm.h> 64#include <linux/sched/mm.h>
64#include <linux/sched/numa_balancing.h> 65#include <linux/sched/numa_balancing.h>
66#include <linux/sched/task_stack.h>
65#include <linux/sched/task.h> 67#include <linux/sched/task.h>
66#include <linux/sched/cputime.h> 68#include <linux/sched/cputime.h>
67#include <linux/proc_fs.h> 69#include <linux/proc_fs.h>
@@ -118,30 +120,25 @@ static inline void task_name(struct seq_file *m, struct task_struct *p)
118 * simple bit tests. 120 * simple bit tests.
119 */ 121 */
120static const char * const task_state_array[] = { 122static const char * const task_state_array[] = {
121 "R (running)", /* 0 */ 123
122 "S (sleeping)", /* 1 */ 124 /* states in TASK_REPORT: */
123 "D (disk sleep)", /* 2 */ 125 "R (running)", /* 0x00 */
124 "T (stopped)", /* 4 */ 126 "S (sleeping)", /* 0x01 */
125 "t (tracing stop)", /* 8 */ 127 "D (disk sleep)", /* 0x02 */
126 "X (dead)", /* 16 */ 128 "T (stopped)", /* 0x04 */
127 "Z (zombie)", /* 32 */ 129 "t (tracing stop)", /* 0x08 */
130 "X (dead)", /* 0x10 */
131 "Z (zombie)", /* 0x20 */
132 "P (parked)", /* 0x40 */
133
134 /* states beyond TASK_REPORT: */
135 "I (idle)", /* 0x80 */
128}; 136};
129 137
130static inline const char *get_task_state(struct task_struct *tsk) 138static inline const char *get_task_state(struct task_struct *tsk)
131{ 139{
132 unsigned int state = (tsk->state | tsk->exit_state) & TASK_REPORT; 140 BUILD_BUG_ON(1 + ilog2(TASK_REPORT_MAX) != ARRAY_SIZE(task_state_array));
133 141 return task_state_array[__get_task_state(tsk)];
134 /*
135 * Parked tasks do not run; they sit in __kthread_parkme().
136 * Without this check, we would report them as running, which is
137 * clearly wrong, so we report them as sleeping instead.
138 */
139 if (tsk->state == TASK_PARKED)
140 state = TASK_INTERRUPTIBLE;
141
142 BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != ARRAY_SIZE(task_state_array)-1);
143
144 return task_state_array[fls(state)];
145} 142}
146 143
147static inline int get_task_umask(struct task_struct *tsk) 144static inline int get_task_umask(struct task_struct *tsk)
@@ -421,7 +418,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
421 * esp and eip are intentionally zeroed out. There is no 418 * esp and eip are intentionally zeroed out. There is no
422 * non-racy way to read them without freezing the task. 419 * non-racy way to read them without freezing the task.
423 * Programs that need reliable values can use ptrace(2). 420 * Programs that need reliable values can use ptrace(2).
421 *
422 * The only exception is if the task is core dumping because
423 * a program is not able to use ptrace(2) in that case. It is
424 * safe because the task has stopped executing permanently.
424 */ 425 */
426 if (permitted && (task->flags & PF_DUMPCORE)) {
427 eip = KSTK_EIP(task);
428 esp = KSTK_ESP(task);
429 }
425 } 430 }
426 431
427 get_task_comm(tcomm, task); 432 get_task_comm(tcomm, task);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index ad3b0762cc3e..9d357b2ea6cb 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/proc/base.c 3 * linux/fs/proc/base.c
3 * 4 *
diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
index cbd82dff7e81..403cbb12a6e9 100644
--- a/fs/proc/cmdline.c
+++ b/fs/proc/cmdline.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/proc_fs.h> 4#include <linux/proc_fs.h>
diff --git a/fs/proc/cpuinfo.c b/fs/proc/cpuinfo.c
index 06f4d31e0396..e0f867cd8553 100644
--- a/fs/proc/cpuinfo.c
+++ b/fs/proc/cpuinfo.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/proc_fs.h> 4#include <linux/proc_fs.h>
diff --git a/fs/proc/devices.c b/fs/proc/devices.c
index e5709343feb7..2c7f22b14489 100644
--- a/fs/proc/devices.c
+++ b/fs/proc/devices.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/proc_fs.h> 4#include <linux/proc_fs.h>
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index c330495c3115..96fc70225e54 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/sched/signal.h> 2#include <linux/sched/signal.h>
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/dcache.h> 4#include <linux/dcache.h>
diff --git a/fs/proc/fd.h b/fs/proc/fd.h
index 46dafadd0083..f371a602bf58 100644
--- a/fs/proc/fd.h
+++ b/fs/proc/fd.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __PROCFS_FD_H__ 2#ifndef __PROCFS_FD_H__
2#define __PROCFS_FD_H__ 3#define __PROCFS_FD_H__
3 4
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index e250910cffc8..225f541f7078 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/proc/inode.c 3 * linux/fs/proc/inode.c
3 * 4 *
diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
index a352d5703b41..6a6bee9c603c 100644
--- a/fs/proc/interrupts.c
+++ b/fs/proc/interrupts.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/interrupt.h> 4#include <linux/interrupt.h>
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 45629f4b5402..4bc85cb8be6a 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/proc/kcore.c kernel ELF core dumper 3 * fs/proc/kcore.c kernel ELF core dumper
3 * 4 *
diff --git a/fs/proc/kmsg.c b/fs/proc/kmsg.c
index f9387bb7631b..e0f8774acd65 100644
--- a/fs/proc/kmsg.c
+++ b/fs/proc/kmsg.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/proc/kmsg.c 3 * linux/fs/proc/kmsg.c
3 * 4 *
diff --git a/fs/proc/loadavg.c b/fs/proc/loadavg.c
index 983fce5c2418..9bc5c58c00ee 100644
--- a/fs/proc/loadavg.c
+++ b/fs/proc/loadavg.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/pid_namespace.h> 4#include <linux/pid_namespace.h>
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index cdd979724c74..6bb20f864259 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/kernel.h> 4#include <linux/kernel.h>
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 3803b24ca220..59b17e509f46 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/proc_fs.h> 2#include <linux/proc_fs.h>
2#include <linux/nsproxy.h> 3#include <linux/nsproxy.h>
3#include <linux/ptrace.h> 4#include <linux/ptrace.h>
diff --git a/fs/proc/page.c b/fs/proc/page.c
index 2726536489b1..1491918a33c3 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/bootmem.h> 2#include <linux/bootmem.h>
2#include <linux/compiler.h> 3#include <linux/compiler.h>
3#include <linux/fs.h> 4#include <linux/fs.h>
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 8f479229b349..c5cbbdff3c3d 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * /proc/sys support 3 * /proc/sys support
3 */ 4 */
diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c
index 901bd06f437d..2da657848cfc 100644
--- a/fs/proc/proc_tty.c
+++ b/fs/proc/proc_tty.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * proc_tty.c -- handles /proc/tty 3 * proc_tty.c -- handles /proc/tty
3 * 4 *
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 926fb27f4ca2..4e42aba97f2e 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/proc/root.c 3 * linux/fs/proc/root.c
3 * 4 *
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 39857f6db5cf..31326bb23b8b 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/sched.h> 2#include <linux/sched.h>
2#include <linux/slab.h> 3#include <linux/slab.h>
3#include <linux/pid_namespace.h> 4#include <linux/pid_namespace.h>
diff --git a/fs/proc/softirqs.c b/fs/proc/softirqs.c
index ad8a77f94beb..24072cc06e65 100644
--- a/fs/proc/softirqs.c
+++ b/fs/proc/softirqs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/init.h> 2#include <linux/init.h>
2#include <linux/kernel_stat.h> 3#include <linux/kernel_stat.h>
3#include <linux/proc_fs.h> 4#include <linux/proc_fs.h>
diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index bd4e55f4aa20..59749dfaef67 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/cpumask.h> 2#include <linux/cpumask.h>
2#include <linux/fs.h> 3#include <linux/fs.h>
3#include <linux/init.h> 4#include <linux/init.h>
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 5589b4bd4b85..6744bd706ecf 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/mm.h> 2#include <linux/mm.h>
2#include <linux/vmacache.h> 3#include <linux/vmacache.h>
3#include <linux/hugetlb.h> 4#include <linux/hugetlb.h>
@@ -1310,13 +1311,15 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
1310 pmd_t pmd = *pmdp; 1311 pmd_t pmd = *pmdp;
1311 struct page *page = NULL; 1312 struct page *page = NULL;
1312 1313
1313 if ((vma->vm_flags & VM_SOFTDIRTY) || pmd_soft_dirty(pmd)) 1314 if (vma->vm_flags & VM_SOFTDIRTY)
1314 flags |= PM_SOFT_DIRTY; 1315 flags |= PM_SOFT_DIRTY;
1315 1316
1316 if (pmd_present(pmd)) { 1317 if (pmd_present(pmd)) {
1317 page = pmd_page(pmd); 1318 page = pmd_page(pmd);
1318 1319
1319 flags |= PM_PRESENT; 1320 flags |= PM_PRESENT;
1321 if (pmd_soft_dirty(pmd))
1322 flags |= PM_SOFT_DIRTY;
1320 if (pm->show_pfn) 1323 if (pm->show_pfn)
1321 frame = pmd_pfn(pmd) + 1324 frame = pmd_pfn(pmd) +
1322 ((addr & ~PMD_MASK) >> PAGE_SHIFT); 1325 ((addr & ~PMD_MASK) >> PAGE_SHIFT);
@@ -1328,6 +1331,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
1328 frame = swp_type(entry) | 1331 frame = swp_type(entry) |
1329 (swp_offset(entry) << MAX_SWAPFILES_SHIFT); 1332 (swp_offset(entry) << MAX_SWAPFILES_SHIFT);
1330 flags |= PM_SWAP; 1333 flags |= PM_SWAP;
1334 if (pmd_swp_soft_dirty(pmd))
1335 flags |= PM_SOFT_DIRTY;
1331 VM_BUG_ON(!is_pmd_migration_entry(pmd)); 1336 VM_BUG_ON(!is_pmd_migration_entry(pmd));
1332 page = migration_entry_to_page(entry); 1337 page = migration_entry_to_page(entry);
1333 } 1338 }
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index b00b766098fa..5b62f57bd9bc 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1 2
2#include <linux/mm.h> 3#include <linux/mm.h>
3#include <linux/file.h> 4#include <linux/file.h>
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 20614b62a9b7..b813e3b529f2 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/sched.h> 2#include <linux/sched.h>
2#include <linux/slab.h> 3#include <linux/slab.h>
3#include <linux/pid_namespace.h> 4#include <linux/pid_namespace.h>
diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c
index 7981c4ffe787..95a708d83721 100644
--- a/fs/proc/uptime.c
+++ b/fs/proc/uptime.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/proc_fs.h> 4#include <linux/proc_fs.h>
diff --git a/fs/proc/version.c b/fs/proc/version.c
index d2154eb6d78f..94901e8e700d 100644
--- a/fs/proc/version.c
+++ b/fs/proc/version.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/kernel.h> 4#include <linux/kernel.h>
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 99dff222fe67..7626ee11b06c 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/proc_namespace.c - handling of /proc/<pid>/{mounts,mountinfo,mountstats} 3 * fs/proc_namespace.c - handling of /proc/<pid>/{mounts,mountinfo,mountstats}
3 * 4 *
diff --git a/fs/pstore/Makefile b/fs/pstore/Makefile
index b8803cc07fce..967b5891f325 100644
--- a/fs/pstore/Makefile
+++ b/fs/pstore/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the linux pstorefs routines. 3# Makefile for the linux pstorefs routines.
3# 4#
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index 7f4e48c8d188..c029314478fa 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __PSTORE_INTERNAL_H__ 2#ifndef __PSTORE_INTERNAL_H__
2#define __PSTORE_INTERNAL_H__ 3#define __PSTORE_INTERNAL_H__
3 4
diff --git a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c
index 76a7a697b778..163afc4ba4b2 100644
--- a/fs/qnx4/bitmap.c
+++ b/fs/qnx4/bitmap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * QNX4 file system, Linux implementation. 3 * QNX4 file system, Linux implementation.
3 * 4 *
diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c
index 781056a0480f..a6ee23aadd28 100644
--- a/fs/qnx4/dir.c
+++ b/fs/qnx4/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * QNX4 file system, Linux implementation. 3 * QNX4 file system, Linux implementation.
3 * 4 *
diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c
index e62c8183777a..eca27878079d 100644
--- a/fs/qnx4/namei.c
+++ b/fs/qnx4/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * QNX4 file system, Linux implementation. 3 * QNX4 file system, Linux implementation.
3 * 4 *
diff --git a/fs/qnx4/qnx4.h b/fs/qnx4/qnx4.h
index c9b1be2c164d..6283705466a4 100644
--- a/fs/qnx4/qnx4.h
+++ b/fs/qnx4/qnx4.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/qnx4_fs.h> 3#include <linux/qnx4_fs.h>
3 4
diff --git a/fs/qnx6/dir.c b/fs/qnx6/dir.c
index 27637e0bdc9f..c1cfb8a19e9d 100644
--- a/fs/qnx6/dir.c
+++ b/fs/qnx6/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * QNX6 file system, Linux implementation. 3 * QNX6 file system, Linux implementation.
3 * 4 *
diff --git a/fs/qnx6/namei.c b/fs/qnx6/namei.c
index 6c1a323137dd..72c2770830be 100644
--- a/fs/qnx6/namei.c
+++ b/fs/qnx6/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * QNX6 file system, Linux implementation. 3 * QNX6 file system, Linux implementation.
3 * 4 *
diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
index f23b5c4a66ad..34a6b126a3a9 100644
--- a/fs/qnx6/qnx6.h
+++ b/fs/qnx6/qnx6.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * QNX6 file system, Linux implementation. 3 * QNX6 file system, Linux implementation.
3 * 4 *
diff --git a/fs/qnx6/super_mmi.c b/fs/qnx6/super_mmi.c
index 62aaf3e3126a..d282c2c73404 100644
--- a/fs/qnx6/super_mmi.c
+++ b/fs/qnx6/super_mmi.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * QNX6 file system, Linux implementation. 3 * QNX6 file system, Linux implementation.
3 * 4 *
diff --git a/fs/quota/Makefile b/fs/quota/Makefile
index c66c37cdaa39..f2b49d0f0287 100644
--- a/fs/quota/Makefile
+++ b/fs/quota/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_QUOTA) += dquot.o 2obj-$(CONFIG_QUOTA) += dquot.o
2obj-$(CONFIG_QFMT_V1) += quota_v1.o 3obj-$(CONFIG_QFMT_V1) += quota_v1.o
3obj-$(CONFIG_QFMT_V2) += quota_v2.o 4obj-$(CONFIG_QFMT_V2) += quota_v2.o
diff --git a/fs/quota/compat.c b/fs/quota/compat.c
index fb1892fe3e56..779caed4f078 100644
--- a/fs/quota/compat.c
+++ b/fs/quota/compat.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1 2
2#include <linux/syscalls.h> 3#include <linux/syscalls.h>
3#include <linux/compat.h> 4#include <linux/compat.h>
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 8381db9db6d9..9f78b5015f2e 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Implementation of the diskquota system for the LINUX operating system. QUOTA 3 * Implementation of the diskquota system for the LINUX operating system. QUOTA
3 * is implemented using the BSD system call interface as the means of 4 * is implemented using the BSD system call interface as the means of
@@ -1297,21 +1298,18 @@ static int dquot_add_space(struct dquot *dquot, qsize_t space,
1297 spin_lock(&dquot->dq_dqb_lock); 1298 spin_lock(&dquot->dq_dqb_lock);
1298 if (!sb_has_quota_limits_enabled(sb, dquot->dq_id.type) || 1299 if (!sb_has_quota_limits_enabled(sb, dquot->dq_id.type) ||
1299 test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1300 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1300 goto add; 1301 goto finish;
1301 1302
1302 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace 1303 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace
1303 + space + rsv_space; 1304 + space + rsv_space;
1304 1305
1305 if (flags & DQUOT_SPACE_NOFAIL)
1306 goto add;
1307
1308 if (dquot->dq_dqb.dqb_bhardlimit && 1306 if (dquot->dq_dqb.dqb_bhardlimit &&
1309 tspace > dquot->dq_dqb.dqb_bhardlimit && 1307 tspace > dquot->dq_dqb.dqb_bhardlimit &&
1310 !ignore_hardlimit(dquot)) { 1308 !ignore_hardlimit(dquot)) {
1311 if (flags & DQUOT_SPACE_WARN) 1309 if (flags & DQUOT_SPACE_WARN)
1312 prepare_warning(warn, dquot, QUOTA_NL_BHARDWARN); 1310 prepare_warning(warn, dquot, QUOTA_NL_BHARDWARN);
1313 ret = -EDQUOT; 1311 ret = -EDQUOT;
1314 goto out; 1312 goto finish;
1315 } 1313 }
1316 1314
1317 if (dquot->dq_dqb.dqb_bsoftlimit && 1315 if (dquot->dq_dqb.dqb_bsoftlimit &&
@@ -1322,7 +1320,7 @@ static int dquot_add_space(struct dquot *dquot, qsize_t space,
1322 if (flags & DQUOT_SPACE_WARN) 1320 if (flags & DQUOT_SPACE_WARN)
1323 prepare_warning(warn, dquot, QUOTA_NL_BSOFTLONGWARN); 1321 prepare_warning(warn, dquot, QUOTA_NL_BSOFTLONGWARN);
1324 ret = -EDQUOT; 1322 ret = -EDQUOT;
1325 goto out; 1323 goto finish;
1326 } 1324 }
1327 1325
1328 if (dquot->dq_dqb.dqb_bsoftlimit && 1326 if (dquot->dq_dqb.dqb_bsoftlimit &&
@@ -1338,13 +1336,21 @@ static int dquot_add_space(struct dquot *dquot, qsize_t space,
1338 * be always printed 1336 * be always printed
1339 */ 1337 */
1340 ret = -EDQUOT; 1338 ret = -EDQUOT;
1341 goto out; 1339 goto finish;
1342 } 1340 }
1343 } 1341 }
1344add: 1342finish:
1345 dquot->dq_dqb.dqb_rsvspace += rsv_space; 1343 /*
1346 dquot->dq_dqb.dqb_curspace += space; 1344 * We have to be careful and go through warning generation & grace time
1347out: 1345 * setting even if DQUOT_SPACE_NOFAIL is set. That's why we check it
1346 * only here...
1347 */
1348 if (flags & DQUOT_SPACE_NOFAIL)
1349 ret = 0;
1350 if (!ret) {
1351 dquot->dq_dqb.dqb_rsvspace += rsv_space;
1352 dquot->dq_dqb.dqb_curspace += space;
1353 }
1348 spin_unlock(&dquot->dq_dqb_lock); 1354 spin_unlock(&dquot->dq_dqb_lock);
1349 return ret; 1355 return ret;
1350} 1356}
@@ -1980,7 +1986,9 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
1980 ret = dquot_add_space(transfer_to[cnt], cur_space, rsv_space, 0, 1986 ret = dquot_add_space(transfer_to[cnt], cur_space, rsv_space, 0,
1981 &warn_to[cnt]); 1987 &warn_to[cnt]);
1982 if (ret) { 1988 if (ret) {
1989 spin_lock(&transfer_to[cnt]->dq_dqb_lock);
1983 dquot_decr_inodes(transfer_to[cnt], inode_usage); 1990 dquot_decr_inodes(transfer_to[cnt], inode_usage);
1991 spin_unlock(&transfer_to[cnt]->dq_dqb_lock);
1984 goto over_quota; 1992 goto over_quota;
1985 } 1993 }
1986 } 1994 }
diff --git a/fs/quota/kqid.c b/fs/quota/kqid.c
index ebc5e6285800..f814fa90af38 100644
--- a/fs/quota/kqid.c
+++ b/fs/quota/kqid.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/quota.h> 3#include <linux/quota.h>
3#include <linux/export.h> 4#include <linux/export.h>
diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
index e99b1a72d9a7..95acdae391b4 100644
--- a/fs/quota/netlink.c
+++ b/fs/quota/netlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/cred.h> 2#include <linux/cred.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/kernel.h> 4#include <linux/kernel.h>
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index a9c5dfe6b83e..43612e2a73af 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Quota code necessary even when VFS quota support is not compiled 3 * Quota code necessary even when VFS quota support is not compiled
3 * into the kernel. The interesting stuff is over in dquot.c, here 4 * into the kernel. The interesting stuff is over in dquot.c, here
diff --git a/fs/quota/quota_tree.h b/fs/quota/quota_tree.h
index a1ab8db81a51..31cf27e0e9e0 100644
--- a/fs/quota/quota_tree.h
+++ b/fs/quota/quota_tree.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Definitions of structures for vfsv0 quota format 3 * Definitions of structures for vfsv0 quota format
3 */ 4 */
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index c0187cda2c1e..a73e5b34db41 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -328,12 +328,16 @@ static int v2_write_dquot(struct dquot *dquot)
328 if (!dquot->dq_off) { 328 if (!dquot->dq_off) {
329 alloc = true; 329 alloc = true;
330 down_write(&dqopt->dqio_sem); 330 down_write(&dqopt->dqio_sem);
331 } else {
332 down_read(&dqopt->dqio_sem);
331 } 333 }
332 ret = qtree_write_dquot( 334 ret = qtree_write_dquot(
333 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, 335 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv,
334 dquot); 336 dquot);
335 if (alloc) 337 if (alloc)
336 up_write(&dqopt->dqio_sem); 338 up_write(&dqopt->dqio_sem);
339 else
340 up_read(&dqopt->dqio_sem);
337 return ret; 341 return ret;
338} 342}
339 343
diff --git a/fs/quota/quotaio_v1.h b/fs/quota/quotaio_v1.h
index 746654b5de70..bd11e2c08119 100644
--- a/fs/quota/quotaio_v1.h
+++ b/fs/quota/quotaio_v1.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _LINUX_QUOTAIO_V1_H 2#ifndef _LINUX_QUOTAIO_V1_H
2#define _LINUX_QUOTAIO_V1_H 3#define _LINUX_QUOTAIO_V1_H
3 4
diff --git a/fs/quota/quotaio_v2.h b/fs/quota/quotaio_v2.h
index 4e95430093d9..43cf0f0e2902 100644
--- a/fs/quota/quotaio_v2.h
+++ b/fs/quota/quotaio_v2.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Definitions of structures for vfsv0 quota format 3 * Definitions of structures for vfsv0 quota format
3 */ 4 */
diff --git a/fs/read_write.c b/fs/read_write.c
index a2b9a47235c5..0046d72efe94 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/read_write.c 3 * linux/fs/read_write.c
3 * 4 *
@@ -112,7 +113,7 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence,
112 * In the generic case the entire file is data, so as long as 113 * In the generic case the entire file is data, so as long as
113 * offset isn't at the end of the file then the offset is data. 114 * offset isn't at the end of the file then the offset is data.
114 */ 115 */
115 if (offset >= eof) 116 if ((unsigned long long)offset >= eof)
116 return -ENXIO; 117 return -ENXIO;
117 break; 118 break;
118 case SEEK_HOLE: 119 case SEEK_HOLE:
@@ -120,7 +121,7 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence,
120 * There is a virtual hole at the end of the file, so as long as 121 * There is a virtual hole at the end of the file, so as long as
121 * offset isn't i_size or larger, return i_size. 122 * offset isn't i_size or larger, return i_size.
122 */ 123 */
123 if (offset >= eof) 124 if ((unsigned long long)offset >= eof)
124 return -ENXIO; 125 return -ENXIO;
125 offset = eof; 126 offset = eof;
126 break; 127 break;
diff --git a/fs/readdir.c b/fs/readdir.c
index 89659549c09d..d336db65a33e 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/readdir.c 3 * linux/fs/readdir.c
3 * 4 *
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile
index 3c3b00165114..a39a562c1c10 100644
--- a/fs/reiserfs/Makefile
+++ b/fs/reiserfs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the linux reiser-filesystem routines. 3# Makefile for the linux reiser-filesystem routines.
3# 4#
diff --git a/fs/reiserfs/acl.h b/fs/reiserfs/acl.h
index 4a211f5b34b8..0c1c847f992f 100644
--- a/fs/reiserfs/acl.h
+++ b/fs/reiserfs/acl.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/init.h> 2#include <linux/init.h>
2#include <linux/posix_acl.h> 3#include <linux/posix_acl.h>
3 4
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index f59c667df15b..69ff280bdfe8 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Write ahead logging implementation copyright Chris Mason 2000 3 * Write ahead logging implementation copyright Chris Mason 2000
3 * 4 *
diff --git a/fs/reiserfs/lock.c b/fs/reiserfs/lock.c
index 045b83ef9fd9..46bd7bd63a71 100644
--- a/fs/reiserfs/lock.c
+++ b/fs/reiserfs/lock.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include "reiserfs.h" 2#include "reiserfs.h"
2#include <linux/mutex.h> 3#include <linux/mutex.h>
3 4
diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
index 1d34377fef97..48835a659948 100644
--- a/fs/reiserfs/reiserfs.h
+++ b/fs/reiserfs/reiserfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Copyright 1996, 1997, 1998 Hans Reiser, see reiserfs/README for 3 * Copyright 1996, 1997, 1998 Hans Reiser, see reiserfs/README for
3 * licensing and copyright details 4 * licensing and copyright details
diff --git a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c
index 2d5489b0a269..b0ae088dffc7 100644
--- a/fs/reiserfs/tail_conversion.c
+++ b/fs/reiserfs/tail_conversion.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 1999 Hans Reiser, see reiserfs/README for licensing and copyright 3 * Copyright 1999 Hans Reiser, see reiserfs/README for licensing and copyright
3 * details 4 * details
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index e87aa21c30de..46492fb37a4c 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/reiserfs/xattr.c 3 * linux/fs/reiserfs/xattr.c
3 * 4 *
diff --git a/fs/reiserfs/xattr.h b/fs/reiserfs/xattr.h
index 613ff5aef94e..c764352447ba 100644
--- a/fs/reiserfs/xattr.h
+++ b/fs/reiserfs/xattr.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <linux/reiserfs_xattr.h> 2#include <linux/reiserfs_xattr.h>
2#include <linux/init.h> 3#include <linux/init.h>
3#include <linux/list.h> 4#include <linux/list.h>
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index 54415f0e3d18..aa9380bac196 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/capability.h> 2#include <linux/capability.h>
2#include <linux/fs.h> 3#include <linux/fs.h>
3#include <linux/posix_acl.h> 4#include <linux/posix_acl.h>
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c
index e4cbb7719906..20be9a0e5870 100644
--- a/fs/reiserfs/xattr_security.c
+++ b/fs/reiserfs/xattr_security.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include "reiserfs.h" 2#include "reiserfs.h"
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/fs.h> 4#include <linux/fs.h>
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c
index f15a5f9e84ce..5ed48da3d02b 100644
--- a/fs/reiserfs/xattr_trusted.c
+++ b/fs/reiserfs/xattr_trusted.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include "reiserfs.h" 2#include "reiserfs.h"
2#include <linux/capability.h> 3#include <linux/capability.h>
3#include <linux/errno.h> 4#include <linux/errno.h>
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c
index dc59df43b2db..a573ca45bacc 100644
--- a/fs/reiserfs/xattr_user.c
+++ b/fs/reiserfs/xattr_user.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include "reiserfs.h" 2#include "reiserfs.h"
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/fs.h> 4#include <linux/fs.h>
diff --git a/fs/romfs/Makefile b/fs/romfs/Makefile
index 420beb7d495c..844928f15711 100644
--- a/fs/romfs/Makefile
+++ b/fs/romfs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the linux RomFS filesystem routines. 3# Makefile for the linux RomFS filesystem routines.
3# 4#
diff --git a/fs/select.c b/fs/select.c
index c6362e38ae92..063067e606ca 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This file contains the procedures for the handling of select and poll 3 * This file contains the procedures for the handling of select and poll
3 * 4 *
diff --git a/fs/seq_file.c b/fs/seq_file.c
index dc7c2be963ed..4be761c1a03d 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/seq_file.c 3 * linux/fs/seq_file.c
3 * 4 *
diff --git a/fs/signalfd.c b/fs/signalfd.c
index d2c434112f42..1c667af86da5 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/signalfd.c 3 * fs/signalfd.c
3 * 4 *
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index 6655631c53ae..7bd9b8b856d0 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the linux squashfs routines. 3# Makefile for the linux squashfs routines.
3# 4#
diff --git a/fs/stat.c b/fs/stat.c
index 8a6aa8caf891..873785dae022 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/stat.c 3 * linux/fs/stat.c
3 * 4 *
diff --git a/fs/statfs.c b/fs/statfs.c
index fab9b6a3c116..c25dd9a26cc1 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/syscalls.h> 2#include <linux/syscalls.h>
2#include <linux/export.h> 3#include <linux/export.h>
3#include <linux/fs.h> 4#include <linux/fs.h>
diff --git a/fs/super.c b/fs/super.c
index 166c4ee0d0ed..994db21f59bf 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/super.c 3 * linux/fs/super.c
3 * 4 *
diff --git a/fs/sync.c b/fs/sync.c
index a576aa2e6b09..83ac79a960dd 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * High-level sync()-related operations 3 * High-level sync()-related operations
3 */ 4 */
diff --git a/fs/sysv/balloc.c b/fs/sysv/balloc.c
index 862c1f74a583..0e69dbdf7277 100644
--- a/fs/sysv/balloc.c
+++ b/fs/sysv/balloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/sysv/balloc.c 3 * linux/fs/sysv/balloc.c
3 * 4 *
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index f5191cb2c947..88e38cd8f5c9 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/sysv/dir.c 3 * linux/fs/sysv/dir.c
3 * 4 *
diff --git a/fs/sysv/file.c b/fs/sysv/file.c
index 7ba997e31aeb..45fc79a18594 100644
--- a/fs/sysv/file.c
+++ b/fs/sysv/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/sysv/file.c 3 * linux/fs/sysv/file.c
3 * 4 *
diff --git a/fs/sysv/ialloc.c b/fs/sysv/ialloc.c
index eb963fbb7903..6c9801986af6 100644
--- a/fs/sysv/ialloc.c
+++ b/fs/sysv/ialloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/sysv/ialloc.c 3 * linux/fs/sysv/ialloc.c
3 * 4 *
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index 1c8bf9453a71..3c47b7d5d4cf 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/sysv/inode.c 3 * linux/fs/sysv/inode.c
3 * 4 *
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index 83809f5b5eca..bcb67b0cabe7 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/sysv/itree.c 3 * linux/fs/sysv/itree.c
3 * 4 *
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index d8817f139763..250b0755b908 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/sysv/namei.c 3 * linux/fs/sysv/namei.c
3 * 4 *
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index 1e7e27c729af..e913698779c0 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _SYSV_H 2#ifndef _SYSV_H
2#define _SYSV_H 3#define _SYSV_H
3 4
diff --git a/fs/timerfd.c b/fs/timerfd.c
index ece0c02d7e63..040612ec9598 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/timerfd.c 3 * fs/timerfd.c
3 * 4 *
diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile
index 6f3251c2bf08..9758f709c736 100644
--- a/fs/ubifs/Makefile
+++ b/fs/ubifs/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_UBIFS_FS) += ubifs.o 2obj-$(CONFIG_UBIFS_FS) += ubifs.o
2 3
3ubifs-y += shrinker.o journal.o file.o dir.o super.o sb.o io.o 4ubifs-y += shrinker.o journal.o file.o dir.o super.o sb.o io.o
diff --git a/fs/ubifs/crypto.c b/fs/ubifs/crypto.c
index 114ba455bac3..16a5d5c82073 100644
--- a/fs/ubifs/crypto.c
+++ b/fs/ubifs/crypto.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include "ubifs.h" 2#include "ubifs.h"
2 3
3static int ubifs_crypt_get_context(struct inode *inode, void *ctx, size_t len) 4static int ubifs_crypt_get_context(struct inode *inode, void *ctx, size_t len)
diff --git a/fs/ubifs/misc.c b/fs/ubifs/misc.c
index 486a2844949f..586fd5b578a7 100644
--- a/fs/ubifs/misc.c
+++ b/fs/ubifs/misc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/kernel.h> 2#include <linux/kernel.h>
2#include "ubifs.h" 3#include "ubifs.h"
3 4
diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h
index b1b9a63d8cf3..630426ffb775 100644
--- a/fs/udf/udf_i.h
+++ b/fs/udf/udf_i.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _UDF_I_H 2#ifndef _UDF_I_H
2#define _UDF_I_H 3#define _UDF_I_H
3 4
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index c13875d669c0..68c9f1d618f5 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __LINUX_UDF_SB_H 2#ifndef __LINUX_UDF_SB_H
2#define __LINUX_UDF_SB_H 3#define __LINUX_UDF_SB_H
3 4
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 63b034984378..fa206558128d 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __UDF_DECL_H 2#ifndef __UDF_DECL_H
2#define __UDF_DECL_H 3#define __UDF_DECL_H
3 4
diff --git a/fs/udf/udfend.h b/fs/udf/udfend.h
index 6a9f3a9cc428..a4363ac2cfeb 100644
--- a/fs/udf/udfend.h
+++ b/fs/udf/udfend.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __UDF_ENDIAN_H 2#ifndef __UDF_ENDIAN_H
2#define __UDF_ENDIAN_H 3#define __UDF_ENDIAN_H
3 4
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index f80be4c5df9d..b5cd79065ef9 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ufs/balloc.c 3 * linux/fs/ufs/balloc.c
3 * 4 *
diff --git a/fs/ufs/cylinder.c b/fs/ufs/cylinder.c
index b4676322ddb6..1abe5454de47 100644
--- a/fs/ufs/cylinder.c
+++ b/fs/ufs/cylinder.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ufs/cylinder.c 3 * linux/fs/ufs/cylinder.c
3 * 4 *
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index 48609f1d9580..2edc1755b7c5 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ufs/ufs_dir.c 3 * linux/fs/ufs/ufs_dir.c
3 * 4 *
diff --git a/fs/ufs/file.c b/fs/ufs/file.c
index 042ddbf110cc..7e087581be7e 100644
--- a/fs/ufs/file.c
+++ b/fs/ufs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ufs/file.c 3 * linux/fs/ufs/file.c
3 * 4 *
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index d1dd8cc33179..916b4a428933 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ufs/ialloc.c 3 * linux/fs/ufs/ialloc.c
3 * 4 *
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index f36d6a53687d..afb601c0dda0 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ufs/inode.c 3 * linux/fs/ufs/inode.c
3 * 4 *
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 8eca4eda8450..32545cd00ceb 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ufs/namei.c 3 * linux/fs/ufs/namei.c
3 * 4 *
diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
index 8d974c4fd18b..a0e1d8c827f4 100644
--- a/fs/ufs/swab.h
+++ b/fs/ufs/swab.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/ufs/swab.h 3 * linux/fs/ufs/swab.h
3 * 4 *
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index c87f4c3fa9dd..b49e0efdf3d7 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _UFS_UFS_H 2#ifndef _UFS_UFS_H
2#define _UFS_UFS_H 1 3#define _UFS_UFS_H 1
3 4
diff --git a/fs/ufs/ufs_fs.h b/fs/ufs/ufs_fs.h
index 150eef6f1233..ef9ead44776a 100644
--- a/fs/ufs/ufs_fs.h
+++ b/fs/ufs/ufs_fs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/include/linux/ufs_fs.h 3 * linux/include/linux/ufs_fs.h
3 * 4 *
diff --git a/fs/ufs/util.c b/fs/ufs/util.c
index 02497a492eb2..4fa633f84274 100644
--- a/fs/ufs/util.c
+++ b/fs/ufs/util.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/fs/ufs/util.c 3 * linux/fs/ufs/util.c
3 * 4 *
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index 9fc7119a1551..1907be6d5808 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * linux/fs/ufs/util.h 3 * linux/fs/ufs/util.h
3 * 4 *
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index ef4b48d1ea42..1c713fd5b3e6 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -588,6 +588,12 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
588 break; 588 break;
589 if (ACCESS_ONCE(ctx->released) || 589 if (ACCESS_ONCE(ctx->released) ||
590 fatal_signal_pending(current)) { 590 fatal_signal_pending(current)) {
591 /*
592 * &ewq->wq may be queued in fork_event, but
593 * __remove_wait_queue ignores the head
594 * parameter. It would be a problem if it
595 * didn't.
596 */
591 __remove_wait_queue(&ctx->event_wqh, &ewq->wq); 597 __remove_wait_queue(&ctx->event_wqh, &ewq->wq);
592 if (ewq->msg.event == UFFD_EVENT_FORK) { 598 if (ewq->msg.event == UFFD_EVENT_FORK) {
593 struct userfaultfd_ctx *new; 599 struct userfaultfd_ctx *new;
@@ -1061,6 +1067,12 @@ static ssize_t userfaultfd_ctx_read(struct userfaultfd_ctx *ctx, int no_wait,
1061 (unsigned long) 1067 (unsigned long)
1062 uwq->msg.arg.reserved.reserved1; 1068 uwq->msg.arg.reserved.reserved1;
1063 list_move(&uwq->wq.entry, &fork_event); 1069 list_move(&uwq->wq.entry, &fork_event);
1070 /*
1071 * fork_nctx can be freed as soon as
1072 * we drop the lock, unless we take a
1073 * reference on it.
1074 */
1075 userfaultfd_ctx_get(fork_nctx);
1064 spin_unlock(&ctx->event_wqh.lock); 1076 spin_unlock(&ctx->event_wqh.lock);
1065 ret = 0; 1077 ret = 0;
1066 break; 1078 break;
@@ -1091,19 +1103,53 @@ static ssize_t userfaultfd_ctx_read(struct userfaultfd_ctx *ctx, int no_wait,
1091 1103
1092 if (!ret && msg->event == UFFD_EVENT_FORK) { 1104 if (!ret && msg->event == UFFD_EVENT_FORK) {
1093 ret = resolve_userfault_fork(ctx, fork_nctx, msg); 1105 ret = resolve_userfault_fork(ctx, fork_nctx, msg);
1106 spin_lock(&ctx->event_wqh.lock);
1107 if (!list_empty(&fork_event)) {
1108 /*
1109 * The fork thread didn't abort, so we can
1110 * drop the temporary refcount.
1111 */
1112 userfaultfd_ctx_put(fork_nctx);
1113
1114 uwq = list_first_entry(&fork_event,
1115 typeof(*uwq),
1116 wq.entry);
1117 /*
1118 * If fork_event list wasn't empty and in turn
1119 * the event wasn't already released by fork
1120 * (the event is allocated on fork kernel
1121 * stack), put the event back to its place in
1122 * the event_wq. fork_event head will be freed
1123 * as soon as we return so the event cannot
1124 * stay queued there no matter the current
1125 * "ret" value.
1126 */
1127 list_del(&uwq->wq.entry);
1128 __add_wait_queue(&ctx->event_wqh, &uwq->wq);
1094 1129
1095 if (!ret) { 1130 /*
1096 spin_lock(&ctx->event_wqh.lock); 1131 * Leave the event in the waitqueue and report
1097 if (!list_empty(&fork_event)) { 1132 * error to userland if we failed to resolve
1098 uwq = list_first_entry(&fork_event, 1133 * the userfault fork.
1099 typeof(*uwq), 1134 */
1100 wq.entry); 1135 if (likely(!ret))
1101 list_del(&uwq->wq.entry);
1102 __add_wait_queue(&ctx->event_wqh, &uwq->wq);
1103 userfaultfd_event_complete(ctx, uwq); 1136 userfaultfd_event_complete(ctx, uwq);
1104 } 1137 } else {
1105 spin_unlock(&ctx->event_wqh.lock); 1138 /*
1139 * Here the fork thread aborted and the
1140 * refcount from the fork thread on fork_nctx
1141 * has already been released. We still hold
1142 * the reference we took before releasing the
1143 * lock above. If resolve_userfault_fork
1144 * failed we've to drop it because the
1145 * fork_nctx has to be freed in such case. If
1146 * it succeeded we'll hold it because the new
1147 * uffd references it.
1148 */
1149 if (ret)
1150 userfaultfd_ctx_put(fork_nctx);
1106 } 1151 }
1152 spin_unlock(&ctx->event_wqh.lock);
1107 } 1153 }
1108 1154
1109 return ret; 1155 return ret;
diff --git a/fs/utimes.c b/fs/utimes.c
index 51edb9f9507c..e4b3d7c2c9f5 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/file.h> 2#include <linux/file.h>
2#include <linux/mount.h> 3#include <linux/mount.h>
3#include <linux/namei.h> 4#include <linux/namei.h>
diff --git a/fs/xattr.c b/fs/xattr.c
index 4424f7fecf14..61cd28ba25f3 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -250,7 +250,7 @@ xattr_getsecurity(struct inode *inode, const char *name, void *value,
250 } 250 }
251 memcpy(value, buffer, len); 251 memcpy(value, buffer, len);
252out: 252out:
253 security_release_secctx(buffer, len); 253 kfree(buffer);
254out_noalloc: 254out_noalloc:
255 return len; 255 return len;
256} 256}
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index b008ff3250eb..df3e600835e8 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -156,7 +156,8 @@ __xfs_ag_resv_free(
156 trace_xfs_ag_resv_free(pag, type, 0); 156 trace_xfs_ag_resv_free(pag, type, 0);
157 157
158 resv = xfs_perag_resv(pag, type); 158 resv = xfs_perag_resv(pag, type);
159 pag->pag_mount->m_ag_max_usable += resv->ar_asked; 159 if (pag->pag_agno == 0)
160 pag->pag_mount->m_ag_max_usable += resv->ar_asked;
160 /* 161 /*
161 * AGFL blocks are always considered "free", so whatever 162 * AGFL blocks are always considered "free", so whatever
162 * was reserved at mount time must be given back at umount. 163 * was reserved at mount time must be given back at umount.
@@ -216,7 +217,14 @@ __xfs_ag_resv_init(
216 return error; 217 return error;
217 } 218 }
218 219
219 mp->m_ag_max_usable -= ask; 220 /*
221 * Reduce the maximum per-AG allocation length by however much we're
222 * trying to reserve for an AG. Since this is a filesystem-wide
223 * counter, we only make the adjustment for AG 0. This assumes that
224 * there aren't any AGs hungrier for per-AG reservation than AG 0.
225 */
226 if (pag->pag_agno == 0)
227 mp->m_ag_max_usable -= ask;
220 228
221 resv = xfs_perag_resv(pag, type); 229 resv = xfs_perag_resv(pag, type);
222 resv->ar_asked = ask; 230 resv->ar_asked = ask;
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 744dcaec34cc..f965ce832bc0 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -1584,6 +1584,10 @@ xfs_alloc_ag_vextent_small(
1584 1584
1585 bp = xfs_btree_get_bufs(args->mp, args->tp, 1585 bp = xfs_btree_get_bufs(args->mp, args->tp,
1586 args->agno, fbno, 0); 1586 args->agno, fbno, 0);
1587 if (!bp) {
1588 error = -EFSCORRUPTED;
1589 goto error0;
1590 }
1587 xfs_trans_binval(args->tp, bp); 1591 xfs_trans_binval(args->tp, bp);
1588 } 1592 }
1589 args->len = 1; 1593 args->len = 1;
@@ -2141,6 +2145,10 @@ xfs_alloc_fix_freelist(
2141 if (error) 2145 if (error)
2142 goto out_agbp_relse; 2146 goto out_agbp_relse;
2143 bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0); 2147 bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0);
2148 if (!bp) {
2149 error = -EFSCORRUPTED;
2150 goto out_agbp_relse;
2151 }
2144 xfs_trans_binval(tp, bp); 2152 xfs_trans_binval(tp, bp);
2145 } 2153 }
2146 2154
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 459f4b4f08fe..89263797cf32 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -49,7 +49,6 @@
49#include "xfs_rmap.h" 49#include "xfs_rmap.h"
50#include "xfs_ag_resv.h" 50#include "xfs_ag_resv.h"
51#include "xfs_refcount.h" 51#include "xfs_refcount.h"
52#include "xfs_rmap_btree.h"
53#include "xfs_icache.h" 52#include "xfs_icache.h"
54 53
55 54
@@ -192,12 +191,8 @@ xfs_bmap_worst_indlen(
192 int maxrecs; /* maximum record count at this level */ 191 int maxrecs; /* maximum record count at this level */
193 xfs_mount_t *mp; /* mount structure */ 192 xfs_mount_t *mp; /* mount structure */
194 xfs_filblks_t rval; /* return value */ 193 xfs_filblks_t rval; /* return value */
195 xfs_filblks_t orig_len;
196 194
197 mp = ip->i_mount; 195 mp = ip->i_mount;
198
199 /* Calculate the worst-case size of the bmbt. */
200 orig_len = len;
201 maxrecs = mp->m_bmap_dmxr[0]; 196 maxrecs = mp->m_bmap_dmxr[0];
202 for (level = 0, rval = 0; 197 for (level = 0, rval = 0;
203 level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK); 198 level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
@@ -205,20 +200,12 @@ xfs_bmap_worst_indlen(
205 len += maxrecs - 1; 200 len += maxrecs - 1;
206 do_div(len, maxrecs); 201 do_div(len, maxrecs);
207 rval += len; 202 rval += len;
208 if (len == 1) { 203 if (len == 1)
209 rval += XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 204 return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
210 level - 1; 205 level - 1;
211 break;
212 }
213 if (level == 0) 206 if (level == 0)
214 maxrecs = mp->m_bmap_dmxr[1]; 207 maxrecs = mp->m_bmap_dmxr[1];
215 } 208 }
216
217 /* Calculate the worst-case size of the rmapbt. */
218 if (xfs_sb_version_hasrmapbt(&mp->m_sb))
219 rval += 1 + xfs_rmapbt_calc_size(mp, orig_len) +
220 mp->m_rmap_maxlevels;
221
222 return rval; 209 return rval;
223} 210}
224 211
@@ -1490,14 +1477,14 @@ xfs_bmap_isaeof(
1490 int is_empty; 1477 int is_empty;
1491 int error; 1478 int error;
1492 1479
1493 bma->aeof = 0; 1480 bma->aeof = false;
1494 error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec, 1481 error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec,
1495 &is_empty); 1482 &is_empty);
1496 if (error) 1483 if (error)
1497 return error; 1484 return error;
1498 1485
1499 if (is_empty) { 1486 if (is_empty) {
1500 bma->aeof = 1; 1487 bma->aeof = true;
1501 return 0; 1488 return 0;
1502 } 1489 }
1503 1490
@@ -3865,6 +3852,17 @@ xfs_trim_extent(
3865 } 3852 }
3866} 3853}
3867 3854
3855/* trim extent to within eof */
3856void
3857xfs_trim_extent_eof(
3858 struct xfs_bmbt_irec *irec,
3859 struct xfs_inode *ip)
3860
3861{
3862 xfs_trim_extent(irec, 0, XFS_B_TO_FSB(ip->i_mount,
3863 i_size_read(VFS_I(ip))));
3864}
3865
3868/* 3866/*
3869 * Trim the returned map to the required bounds 3867 * Trim the returned map to the required bounds
3870 */ 3868 */
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 851982a5dfbc..502e0d8fb4ff 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -208,6 +208,7 @@ void xfs_bmap_trace_exlist(struct xfs_inode *ip, xfs_extnum_t cnt,
208 208
209void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno, 209void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
210 xfs_filblks_t len); 210 xfs_filblks_t len);
211void xfs_trim_extent_eof(struct xfs_bmbt_irec *, struct xfs_inode *);
211int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); 212int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
212void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); 213void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
213void xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 214void xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h
index 8211f48b98e6..999a290cfd72 100644
--- a/fs/xfs/libxfs/xfs_cksum.h
+++ b/fs/xfs/libxfs/xfs_cksum.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _XFS_CKSUM_H 2#ifndef _XFS_CKSUM_H
2#define _XFS_CKSUM_H 1 3#define _XFS_CKSUM_H 1
3 4
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 988bb3f31446..dfd643909f85 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -1962,7 +1962,7 @@ xfs_difree_inobt(
1962 if (!(mp->m_flags & XFS_MOUNT_IKEEP) && 1962 if (!(mp->m_flags & XFS_MOUNT_IKEEP) &&
1963 rec.ir_free == XFS_INOBT_ALL_FREE && 1963 rec.ir_free == XFS_INOBT_ALL_FREE &&
1964 mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) { 1964 mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) {
1965 xic->deleted = 1; 1965 xic->deleted = true;
1966 xic->first_ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino); 1966 xic->first_ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino);
1967 xic->alloc = xfs_inobt_irec_to_allocmask(&rec); 1967 xic->alloc = xfs_inobt_irec_to_allocmask(&rec);
1968 1968
@@ -1989,7 +1989,7 @@ xfs_difree_inobt(
1989 1989
1990 xfs_difree_inode_chunk(mp, agno, &rec, dfops); 1990 xfs_difree_inode_chunk(mp, agno, &rec, dfops);
1991 } else { 1991 } else {
1992 xic->deleted = 0; 1992 xic->deleted = false;
1993 1993
1994 error = xfs_inobt_update(cur, &rec); 1994 error = xfs_inobt_update(cur, &rec);
1995 if (error) { 1995 if (error) {
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index 8372e9bcd7b6..71de185735e0 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -270,6 +270,7 @@ typedef struct xfs_inode_log_format {
270 uint32_t ilf_fields; /* flags for fields logged */ 270 uint32_t ilf_fields; /* flags for fields logged */
271 uint16_t ilf_asize; /* size of attr d/ext/root */ 271 uint16_t ilf_asize; /* size of attr d/ext/root */
272 uint16_t ilf_dsize; /* size of data/ext/root */ 272 uint16_t ilf_dsize; /* size of data/ext/root */
273 uint32_t ilf_pad; /* pad for 64 bit boundary */
273 uint64_t ilf_ino; /* inode number */ 274 uint64_t ilf_ino; /* inode number */
274 union { 275 union {
275 uint32_t ilfu_rdev; /* rdev value for dev inode*/ 276 uint32_t ilfu_rdev; /* rdev value for dev inode*/
@@ -280,29 +281,17 @@ typedef struct xfs_inode_log_format {
280 int32_t ilf_boffset; /* off of inode in buffer */ 281 int32_t ilf_boffset; /* off of inode in buffer */
281} xfs_inode_log_format_t; 282} xfs_inode_log_format_t;
282 283
283typedef struct xfs_inode_log_format_32 { 284/*
284 uint16_t ilf_type; /* inode log item type */ 285 * Old 32 bit systems will log in this format without the 64 bit
285 uint16_t ilf_size; /* size of this item */ 286 * alignment padding. Recovery will detect this and convert it to the
286 uint32_t ilf_fields; /* flags for fields logged */ 287 * correct format.
287 uint16_t ilf_asize; /* size of attr d/ext/root */ 288 */
288 uint16_t ilf_dsize; /* size of data/ext/root */ 289struct xfs_inode_log_format_32 {
289 uint64_t ilf_ino; /* inode number */
290 union {
291 uint32_t ilfu_rdev; /* rdev value for dev inode*/
292 uuid_t ilfu_uuid; /* mount point value */
293 } ilf_u;
294 int64_t ilf_blkno; /* blkno of inode buffer */
295 int32_t ilf_len; /* len of inode buffer */
296 int32_t ilf_boffset; /* off of inode in buffer */
297} __attribute__((packed)) xfs_inode_log_format_32_t;
298
299typedef struct xfs_inode_log_format_64 {
300 uint16_t ilf_type; /* inode log item type */ 290 uint16_t ilf_type; /* inode log item type */
301 uint16_t ilf_size; /* size of this item */ 291 uint16_t ilf_size; /* size of this item */
302 uint32_t ilf_fields; /* flags for fields logged */ 292 uint32_t ilf_fields; /* flags for fields logged */
303 uint16_t ilf_asize; /* size of attr d/ext/root */ 293 uint16_t ilf_asize; /* size of attr d/ext/root */
304 uint16_t ilf_dsize; /* size of data/ext/root */ 294 uint16_t ilf_dsize; /* size of data/ext/root */
305 uint32_t ilf_pad; /* pad for 64 bit boundary */
306 uint64_t ilf_ino; /* inode number */ 295 uint64_t ilf_ino; /* inode number */
307 union { 296 union {
308 uint32_t ilfu_rdev; /* rdev value for dev inode*/ 297 uint32_t ilfu_rdev; /* rdev value for dev inode*/
@@ -311,7 +300,7 @@ typedef struct xfs_inode_log_format_64 {
311 int64_t ilf_blkno; /* blkno of inode buffer */ 300 int64_t ilf_blkno; /* blkno of inode buffer */
312 int32_t ilf_len; /* len of inode buffer */ 301 int32_t ilf_len; /* len of inode buffer */
313 int32_t ilf_boffset; /* off of inode in buffer */ 302 int32_t ilf_boffset; /* off of inode in buffer */
314} xfs_inode_log_format_64_t; 303} __attribute__((packed));
315 304
316 305
317/* 306/*
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 7034e17535de..3354140de07e 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -247,6 +247,8 @@ xfs_set_mode(struct inode *inode, umode_t mode)
247int 247int
248xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 248xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
249{ 249{
250 umode_t mode;
251 bool set_mode = false;
250 int error = 0; 252 int error = 0;
251 253
252 if (!acl) 254 if (!acl)
@@ -257,16 +259,24 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
257 return error; 259 return error;
258 260
259 if (type == ACL_TYPE_ACCESS) { 261 if (type == ACL_TYPE_ACCESS) {
260 umode_t mode;
261
262 error = posix_acl_update_mode(inode, &mode, &acl); 262 error = posix_acl_update_mode(inode, &mode, &acl);
263 if (error) 263 if (error)
264 return error; 264 return error;
265 error = xfs_set_mode(inode, mode); 265 set_mode = true;
266 if (error)
267 return error;
268 } 266 }
269 267
270 set_acl: 268 set_acl:
271 return __xfs_set_acl(inode, acl, type); 269 error = __xfs_set_acl(inode, acl, type);
270 if (error)
271 return error;
272
273 /*
274 * We set the mode after successfully updating the ACL xattr because the
275 * xattr update can fail at ENOSPC and we don't want to change the mode
276 * if the ACL update hasn't been applied.
277 */
278 if (set_mode)
279 error = xfs_set_mode(inode, mode);
280
281 return error;
272} 282}
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 29172609f2a3..a3eeaba156c5 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -343,7 +343,8 @@ xfs_end_io(
343 error = xfs_reflink_end_cow(ip, offset, size); 343 error = xfs_reflink_end_cow(ip, offset, size);
344 break; 344 break;
345 case XFS_IO_UNWRITTEN: 345 case XFS_IO_UNWRITTEN:
346 error = xfs_iomap_write_unwritten(ip, offset, size); 346 /* writeback should never update isize */
347 error = xfs_iomap_write_unwritten(ip, offset, size, false);
347 break; 348 break;
348 default: 349 default:
349 ASSERT(!xfs_ioend_is_append(ioend) || ioend->io_append_trans); 350 ASSERT(!xfs_ioend_is_append(ioend) || ioend->io_append_trans);
@@ -445,6 +446,19 @@ xfs_imap_valid(
445{ 446{
446 offset >>= inode->i_blkbits; 447 offset >>= inode->i_blkbits;
447 448
449 /*
450 * We have to make sure the cached mapping is within EOF to protect
451 * against eofblocks trimming on file release leaving us with a stale
452 * mapping. Otherwise, a page for a subsequent file extending buffered
453 * write could get picked up by this writeback cycle and written to the
454 * wrong blocks.
455 *
456 * Note that what we really want here is a generic mapping invalidation
457 * mechanism to protect us from arbitrary extent modifying contexts, not
458 * just eofblocks.
459 */
460 xfs_trim_extent_eof(imap, XFS_I(inode));
461
448 return offset >= imap->br_startoff && 462 return offset >= imap->br_startoff &&
449 offset < imap->br_startoff + imap->br_blockcount; 463 offset < imap->br_startoff + imap->br_blockcount;
450} 464}
@@ -734,6 +748,14 @@ xfs_vm_invalidatepage(
734{ 748{
735 trace_xfs_invalidatepage(page->mapping->host, page, offset, 749 trace_xfs_invalidatepage(page->mapping->host, page, offset,
736 length); 750 length);
751
752 /*
753 * If we are invalidating the entire page, clear the dirty state from it
754 * so that we can check for attempts to release dirty cached pages in
755 * xfs_vm_releasepage().
756 */
757 if (offset == 0 && length >= PAGE_SIZE)
758 cancel_dirty_page(page);
737 block_invalidatepage(page, offset, length); 759 block_invalidatepage(page, offset, length);
738} 760}
739 761
@@ -1189,25 +1211,27 @@ xfs_vm_releasepage(
1189 * mm accommodates an old ext3 case where clean pages might not have had 1211 * mm accommodates an old ext3 case where clean pages might not have had
1190 * the dirty bit cleared. Thus, it can send actual dirty pages to 1212 * the dirty bit cleared. Thus, it can send actual dirty pages to
1191 * ->releasepage() via shrink_active_list(). Conversely, 1213 * ->releasepage() via shrink_active_list(). Conversely,
1192 * block_invalidatepage() can send pages that are still marked dirty 1214 * block_invalidatepage() can send pages that are still marked dirty but
1193 * but otherwise have invalidated buffers. 1215 * otherwise have invalidated buffers.
1194 * 1216 *
1195 * We want to release the latter to avoid unnecessary buildup of the 1217 * We want to release the latter to avoid unnecessary buildup of the
1196 * LRU, skip the former and warn if we've left any lingering 1218 * LRU, so xfs_vm_invalidatepage() clears the page dirty flag on pages
1197 * delalloc/unwritten buffers on clean pages. Skip pages with delalloc 1219 * that are entirely invalidated and need to be released. Hence the
1198 * or unwritten buffers and warn if the page is not dirty. Otherwise 1220 * only time we should get dirty pages here is through
1199 * try to release the buffers. 1221 * shrink_active_list() and so we can simply skip those now.
1222 *
1223 * warn if we've left any lingering delalloc/unwritten buffers on clean
1224 * or invalidated pages we are about to release.
1200 */ 1225 */
1226 if (PageDirty(page))
1227 return 0;
1228
1201 xfs_count_page_state(page, &delalloc, &unwritten); 1229 xfs_count_page_state(page, &delalloc, &unwritten);
1202 1230
1203 if (delalloc) { 1231 if (WARN_ON_ONCE(delalloc))
1204 WARN_ON_ONCE(!PageDirty(page));
1205 return 0; 1232 return 0;
1206 } 1233 if (WARN_ON_ONCE(unwritten))
1207 if (unwritten) {
1208 WARN_ON_ONCE(!PageDirty(page));
1209 return 0; 1234 return 0;
1210 }
1211 1235
1212 return try_to_free_buffers(page); 1236 return try_to_free_buffers(page);
1213} 1237}
diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
index ebd66b19fbfc..e3a950ed35a8 100644
--- a/fs/xfs/xfs_attr_inactive.c
+++ b/fs/xfs/xfs_attr_inactive.c
@@ -302,6 +302,8 @@ xfs_attr3_node_inactive(
302 &bp, XFS_ATTR_FORK); 302 &bp, XFS_ATTR_FORK);
303 if (error) 303 if (error)
304 return error; 304 return error;
305 node = bp->b_addr;
306 btree = dp->d_ops->node_tree_p(node);
305 child_fsb = be32_to_cpu(btree[i + 1].before); 307 child_fsb = be32_to_cpu(btree[i + 1].before);
306 xfs_trans_brelse(*trans, bp); 308 xfs_trans_brelse(*trans, bp);
307 } 309 }
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index cd9a5400ba4f..6503cfa44262 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -84,6 +84,7 @@ xfs_zero_extent(
84 GFP_NOFS, 0); 84 GFP_NOFS, 0);
85} 85}
86 86
87#ifdef CONFIG_XFS_RT
87int 88int
88xfs_bmap_rtalloc( 89xfs_bmap_rtalloc(
89 struct xfs_bmalloca *ap) /* bmap alloc argument struct */ 90 struct xfs_bmalloca *ap) /* bmap alloc argument struct */
@@ -190,6 +191,7 @@ xfs_bmap_rtalloc(
190 } 191 }
191 return 0; 192 return 0;
192} 193}
194#endif /* CONFIG_XFS_RT */
193 195
194/* 196/*
195 * Check if the endoff is outside the last extent. If so the caller will grow 197 * Check if the endoff is outside the last extent. If so the caller will grow
@@ -1459,7 +1461,19 @@ xfs_shift_file_space(
1459 return error; 1461 return error;
1460 1462
1461 /* 1463 /*
1462 * The extent shiting code works on extent granularity. So, if 1464 * Clean out anything hanging around in the cow fork now that
1465 * we've flushed all the dirty data out to disk to avoid having
1466 * CoW extents at the wrong offsets.
1467 */
1468 if (xfs_is_reflink_inode(ip)) {
1469 error = xfs_reflink_cancel_cow_range(ip, offset, NULLFILEOFF,
1470 true);
1471 if (error)
1472 return error;
1473 }
1474
1475 /*
1476 * The extent shifting code works on extent granularity. So, if
1463 * stop_fsb is not the starting block of extent, we need to split 1477 * stop_fsb is not the starting block of extent, we need to split
1464 * the extent at stop_fsb. 1478 * the extent at stop_fsb.
1465 */ 1479 */
@@ -2110,11 +2124,31 @@ xfs_swap_extents(
2110 ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK; 2124 ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
2111 tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; 2125 tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
2112 tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK; 2126 tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK;
2127 }
2128
2129 /* Swap the cow forks. */
2130 if (xfs_sb_version_hasreflink(&mp->m_sb)) {
2131 xfs_extnum_t extnum;
2132
2133 ASSERT(ip->i_cformat == XFS_DINODE_FMT_EXTENTS);
2134 ASSERT(tip->i_cformat == XFS_DINODE_FMT_EXTENTS);
2135
2136 extnum = ip->i_cnextents;
2137 ip->i_cnextents = tip->i_cnextents;
2138 tip->i_cnextents = extnum;
2139
2113 cowfp = ip->i_cowfp; 2140 cowfp = ip->i_cowfp;
2114 ip->i_cowfp = tip->i_cowfp; 2141 ip->i_cowfp = tip->i_cowfp;
2115 tip->i_cowfp = cowfp; 2142 tip->i_cowfp = cowfp;
2116 xfs_inode_set_cowblocks_tag(ip); 2143
2117 xfs_inode_set_cowblocks_tag(tip); 2144 if (ip->i_cowfp && ip->i_cnextents)
2145 xfs_inode_set_cowblocks_tag(ip);
2146 else
2147 xfs_inode_clear_cowblocks_tag(ip);
2148 if (tip->i_cowfp && tip->i_cnextents)
2149 xfs_inode_set_cowblocks_tag(tip);
2150 else
2151 xfs_inode_clear_cowblocks_tag(tip);
2118 } 2152 }
2119 2153
2120 xfs_trans_log_inode(tp, ip, src_log_flags); 2154 xfs_trans_log_inode(tp, ip, src_log_flags);
diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h
index 0eaa81dc49be..7d330b3c77c3 100644
--- a/fs/xfs/xfs_bmap_util.h
+++ b/fs/xfs/xfs_bmap_util.h
@@ -28,7 +28,20 @@ struct xfs_mount;
28struct xfs_trans; 28struct xfs_trans;
29struct xfs_bmalloca; 29struct xfs_bmalloca;
30 30
31#ifdef CONFIG_XFS_RT
31int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); 32int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
33#else /* !CONFIG_XFS_RT */
34/*
35 * Attempts to allocate RT extents when RT is disable indicates corruption and
36 * should trigger a shutdown.
37 */
38static inline int
39xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
40{
41 return -EFSCORRUPTED;
42}
43#endif /* CONFIG_XFS_RT */
44
32int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, 45int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
33 int whichfork, int *eof); 46 int whichfork, int *eof);
34int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip, 47int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index da14658da310..2f97c12ca75e 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1258,8 +1258,6 @@ xfs_buf_ioapply_map(
1258 int size; 1258 int size;
1259 int offset; 1259 int offset;
1260 1260
1261 total_nr_pages = bp->b_page_count;
1262
1263 /* skip the pages in the buffer before the start offset */ 1261 /* skip the pages in the buffer before the start offset */
1264 page_index = 0; 1262 page_index = 0;
1265 offset = *buf_offset; 1263 offset = *buf_offset;
diff --git a/fs/xfs/xfs_discard.h b/fs/xfs/xfs_discard.h
index 0f070f9e44e1..de92d9cc958f 100644
--- a/fs/xfs/xfs_discard.h
+++ b/fs/xfs/xfs_discard.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef XFS_DISCARD_H 2#ifndef XFS_DISCARD_H
2#define XFS_DISCARD_H 1 3#define XFS_DISCARD_H 1
3 4
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index bd786a9ac2c3..eaf86f55b7f2 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -347,7 +347,7 @@ xfs_verifier_error(
347{ 347{
348 struct xfs_mount *mp = bp->b_target->bt_mount; 348 struct xfs_mount *mp = bp->b_target->bt_mount;
349 349
350 xfs_alert(mp, "Metadata %s detected at %pF, %s block 0x%llx", 350 xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx",
351 bp->b_error == -EFSBADCRC ? "CRC error" : "corruption", 351 bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
352 __return_address, bp->b_ops->name, bp->b_bn); 352 __return_address, bp->b_ops->name, bp->b_bn);
353 353
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index ebdd0bd2b261..6526ef0e2a23 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -58,7 +58,7 @@ xfs_zero_range(
58 xfs_off_t count, 58 xfs_off_t count,
59 bool *did_zero) 59 bool *did_zero)
60{ 60{
61 return iomap_zero_range(VFS_I(ip), pos, count, NULL, &xfs_iomap_ops); 61 return iomap_zero_range(VFS_I(ip), pos, count, did_zero, &xfs_iomap_ops);
62} 62}
63 63
64int 64int
@@ -237,11 +237,13 @@ xfs_file_dax_read(
237 if (!count) 237 if (!count)
238 return 0; /* skip atime */ 238 return 0; /* skip atime */
239 239
240 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) { 240 if (iocb->ki_flags & IOCB_NOWAIT) {
241 if (iocb->ki_flags & IOCB_NOWAIT) 241 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
242 return -EAGAIN; 242 return -EAGAIN;
243 } else {
243 xfs_ilock(ip, XFS_IOLOCK_SHARED); 244 xfs_ilock(ip, XFS_IOLOCK_SHARED);
244 } 245 }
246
245 ret = dax_iomap_rw(iocb, to, &xfs_iomap_ops); 247 ret = dax_iomap_rw(iocb, to, &xfs_iomap_ops);
246 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 248 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
247 249
@@ -259,9 +261,10 @@ xfs_file_buffered_aio_read(
259 261
260 trace_xfs_file_buffered_read(ip, iov_iter_count(to), iocb->ki_pos); 262 trace_xfs_file_buffered_read(ip, iov_iter_count(to), iocb->ki_pos);
261 263
262 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) { 264 if (iocb->ki_flags & IOCB_NOWAIT) {
263 if (iocb->ki_flags & IOCB_NOWAIT) 265 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
264 return -EAGAIN; 266 return -EAGAIN;
267 } else {
265 xfs_ilock(ip, XFS_IOLOCK_SHARED); 268 xfs_ilock(ip, XFS_IOLOCK_SHARED);
266 } 269 }
267 ret = generic_file_read_iter(iocb, to); 270 ret = generic_file_read_iter(iocb, to);
@@ -377,8 +380,6 @@ restart:
377 */ 380 */
378 spin_lock(&ip->i_flags_lock); 381 spin_lock(&ip->i_flags_lock);
379 if (iocb->ki_pos > i_size_read(inode)) { 382 if (iocb->ki_pos > i_size_read(inode)) {
380 bool zero = false;
381
382 spin_unlock(&ip->i_flags_lock); 383 spin_unlock(&ip->i_flags_lock);
383 if (!drained_dio) { 384 if (!drained_dio) {
384 if (*iolock == XFS_IOLOCK_SHARED) { 385 if (*iolock == XFS_IOLOCK_SHARED) {
@@ -399,7 +400,7 @@ restart:
399 drained_dio = true; 400 drained_dio = true;
400 goto restart; 401 goto restart;
401 } 402 }
402 error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), &zero); 403 error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), NULL);
403 if (error) 404 if (error)
404 return error; 405 return error;
405 } else 406 } else
@@ -436,7 +437,6 @@ xfs_dio_write_end_io(
436 struct inode *inode = file_inode(iocb->ki_filp); 437 struct inode *inode = file_inode(iocb->ki_filp);
437 struct xfs_inode *ip = XFS_I(inode); 438 struct xfs_inode *ip = XFS_I(inode);
438 loff_t offset = iocb->ki_pos; 439 loff_t offset = iocb->ki_pos;
439 bool update_size = false;
440 int error = 0; 440 int error = 0;
441 441
442 trace_xfs_end_io_direct_write(ip, offset, size); 442 trace_xfs_end_io_direct_write(ip, offset, size);
@@ -447,6 +447,21 @@ xfs_dio_write_end_io(
447 if (size <= 0) 447 if (size <= 0)
448 return size; 448 return size;
449 449
450 if (flags & IOMAP_DIO_COW) {
451 error = xfs_reflink_end_cow(ip, offset, size);
452 if (error)
453 return error;
454 }
455
456 /*
457 * Unwritten conversion updates the in-core isize after extent
458 * conversion but before updating the on-disk size. Updating isize any
459 * earlier allows a racing dio read to find unwritten extents before
460 * they are converted.
461 */
462 if (flags & IOMAP_DIO_UNWRITTEN)
463 return xfs_iomap_write_unwritten(ip, offset, size, true);
464
450 /* 465 /*
451 * We need to update the in-core inode size here so that we don't end up 466 * We need to update the in-core inode size here so that we don't end up
452 * with the on-disk inode size being outside the in-core inode size. We 467 * with the on-disk inode size being outside the in-core inode size. We
@@ -461,20 +476,11 @@ xfs_dio_write_end_io(
461 spin_lock(&ip->i_flags_lock); 476 spin_lock(&ip->i_flags_lock);
462 if (offset + size > i_size_read(inode)) { 477 if (offset + size > i_size_read(inode)) {
463 i_size_write(inode, offset + size); 478 i_size_write(inode, offset + size);
464 update_size = true; 479 spin_unlock(&ip->i_flags_lock);
465 }
466 spin_unlock(&ip->i_flags_lock);
467
468 if (flags & IOMAP_DIO_COW) {
469 error = xfs_reflink_end_cow(ip, offset, size);
470 if (error)
471 return error;
472 }
473
474 if (flags & IOMAP_DIO_UNWRITTEN)
475 error = xfs_iomap_write_unwritten(ip, offset, size);
476 else if (update_size)
477 error = xfs_setfilesize(ip, offset, size); 480 error = xfs_setfilesize(ip, offset, size);
481 } else {
482 spin_unlock(&ip->i_flags_lock);
483 }
478 484
479 return error; 485 return error;
480} 486}
@@ -549,9 +555,10 @@ xfs_file_dio_aio_write(
549 iolock = XFS_IOLOCK_SHARED; 555 iolock = XFS_IOLOCK_SHARED;
550 } 556 }
551 557
552 if (!xfs_ilock_nowait(ip, iolock)) { 558 if (iocb->ki_flags & IOCB_NOWAIT) {
553 if (iocb->ki_flags & IOCB_NOWAIT) 559 if (!xfs_ilock_nowait(ip, iolock))
554 return -EAGAIN; 560 return -EAGAIN;
561 } else {
555 xfs_ilock(ip, iolock); 562 xfs_ilock(ip, iolock);
556 } 563 }
557 564
@@ -603,9 +610,10 @@ xfs_file_dax_write(
603 size_t count; 610 size_t count;
604 loff_t pos; 611 loff_t pos;
605 612
606 if (!xfs_ilock_nowait(ip, iolock)) { 613 if (iocb->ki_flags & IOCB_NOWAIT) {
607 if (iocb->ki_flags & IOCB_NOWAIT) 614 if (!xfs_ilock_nowait(ip, iolock))
608 return -EAGAIN; 615 return -EAGAIN;
616 } else {
609 xfs_ilock(ip, iolock); 617 xfs_ilock(ip, iolock);
610 } 618 }
611 619
@@ -761,7 +769,7 @@ xfs_file_fallocate(
761 enum xfs_prealloc_flags flags = 0; 769 enum xfs_prealloc_flags flags = 0;
762 uint iolock = XFS_IOLOCK_EXCL; 770 uint iolock = XFS_IOLOCK_EXCL;
763 loff_t new_size = 0; 771 loff_t new_size = 0;
764 bool do_file_insert = 0; 772 bool do_file_insert = false;
765 773
766 if (!S_ISREG(inode->i_mode)) 774 if (!S_ISREG(inode->i_mode))
767 return -EINVAL; 775 return -EINVAL;
@@ -822,7 +830,7 @@ xfs_file_fallocate(
822 error = -EINVAL; 830 error = -EINVAL;
823 goto out_unlock; 831 goto out_unlock;
824 } 832 }
825 do_file_insert = 1; 833 do_file_insert = true;
826 } else { 834 } else {
827 flags |= XFS_PREALLOC_SET; 835 flags |= XFS_PREALLOC_SET;
828 836
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index 814ed729881d..43cfc07996a4 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -367,29 +367,6 @@ xfs_getfsmap_datadev_helper(
367 return xfs_getfsmap_helper(cur->bc_tp, info, rec, rec_daddr); 367 return xfs_getfsmap_helper(cur->bc_tp, info, rec, rec_daddr);
368} 368}
369 369
370/* Transform a rtbitmap "record" into a fsmap */
371STATIC int
372xfs_getfsmap_rtdev_rtbitmap_helper(
373 struct xfs_trans *tp,
374 struct xfs_rtalloc_rec *rec,
375 void *priv)
376{
377 struct xfs_mount *mp = tp->t_mountp;
378 struct xfs_getfsmap_info *info = priv;
379 struct xfs_rmap_irec irec;
380 xfs_daddr_t rec_daddr;
381
382 rec_daddr = XFS_FSB_TO_BB(mp, rec->ar_startblock);
383
384 irec.rm_startblock = rec->ar_startblock;
385 irec.rm_blockcount = rec->ar_blockcount;
386 irec.rm_owner = XFS_RMAP_OWN_NULL; /* "free" */
387 irec.rm_offset = 0;
388 irec.rm_flags = 0;
389
390 return xfs_getfsmap_helper(tp, info, &irec, rec_daddr);
391}
392
393/* Transform a bnobt irec into a fsmap */ 370/* Transform a bnobt irec into a fsmap */
394STATIC int 371STATIC int
395xfs_getfsmap_datadev_bnobt_helper( 372xfs_getfsmap_datadev_bnobt_helper(
@@ -475,6 +452,30 @@ xfs_getfsmap_logdev(
475 return xfs_getfsmap_helper(tp, info, &rmap, 0); 452 return xfs_getfsmap_helper(tp, info, &rmap, 0);
476} 453}
477 454
455#ifdef CONFIG_XFS_RT
456/* Transform a rtbitmap "record" into a fsmap */
457STATIC int
458xfs_getfsmap_rtdev_rtbitmap_helper(
459 struct xfs_trans *tp,
460 struct xfs_rtalloc_rec *rec,
461 void *priv)
462{
463 struct xfs_mount *mp = tp->t_mountp;
464 struct xfs_getfsmap_info *info = priv;
465 struct xfs_rmap_irec irec;
466 xfs_daddr_t rec_daddr;
467
468 rec_daddr = XFS_FSB_TO_BB(mp, rec->ar_startblock);
469
470 irec.rm_startblock = rec->ar_startblock;
471 irec.rm_blockcount = rec->ar_blockcount;
472 irec.rm_owner = XFS_RMAP_OWN_NULL; /* "free" */
473 irec.rm_offset = 0;
474 irec.rm_flags = 0;
475
476 return xfs_getfsmap_helper(tp, info, &irec, rec_daddr);
477}
478
478/* Execute a getfsmap query against the realtime device. */ 479/* Execute a getfsmap query against the realtime device. */
479STATIC int 480STATIC int
480__xfs_getfsmap_rtdev( 481__xfs_getfsmap_rtdev(
@@ -561,6 +562,7 @@ xfs_getfsmap_rtdev_rtbitmap(
561 return __xfs_getfsmap_rtdev(tp, keys, xfs_getfsmap_rtdev_rtbitmap_query, 562 return __xfs_getfsmap_rtdev(tp, keys, xfs_getfsmap_rtdev_rtbitmap_query,
562 info); 563 info);
563} 564}
565#endif /* CONFIG_XFS_RT */
564 566
565/* Execute a getfsmap query against the regular data device. */ 567/* Execute a getfsmap query against the regular data device. */
566STATIC int 568STATIC int
@@ -795,7 +797,15 @@ xfs_getfsmap_check_keys(
795 return false; 797 return false;
796} 798}
797 799
800/*
801 * There are only two devices if we didn't configure RT devices at build time.
802 */
803#ifdef CONFIG_XFS_RT
798#define XFS_GETFSMAP_DEVS 3 804#define XFS_GETFSMAP_DEVS 3
805#else
806#define XFS_GETFSMAP_DEVS 2
807#endif /* CONFIG_XFS_RT */
808
799/* 809/*
800 * Get filesystem's extents as described in head, and format for 810 * Get filesystem's extents as described in head, and format for
801 * output. Calls formatter to fill the user's buffer until all 811 * output. Calls formatter to fill the user's buffer until all
@@ -853,10 +863,12 @@ xfs_getfsmap(
853 handlers[1].dev = new_encode_dev(mp->m_logdev_targp->bt_dev); 863 handlers[1].dev = new_encode_dev(mp->m_logdev_targp->bt_dev);
854 handlers[1].fn = xfs_getfsmap_logdev; 864 handlers[1].fn = xfs_getfsmap_logdev;
855 } 865 }
866#ifdef CONFIG_XFS_RT
856 if (mp->m_rtdev_targp) { 867 if (mp->m_rtdev_targp) {
857 handlers[2].dev = new_encode_dev(mp->m_rtdev_targp->bt_dev); 868 handlers[2].dev = new_encode_dev(mp->m_rtdev_targp->bt_dev);
858 handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap; 869 handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap;
859 } 870 }
871#endif /* CONFIG_XFS_RT */
860 872
861 xfs_sort(handlers, XFS_GETFSMAP_DEVS, sizeof(struct xfs_getfsmap_dev), 873 xfs_sort(handlers, XFS_GETFSMAP_DEVS, sizeof(struct xfs_getfsmap_dev),
862 xfs_getfsmap_dev_compare); 874 xfs_getfsmap_dev_compare);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 5599dda4727a..4ec5b7f45401 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1624,10 +1624,12 @@ xfs_itruncate_extents(
1624 goto out; 1624 goto out;
1625 1625
1626 /* 1626 /*
1627 * Clear the reflink flag if we truncated everything. 1627 * Clear the reflink flag if there are no data fork blocks and
1628 * there are no extents staged in the cow fork.
1628 */ 1629 */
1629 if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) { 1630 if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) {
1630 ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; 1631 if (ip->i_d.di_nblocks == 0)
1632 ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
1631 xfs_inode_clear_cowblocks_tag(ip); 1633 xfs_inode_clear_cowblocks_tag(ip);
1632 } 1634 }
1633 1635
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 6d0f74ec31e8..9bbc2d7cc8cb 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -364,6 +364,9 @@ xfs_inode_to_log_dinode(
364 to->di_dmstate = from->di_dmstate; 364 to->di_dmstate = from->di_dmstate;
365 to->di_flags = from->di_flags; 365 to->di_flags = from->di_flags;
366 366
367 /* log a dummy value to ensure log structure is fully initialised */
368 to->di_next_unlinked = NULLAGINO;
369
367 if (from->di_version == 3) { 370 if (from->di_version == 3) {
368 to->di_changecount = inode->i_version; 371 to->di_changecount = inode->i_version;
369 to->di_crtime.t_sec = from->di_crtime.t_sec; 372 to->di_crtime.t_sec = from->di_crtime.t_sec;
@@ -404,6 +407,11 @@ xfs_inode_item_format_core(
404 * the second with the on-disk inode structure, and a possible third and/or 407 * the second with the on-disk inode structure, and a possible third and/or
405 * fourth with the inode data/extents/b-tree root and inode attributes 408 * fourth with the inode data/extents/b-tree root and inode attributes
406 * data/extents/b-tree root. 409 * data/extents/b-tree root.
410 *
411 * Note: Always use the 64 bit inode log format structure so we don't
412 * leave an uninitialised hole in the format item on 64 bit systems. Log
413 * recovery on 32 bit systems handles this just fine, so there's no reason
414 * for not using an initialising the properly padded structure all the time.
407 */ 415 */
408STATIC void 416STATIC void
409xfs_inode_item_format( 417xfs_inode_item_format(
@@ -412,8 +420,8 @@ xfs_inode_item_format(
412{ 420{
413 struct xfs_inode_log_item *iip = INODE_ITEM(lip); 421 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
414 struct xfs_inode *ip = iip->ili_inode; 422 struct xfs_inode *ip = iip->ili_inode;
415 struct xfs_inode_log_format *ilf;
416 struct xfs_log_iovec *vecp = NULL; 423 struct xfs_log_iovec *vecp = NULL;
424 struct xfs_inode_log_format *ilf;
417 425
418 ASSERT(ip->i_d.di_version > 1); 426 ASSERT(ip->i_d.di_version > 1);
419 427
@@ -425,7 +433,17 @@ xfs_inode_item_format(
425 ilf->ilf_boffset = ip->i_imap.im_boffset; 433 ilf->ilf_boffset = ip->i_imap.im_boffset;
426 ilf->ilf_fields = XFS_ILOG_CORE; 434 ilf->ilf_fields = XFS_ILOG_CORE;
427 ilf->ilf_size = 2; /* format + core */ 435 ilf->ilf_size = 2; /* format + core */
428 xlog_finish_iovec(lv, vecp, sizeof(struct xfs_inode_log_format)); 436
437 /*
438 * make sure we don't leak uninitialised data into the log in the case
439 * when we don't log every field in the inode.
440 */
441 ilf->ilf_dsize = 0;
442 ilf->ilf_asize = 0;
443 ilf->ilf_pad = 0;
444 uuid_copy(&ilf->ilf_u.ilfu_uuid, &uuid_null);
445
446 xlog_finish_iovec(lv, vecp, sizeof(*ilf));
429 447
430 xfs_inode_item_format_core(ip, lv, &vecp); 448 xfs_inode_item_format_core(ip, lv, &vecp);
431 xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp); 449 xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp);
@@ -745,7 +763,7 @@ xfs_iflush_done(
745 */ 763 */
746 iip = INODE_ITEM(blip); 764 iip = INODE_ITEM(blip);
747 if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) || 765 if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
748 lip->li_flags & XFS_LI_FAILED) 766 (blip->li_flags & XFS_LI_FAILED))
749 need_ail++; 767 need_ail++;
750 768
751 blip = next; 769 blip = next;
@@ -855,44 +873,29 @@ xfs_istale_done(
855} 873}
856 874
857/* 875/*
858 * convert an xfs_inode_log_format struct from either 32 or 64 bit versions 876 * convert an xfs_inode_log_format struct from the old 32 bit version
859 * (which can have different field alignments) to the native version 877 * (which can have different field alignments) to the native 64 bit version
860 */ 878 */
861int 879int
862xfs_inode_item_format_convert( 880xfs_inode_item_format_convert(
863 xfs_log_iovec_t *buf, 881 struct xfs_log_iovec *buf,
864 xfs_inode_log_format_t *in_f) 882 struct xfs_inode_log_format *in_f)
865{ 883{
866 if (buf->i_len == sizeof(xfs_inode_log_format_32_t)) { 884 struct xfs_inode_log_format_32 *in_f32 = buf->i_addr;
867 xfs_inode_log_format_32_t *in_f32 = buf->i_addr; 885
868 886 if (buf->i_len != sizeof(*in_f32))
869 in_f->ilf_type = in_f32->ilf_type; 887 return -EFSCORRUPTED;
870 in_f->ilf_size = in_f32->ilf_size; 888
871 in_f->ilf_fields = in_f32->ilf_fields; 889 in_f->ilf_type = in_f32->ilf_type;
872 in_f->ilf_asize = in_f32->ilf_asize; 890 in_f->ilf_size = in_f32->ilf_size;
873 in_f->ilf_dsize = in_f32->ilf_dsize; 891 in_f->ilf_fields = in_f32->ilf_fields;
874 in_f->ilf_ino = in_f32->ilf_ino; 892 in_f->ilf_asize = in_f32->ilf_asize;
875 /* copy biggest field of ilf_u */ 893 in_f->ilf_dsize = in_f32->ilf_dsize;
876 uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid); 894 in_f->ilf_ino = in_f32->ilf_ino;
877 in_f->ilf_blkno = in_f32->ilf_blkno; 895 /* copy biggest field of ilf_u */
878 in_f->ilf_len = in_f32->ilf_len; 896 uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid);
879 in_f->ilf_boffset = in_f32->ilf_boffset; 897 in_f->ilf_blkno = in_f32->ilf_blkno;
880 return 0; 898 in_f->ilf_len = in_f32->ilf_len;
881 } else if (buf->i_len == sizeof(xfs_inode_log_format_64_t)){ 899 in_f->ilf_boffset = in_f32->ilf_boffset;
882 xfs_inode_log_format_64_t *in_f64 = buf->i_addr; 900 return 0;
883
884 in_f->ilf_type = in_f64->ilf_type;
885 in_f->ilf_size = in_f64->ilf_size;
886 in_f->ilf_fields = in_f64->ilf_fields;
887 in_f->ilf_asize = in_f64->ilf_asize;
888 in_f->ilf_dsize = in_f64->ilf_dsize;
889 in_f->ilf_ino = in_f64->ilf_ino;
890 /* copy biggest field of ilf_u */
891 uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f64->ilf_u.ilfu_uuid);
892 in_f->ilf_blkno = in_f64->ilf_blkno;
893 in_f->ilf_len = in_f64->ilf_len;
894 in_f->ilf_boffset = in_f64->ilf_boffset;
895 return 0;
896 }
897 return -EFSCORRUPTED;
898} 901}
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 5049e8ab6e30..aa75389be8cf 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1088,6 +1088,7 @@ xfs_ioctl_setattr_dax_invalidate(
1088 int *join_flags) 1088 int *join_flags)
1089{ 1089{
1090 struct inode *inode = VFS_I(ip); 1090 struct inode *inode = VFS_I(ip);
1091 struct super_block *sb = inode->i_sb;
1091 int error; 1092 int error;
1092 1093
1093 *join_flags = 0; 1094 *join_flags = 0;
@@ -1100,7 +1101,7 @@ xfs_ioctl_setattr_dax_invalidate(
1100 if (fa->fsx_xflags & FS_XFLAG_DAX) { 1101 if (fa->fsx_xflags & FS_XFLAG_DAX) {
1101 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) 1102 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
1102 return -EINVAL; 1103 return -EINVAL;
1103 if (ip->i_mount->m_sb.sb_blocksize != PAGE_SIZE) 1104 if (bdev_dax_supported(sb, sb->s_blocksize) < 0)
1104 return -EINVAL; 1105 return -EINVAL;
1105 } 1106 }
1106 1107
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index a1909bc064e9..f179bdf1644d 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -829,7 +829,8 @@ int
829xfs_iomap_write_unwritten( 829xfs_iomap_write_unwritten(
830 xfs_inode_t *ip, 830 xfs_inode_t *ip,
831 xfs_off_t offset, 831 xfs_off_t offset,
832 xfs_off_t count) 832 xfs_off_t count,
833 bool update_isize)
833{ 834{
834 xfs_mount_t *mp = ip->i_mount; 835 xfs_mount_t *mp = ip->i_mount;
835 xfs_fileoff_t offset_fsb; 836 xfs_fileoff_t offset_fsb;
@@ -840,6 +841,7 @@ xfs_iomap_write_unwritten(
840 xfs_trans_t *tp; 841 xfs_trans_t *tp;
841 xfs_bmbt_irec_t imap; 842 xfs_bmbt_irec_t imap;
842 struct xfs_defer_ops dfops; 843 struct xfs_defer_ops dfops;
844 struct inode *inode = VFS_I(ip);
843 xfs_fsize_t i_size; 845 xfs_fsize_t i_size;
844 uint resblks; 846 uint resblks;
845 int error; 847 int error;
@@ -899,7 +901,8 @@ xfs_iomap_write_unwritten(
899 i_size = XFS_FSB_TO_B(mp, offset_fsb + count_fsb); 901 i_size = XFS_FSB_TO_B(mp, offset_fsb + count_fsb);
900 if (i_size > offset + count) 902 if (i_size > offset + count)
901 i_size = offset + count; 903 i_size = offset + count;
902 904 if (update_isize && i_size > i_size_read(inode))
905 i_size_write(inode, i_size);
903 i_size = xfs_new_eof(ip, i_size); 906 i_size = xfs_new_eof(ip, i_size);
904 if (i_size) { 907 if (i_size) {
905 ip->i_d.di_size = i_size; 908 ip->i_d.di_size = i_size;
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h
index 00db3ecea084..ee535065c5d0 100644
--- a/fs/xfs/xfs_iomap.h
+++ b/fs/xfs/xfs_iomap.h
@@ -27,7 +27,7 @@ int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t,
27 struct xfs_bmbt_irec *, int); 27 struct xfs_bmbt_irec *, int);
28int xfs_iomap_write_allocate(struct xfs_inode *, int, xfs_off_t, 28int xfs_iomap_write_allocate(struct xfs_inode *, int, xfs_off_t,
29 struct xfs_bmbt_irec *); 29 struct xfs_bmbt_irec *);
30int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t); 30int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool);
31 31
32void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *, 32void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
33 struct xfs_bmbt_irec *); 33 struct xfs_bmbt_irec *);
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index c5107c7bc4bf..dc95a49d62e7 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2515,7 +2515,7 @@ next_lv:
2515 if (lv) 2515 if (lv)
2516 vecp = lv->lv_iovecp; 2516 vecp = lv->lv_iovecp;
2517 } 2517 }
2518 if (record_cnt == 0 && ordered == false) { 2518 if (record_cnt == 0 && !ordered) {
2519 if (!lv) 2519 if (!lv)
2520 return 0; 2520 return 0;
2521 break; 2521 break;
diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h
index 85401155750e..34447dca97d1 100644
--- a/fs/xfs/xfs_message.h
+++ b/fs/xfs/xfs_message.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef __XFS_MESSAGE_H 2#ifndef __XFS_MESSAGE_H
2#define __XFS_MESSAGE_H 1 3#define __XFS_MESSAGE_H 1
3 4
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index ea7d4b4e50d0..e9727d0a541a 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -704,7 +704,7 @@ xfs_mountfs(
704 xfs_set_maxicount(mp); 704 xfs_set_maxicount(mp);
705 705
706 /* enable fail_at_unmount as default */ 706 /* enable fail_at_unmount as default */
707 mp->m_fail_unmount = 1; 707 mp->m_fail_unmount = true;
708 708
709 error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname); 709 error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname);
710 if (error) 710 if (error)
diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h
index 0c381d71b242..0492436a053f 100644
--- a/fs/xfs/xfs_ondisk.h
+++ b/fs/xfs/xfs_ondisk.h
@@ -134,7 +134,7 @@ xfs_check_ondisk_structs(void)
134 XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28); 134 XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
135 XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8); 135 XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
136 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52); 136 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
137 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56); 137 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56);
138 XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20); 138 XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
139 XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16); 139 XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
140} 140}
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index 2f2dc3c09ad0..aa6c5c193f45 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2014 Christoph Hellwig. 3 * Copyright (c) 2014 Christoph Hellwig.
3 */ 4 */
@@ -274,7 +275,7 @@ xfs_fs_commit_blocks(
274 (end - 1) >> PAGE_SHIFT); 275 (end - 1) >> PAGE_SHIFT);
275 WARN_ON_ONCE(error); 276 WARN_ON_ONCE(error);
276 277
277 error = xfs_iomap_write_unwritten(ip, start, length); 278 error = xfs_iomap_write_unwritten(ip, start, length, false);
278 if (error) 279 if (error)
279 goto out_drop_iolock; 280 goto out_drop_iolock;
280 } 281 }
diff --git a/fs/xfs/xfs_pnfs.h b/fs/xfs/xfs_pnfs.h
index b587cb99b2b7..bf45951e28fe 100644
--- a/fs/xfs/xfs_pnfs.h
+++ b/fs/xfs/xfs_pnfs.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef _XFS_PNFS_H 2#ifndef _XFS_PNFS_H
2#define _XFS_PNFS_H 1 3#define _XFS_PNFS_H 1
3 4
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 3246815c24d6..37e603bf1591 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -736,7 +736,13 @@ xfs_reflink_end_cow(
736 /* If there is a hole at end_fsb - 1 go to the previous extent */ 736 /* If there is a hole at end_fsb - 1 go to the previous extent */
737 if (!xfs_iext_lookup_extent(ip, ifp, end_fsb - 1, &idx, &got) || 737 if (!xfs_iext_lookup_extent(ip, ifp, end_fsb - 1, &idx, &got) ||
738 got.br_startoff > end_fsb) { 738 got.br_startoff > end_fsb) {
739 ASSERT(idx > 0); 739 /*
740 * In case of racing, overlapping AIO writes no COW extents
741 * might be left by the time I/O completes for the loser of
742 * the race. In that case we are done.
743 */
744 if (idx <= 0)
745 goto out_cancel;
740 xfs_iext_get_extent(ifp, --idx, &got); 746 xfs_iext_get_extent(ifp, --idx, &got);
741 } 747 }
742 748
@@ -809,6 +815,7 @@ next_extent:
809 815
810out_defer: 816out_defer:
811 xfs_defer_cancel(&dfops); 817 xfs_defer_cancel(&dfops);
818out_cancel:
812 xfs_trans_cancel(tp); 819 xfs_trans_cancel(tp);
813 xfs_iunlock(ip, XFS_ILOCK_EXCL); 820 xfs_iunlock(ip, XFS_ILOCK_EXCL);
814out: 821out:
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index c996f4ae4a5f..f663022353c0 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1637,7 +1637,7 @@ xfs_fs_fill_super(
1637 1637
1638 /* version 5 superblocks support inode version counters. */ 1638 /* version 5 superblocks support inode version counters. */
1639 if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5) 1639 if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5)
1640 sb->s_flags |= MS_I_VERSION; 1640 sb->s_flags |= SB_I_VERSION;
1641 1641
1642 if (mp->m_flags & XFS_MOUNT_DAX) { 1642 if (mp->m_flags & XFS_MOUNT_DAX) {
1643 xfs_warn(mp, 1643 xfs_warn(mp,
@@ -1654,6 +1654,16 @@ xfs_fs_fill_super(
1654 "DAX and reflink have not been tested together!"); 1654 "DAX and reflink have not been tested together!");
1655 } 1655 }
1656 1656
1657 if (mp->m_flags & XFS_MOUNT_DISCARD) {
1658 struct request_queue *q = bdev_get_queue(sb->s_bdev);
1659
1660 if (!blk_queue_discard(q)) {
1661 xfs_warn(mp, "mounting with \"discard\" option, but "
1662 "the device does not support discard");
1663 mp->m_flags &= ~XFS_MOUNT_DISCARD;
1664 }
1665 }
1666
1657 if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { 1667 if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {
1658 if (mp->m_sb.sb_rblocks) { 1668 if (mp->m_sb.sb_rblocks) {
1659 xfs_alert(mp, 1669 xfs_alert(mp,