Merge branch 'akpm' (Andrew's patch-bomb)
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 21 Dec 2012 04:00:43 +0000 (20:00 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 21 Dec 2012 04:00:43 +0000 (20:00 -0800)
Merge the rest of Andrew's patches for -rc1:
 "A bunch of fixes and misc missed-out-on things.

  That'll do for -rc1.  I still have a batch of IPC patches which still
  have a possible bug report which I'm chasing down."

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (25 commits)
  keys: use keyring_alloc() to create module signing keyring
  keys: fix unreachable code
  sendfile: allows bypassing of notifier events
  SGI-XP: handle non-fatal traps
  fat: fix incorrect function comment
  Documentation: ABI: remove testing/sysfs-devices-node
  proc: fix inconsistent lock state
  linux/kernel.h: fix DIV_ROUND_CLOSEST with unsigned divisors
  memcg: don't register hotcpu notifier from ->css_alloc()
  checkpatch: warn on uapi #includes that #include <uapi/...
  revert "rtc: recycle id when unloading a rtc driver"
  mm: clean up transparent hugepage sysfs error messages
  hfsplus: add error message for the case of failure of sync fs in delayed_sync_fs() method
  hfsplus: rework processing of hfs_btree_write() returned error
  hfsplus: rework processing errors in hfsplus_free_extents()
  hfsplus: avoid crash on failed block map free
  kcmp: include linux/ptrace.h
  drivers/rtc/rtc-imxdi.c: must include <linux/spinlock.h>
  mm: cma: WARN if freed memory is still in use
  exec: do not leave bprm->interp on stack
  ...

319 files changed:
Documentation/ABI/testing/sysfs-bus-rbd
Documentation/filesystems/00-INDEX
Documentation/filesystems/Locking
Documentation/filesystems/caching/backend-api.txt
Documentation/filesystems/caching/netfs-api.txt
Documentation/filesystems/caching/object.txt
Documentation/filesystems/caching/operations.txt
Documentation/filesystems/f2fs.txt [new file with mode: 0644]
Documentation/filesystems/nfs/nfs41-server.txt
Documentation/filesystems/porting
Documentation/filesystems/vfs.txt
Makefile
arch/Kconfig
arch/alpha/Kconfig
arch/alpha/include/asm/ptrace.h
arch/alpha/include/asm/unistd.h
arch/alpha/include/uapi/asm/signal.h
arch/alpha/kernel/signal.c
arch/arm/Kconfig
arch/arm/boot/compressed/head.S
arch/arm/boot/dts/sun4i-a10-cubieboard.dts [new file with mode: 0644]
arch/arm/boot/dts/sun4i-a10.dtsi [new file with mode: 0644]
arch/arm/boot/dts/sun4i-cubieboard.dts [deleted file]
arch/arm/boot/dts/sun4i.dtsi [deleted file]
arch/arm/boot/dts/sun5i-a13-olinuxino.dts [new file with mode: 0644]
arch/arm/boot/dts/sun5i-a13.dtsi [new file with mode: 0644]
arch/arm/boot/dts/sun5i-olinuxino.dts [deleted file]
arch/arm/boot/dts/sun5i.dtsi [deleted file]
arch/arm/include/asm/unistd.h
arch/arm/include/uapi/asm/signal.h
arch/arm/kernel/setup.c
arch/arm/kernel/swp_emulate.c
arch/arm/kernel/vmlinux.lds.S
arch/arm/mach-exynos/clock-exynos4.c
arch/arm/mach-exynos/common.c
arch/arm/mach-exynos/dev-audio.c
arch/arm/mach-exynos/mach-exynos5-dt.c
arch/arm/mach-exynos/mach-origen.c
arch/arm/mach-exynos/mach-smdk4x12.c
arch/arm/mach-exynos/mach-smdkv310.c
arch/arm/mach-exynos/platsmp.c
arch/arm/mach-omap2/omap-iommu.c
arch/arm/mach-omap2/timer.c
arch/arm/mach-realview/include/mach/board-eb.h
arch/arm/mach-s3c64xx/clock.c
arch/arm/mach-s3c64xx/dev-audio.c
arch/arm/mach-s5p64x0/clock-s5p6440.c
arch/arm/mach-s5p64x0/clock-s5p6450.c
arch/arm/mach-s5p64x0/dev-audio.c
arch/arm/mach-s5pc100/clock.c
arch/arm/mach-s5pc100/dev-audio.c
arch/arm/mach-s5pv210/dev-audio.c
arch/arm/mm/cache-v7.S
arch/arm/plat-samsung/include/plat/gpio-core.h
arch/arm64/Kconfig
arch/arm64/include/asm/compat.h
arch/arm64/include/asm/unistd.h
arch/avr32/Kconfig
arch/avr32/include/asm/ptrace.h
arch/avr32/include/asm/unistd.h
arch/avr32/include/uapi/asm/signal.h
arch/blackfin/Kconfig
arch/blackfin/include/asm/ptrace.h
arch/blackfin/include/asm/unistd.h
arch/c6x/Kconfig
arch/c6x/include/uapi/asm/unistd.h
arch/cris/Kconfig
arch/cris/include/asm/ptrace.h
arch/cris/include/asm/unistd.h
arch/cris/include/uapi/asm/signal.h
arch/frv/Kconfig
arch/frv/include/asm/unistd.h
arch/h8300/Kconfig
arch/h8300/include/asm/ptrace.h
arch/h8300/include/asm/unistd.h
arch/h8300/include/uapi/asm/signal.h
arch/hexagon/Kconfig
arch/hexagon/include/uapi/asm/unistd.h
arch/ia64/Kconfig
arch/ia64/include/asm/ptrace.h
arch/ia64/include/asm/unistd.h
arch/ia64/include/uapi/asm/signal.h
arch/m32r/Kconfig
arch/m32r/include/asm/ptrace.h
arch/m32r/include/asm/unistd.h
arch/m32r/include/uapi/asm/signal.h
arch/m68k/Kconfig
arch/m68k/include/asm/ptrace.h
arch/m68k/include/asm/unistd.h
arch/m68k/include/uapi/asm/signal.h
arch/microblaze/Kconfig
arch/microblaze/include/asm/ptrace.h
arch/microblaze/include/asm/unistd.h
arch/mips/Kconfig
arch/mips/include/asm/ptrace.h
arch/mips/include/asm/unistd.h
arch/mips/include/uapi/asm/signal.h
arch/mn10300/Kconfig
arch/mn10300/include/asm/unistd.h
arch/mn10300/include/uapi/asm/signal.h
arch/openrisc/Kconfig
arch/openrisc/include/uapi/asm/unistd.h
arch/parisc/Kconfig
arch/parisc/include/asm/unistd.h
arch/parisc/include/uapi/asm/signal.h
arch/powerpc/Kconfig
arch/powerpc/include/asm/unistd.h
arch/powerpc/include/uapi/asm/signal.h
arch/powerpc/platforms/cell/spufs/syscalls.c
arch/s390/Kconfig
arch/s390/include/asm/compat.h
arch/s390/include/asm/unistd.h
arch/s390/include/uapi/asm/signal.h
arch/score/Kconfig
arch/score/include/asm/ptrace.h
arch/score/include/uapi/asm/unistd.h
arch/sh/Kconfig
arch/sh/include/asm/unistd.h
arch/sparc/Kconfig
arch/sparc/include/asm/unistd.h
arch/sparc/include/uapi/asm/signal.h
arch/tile/Kconfig
arch/tile/include/asm/ptrace.h
arch/tile/include/asm/unistd.h
arch/um/kernel/signal.c
arch/unicore32/Kconfig
arch/unicore32/include/asm/ptrace.h
arch/unicore32/include/uapi/asm/unistd.h
arch/x86/Kconfig
arch/x86/ia32/ia32_signal.c
arch/x86/ia32/ia32entry.S
arch/x86/include/asm/ia32.h
arch/x86/include/asm/ptrace.h
arch/x86/include/asm/sys_ia32.h
arch/x86/include/asm/syscalls.h
arch/x86/include/asm/unistd.h
arch/x86/include/uapi/asm/signal.h
arch/x86/kernel/entry_32.S
arch/x86/kernel/entry_64.S
arch/x86/kernel/signal.c
arch/x86/syscalls/syscall_32.tbl
arch/x86/syscalls/syscall_64.tbl
arch/x86/um/Kconfig
arch/x86/um/asm/ptrace.h
arch/x86/um/signal.c
arch/x86/um/sys_call_table_32.c
arch/x86/um/sys_call_table_64.c
arch/xtensa/Kconfig
arch/xtensa/include/asm/ptrace.h
arch/xtensa/include/asm/unistd.h
arch/xtensa/include/uapi/asm/signal.h
drivers/base/devtmpfs.c
drivers/block/rbd.c
drivers/block/rbd_types.h
drivers/pinctrl/pinctrl-exynos5440.c
drivers/pinctrl/pinctrl-samsung.c
drivers/pinctrl/pinctrl-samsung.h
fs/Kconfig
fs/Makefile
fs/adfs/inode.c
fs/affs/file.c
fs/affs/inode.c
fs/bfs/file.c
fs/btrfs/ctree.c
fs/btrfs/inode.c
fs/cachefiles/interface.c
fs/cachefiles/internal.h
fs/cachefiles/key.c
fs/cachefiles/namei.c
fs/cachefiles/rdwr.c
fs/cachefiles/xattr.c
fs/ceph/addr.c
fs/ceph/caps.c
fs/ceph/file.c
fs/ceph/inode.c
fs/ceph/mds_client.c
fs/ceph/super.c
fs/dcache.c
fs/exec.c
fs/exportfs/expfs.c
fs/f2fs/Kconfig [new file with mode: 0644]
fs/f2fs/Makefile [new file with mode: 0644]
fs/f2fs/acl.c [new file with mode: 0644]
fs/f2fs/acl.h [new file with mode: 0644]
fs/f2fs/checkpoint.c [new file with mode: 0644]
fs/f2fs/data.c [new file with mode: 0644]
fs/f2fs/debug.c [new file with mode: 0644]
fs/f2fs/dir.c [new file with mode: 0644]
fs/f2fs/f2fs.h [new file with mode: 0644]
fs/f2fs/file.c [new file with mode: 0644]
fs/f2fs/gc.c [new file with mode: 0644]
fs/f2fs/gc.h [new file with mode: 0644]
fs/f2fs/hash.c [new file with mode: 0644]
fs/f2fs/inode.c [new file with mode: 0644]
fs/f2fs/namei.c [new file with mode: 0644]
fs/f2fs/node.c [new file with mode: 0644]
fs/f2fs/node.h [new file with mode: 0644]
fs/f2fs/recovery.c [new file with mode: 0644]
fs/f2fs/segment.c [new file with mode: 0644]
fs/f2fs/segment.h [new file with mode: 0644]
fs/f2fs/super.c [new file with mode: 0644]
fs/f2fs/xattr.c [new file with mode: 0644]
fs/f2fs/xattr.h [new file with mode: 0644]
fs/fhandle.c
fs/file_table.c
fs/fscache/cache.c
fs/fscache/cookie.c
fs/fscache/internal.h
fs/fscache/object-list.c
fs/fscache/object.c
fs/fscache/operation.c
fs/fscache/page.c
fs/fscache/stats.c
fs/hfs/inode.c
fs/hfsplus/inode.c
fs/hpfs/file.c
fs/hpfs/hpfs_fn.h
fs/hpfs/inode.c
fs/jfs/file.c
fs/jfs/inode.c
fs/libfs.c
fs/logfs/readwrite.c
fs/minix/file.c
fs/minix/inode.c
fs/namei.c
fs/namespace.c
fs/ncpfs/inode.c
fs/nfs/fscache.c
fs/nfs/fscache.h
fs/nfs/inode.c
fs/nfs/nfs4file.c
fs/nfs/nfs4proc.c
fs/nfs/write.c
fs/nfsd/fault_inject.c
fs/nfsd/fault_inject.h [deleted file]
fs/nfsd/netns.h
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/nfs3proc.c
fs/nfsd/nfs3xdr.c
fs/nfsd/nfs4callback.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4recover.c
fs/nfsd/nfs4state.c
fs/nfsd/nfs4xdr.c
fs/nfsd/nfsctl.c
fs/nfsd/nfsd.h
fs/nfsd/nfsfh.c
fs/nfsd/nfssvc.c
fs/nfsd/nfsxdr.c
fs/nfsd/state.h
fs/nfsd/vfs.c
fs/nfsd/xdr4.h
fs/nilfs2/file.c
fs/nilfs2/inode.c
fs/nilfs2/nilfs.h
fs/nilfs2/recovery.c
fs/ntfs/file.c
fs/ntfs/inode.c
fs/ntfs/inode.h
fs/ocfs2/file.c
fs/omfs/file.c
fs/open.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/proc_sysctl.c
fs/reiserfs/file.c
fs/reiserfs/inode.c
fs/reiserfs/reiserfs.h
fs/stat.c
fs/statfs.c
fs/sysv/file.c
fs/sysv/itree.c
fs/ufs/inode.c
fs/utimes.c
fs/xattr.c
include/linux/backing-dev.h
include/linux/binfmts.h
include/linux/ceph/libceph.h
include/linux/ceph/osdmap.h
include/linux/ceph/rados.h
include/linux/compat.h
include/linux/dcache.h
include/linux/exportfs.h
include/linux/f2fs_fs.h [new file with mode: 0644]
include/linux/fs.h
include/linux/fscache-cache.h
include/linux/fscache.h
include/linux/mm.h
include/linux/namei.h
include/linux/ptrace.h
include/linux/sched.h
include/linux/signal.h
include/linux/sunrpc/cache.h
include/linux/sunrpc/svc.h
include/linux/sunrpc/svcsock.h
include/linux/syscalls.h
include/uapi/asm-generic/signal.h
include/uapi/linux/magic.h
include/uapi/linux/signal.h
init/main.c
kernel/fork.c
kernel/kmod.c
kernel/signal.c
lib/atomic64.c
mm/truncate.c
net/ceph/ceph_common.c
net/ceph/messenger.c
net/ceph/osd_client.c
net/ceph/osdmap.c
net/sunrpc/rpcb_clnt.c
net/sunrpc/svc.c
net/sunrpc/svcsock.c
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
net/sunrpc/xprtrdma/svc_rdma_sendto.c
scripts/coccinelle/misc/warn.cocci [new file with mode: 0644]
scripts/config
scripts/pnmtologo.c
scripts/tags.sh

index 1cf2adf46b118cd4b2f7bc2449a1065d764a2bd6..cd9213ccf3dc263ba2e87ff2ecc660ef370c1f1a 100644 (file)
@@ -70,6 +70,10 @@ snap_*
 
        A directory per each snapshot
 
+parent
+
+       Information identifying the pool, image, and snapshot id for
+       the parent image in a layered rbd image (format 2 only).
 
 Entries under /sys/bus/rbd/devices/<dev-id>/snap_<snap-name>
 -------------------------------------------------------------
index 7b52ba7bf32aaf255c0bc7c584609834f6748c0b..8042050eb265b34cbb367e51df2805258667ae8d 100644 (file)
@@ -50,6 +50,8 @@ ext4.txt
        - info, mount options and specifications for the Ext4 filesystem.
 files.txt
        - info on file management in the Linux kernel.
+f2fs.txt
+       - info and mount options for the F2FS filesystem.
 fuse.txt
        - info on the Filesystem in User SpacE including mount options.
 gfs2.txt
index e540a24e5d069d4f6372adaabfa792ff11897ca9..f48e0c6b4c4295deeda9358cfe8f706b8feea2c0 100644 (file)
@@ -80,7 +80,6 @@ rename:               yes (all)       (see below)
 readlink:      no
 follow_link:   no
 put_link:      no
-truncate:      yes             (see below)
 setattr:       yes
 permission:    no (may not block if called in rcu-walk mode)
 get_acl:       no
@@ -96,11 +95,6 @@ atomic_open: yes
        Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
 victim.
        cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
-       ->truncate() is never called directly - it's a callback, not a
-method. It's called by vmtruncate() - deprecated library function used by
-->setattr(). Locking information above applies to that call (i.e. is
-inherited from ->setattr() - vmtruncate() is used when ATTR_SIZE had been
-passed).
 
 See Documentation/filesystems/directory-locking for more detailed discussion
 of the locking scheme for directory operations.
index 382d52cdaf2da374061764865fa04db2c73fa072..d78bab9622c63d8ff1b21f9886523f1b90d57ee8 100644 (file)
@@ -308,6 +308,18 @@ performed on the denizens of the cache.  These are held in a structure of type:
      obtained by calling object->cookie->def->get_aux()/get_attr().
 
 
+ (*) Invalidate data object [mandatory]:
+
+       int (*invalidate_object)(struct fscache_operation *op)
+
+     This is called to invalidate a data object (as pointed to by op->object).
+     All the data stored for this object should be discarded and an
+     attr_changed operation should be performed.  The caller will follow up
+     with an object update operation.
+
+     fscache_op_complete() must be called on op before returning.
+
+
  (*) Discard object [mandatory]:
 
        void (*drop_object)(struct fscache_object *object)
@@ -419,7 +431,10 @@ performed on the denizens of the cache.  These are held in a structure of type:
 
      If an I/O error occurs, fscache_io_error() should be called and -ENOBUFS
      returned if possible or fscache_end_io() called with a suitable error
-     code..
+     code.
+
+     fscache_put_retrieval() should be called after a page or pages are dealt
+     with.  This will complete the operation when all pages are dealt with.
 
 
  (*) Request pages be read from cache [mandatory]:
@@ -526,6 +541,27 @@ FS-Cache provides some utilities that a cache backend may make use of:
      error value should be 0 if successful and an error otherwise.
 
 
+ (*) Record that one or more pages being retrieved or allocated have been dealt
+     with:
+
+       void fscache_retrieval_complete(struct fscache_retrieval *op,
+                                       int n_pages);
+
+     This is called to record the fact that one or more pages have been dealt
+     with and are no longer the concern of this operation.  When the number of
+     pages remaining in the operation reaches 0, the operation will be
+     completed.
+
+
+ (*) Record operation completion:
+
+       void fscache_op_complete(struct fscache_operation *op);
+
+     This is called to record the completion of an operation.  This deducts
+     this operation from the parent object's run state, potentially permitting
+     one or more pending operations to start running.
+
+
  (*) Set highest store limit:
 
        void fscache_set_store_limit(struct fscache_object *object,
index 7cc6bf2871ebfbae736436959a3d8a2e5153334d..97e6c0ecc5efc0ad763b1d2d3e376c38e057ae07 100644 (file)
@@ -35,8 +35,9 @@ This document contains the following sections:
        (12) Index and data file update
        (13) Miscellaneous cookie operations
        (14) Cookie unregistration
-       (15) Index and data file invalidation
-       (16) FS-Cache specific page flags.
+       (15) Index invalidation
+       (16) Data file invalidation
+       (17) FS-Cache specific page flags.
 
 
 =============================
@@ -767,13 +768,42 @@ the cookies for "child" indices, objects and pages have been relinquished
 first.
 
 
-================================
-INDEX AND DATA FILE INVALIDATION
-================================
+==================
+INDEX INVALIDATION
+==================
+
+There is no direct way to invalidate an index subtree.  To do this, the caller
+should relinquish and retire the cookie they have, and then acquire a new one.
+
+
+======================
+DATA FILE INVALIDATION
+======================
+
+Sometimes it will be necessary to invalidate an object that contains data.
+Typically this will be necessary when the server tells the netfs of a foreign
+change - at which point the netfs has to throw away all the state it had for an
+inode and reload from the server.
+
+To indicate that a cache object should be invalidated, the following function
+can be called:
+
+       void fscache_invalidate(struct fscache_cookie *cookie);
+
+This can be called with spinlocks held as it defers the work to a thread pool.
+All extant storage, retrieval and attribute change ops at this point are
+cancelled and discarded.  Some future operations will be rejected until the
+cache has had a chance to insert a barrier in the operations queue.  After
+that, operations will be queued again behind the invalidation operation.
+
+The invalidation operation will perform an attribute change operation and an
+auxiliary data update operation as it is very likely these will have changed.
+
+Using the following function, the netfs can wait for the invalidation operation
+to have reached a point at which it can start submitting ordinary operations
+once again:
 
-There is no direct way to invalidate an index subtree or a data file.  To do
-this, the caller should relinquish and retire the cookie they have, and then
-acquire a new one.
+       void fscache_wait_on_invalidate(struct fscache_cookie *cookie);
 
 
 ===========================
index 58313348da870ec0a0dda2c6190354593352f7fc..100ff41127e436ac8614c6c095a4e56dff2ccb62 100644 (file)
@@ -216,7 +216,14 @@ servicing netfs requests:
      The normal running state.  In this state, requests the netfs makes will be
      passed on to the cache.
 
- (6) State FSCACHE_OBJECT_UPDATING.
+ (6) State FSCACHE_OBJECT_INVALIDATING.
+
+     The object is undergoing invalidation.  When the state comes here, it
+     discards all pending read, write and attribute change operations as it is
+     going to clear out the cache entirely and reinitialise it.  It will then
+     continue to the FSCACHE_OBJECT_UPDATING state.
+
+ (7) State FSCACHE_OBJECT_UPDATING.
 
      The state machine comes here to update the object in the cache from the
      netfs's records.  This involves updating the auxiliary data that is used
@@ -225,13 +232,13 @@ servicing netfs requests:
 And there are terminal states in which an object cleans itself up, deallocates
 memory and potentially deletes stuff from disk:
 
- (7) State FSCACHE_OBJECT_LC_DYING.
+ (8) State FSCACHE_OBJECT_LC_DYING.
 
      The object comes here if it is dying because of a lookup or creation
      error.  This would be due to a disk error or system error of some sort.
      Temporary data is cleaned up, and the parent is released.
 
- (8) State FSCACHE_OBJECT_DYING.
+ (9) State FSCACHE_OBJECT_DYING.
 
      The object comes here if it is dying due to an error, because its parent
      cookie has been relinquished by the netfs or because the cache is being
@@ -241,27 +248,27 @@ memory and potentially deletes stuff from disk:
      can destroy themselves.  This object waits for all its children to go away
      before advancing to the next state.
 
- (9) State FSCACHE_OBJECT_ABORT_INIT.
+(10) State FSCACHE_OBJECT_ABORT_INIT.
 
      The object comes to this state if it was waiting on its parent in
      FSCACHE_OBJECT_INIT, but its parent died.  The object will destroy itself
      so that the parent may proceed from the FSCACHE_OBJECT_DYING state.
 
-(10) State FSCACHE_OBJECT_RELEASING.
-(11) State FSCACHE_OBJECT_RECYCLING.
+(11) State FSCACHE_OBJECT_RELEASING.
+(12) State FSCACHE_OBJECT_RECYCLING.
 
      The object comes to one of these two states when dying once it is rid of
      all its children, if it is dying because the netfs relinquished its
      cookie.  In the first state, the cached data is expected to persist, and
      in the second it will be deleted.
 
-(12) State FSCACHE_OBJECT_WITHDRAWING.
+(13) State FSCACHE_OBJECT_WITHDRAWING.
 
      The object transits to this state if the cache decides it wants to
      withdraw the object from service, perhaps to make space, but also due to
      error or just because the whole cache is being withdrawn.
 
-(13) State FSCACHE_OBJECT_DEAD.
+(14) State FSCACHE_OBJECT_DEAD.
 
      The object transits to this state when the in-memory object record is
      ready to be deleted.  The object processor shouldn't ever see an object in
index b6b070c57cbf5861d425451ccd3505ec9a86e5bf..bee2a5f93d6059da8621afc1854526b088242c5b 100644 (file)
@@ -174,7 +174,7 @@ Operations are used through the following procedure:
      necessary (the object might have died whilst the thread was waiting).
 
      When it has finished doing its processing, it should call
-     fscache_put_operation() on it.
+     fscache_op_complete() and fscache_put_operation() on it.
 
  (4) The operation holds an effective lock upon the object, preventing other
      exclusive ops conflicting until it is released.  The operation can be
diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
new file mode 100644 (file)
index 0000000..8fbd8b4
--- /dev/null
@@ -0,0 +1,421 @@
+================================================================================
+WHAT IS Flash-Friendly File System (F2FS)?
+================================================================================
+
+NAND flash memory-based storage devices, such as SSD, eMMC, and SD cards, have
+been equipped on a variety systems ranging from mobile to server systems. Since
+they are known to have different characteristics from the conventional rotating
+disks, a file system, an upper layer to the storage device, should adapt to the
+changes from the sketch in the design level.
+
+F2FS is a file system exploiting NAND flash memory-based storage devices, which
+is based on Log-structured File System (LFS). The design has been focused on
+addressing the fundamental issues in LFS, which are snowball effect of wandering
+tree and high cleaning overhead.
+
+Since a NAND flash memory-based storage device shows different characteristic
+according to its internal geometry or flash memory management scheme, namely FTL,
+F2FS and its tools support various parameters not only for configuring on-disk
+layout, but also for selecting allocation and cleaning algorithms.
+
+The file system formatting tool, "mkfs.f2fs", is available from the following
+git tree:
+>> git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git
+
+For reporting bugs and sending patches, please use the following mailing list:
+>> linux-f2fs-devel@lists.sourceforge.net
+
+================================================================================
+BACKGROUND AND DESIGN ISSUES
+================================================================================
+
+Log-structured File System (LFS)
+--------------------------------
+"A log-structured file system writes all modifications to disk sequentially in
+a log-like structure, thereby speeding up  both file writing and crash recovery.
+The log is the only structure on disk; it contains indexing information so that
+files can be read back from the log efficiently. In order to maintain large free
+areas on disk for fast writing, we divide  the log into segments and use a
+segment cleaner to compress the live information from heavily fragmented
+segments." from Rosenblum, M. and Ousterhout, J. K., 1992, "The design and
+implementation of a log-structured file system", ACM Trans. Computer Systems
+10, 1, 26–52.
+
+Wandering Tree Problem
+----------------------
+In LFS, when a file data is updated and written to the end of log, its direct
+pointer block is updated due to the changed location. Then the indirect pointer
+block is also updated due to the direct pointer block update. In this manner,
+the upper index structures such as inode, inode map, and checkpoint block are
+also updated recursively. This problem is called as wandering tree problem [1],
+and in order to enhance the performance, it should eliminate or relax the update
+propagation as much as possible.
+
+[1] Bityutskiy, A. 2005. JFFS3 design issues. http://www.linux-mtd.infradead.org/
+
+Cleaning Overhead
+-----------------
+Since LFS is based on out-of-place writes, it produces so many obsolete blocks
+scattered across the whole storage. In order to serve new empty log space, it
+needs to reclaim these obsolete blocks seamlessly to users. This job is called
+as a cleaning process.
+
+The process consists of three operations as follows.
+1. A victim segment is selected through referencing segment usage table.
+2. It loads parent index structures of all the data in the victim identified by
+   segment summary blocks.
+3. It checks the cross-reference between the data and its parent index structure.
+4. It moves valid data selectively.
+
+This cleaning job may cause unexpected long delays, so the most important goal
+is to hide the latencies to users. And also definitely, it should reduce the
+amount of valid data to be moved, and move them quickly as well.
+
+================================================================================
+KEY FEATURES
+================================================================================
+
+Flash Awareness
+---------------
+- Enlarge the random write area for better performance, but provide the high
+  spatial locality
+- Align FS data structures to the operational units in FTL as best efforts
+
+Wandering Tree Problem
+----------------------
+- Use a term, “node”, that represents inodes as well as various pointer blocks
+- Introduce Node Address Table (NAT) containing the locations of all the “node”
+  blocks; this will cut off the update propagation.
+
+Cleaning Overhead
+-----------------
+- Support a background cleaning process
+- Support greedy and cost-benefit algorithms for victim selection policies
+- Support multi-head logs for static/dynamic hot and cold data separation
+- Introduce adaptive logging for efficient block allocation
+
+================================================================================
+MOUNT OPTIONS
+================================================================================
+
+background_gc_off      Turn off cleaning operations, namely garbage collection,
+                      triggered in background when I/O subsystem is idle.
+disable_roll_forward   Disable the roll-forward recovery routine
+discard                Issue discard/TRIM commands when a segment is cleaned.
+no_heap                Disable heap-style segment allocation which finds free
+                       segments for data from the beginning of main area, while
+                      for node from the end of main area.
+nouser_xattr           Disable Extended User Attributes. Note: xattr is enabled
+                       by default if CONFIG_F2FS_FS_XATTR is selected.
+noacl                  Disable POSIX Access Control List. Note: acl is enabled
+                       by default if CONFIG_F2FS_FS_POSIX_ACL is selected.
+active_logs=%u         Support configuring the number of active logs. In the
+                       current design, f2fs supports only 2, 4, and 6 logs.
+                       Default number is 6.
+disable_ext_identify   Disable the extension list configured by mkfs, so f2fs
+                       does not aware of cold files such as media files.
+
+================================================================================
+DEBUGFS ENTRIES
+================================================================================
+
+/sys/kernel/debug/f2fs/ contains information about all the partitions mounted as
+f2fs. Each file shows the whole f2fs information.
+
+/sys/kernel/debug/f2fs/status includes:
+ - major file system information managed by f2fs currently
+ - average SIT information about whole segments
+ - current memory footprint consumed by f2fs.
+
+================================================================================
+USAGE
+================================================================================
+
+1. Download userland tools and compile them.
+
+2. Skip, if f2fs was compiled statically inside kernel.
+   Otherwise, insert the f2fs.ko module.
+ # insmod f2fs.ko
+
+3. Create a directory trying to mount
+ # mkdir /mnt/f2fs
+
+4. Format the block device, and then mount as f2fs
+ # mkfs.f2fs -l label /dev/block_device
+ # mount -t f2fs /dev/block_device /mnt/f2fs
+
+Format options
+--------------
+-l [label]   : Give a volume label, up to 256 unicode name.
+-a [0 or 1]  : Split start location of each area for heap-based allocation.
+               1 is set by default, which performs this.
+-o [int]     : Set overprovision ratio in percent over volume size.
+               5 is set by default.
+-s [int]     : Set the number of segments per section.
+               1 is set by default.
+-z [int]     : Set the number of sections per zone.
+               1 is set by default.
+-e [str]     : Set basic extension list. e.g. "mp3,gif,mov"
+
+================================================================================
+DESIGN
+================================================================================
+
+On-disk Layout
+--------------
+
+F2FS divides the whole volume into a number of segments, each of which is fixed
+to 2MB in size. A section is composed of consecutive segments, and a zone
+consists of a set of sections. By default, section and zone sizes are set to one
+segment size identically, but users can easily modify the sizes by mkfs.
+
+F2FS splits the entire volume into six areas, and all the areas except superblock
+consists of multiple segments as described below.
+
+                                            align with the zone size <-|
+                 |-> align with the segment size
+     _________________________________________________________________________
+    |            |            |    Node     |   Segment   |   Segment  |      |
+    | Superblock | Checkpoint |   Address   |    Info.    |   Summary  | Main |
+    |    (SB)    |   (CP)     | Table (NAT) | Table (SIT) | Area (SSA) |      |
+    |____________|_____2______|______N______|______N______|______N_____|__N___|
+                                                                       .      .
+                                                             .                .
+                                                 .                            .
+                                    ._________________________________________.
+                                    |_Segment_|_..._|_Segment_|_..._|_Segment_|
+                                    .           .
+                                    ._________._________
+                                    |_section_|__...__|_
+                                    .            .
+                                   .________.
+                                   |__zone__|
+
+- Superblock (SB)
+ : It is located at the beginning of the partition, and there exist two copies
+   to avoid file system crash. It contains basic partition information and some
+   default parameters of f2fs.
+
+- Checkpoint (CP)
+ : It contains file system information, bitmaps for valid NAT/SIT sets, orphan
+   inode lists, and summary entries of current active segments.
+
+- Node Address Table (NAT)
+ : It is composed of a block address table for all the node blocks stored in
+   Main area.
+
+- Segment Information Table (SIT)
+ : It contains segment information such as valid block count and bitmap for the
+   validity of all the blocks.
+
+- Segment Summary Area (SSA)
+ : It contains summary entries which contains the owner information of all the
+   data and node blocks stored in Main area.
+
+- Main Area
+ : It contains file and directory data including their indices.
+
+In order to avoid misalignment between file system and flash-based storage, F2FS
+aligns the start block address of CP with the segment size. Also, it aligns the
+start block address of Main area with the zone size by reserving some segments
+in SSA area.
+
+Reference the following survey for additional technical details.
+https://wiki.linaro.org/WorkingGroups/Kernel/Projects/FlashCardSurvey
+
+File System Metadata Structure
+------------------------------
+
+F2FS adopts the checkpointing scheme to maintain file system consistency. At
+mount time, F2FS first tries to find the last valid checkpoint data by scanning
+CP area. In order to reduce the scanning time, F2FS uses only two copies of CP.
+One of them always indicates the last valid data, which is called as shadow copy
+mechanism. In addition to CP, NAT and SIT also adopt the shadow copy mechanism.
+
+For file system consistency, each CP points to which NAT and SIT copies are
+valid, as shown as below.
+
+  +--------+----------+---------+
+  |   CP   |    NAT   |   SIT   |
+  +--------+----------+---------+
+  .         .          .          .
+  .            .              .              .
+  .               .                 .                 .
+  +-------+-------+--------+--------+--------+--------+
+  | CP #0 | CP #1 | NAT #0 | NAT #1 | SIT #0 | SIT #1 |
+  +-------+-------+--------+--------+--------+--------+
+     |             ^                          ^
+     |             |                          |
+     `----------------------------------------'
+
+Index Structure
+---------------
+
+The key data structure to manage the data locations is a "node". Similar to
+traditional file structures, F2FS has three types of node: inode, direct node,
+indirect node. F2FS assigns 4KB to an inode block which contains 923 data block
+indices, two direct node pointers, two indirect node pointers, and one double
+indirect node pointer as described below. One direct node block contains 1018
+data blocks, and one indirect node block contains also 1018 node blocks. Thus,
+one inode block (i.e., a file) covers:
+
+  4KB * (923 + 2 * 1018 + 2 * 1018 * 1018 + 1018 * 1018 * 1018) := 3.94TB.
+
+   Inode block (4KB)
+     |- data (923)
+     |- direct node (2)
+     |          `- data (1018)
+     |- indirect node (2)
+     |            `- direct node (1018)
+     |                       `- data (1018)
+     `- double indirect node (1)
+                         `- indirect node (1018)
+                                     `- direct node (1018)
+                                                `- data (1018)
+
+Note that, all the node blocks are mapped by NAT which means the location of
+each node is translated by the NAT table. In the consideration of the wandering
+tree problem, F2FS is able to cut off the propagation of node updates caused by
+leaf data writes.
+
+Directory Structure
+-------------------
+
+A directory entry occupies 11 bytes, which consists of the following attributes.
+
+- hash         hash value of the file name
+- ino          inode number
+- len          the length of file name
+- type         file type such as directory, symlink, etc
+
+A dentry block consists of 214 dentry slots and file names. Therein a bitmap is
+used to represent whether each dentry is valid or not. A dentry block occupies
+4KB with the following composition.
+
+  Dentry Block(4 K) = bitmap (27 bytes) + reserved (3 bytes) +
+                     dentries(11 * 214 bytes) + file name (8 * 214 bytes)
+
+                         [Bucket]
+             +--------------------------------+
+             |dentry block 1 | dentry block 2 |
+             +--------------------------------+
+             .               .
+       .                             .
+  .       [Dentry Block Structure: 4KB]       .
+  +--------+----------+----------+------------+
+  | bitmap | reserved | dentries | file names |
+  +--------+----------+----------+------------+
+  [Dentry Block: 4KB] .   .
+                .               .
+            .                          .
+            +------+------+-----+------+
+            | hash | ino  | len | type |
+            +------+------+-----+------+
+            [Dentry Structure: 11 bytes]
+
+F2FS implements multi-level hash tables for directory structure. Each level has
+a hash table with dedicated number of hash buckets as shown below. Note that
+"A(2B)" means a bucket includes 2 data blocks.
+
+----------------------
+A : bucket
+B : block
+N : MAX_DIR_HASH_DEPTH
+----------------------
+
+level #0   | A(2B)
+           |
+level #1   | A(2B) - A(2B)
+           |
+level #2   | A(2B) - A(2B) - A(2B) - A(2B)
+     .     |   .       .       .       .
+level #N/2 | A(2B) - A(2B) - A(2B) - A(2B) - A(2B) - ... - A(2B)
+     .     |   .       .       .       .
+level #N   | A(4B) - A(4B) - A(4B) - A(4B) - A(4B) - ... - A(4B)
+
+The number of blocks and buckets are determined by,
+
+                            ,- 2, if n < MAX_DIR_HASH_DEPTH / 2,
+  # of blocks in level #n = |
+                            `- 4, Otherwise
+
+                             ,- 2^n, if n < MAX_DIR_HASH_DEPTH / 2,
+  # of buckets in level #n = |
+                             `- 2^((MAX_DIR_HASH_DEPTH / 2) - 1), Otherwise
+
+When F2FS finds a file name in a directory, at first a hash value of the file
+name is calculated. Then, F2FS scans the hash table in level #0 to find the
+dentry consisting of the file name and its inode number. If not found, F2FS
+scans the next hash table in level #1. In this way, F2FS scans hash tables in
+each levels incrementally from 1 to N. In each levels F2FS needs to scan only
+one bucket determined by the following equation, which shows O(log(# of files))
+complexity.
+
+  bucket number to scan in level #n = (hash value) % (# of buckets in level #n)
+
+In the case of file creation, F2FS finds empty consecutive slots that cover the
+file name. F2FS searches the empty slots in the hash tables of whole levels from
+1 to N in the same way as the lookup operation.
+
+The following figure shows an example of two cases holding children.
+       --------------> Dir <--------------
+       |                                 |
+    child                             child
+
+    child - child                     [hole] - child
+
+    child - child - child             [hole] - [hole] - child
+
+   Case 1:                           Case 2:
+   Number of children = 6,           Number of children = 3,
+   File size = 7                     File size = 7
+
+Default Block Allocation
+------------------------
+
+At runtime, F2FS manages six active logs inside "Main" area: Hot/Warm/Cold node
+and Hot/Warm/Cold data.
+
+- Hot node     contains direct node blocks of directories.
+- Warm node    contains direct node blocks except hot node blocks.
+- Cold node    contains indirect node blocks
+- Hot data     contains dentry blocks
+- Warm data    contains data blocks except hot and cold data blocks
+- Cold data    contains multimedia data or migrated data blocks
+
+LFS has two schemes for free space management: threaded log and copy-and-compac-
+tion. The copy-and-compaction scheme which is known as cleaning, is well-suited
+for devices showing very good sequential write performance, since free segments
+are served all the time for writing new data. However, it suffers from cleaning
+overhead under high utilization. Contrarily, the threaded log scheme suffers
+from random writes, but no cleaning process is needed. F2FS adopts a hybrid
+scheme where the copy-and-compaction scheme is adopted by default, but the
+policy is dynamically changed to the threaded log scheme according to the file
+system status.
+
+In order to align F2FS with underlying flash-based storage, F2FS allocates a
+segment in a unit of section. F2FS expects that the section size would be the
+same as the unit size of garbage collection in FTL. Furthermore, with respect
+to the mapping granularity in FTL, F2FS allocates each section of the active
+logs from different zones as much as possible, since FTL can write the data in
+the active logs into one allocation unit according to its mapping granularity.
+
+Cleaning process
+----------------
+
+F2FS does cleaning both on demand and in the background. On-demand cleaning is
+triggered when there are not enough free segments to serve VFS calls. Background
+cleaner is operated by a kernel thread, and triggers the cleaning job when the
+system is idle.
+
+F2FS supports two victim selection policies: greedy and cost-benefit algorithms.
+In the greedy algorithm, F2FS selects a victim segment having the smallest number
+of valid blocks. In the cost-benefit algorithm, F2FS selects a victim segment
+according to the segment age and the number of valid blocks in order to address
+log block thrashing problem in the greedy algorithm. F2FS adopts the greedy
+algorithm for on-demand cleaner, while background cleaner adopts cost-benefit
+algorithm.
+
+In order to identify whether the data in the victim segment are valid or not,
+F2FS manages a bitmap. Each bit represents the validity of a block, and the
+bitmap is composed of a bit stream covering whole blocks in main area.
index 092fad92a3f0e9bcc164b40595c19055e398d9ba..01c2db769791832b989b738d413cea2ecefcba68 100644 (file)
@@ -39,21 +39,10 @@ interoperability problems with future clients.  Known issues:
          from a linux client are possible, but we aren't really
          conformant with the spec (for example, we don't use kerberos
          on the backchannel correctly).
-       - Incomplete backchannel support: incomplete backchannel gss
-         support and no support for BACKCHANNEL_CTL mean that
-         callbacks (hence delegations and layouts) may not be
-         available and clients confused by the incomplete
-         implementation may fail.
        - We do not support SSV, which provides security for shared
          client-server state (thus preventing unauthorized tampering
          with locks and opens, for example).  It is mandatory for
          servers to support this, though no clients use it yet.
-       - Mandatory operations which we do not support, such as
-         DESTROY_CLIENTID, are not currently used by clients, but will be
-         (and the spec recommends their uses in common cases), and
-         clients should not be expected to know how to recover from the
-         case where they are not supported.  This will eventually cause
-         interoperability failures.
 
 In addition, some limitations are inherited from the current NFSv4
 implementation:
@@ -89,7 +78,7 @@ Operations
    |                      | MNI        | or OPT)      |                |
    +----------------------+------------+--------------+----------------+
    | ACCESS               | REQ        |              | Section 18.1   |
-NS | BACKCHANNEL_CTL      | REQ        |              | Section 18.33  |
+ | BACKCHANNEL_CTL      | REQ        |              | Section 18.33  |
 I  | BIND_CONN_TO_SESSION | REQ        |              | Section 18.34  |
    | CLOSE                | REQ        |              | Section 18.2   |
    | COMMIT               | REQ        |              | Section 18.3   |
@@ -99,7 +88,7 @@ NS*| DELEGPURGE           | OPT        | FDELG (REQ)  | Section 18.5   |
    | DELEGRETURN          | OPT        | FDELG,       | Section 18.6   |
    |                      |            | DDELG, pNFS  |                |
    |                      |            | (REQ)        |                |
-NS | DESTROY_CLIENTID     | REQ        |              | Section 18.50  |
+ | DESTROY_CLIENTID     | REQ        |              | Section 18.50  |
 I  | DESTROY_SESSION      | REQ        |              | Section 18.37  |
 I  | EXCHANGE_ID          | REQ        |              | Section 18.35  |
 I  | FREE_STATEID         | REQ        |              | Section 18.38  |
@@ -192,7 +181,6 @@ EXCHANGE_ID:
 
 CREATE_SESSION:
 * backchannel attributes are ignored
-* backchannel security parameters are ignored
 
 SEQUENCE:
 * no support for dynamic slot table renegotiation (optional)
@@ -202,7 +190,7 @@ Nonstandard compound limitations:
   ca_maxrequestsize request and a ca_maxresponsesize reply, so we may
   fail to live up to the promise we made in CREATE_SESSION fore channel
   negotiation.
-* No more than one IO operation (read, write, readdir) allowed per
-  compound.
+* No more than one read-like operation allowed per compound; encoding
+  replies that cross page boundaries (except for read data) not handled.
 
 See also http://wiki.linux-nfs.org/wiki/index.php/Server_4.0_and_4.1_issues.
index 0742feebc6e221f9d79e400adab5feaba23098de..0472c31c163b4de67d73a52d8aa1953597df8ca1 100644 (file)
@@ -281,7 +281,7 @@ ext2_write_failed and callers for an example.
 
 [mandatory]
 
-       ->truncate is going away.  The whole truncate sequence needs to be
+       ->truncate is gone.  The whole truncate sequence needs to be
 implemented in ->setattr, which is now mandatory for filesystems
 implementing on-disk size changes.  Start with a copy of the old inode_setattr
 and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
index 2ee133e030c3f51521321afd62d5dd3b1d1650fb..e3869098163e1bdb347236e0dcede6bb2b8d80ca 100644 (file)
@@ -350,7 +350,6 @@ struct inode_operations {
        int (*readlink) (struct dentry *, char __user *,int);
         void * (*follow_link) (struct dentry *, struct nameidata *);
         void (*put_link) (struct dentry *, struct nameidata *, void *);
-       void (*truncate) (struct inode *);
        int (*permission) (struct inode *, int);
        int (*get_acl)(struct inode *, int);
        int (*setattr) (struct dentry *, struct iattr *);
@@ -431,16 +430,6 @@ otherwise noted.
        started might not be in the page cache at the end of the
        walk).
 
-  truncate: Deprecated. This will not be called if ->setsize is defined.
-       Called by the VFS to change the size of a file.  The
-       i_size field of the inode is set to the desired size by the
-       VFS before this method is called.  This method is called by
-       the truncate(2) system call and related functionality.
-
-       Note: ->truncate and vmtruncate are deprecated. Do not add new
-       instances/calls of these. Filesystems should be converted to do their
-       truncate sequence via ->setattr().
-
   permission: called by the VFS to check for access rights on a POSIX-like
        filesystem.
 
index 6f07f4a28b479e01ef73371537794974e2ec4824..4fe05595b2da996958811226d6607ff9cd15aba2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -124,7 +124,7 @@ $(if $(KBUILD_OUTPUT),, \
 PHONY += $(MAKECMDGOALS) sub-make
 
 $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
-       $(Q)@:
+       @:
 
 sub-make: FORCE
        $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
@@ -1027,11 +1027,14 @@ clean: rm-dirs  := $(CLEAN_DIRS)
 clean: rm-files := $(CLEAN_FILES)
 clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation samples)
 
-PHONY += $(clean-dirs) clean archclean
+PHONY += $(clean-dirs) clean archclean vmlinuxclean
 $(clean-dirs):
        $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
 
-clean: archclean
+vmlinuxclean:
+       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
+
+clean: archclean vmlinuxclean
 
 # mrproper - Delete all generated files, including .config
 #
@@ -1258,7 +1261,6 @@ scripts: ;
 endif # KBUILD_EXTMOD
 
 clean: $(clean-dirs)
-       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
        $(call cmd,rmdirs)
        $(call cmd,rmfiles)
        @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
index 8e9e3246b2b4e0f1a0b2218f5e49a8cacecb24d2..7f8f281f2585e25ee74853bfb88183514ce3d5ca 100644 (file)
@@ -291,12 +291,6 @@ config ARCH_WANT_OLD_COMPAT_IPC
        select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
        bool
 
-config GENERIC_KERNEL_THREAD
-       bool
-
-config GENERIC_KERNEL_EXECVE
-       bool
-
 config HAVE_ARCH_SECCOMP_FILTER
        bool
        help
@@ -362,6 +356,9 @@ config MODULES_USE_ELF_REL
          Modules only use ELF REL relocations.  Modules with ELF RELA
          relocations will give an error.
 
+config GENERIC_SIGALTSTACK
+       bool
+
 #
 # ABI hall of shame
 #
index 5dd7f5db24d45e6d98961ae53cc4478224068d8b..9d5904cc7712fbdd64ce3d682617d5f31be6b268 100644 (file)
@@ -20,10 +20,9 @@ config ALPHA
        select GENERIC_CMOS_UPDATE
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_RELA
+       select GENERIC_SIGALTSTACK
        help
          The Alpha is a 64-bit general-purpose processor designed and
          marketed by the Digital Equipment Corporation of blessed memory,
index df9a6cd748d500e4cf4d394b0c0b24fc4a4c955c..21128505ddbe31e006718355d90e791a2f9c532e 100644 (file)
@@ -8,6 +8,7 @@
 #define user_mode(regs) (((regs)->ps & 8) != 0)
 #define instruction_pointer(regs) ((regs)->pc)
 #define profile_pc(regs) instruction_pointer(regs)
+#define current_user_stack_pointer() rdusp()
 
 #define task_pt_regs(task) \
   ((struct pt_regs *) (task_stack_page(task) + 2*PAGE_SIZE) - 1)
index d6069ff3b1c8f270151be7abe34525ba5e60a4f4..b3396ee039b77df8ba4459dad3f00ac3a47be438 100644 (file)
@@ -15,7 +15,6 @@
 #define __ARCH_WANT_SYS_OLDUMOUNT
 #define __ARCH_WANT_SYS_SIGPENDING
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index 965bbfa59c658f7d0d6c6e7a4c116e05174d4bc5..dd4ca4bcbb4a0488cfd6c42334cb8dae97e2b16d 100644 (file)
@@ -84,12 +84,6 @@ typedef unsigned long sigset_t;
 #define SA_ONESHOT     SA_RESETHAND
 #define SA_NOMASK      SA_NODEFER
 
-/* 
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    4096
 #define SIGSTKSZ       16384
 
index 336393c9c11f507bb14897de9c3ab7c74fd8a0c3..02d02c047f17e13d8c7714e0cd4d328ea2a2ce11 100644 (file)
@@ -122,12 +122,6 @@ SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
        return sigsuspend(&blocked);
 }
 
-asmlinkage int
-sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
-{
-       return do_sigaltstack(uss, uoss, rdusp());
-}
-
 /*
  * Do a signal return; undo the signal stack.
  */
@@ -418,9 +412,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
        err |= __put_user(0, &frame->uc.uc_flags);
        err |= __put_user(0, &frame->uc.uc_link);
        err |= __put_user(set->sig[0], &frame->uc.uc_osf_sigmask);
-       err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
-       err |= __put_user(sas_ss_flags(oldsp), &frame->uc.uc_stack.ss_flags);
-       err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
+       err |= __save_altstack(&frame->uc.uc_stack, oldsp);
        err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, 
                                set->sig[0], oldsp);
        err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
index 8c83d98424c7a68703261d8bbc496130c784c21c..f95ba14ae3d067c7ddfbd139e4207c0ee24bd82c 100644 (file)
@@ -12,8 +12,6 @@ config ARM
        select GENERIC_CLOCKEVENTS_BROADCAST if SMP
        select GENERIC_IRQ_PROBE
        select GENERIC_IRQ_SHOW
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select GENERIC_PCI_IOMAP
        select GENERIC_SMP_IDLE_THREAD
        select GENERIC_STRNCPY_FROM_USER
index 49ca86e37b8d3c0cbe2b0e84a5ab3abeacee6926..fe4d9c3ad761c8dfaadce6e214d709417947f396 100644 (file)
@@ -44,7 +44,7 @@
 
 #else
 
-#include <mach/debug-macro.S>
+#include CONFIG_DEBUG_LL_INCLUDE
 
                .macro  writeb, ch, rb
                senduart \ch, \rb
diff --git a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
new file mode 100644 (file)
index 0000000..5cab825
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2012 Stefan Roese
+ * Stefan Roese <sr@denx.de>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ "sun4i-a10.dtsi"
+
+/ {
+       model = "Cubietech Cubieboard";
+       compatible = "cubietech,a10-cubieboard", "allwinner,sun4i-a10";
+
+       aliases {
+               serial0 = &uart0;
+               serial1 = &uart1;
+       };
+
+       chosen {
+               bootargs = "earlyprintk console=ttyS0,115200";
+       };
+
+       soc {
+               uart0: uart@01c28000 {
+                       status = "okay";
+               };
+
+               uart1: uart@01c28400 {
+                       status = "okay";
+               };
+       };
+};
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
new file mode 100644 (file)
index 0000000..e61fdd4
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2012 Stefan Roese
+ * Stefan Roese <sr@denx.de>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/include/ "sunxi.dtsi"
+
+/ {
+       memory {
+               reg = <0x40000000 0x80000000>;
+       };
+};
diff --git a/arch/arm/boot/dts/sun4i-cubieboard.dts b/arch/arm/boot/dts/sun4i-cubieboard.dts
deleted file mode 100644 (file)
index 5cab825..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2012 Stefan Roese
- * Stefan Roese <sr@denx.de>
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-/dts-v1/;
-/include/ "sun4i-a10.dtsi"
-
-/ {
-       model = "Cubietech Cubieboard";
-       compatible = "cubietech,a10-cubieboard", "allwinner,sun4i-a10";
-
-       aliases {
-               serial0 = &uart0;
-               serial1 = &uart1;
-       };
-
-       chosen {
-               bootargs = "earlyprintk console=ttyS0,115200";
-       };
-
-       soc {
-               uart0: uart@01c28000 {
-                       status = "okay";
-               };
-
-               uart1: uart@01c28400 {
-                       status = "okay";
-               };
-       };
-};
diff --git a/arch/arm/boot/dts/sun4i.dtsi b/arch/arm/boot/dts/sun4i.dtsi
deleted file mode 100644 (file)
index e61fdd4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2012 Stefan Roese
- * Stefan Roese <sr@denx.de>
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-/include/ "sunxi.dtsi"
-
-/ {
-       memory {
-               reg = <0x40000000 0x80000000>;
-       };
-};
diff --git a/arch/arm/boot/dts/sun5i-a13-olinuxino.dts b/arch/arm/boot/dts/sun5i-a13-olinuxino.dts
new file mode 100644 (file)
index 0000000..498a091
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 Maxime Ripard
+ *
+ * Maxime Ripard <maxime.ripard@free-electrons.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ "sun5i-a13.dtsi"
+
+/ {
+       model = "Olimex A13-Olinuxino";
+       compatible = "olimex,a13-olinuxino", "allwinner,sun5i-a13";
+
+       chosen {
+               bootargs = "earlyprintk console=ttyS0,115200";
+       };
+
+       soc {
+               uart1: uart@01c28400 {
+                       status = "okay";
+               };
+       };
+};
diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi
new file mode 100644 (file)
index 0000000..59a2d26
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012 Maxime Ripard
+ *
+ * Maxime Ripard <maxime.ripard@free-electrons.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/include/ "sunxi.dtsi"
+
+/ {
+       memory {
+               reg = <0x40000000 0x20000000>;
+       };
+};
diff --git a/arch/arm/boot/dts/sun5i-olinuxino.dts b/arch/arm/boot/dts/sun5i-olinuxino.dts
deleted file mode 100644 (file)
index 498a091..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2012 Maxime Ripard
- *
- * Maxime Ripard <maxime.ripard@free-electrons.com>
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-/dts-v1/;
-/include/ "sun5i-a13.dtsi"
-
-/ {
-       model = "Olimex A13-Olinuxino";
-       compatible = "olimex,a13-olinuxino", "allwinner,sun5i-a13";
-
-       chosen {
-               bootargs = "earlyprintk console=ttyS0,115200";
-       };
-
-       soc {
-               uart1: uart@01c28400 {
-                       status = "okay";
-               };
-       };
-};
diff --git a/arch/arm/boot/dts/sun5i.dtsi b/arch/arm/boot/dts/sun5i.dtsi
deleted file mode 100644 (file)
index 59a2d26..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2012 Maxime Ripard
- *
- * Maxime Ripard <maxime.ripard@free-electrons.com>
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-/include/ "sunxi.dtsi"
-
-/ {
-       memory {
-               reg = <0x40000000 0x20000000>;
-       };
-};
index 7cd13cc62624b223873d654b4c8acf40ddd9f4f2..21a2700d295715faabf5083d7dfde05f7628cfa8 100644 (file)
@@ -41,7 +41,6 @@
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_SYS_SOCKETCALL
 #endif
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index 921c57fdc52e13802076b632f3b571266703f06b..33073bdcf091beaf32611cb93dffeb363233b45e 100644 (file)
@@ -87,13 +87,6 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK      SA_NODEFER
 #define SA_ONESHOT     SA_RESETHAND
 
-
-/* 
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index 9a89bf4aefe1e35ff8000a57f0d7b07b9219997c..3f6cbb2e3edae392f2b73520b89b6ee3b19e8437 100644 (file)
@@ -733,7 +733,7 @@ void __init setup_arch(char **cmdline_p)
        setup_processor();
        mdesc = setup_machine_fdt(__atags_pointer);
        if (!mdesc)
-               mdesc = setup_machine_tags(__atags_pointer, machine_arch_type);
+               mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type);
        machine_desc = mdesc;
        machine_name = mdesc->name;
 
index df745188f5de4abdf3bd04faaa5d31b653b0f210..ab1017bd1667d9772e01a903099aa665b3f86b7d 100644 (file)
@@ -109,10 +109,12 @@ static void set_segfault(struct pt_regs *regs, unsigned long addr)
 {
        siginfo_t info;
 
+       down_read(&current->mm->mmap_sem);
        if (find_vma(current->mm, addr) == NULL)
                info.si_code = SEGV_MAPERR;
        else
                info.si_code = SEGV_ACCERR;
+       up_read(&current->mm->mmap_sem);
 
        info.si_signo = SIGSEGV;
        info.si_errno = 0;
index b9f38e388b43ed968cda7b16d2efe081faefc0c0..11c1785bf63e40366f96135d22f291d60e2a20af 100644 (file)
@@ -140,6 +140,8 @@ SECTIONS
        }
 #endif
 
+       NOTES
+
        _etext = .;                     /* End of text and rodata section */
 
 #ifndef CONFIG_XIP_KERNEL
@@ -295,8 +297,6 @@ SECTIONS
        }
 #endif
 
-       NOTES
-
        BSS_SECTION(0, 0, 0)
        _end = .;
 
index efead60b943699d160fa8754e9435cfba4a658fc..bbcb3dea0d40e61de4c003a6c3ac46cc8b5157dc 100644 (file)
@@ -529,7 +529,7 @@ static struct clk exynos4_init_clocks_off[] = {
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 8),
        }, {
-               .name           = "dwmmc",
+               .name           = "biu",
                .parent         = &exynos4_clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 9),
@@ -1134,7 +1134,7 @@ static struct clksrc_clk exynos4_clksrcs[] = {
                .reg_div = { .reg = EXYNOS4_CLKDIV_MFC, .shift = 0, .size = 4 },
        }, {
                .clk    = {
-                       .name           = "sclk_dwmmc",
+                       .name           = "ciu",
                        .parent         = &exynos4_clk_dout_mmc4.clk,
                        .enable         = exynos4_clksrc_mask_fsys_ctrl,
                        .ctrlbit        = (1 << 16),
index ddd4b72c6f9a9530e432399708b7e38af889e1c6..d6d0dc651089a4a253d473783c156d453eda55be 100644 (file)
@@ -679,7 +679,8 @@ void __init exynos5_init_irq(void)
         * Theses parameters should be NULL and 0 because EXYNOS4
         * uses GIC instead of VIC.
         */
-       s5p_init_irq(NULL, 0);
+       if (!of_machine_is_compatible("samsung,exynos5440"))
+               s5p_init_irq(NULL, 0);
 
        gic_arch_extn.irq_set_wake = s3c_irq_wake;
 }
index a1cb42c3959015bfd764b4b94e2374be8916f643..9d1a60951d7bb0d9ce8dbb55d6be2179fac65e35 100644 (file)
 #include <mach/irqs.h>
 #include <mach/regs-audss.h>
 
-static const char *rclksrc[] = {
-       [0] = "busclk",
-       [1] = "i2sclk",
-};
-
 static int exynos4_cfg_i2s(struct platform_device *pdev)
 {
        /* configure GPIO for i2s port */
@@ -55,7 +50,6 @@ static struct s3c_audio_pdata i2sv5_pdata = {
                .i2s = {
                        .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
                                         | QUIRK_NEED_RSTCLR,
-                       .src_clk = rclksrc,
                        .idma_addr = EXYNOS4_AUDSS_INT_MEM,
                },
        },
@@ -78,17 +72,11 @@ struct platform_device exynos4_device_i2s0 = {
        },
 };
 
-static const char *rclksrc_v3[] = {
-       [0] = "sclk_i2s",
-       [1] = "no_such_clock",
-};
-
 static struct s3c_audio_pdata i2sv3_pdata = {
        .cfg_gpio = exynos4_cfg_i2s,
        .type = {
                .i2s = {
                        .quirks = QUIRK_NO_MUXPSR,
-                       .src_clk = rclksrc_v3,
                },
        },
 };
index f038c8cadca484e1831cd3277394bd8565ab88c1..e99d3d8f2bcf436ab52a07f5c8d1d7ad519d8467 100644 (file)
@@ -163,6 +163,7 @@ static char const *exynos5_dt_compat[] __initdata = {
 
 static void __init exynos5_reserve(void)
 {
+#ifdef CONFIG_S5P_DEV_MFC
        struct s5p_mfc_dt_meminfo mfc_mem;
 
        /* Reserve memory for MFC only if it's available */
@@ -170,6 +171,7 @@ static void __init exynos5_reserve(void)
        if (of_scan_flat_dt(s5p_fdt_find_mfc_mem, &mfc_mem))
                s5p_mfc_reserve_mem(mfc_mem.roff, mfc_mem.rsize, mfc_mem.loff,
                                mfc_mem.lsize);
+#endif
 }
 
 DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
index e6f4191cd14c1af36c5df0ac14bb9d136f2f22e9..5e34b9c16196c4d7009d90e5bb55a596c918ee20 100644 (file)
@@ -621,7 +621,7 @@ static struct pwm_lookup origen_pwm_lookup[] = {
        PWM_LOOKUP("s3c24xx-pwm.0", 0, "pwm-backlight.0", NULL),
 };
 
-#ifdef CONFIG_DRM_EXYNOS
+#ifdef CONFIG_DRM_EXYNOS_FIMD
 static struct exynos_drm_fimd_pdata drm_fimd_pdata = {
        .panel  = {
                .timing = {
@@ -793,7 +793,7 @@ static void __init origen_machine_init(void)
        s5p_i2c_hdmiphy_set_platdata(NULL);
        s5p_hdmi_set_platdata(&hdmiphy_info, NULL, 0);
 
-#ifdef CONFIG_DRM_EXYNOS
+#ifdef CONFIG_DRM_EXYNOS_FIMD
        s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata;
        exynos4_fimd0_gpio_setup_24bpp();
 #else
index a1555a73c7afd08f46cec725159b8b3ce1d2afd8..ae6da40c2aa9e168e9bb338b91556985089e5e4f 100644 (file)
@@ -246,7 +246,7 @@ static struct samsung_keypad_platdata smdk4x12_keypad_data __initdata = {
        .cols           = 8,
 };
 
-#ifdef CONFIG_DRM_EXYNOS
+#ifdef CONFIG_DRM_EXYNOS_FIMD
 static struct exynos_drm_fimd_pdata drm_fimd_pdata = {
        .panel  = {
                .timing = {
@@ -360,7 +360,7 @@ static void __init smdk4x12_machine_init(void)
 
        s3c_hsotg_set_platdata(&smdk4x12_hsotg_pdata);
 
-#ifdef CONFIG_DRM_EXYNOS
+#ifdef CONFIG_DRM_EXYNOS_FIMD
        s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata;
        exynos4_fimd0_gpio_setup_24bpp();
 #else
index b7384241fb03ac836e08a74bab3cac4aae8c8881..35548e3c097d8e34916d027457ec6baa2d02b903 100644 (file)
@@ -159,7 +159,7 @@ static struct platform_device smdkv310_lcd_lte480wv = {
        .dev.platform_data      = &smdkv310_lcd_lte480wv_data,
 };
 
-#ifdef CONFIG_DRM_EXYNOS
+#ifdef CONFIG_DRM_EXYNOS_FIMD
 static struct exynos_drm_fimd_pdata drm_fimd_pdata = {
        .panel  = {
                .timing = {
@@ -402,7 +402,7 @@ static void __init smdkv310_machine_init(void)
        samsung_bl_set(&smdkv310_bl_gpio_info, &smdkv310_bl_data);
        pwm_add_table(smdkv310_pwm_lookup, ARRAY_SIZE(smdkv310_pwm_lookup));
 
-#ifdef CONFIG_DRM_EXYNOS
+#ifdef CONFIG_DRM_EXYNOS_FIMD
        s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata;
        exynos4_fimd0_gpio_setup_24bpp();
 #else
index 4ca8ff14a5bfe99dc587bce680fb4afbb4d634a5..c5c840e947b88030156c95c99933891a43416974 100644 (file)
@@ -198,7 +198,7 @@ static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
 {
        int i;
 
-       if (!soc_is_exynos5250())
+       if (!(soc_is_exynos5250() || soc_is_exynos5440()))
                scu_enable(scu_base_addr());
 
        /*
index 7642fc4672c1f57b2b67a1839b341e9f15260170..6da4f7ae9d7f2d80545a53443b9ae51f1e64f214 100644 (file)
@@ -16,8 +16,8 @@
 #include <linux/slab.h>
 
 #include <linux/platform_data/iommu-omap.h>
-#include <plat/omap_hwmod.h>
-#include <plat/omap_device.h>
+#include "omap_hwmod.h"
+#include "omap_device.h"
 
 static int __init omap_iommu_dev_init(struct omap_hwmod *oh, void *unused)
 {
index 06e141543623d46801f3cf7206d3e9879253f648..691aa674665a46cf4c8ce75c279443b82c5aff05 100644 (file)
@@ -175,7 +175,7 @@ static struct device_node * __init omap_get_timer_dt(struct of_device_id *match,
                        continue;
                }
 
-               prom_add_property(np, &device_disabled);
+               of_add_property(np, &device_disabled);
                return np;
        }
 
index 124bce6b4d7ba55df09bc262a3caf2acaf58b0fe..a301e61a55544c2ef6b889e59459bda68812ce90 100644 (file)
@@ -47,7 +47,7 @@
 #define REALVIEW_EB_USB_BASE           0x4F000000      /* USB */
 
 #ifdef CONFIG_REALVIEW_EB_ARM11MP_REVB
-#define REALVIEW_EB11MP_PRIV_MEM_BASE  0x1F000000
+#define REALVIEW_EB11MP_PRIV_MEM_BASE  0x10100000
 #define REALVIEW_EB11MP_L220_BASE      0x10102000      /* L220 registers */
 #define REALVIEW_EB11MP_SYS_PLD_CTRL1  0xD8            /* Register offset for MPCore sysctl */
 #else
index 1a6f8577744926fc593ec6a2a8aea1b8c509850e..803711e283b233d609e7172b7d4678da724a682f 100644 (file)
@@ -149,25 +149,6 @@ static struct clk init_clocks_off[] = {
                .enable         = s3c64xx_pclk_ctrl,
                .ctrlbit        = S3C6410_CLKCON_PCLK_I2C1,
        }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.0",
-               .parent         = &clk_p,
-               .enable         = s3c64xx_pclk_ctrl,
-               .ctrlbit        = S3C_CLKCON_PCLK_IIS0,
-       }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.1",
-               .parent         = &clk_p,
-               .enable         = s3c64xx_pclk_ctrl,
-               .ctrlbit        = S3C_CLKCON_PCLK_IIS1,
-       }, {
-#ifdef CONFIG_CPU_S3C6410
-               .name           = "iis",
-               .parent         = &clk_p,
-               .enable         = s3c64xx_pclk_ctrl,
-               .ctrlbit        = S3C6410_CLKCON_PCLK_IIS2,
-       }, {
-#endif
                .name           = "keypad",
                .parent         = &clk_p,
                .enable         = s3c64xx_pclk_ctrl,
@@ -337,6 +318,32 @@ static struct clk clk_48m_spi1 = {
        .ctrlbit        = S3C_CLKCON_SCLK_SPI1_48,
 };
 
+static struct clk clk_i2s0 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.0",
+       .parent         = &clk_p,
+       .enable         = s3c64xx_pclk_ctrl,
+       .ctrlbit        = S3C_CLKCON_PCLK_IIS0,
+};
+
+static struct clk clk_i2s1 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.1",
+       .parent         = &clk_p,
+       .enable         = s3c64xx_pclk_ctrl,
+       .ctrlbit        = S3C_CLKCON_PCLK_IIS1,
+};
+
+#ifdef CONFIG_CPU_S3C6410
+static struct clk clk_i2s2 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.2",
+       .parent         = &clk_p,
+       .enable         = s3c64xx_pclk_ctrl,
+       .ctrlbit        = S3C6410_CLKCON_PCLK_IIS2,
+};
+#endif
+
 static struct clk init_clocks[] = {
        {
                .name           = "lcd",
@@ -660,6 +667,7 @@ static struct clksrc_sources clkset_audio1 = {
        .nr_sources     = ARRAY_SIZE(clkset_audio1_list),
 };
 
+#ifdef CONFIG_CPU_S3C6410
 static struct clk *clkset_audio2_list[] = {
        [0] = &clk_mout_epll.clk,
        [1] = &clk_dout_mpll,
@@ -672,6 +680,7 @@ static struct clksrc_sources clkset_audio2 = {
        .sources        = clkset_audio2_list,
        .nr_sources     = ARRAY_SIZE(clkset_audio2_list),
 };
+#endif
 
 static struct clksrc_clk clksrcs[] = {
        {
@@ -683,36 +692,6 @@ static struct clksrc_clk clksrcs[] = {
                .reg_src        = { .reg = S3C_CLK_SRC, .shift = 5, .size = 2  },
                .reg_div        = { .reg = S3C_CLK_DIV1, .shift = 20, .size = 4  },
                .sources        = &clkset_uhost,
-       }, {
-               .clk    = {
-                       .name           = "audio-bus",
-                       .devname        = "samsung-i2s.0",
-                       .ctrlbit        = S3C_CLKCON_SCLK_AUDIO0,
-                       .enable         = s3c64xx_sclk_ctrl,
-               },
-               .reg_src        = { .reg = S3C_CLK_SRC, .shift = 7, .size = 3  },
-               .reg_div        = { .reg = S3C_CLK_DIV2, .shift = 8, .size = 4  },
-               .sources        = &clkset_audio0,
-       }, {
-               .clk    = {
-                       .name           = "audio-bus",
-                       .devname        = "samsung-i2s.1",
-                       .ctrlbit        = S3C_CLKCON_SCLK_AUDIO1,
-                       .enable         = s3c64xx_sclk_ctrl,
-               },
-               .reg_src        = { .reg = S3C_CLK_SRC, .shift = 10, .size = 3  },
-               .reg_div        = { .reg = S3C_CLK_DIV2, .shift = 12, .size = 4  },
-               .sources        = &clkset_audio1,
-       }, {
-               .clk    = {
-                       .name           = "audio-bus",
-                       .devname        = "samsung-i2s.2",
-                       .ctrlbit        = S3C6410_CLKCON_SCLK_AUDIO2,
-                       .enable         = s3c64xx_sclk_ctrl,
-               },
-               .reg_src        = { .reg = S3C6410_CLK_SRC2, .shift = 0, .size = 3  },
-               .reg_div        = { .reg = S3C_CLK_DIV2, .shift = 24, .size = 4  },
-               .sources        = &clkset_audio2,
        }, {
                .clk    = {
                        .name           = "irda-bus",
@@ -805,6 +784,43 @@ static struct clksrc_clk clk_sclk_spi1 = {
        .sources = &clkset_spi_mmc,
 };
 
+static struct clksrc_clk clk_audio_bus0 = {
+       .clk    = {
+               .name           = "audio-bus",
+               .devname        = "samsung-i2s.0",
+               .ctrlbit        = S3C_CLKCON_SCLK_AUDIO0,
+               .enable         = s3c64xx_sclk_ctrl,
+       },
+       .reg_src        = { .reg = S3C_CLK_SRC, .shift = 7, .size = 3  },
+       .reg_div        = { .reg = S3C_CLK_DIV2, .shift = 8, .size = 4  },
+       .sources        = &clkset_audio0,
+};
+
+static struct clksrc_clk clk_audio_bus1 = {
+       .clk    = {
+               .name           = "audio-bus",
+               .devname        = "samsung-i2s.1",
+               .ctrlbit        = S3C_CLKCON_SCLK_AUDIO1,
+               .enable         = s3c64xx_sclk_ctrl,
+       },
+       .reg_src        = { .reg = S3C_CLK_SRC, .shift = 10, .size = 3  },
+       .reg_div        = { .reg = S3C_CLK_DIV2, .shift = 12, .size = 4  },
+       .sources        = &clkset_audio1,
+};
+
+#ifdef CONFIG_CPU_S3C6410
+static struct clksrc_clk clk_audio_bus2 = {
+       .clk    = {
+               .name           = "audio-bus",
+               .devname        = "samsung-i2s.2",
+               .ctrlbit        = S3C6410_CLKCON_SCLK_AUDIO2,
+               .enable         = s3c64xx_sclk_ctrl,
+       },
+       .reg_src        = { .reg = S3C6410_CLK_SRC2, .shift = 0, .size = 3  },
+       .reg_div        = { .reg = S3C_CLK_DIV2, .shift = 24, .size = 4  },
+       .sources        = &clkset_audio2,
+};
+#endif
 /* Clock initialisation code */
 
 static struct clksrc_clk *init_parents[] = {
@@ -820,6 +836,8 @@ static struct clksrc_clk *clksrc_cdev[] = {
        &clk_sclk_mmc2,
        &clk_sclk_spi0,
        &clk_sclk_spi1,
+       &clk_audio_bus0,
+       &clk_audio_bus1,
 };
 
 static struct clk *clk_cdev[] = {
@@ -828,6 +846,8 @@ static struct clk *clk_cdev[] = {
        &clk_hsmmc2,
        &clk_48m_spi0,
        &clk_48m_spi1,
+       &clk_i2s0,
+       &clk_i2s1,
 };
 
 static struct clk_lookup s3c64xx_clk_lookup[] = {
@@ -844,6 +864,14 @@ static struct clk_lookup s3c64xx_clk_lookup[] = {
        CLKDEV_INIT("s3c6410-spi.0", "spi_busclk2", &clk_48m_spi0),
        CLKDEV_INIT("s3c6410-spi.1", "spi_busclk1", &clk_sclk_spi1.clk),
        CLKDEV_INIT("s3c6410-spi.1", "spi_busclk2", &clk_48m_spi1),
+       CLKDEV_INIT("samsung-i2s.0", "i2s_opclk0", &clk_i2s0),
+       CLKDEV_INIT("samsung-i2s.0", "i2s_opclk1", &clk_audio_bus0.clk),
+       CLKDEV_INIT("samsung-i2s.1", "i2s_opclk0", &clk_i2s1),
+       CLKDEV_INIT("samsung-i2s.1", "i2s_opclk1", &clk_audio_bus1.clk),
+#ifdef CONFIG_CPU_S3C6410
+       CLKDEV_INIT("samsung-i2s.2", "i2s_opclk0", &clk_i2s2),
+       CLKDEV_INIT("samsung-i2s.2", "i2s_opclk1", &clk_audio_bus2.clk),
+#endif
 };
 
 #define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1)
index 35f3e07eaccc494729b82582c82062cd4bea0a6a..e367e87bbc2966d039eba15bcf90224d0010e105 100644 (file)
 #include <linux/platform_data/asoc-s3c.h>
 #include <plat/gpio-cfg.h>
 
-static const char *rclksrc[] = {
-       [0] = "iis",
-       [1] = "audio-bus",
-};
-
 static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
 {
        unsigned int base;
@@ -64,11 +59,6 @@ static struct resource s3c64xx_iis0_resource[] = {
 
 static struct s3c_audio_pdata i2sv3_pdata = {
        .cfg_gpio = s3c64xx_i2s_cfg_gpio,
-       .type = {
-               .i2s = {
-                       .src_clk = rclksrc,
-               },
-       },
 };
 
 struct platform_device s3c64xx_device_iis0 = {
@@ -110,7 +100,6 @@ static struct s3c_audio_pdata i2sv4_pdata = {
        .type = {
                .i2s = {
                        .quirks = QUIRK_PRI_6CHAN,
-                       .src_clk = rclksrc,
                },
        },
 };
index 000445596ec4ff5a3577e0d034e40c3574a882ae..5112371079d0a3f27f30c044758424d7486ee3be 100644 (file)
@@ -242,12 +242,6 @@ static struct clk init_clocks_off[] = {
                .parent         = &clk_pclk_low.clk,
                .enable         = s5p64x0_pclk_ctrl,
                .ctrlbit        = (1 << 25),
-       }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.0",
-               .parent         = &clk_pclk_low.clk,
-               .enable         = s5p64x0_pclk_ctrl,
-               .ctrlbit        = (1 << 26),
        }, {
                .name           = "dsim",
                .parent         = &clk_pclk_low.clk,
@@ -405,15 +399,6 @@ static struct clksrc_clk clksrcs[] = {
                .sources = &clkset_group1,
                .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 8, .size = 2 },
                .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 4, .size = 4 },
-       }, {
-               .clk    = {
-                       .name           = "sclk_audio2",
-                       .ctrlbit        = (1 << 11),
-                       .enable         = s5p64x0_sclk_ctrl,
-               },
-               .sources = &clkset_audio,
-               .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 0, .size = 3 },
-               .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 24, .size = 4 },
        },
 };
 
@@ -464,6 +449,26 @@ static struct clksrc_clk clk_sclk_uclk = {
        .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 16, .size = 4 },
 };
 
+static struct clk clk_i2s0 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.0",
+       .parent         = &clk_pclk_low.clk,
+       .enable         = s5p64x0_pclk_ctrl,
+       .ctrlbit        = (1 << 26),
+};
+
+static struct clksrc_clk clk_audio_bus2 = {
+       .clk    = {
+               .name           = "sclk_audio2",
+               .devname        = "samsung-i2s.0",
+               .ctrlbit        = (1 << 11),
+               .enable         = s5p64x0_sclk_ctrl,
+       },
+       .sources = &clkset_audio,
+       .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 0, .size = 3 },
+       .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 24, .size = 4 },
+};
+
 static struct clksrc_clk clk_sclk_spi0 = {
        .clk    = {
                .name           = "sclk_spi",
@@ -506,13 +511,18 @@ static struct clk dummy_apb_pclk = {
        .id             = -1,
 };
 
+static struct clk *clk_cdev[] = {
+       &clk_i2s0,
+};
+
 static struct clksrc_clk *clksrc_cdev[] = {
        &clk_sclk_uclk,
        &clk_sclk_spi0,
        &clk_sclk_spi1,
        &clk_sclk_mmc0,
        &clk_sclk_mmc1,
-       &clk_sclk_mmc2
+       &clk_sclk_mmc2,
+       &clk_audio_bus2,
 };
 
 static struct clk_lookup s5p6440_clk_lookup[] = {
@@ -524,6 +534,8 @@ static struct clk_lookup s5p6440_clk_lookup[] = {
        CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk),
        CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
        CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
+       CLKDEV_INIT("samsung-i2s.0", "i2s_opclk0", &clk_i2s0),
+       CLKDEV_INIT("samsung-i2s.0", "i2s_opclk1", &clk_audio_bus2.clk),
 };
 
 void __init_or_cpufreq s5p6440_setup_clocks(void)
@@ -596,12 +608,17 @@ static struct clk *clks[] __initdata = {
 void __init s5p6440_register_clocks(void)
 {
        int ptr;
+       unsigned int cnt;
 
        s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
 
        for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
                s3c_register_clksrc(sysclks[ptr], 1);
 
+       s3c24xx_register_clocks(clk_cdev, ARRAY_SIZE(clk_cdev));
+       for (cnt = 0; cnt < ARRAY_SIZE(clk_cdev); cnt++)
+               s3c_disable_clocks(clk_cdev[cnt], 1);
+
        s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
        s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
        for (ptr = 0; ptr < ARRAY_SIZE(clksrc_cdev); ptr++)
index f3e0ef3d27c9f3d3ba60cc5d053066b0e3af1092..154dea702d70a935901a078e8d67c487b6ca4b27 100644 (file)
@@ -246,24 +246,6 @@ static struct clk init_clocks_off[] = {
                .parent         = &clk_pclk_low.clk,
                .enable         = s5p64x0_pclk_ctrl,
                .ctrlbit        = (1 << 22),
-       }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.0",
-               .parent         = &clk_pclk_low.clk,
-               .enable         = s5p64x0_pclk_ctrl,
-               .ctrlbit        = (1 << 26),
-       }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.1",
-               .parent         = &clk_pclk_low.clk,
-               .enable         = s5p64x0_pclk_ctrl,
-               .ctrlbit        = (1 << 15),
-       }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.2",
-               .parent         = &clk_pclk_low.clk,
-               .enable         = s5p64x0_pclk_ctrl,
-               .ctrlbit        = (1 << 16),
        }, {
                .name           = "i2c",
                .devname        = "s3c2440-i2c.1",
@@ -402,6 +384,7 @@ static struct clksrc_sources clkset_sclk_audio0 = {
 static struct clksrc_clk clk_sclk_audio0 = {
        .clk            = {
                .name           = "audio-bus",
+               .devname        = "samsung-i2s.0",
                .enable         = s5p64x0_sclk_ctrl,
                .ctrlbit        = (1 << 8),
                .parent         = &clk_dout_epll.clk,
@@ -549,6 +532,36 @@ static struct clksrc_clk clk_sclk_spi1 = {
        .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 4, .size = 4 },
 };
 
+static struct clk clk_i2s0 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.0",
+       .parent         = &clk_pclk_low.clk,
+       .enable         = s5p64x0_pclk_ctrl,
+       .ctrlbit        = (1 << 26),
+};
+
+static struct clk clk_i2s1 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.1",
+       .parent         = &clk_pclk_low.clk,
+       .enable         = s5p64x0_pclk_ctrl,
+       .ctrlbit        = (1 << 15),
+};
+
+static struct clk clk_i2s2 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.2",
+       .parent         = &clk_pclk_low.clk,
+       .enable         = s5p64x0_pclk_ctrl,
+       .ctrlbit        = (1 << 16),
+};
+
+static struct clk *clk_cdev[] = {
+       &clk_i2s0,
+       &clk_i2s1,
+       &clk_i2s2,
+};
+
 static struct clksrc_clk *clksrc_cdev[] = {
        &clk_sclk_uclk,
        &clk_sclk_spi0,
@@ -556,6 +569,7 @@ static struct clksrc_clk *clksrc_cdev[] = {
        &clk_sclk_mmc0,
        &clk_sclk_mmc1,
        &clk_sclk_mmc2,
+       &clk_sclk_audio0,
 };
 
 static struct clk_lookup s5p6450_clk_lookup[] = {
@@ -567,6 +581,10 @@ static struct clk_lookup s5p6450_clk_lookup[] = {
        CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk),
        CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
        CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
+       CLKDEV_INIT("samsung-i2s.0", "i2s_opclk0", &clk_i2s0),
+       CLKDEV_INIT("samsung-i2s.0", "i2s_opclk1", &clk_sclk_audio0.clk),
+       CLKDEV_INIT("samsung-i2s.1", "i2s_opclk0", &clk_i2s1),
+       CLKDEV_INIT("samsung-i2s.2", "i2s_opclk0", &clk_i2s2),
 };
 
 /* Clock initialization code */
@@ -584,7 +602,6 @@ static struct clksrc_clk *sysclks[] = {
        &clk_pclk,
        &clk_hclk_low,
        &clk_pclk_low,
-       &clk_sclk_audio0,
 };
 
 static struct clk dummy_apb_pclk = {
@@ -661,10 +678,16 @@ void __init_or_cpufreq s5p6450_setup_clocks(void)
 void __init s5p6450_register_clocks(void)
 {
        int ptr;
+       unsigned int cnt;
 
        for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
                s3c_register_clksrc(sysclks[ptr], 1);
 
+
+       s3c24xx_register_clocks(clk_cdev, ARRAY_SIZE(clk_cdev));
+       for (cnt = 0; cnt < ARRAY_SIZE(clk_cdev); cnt++)
+               s3c_disable_clocks(clk_cdev[cnt], 1);
+
        s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
        s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
        for (ptr = 0; ptr < ARRAY_SIZE(clksrc_cdev); ptr++)
index a0d6edfd23a07f39ed5a28cfdadeba918fafeebb..723d4773c3238050467b4f2defbb15d283ee731d 100644 (file)
 #include <mach/dma.h>
 #include <mach/irqs.h>
 
-static const char *rclksrc[] = {
-       [0] = "iis",
-       [1] = "sclk_audio2",
-};
-
 static int s5p6440_cfg_i2s(struct platform_device *pdev)
 {
        switch (pdev->id) {
@@ -45,7 +40,6 @@ static struct s3c_audio_pdata s5p6440_i2s_pdata = {
        .type = {
                .i2s = {
                        .quirks = QUIRK_PRI_6CHAN,
-                       .src_clk = rclksrc,
                },
        },
 };
@@ -93,7 +87,6 @@ static struct s3c_audio_pdata s5p6450_i2s0_pdata = {
        .type = {
                .i2s = {
                        .quirks = QUIRK_PRI_6CHAN,
-                       .src_clk = rclksrc,
                },
        },
 };
@@ -110,11 +103,6 @@ struct platform_device s5p6450_device_iis0 = {
 
 static struct s3c_audio_pdata s5p6450_i2s_pdata = {
        .cfg_gpio = s5p6450_cfg_i2s,
-       .type = {
-               .i2s = {
-                       .src_clk = rclksrc,
-               },
-       },
 };
 
 static struct resource s5p6450_i2s1_resource[] = {
index 926219791f0dcd1bbaba3b49f5b690f89ab70975..a206dc35eff1d8e7c0da7928048182ab7d0119a2 100644 (file)
@@ -605,24 +605,6 @@ static struct clk init_clocks_off[] = {
                .parent         = &clk_div_d1_bus.clk,
                .enable         = s5pc100_d1_4_ctrl,
                .ctrlbit        = (1 << 13),
-       }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.0",
-               .parent         = &clk_div_pclkd1.clk,
-               .enable         = s5pc100_d1_5_ctrl,
-               .ctrlbit        = (1 << 0),
-       }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.1",
-               .parent         = &clk_div_pclkd1.clk,
-               .enable         = s5pc100_d1_5_ctrl,
-               .ctrlbit        = (1 << 1),
-       }, {
-               .name           = "iis",
-               .devname        = "samsung-i2s.2",
-               .parent         = &clk_div_pclkd1.clk,
-               .enable         = s5pc100_d1_5_ctrl,
-               .ctrlbit        = (1 << 2),
        }, {
                .name           = "ac97",
                .parent         = &clk_div_pclkd1.clk,
@@ -724,6 +706,30 @@ static struct clk clk_48m_spi2 = {
        .ctrlbit        = (1 << 9),
 };
 
+static struct clk clk_i2s0 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.0",
+       .parent         = &clk_div_pclkd1.clk,
+       .enable         = s5pc100_d1_5_ctrl,
+       .ctrlbit        = (1 << 0),
+};
+
+static struct clk clk_i2s1 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.1",
+       .parent         = &clk_div_pclkd1.clk,
+       .enable         = s5pc100_d1_5_ctrl,
+       .ctrlbit        = (1 << 1),
+};
+
+static struct clk clk_i2s2 = {
+       .name           = "iis",
+       .devname        = "samsung-i2s.2",
+       .parent         = &clk_div_pclkd1.clk,
+       .enable         = s5pc100_d1_5_ctrl,
+       .ctrlbit        = (1 << 2),
+};
+
 static struct clk clk_vclk54m = {
        .name           = "vclk_54m",
        .rate           = 54000000,
@@ -1154,6 +1160,9 @@ static struct clk *clk_cdev[] = {
        &clk_48m_spi0,
        &clk_48m_spi1,
        &clk_48m_spi2,
+       &clk_i2s0,
+       &clk_i2s1,
+       &clk_i2s2,
 };
 
 static struct clksrc_clk *clksrc_cdev[] = {
@@ -1321,6 +1330,9 @@ static struct clk_lookup s5pc100_clk_lookup[] = {
        CLKDEV_INIT("s5pc100-spi.1", "spi_busclk2", &clk_sclk_spi1.clk),
        CLKDEV_INIT("s5pc100-spi.2", "spi_busclk1", &clk_48m_spi2),
        CLKDEV_INIT("s5pc100-spi.2", "spi_busclk2", &clk_sclk_spi2.clk),
+       CLKDEV_INIT("samsung-i2s.0", "i2s_opclk0", &clk_i2s0),
+       CLKDEV_INIT("samsung-i2s.1", "i2s_opclk0", &clk_i2s1),
+       CLKDEV_INIT("samsung-i2s.2", "i2s_opclk0", &clk_i2s2),
 };
 
 void __init s5pc100_register_clocks(void)
index 1cc252cef26843a133251ce0ff703fa5ed599ecd..46f488b093916699a5571862206293350cf19f1d 100644 (file)
@@ -39,18 +39,12 @@ static int s5pc100_cfg_i2s(struct platform_device *pdev)
        return 0;
 }
 
-static const char *rclksrc_v5[] = {
-       [0] = "iis",
-       [1] = "i2sclkd2",
-};
-
 static struct s3c_audio_pdata i2sv5_pdata = {
        .cfg_gpio = s5pc100_cfg_i2s,
        .type = {
                .i2s = {
                        .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
                                         | QUIRK_NEED_RSTCLR,
-                       .src_clk = rclksrc_v5,
                },
        },
 };
@@ -72,18 +66,8 @@ struct platform_device s5pc100_device_iis0 = {
        },
 };
 
-static const char *rclksrc_v3[] = {
-       [0] = "iis",
-       [1] = "sclk_audio",
-};
-
 static struct s3c_audio_pdata i2sv3_pdata = {
        .cfg_gpio = s5pc100_cfg_i2s,
-       .type = {
-               .i2s = {
-                       .src_clk = rclksrc_v3,
-               },
-       },
 };
 
 static struct resource s5pc100_iis1_resource[] = {
index 0a5480bbcbd596962c94bea2397698b01ada482e..addfb165c13d050da4bc48a6c08a57c342b36c78 100644 (file)
 #include <mach/irqs.h>
 #include <mach/regs-audss.h>
 
-static const char *rclksrc[] = {
-       [0] = "busclk",
-       [1] = "i2sclk",
-};
-
 static int s5pv210_cfg_i2s(struct platform_device *pdev)
 {
        /* configure GPIO for i2s port */
@@ -52,7 +47,6 @@ static struct s3c_audio_pdata i2sv5_pdata = {
                .i2s = {
                        .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
                                         | QUIRK_NEED_RSTCLR,
-                       .src_clk = rclksrc,
                        .idma_addr = S5PV210_AUDSS_INT_MEM,
                },
        },
@@ -75,18 +69,8 @@ struct platform_device s5pv210_device_iis0 = {
        },
 };
 
-static const char *rclksrc_v3[] = {
-       [0] = "iis",
-       [1] = "audio-bus",
-};
-
 static struct s3c_audio_pdata i2sv3_pdata = {
        .cfg_gpio = s5pv210_cfg_i2s,
-       .type = {
-               .i2s = {
-                       .src_clk = rclksrc_v3,
-               },
-       },
 };
 
 static struct resource s5pv210_iis1_resource[] = {
index cd956647c21a800d69ed3215a774b086fed008a1..7539ec27506585f3dd42b04f785c5edba39d1614 100644 (file)
@@ -44,8 +44,10 @@ ENDPROC(v7_flush_icache_all)
 ENTRY(v7_flush_dcache_louis)
        dmb                                     @ ensure ordering with previous memory accesses
        mrc     p15, 1, r0, c0, c0, 1           @ read clidr, r0 = clidr
-       ands    r3, r0, #0xe00000               @ extract LoUIS from clidr
-       mov     r3, r3, lsr #20                 @ r3 = LoUIS * 2
+       ALT_SMP(ands    r3, r0, #(7 << 21))     @ extract LoUIS from clidr
+       ALT_UP(ands     r3, r0, #(7 << 27))     @ extract LoUU from clidr
+       ALT_SMP(mov     r3, r3, lsr #20)        @ r3 = LoUIS * 2
+       ALT_UP(mov      r3, r3, lsr #26)        @ r3 = LoUU * 2
        moveq   pc, lr                          @ return if level == 0
        mov     r10, #0                         @ r10 (starting level) = 0
        b       flush_levels                    @ start flushing cache levels
index dfd8b7af8c7ac93db4bf6d3d28371a072793c1d9..f7a3ea2c498aa852b2b72d2d8baf79f32f2ac417 100644 (file)
@@ -11,6 +11,9 @@
  * published by the Free Software Foundation.
 */
 
+#ifndef __PLAT_SAMSUNG_GPIO_CORE_H
+#define __PLAT_SAMSUNG_GPIO_CORE_H
+
 #define GPIOCON_OFF    (0x00)
 #define GPIODAT_OFF    (0x04)
 
@@ -124,3 +127,5 @@ extern struct samsung_gpio_pm samsung_gpio_pm_4bit;
 /* locking wrappers to deal with multiple access to the same gpio bank */
 #define samsung_gpio_lock(_oc, _fl) spin_lock_irqsave(&(_oc)->lock, _fl)
 #define samsung_gpio_unlock(_oc, _fl) spin_unlock_irqrestore(&(_oc)->lock, _fl)
+
+#endif /* __PLAT_SAMSUNG_GPIO_CORE_H */
index f9ccff915918fad21f622284e6f456747ac5143f..9c829b0082614ec202e3269288e2e642d8303f0b 100644 (file)
@@ -8,8 +8,6 @@ config ARM64
        select GENERIC_IOMAP
        select GENERIC_IRQ_PROBE
        select GENERIC_IRQ_SHOW
-       select GENERIC_KERNEL_EXECVE
-       select GENERIC_KERNEL_THREAD
        select GENERIC_SMP_IDLE_THREAD
        select GENERIC_TIME_VSYSCALL
        select HARDIRQS_SW_RESEND
index 37e610dc084ed76b532f0647f07d6c2085b69798..d9ec40217a27639280fb958ee49c9f92cb188c90 100644 (file)
@@ -209,10 +209,11 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
        return (u32)(unsigned long)uptr;
 }
 
+#define compat_user_stack_pointer() (current_pt_regs()->compat_sp)
+
 static inline void __user *arch_compat_alloc_user_space(long len)
 {
-       struct pt_regs *regs = task_pt_regs(current);
-       return (void __user *)regs->compat_sp - len;
+       return (void __user *)compat_user_stack_pointer() - len;
 }
 
 struct compat_ipc64_perm {
index 76fb7dd3350aef410b3946095ae98665e5e6a92c..744087fb521cca4cd0fcb2111fe37194f38b5921 100644 (file)
@@ -28,6 +28,5 @@
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #endif
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
 #include <uapi/asm/unistd.h>
index e40c9bd7914341a4381b06b8d13f2a0162f1cfbc..2ae6591b3a55353789bedf11cc5c11faa58ad34b 100644 (file)
@@ -17,8 +17,6 @@ config AVR32
        select GENERIC_CLOCKEVENTS
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        help
          AVR32 is a high-performance 32-bit RISC microprocessor core,
          designed for cost-sensitive embedded applications, with particular
index 8d3c412fc65ff7b86037b6230d953f3feee63b19..630e4f9bf5f084be7a2942126d3e71666482f383 100644 (file)
@@ -21,6 +21,7 @@
 #define user_mode(regs)                 (((regs)->sr & MODE_MASK) == MODE_USER)
 #define instruction_pointer(regs)       ((regs)->pc)
 #define profile_pc(regs)                instruction_pointer(regs)
+#define user_stack_pointer(regs)       ((regs)->sp)
 
 static __inline__ int valid_user_regs(struct pt_regs *regs)
 {
index f05a9804e8e22f929d2d9f0e61808f9f436b8eba..0bdf6371574e76eeaebfd821cbff2dbdb94dd16d 100644 (file)
@@ -39,7 +39,6 @@
 #define __ARCH_WANT_SYS_GETPGRP
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index eb46f61adb7d12727d4b54ad47c571ca79f780ac..1b77a93eff500c14ac9594c9f6098007353c8a78 100644 (file)
@@ -89,12 +89,6 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK      SA_NODEFER
 #define SA_ONESHOT     SA_RESETHAND
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index ab9ff4075f4d3b075692882234bb118a9d9b0349..b6f3ad5441c5f33f27c44850ca8d19c9898001b7 100644 (file)
@@ -45,8 +45,6 @@ config BLACKFIN
        select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTS
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
 
 config GENERIC_CSUM
        def_bool y
index 14ea93388c058d99fe576a0c1084284f64912678..c00491594b46d8b4adf2e75621090187bf778b5b 100644 (file)
@@ -17,6 +17,7 @@
 #define arch_has_single_step() (1)
 /* common code demands this function */
 #define ptrace_disable(child) user_disable_single_step(child)
+#define current_user_stack_pointer() rdusp()
 
 extern int is_user_addr_valid(struct task_struct *child,
                              unsigned long start, unsigned long len);
index 17eb748e9c54ff2d4cbff09e44204f85a3a7b8ef..e943cb1300482b69d3da8577fc9cc47cf6985e3a 100644 (file)
@@ -20,7 +20,6 @@
 #define __ARCH_WANT_SYS_NICE
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_VFORK
 
 /*
index 66eab3703c7571e77d608609c4e401ffce0ffd77..f6a3648f5ec3c7030a8c4294be4e3bee54a25b6c 100644 (file)
@@ -17,8 +17,6 @@ config C6X
        select OF
        select OF_EARLY_FLATTREE
        select GENERIC_CLOCKEVENTS
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select MODULES_USE_ELF_RELA
 
 config MMU
index f3987a8703d92ba18be7cbe949b155985ee59aa3..e7d09a614d1028b4e0673f73f05d3fa0388e23f5 100644 (file)
@@ -14,7 +14,6 @@
  *   more details.
  */
 
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
 
 /* Use the standard ABI for syscalls. */
index 0cac6a49f230d9e20e78bdacf7fa2ebe736a4f59..c59a01dd9c0c627ee4afc7060b90deb0606811c1 100644 (file)
@@ -49,8 +49,6 @@ config CRIS
        select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32
        select GENERIC_CMOS_UPDATE
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select CLONE_BACKWARDS2
 
 config HZ
index 2de84d7061c7015aa8adea1374671e5dcae54c33..9e788d04a4ef1b9c5d956f578fe4ee53b3bb9c2a 100644 (file)
@@ -9,5 +9,6 @@
 #define PTRACE_SETREGS            13
 
 #define profile_pc(regs) instruction_pointer(regs)
+#define current_user_stack_pointer() rdusp()
 
 #endif /* _CRIS_PTRACE_H */
index 89680f9eac0d4e758b14d0026b4b75b4d4c43933..6d062bdf92d4a560b9ec746c434621a10694e28b 100644 (file)
@@ -32,7 +32,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index 21624948a96d72d16502408cabc3b64241eb18c1..ce42fa7c32ad614ba6671a81dd1d2882588509d1 100644 (file)
@@ -83,12 +83,6 @@ typedef unsigned long sigset_t;
 
 #define SA_RESTORER    0x04000000
 
-/* 
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index df2eb4bd9fa2abbaa06c6978537fcabc88c22cf7..9d262645f6675275c9e2c7adca9a66b114d03b88 100644 (file)
@@ -12,8 +12,6 @@ config FRV
        select ARCH_HAVE_NMI_SAFE_CMPXCHG
        select GENERIC_CPU_DEVICES
        select ARCH_WANT_IPC_PARSE_VERSION
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
 
 config ZONE_DMA
        bool
index 1807d8ea8cb5563873dca78bdf1e42300df4aa23..d685da17f5fb9954f1517e35cf6c931024e156ef 100644 (file)
@@ -29,7 +29,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index 0ae44508760736bad5b8b2ed0937aea3f64c0763..2d2efb653ee0a9ecefe1b89b69e1aae08ad73ff2 100644 (file)
@@ -9,8 +9,6 @@ config H8300
        select GENERIC_IRQ_SHOW
        select GENERIC_CPU_DEVICES
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
 
 config SYMBOL_PREFIX
        string
index 79c9a91e75ef6d213338ebc8a4efb2569eda3682..c1826b95c5ca1cb1d810216a4b4a12c9a869811f 100644 (file)
@@ -28,5 +28,6 @@
 #define current_pt_regs() ((struct pt_regs *) \
        (THREAD_SIZE + (unsigned long)current_thread_info()) - 1)
 #define signal_pt_regs() ((struct pt_regs *)current->thread.esp0)
+#define current_user_stack_pointer() rdusp()
 #endif /* __ASSEMBLY__ */
 #endif /* _H8300_PTRACE_H */
index 8215518b3f9fb1e8753132cff0d252732a16f40e..aa38105959fb202ee1be37addaa215c9e3594bcc 100644 (file)
@@ -31,7 +31,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index 913729e581e8341e0d3ae8fd48c7a6119a0c523d..af3a6c37fee68f7ce22e43ba076d75ce46ffd2f7 100644 (file)
@@ -82,12 +82,6 @@ typedef unsigned long sigset_t;
 
 #define SA_RESTORER    0x04000000
 
-/* 
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index e418803b6c8eb71dcf838829b4beebbea835819a..0744f7d7b1fd096b5ccbc71cab7305ea997fb3c3 100644 (file)
@@ -31,8 +31,6 @@ config HEXAGON
        select GENERIC_CLOCKEVENTS
        select GENERIC_CLOCKEVENTS_BROADCAST
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        ---help---
          Qualcomm Hexagon is a processor architecture designed for high
          performance and low power across a wide variety of applications.
index 2af81533bd0ffb305e9c473f2dbf39054244f9cc..4a87cc47075c37d4f3f43997876a1383206e8cba 100644 (file)
@@ -27,7 +27,6 @@
  */
 
 #define sys_mmap2 sys_mmap_pgoff
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
 
 #include <asm-generic/unistd.h>
index 6706004681280ab211e11a8836f71535d4c1bd9f..3279646120e3be5bdbc970ca5297b5fce30011ee 100644 (file)
@@ -42,8 +42,6 @@ config IA64
        select GENERIC_TIME_VSYSCALL_OLD
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        default y
        help
          The Itanium Processor Family is Intel's 64-bit successor to
index b0e973649cb9f4cfdda26b5178291da9bcd0b2e0..845143990a1d66f2c5bb77b8b69225cfe7eb195f 100644 (file)
@@ -78,6 +78,11 @@ static inline long regs_return_value(struct pt_regs *regs)
        unsigned long __ip = instruction_pointer(regs);                 \
        (__ip & ~3UL) + ((__ip & 3UL) << 2);                            \
 })
+/*
+ * Why not default?  Because user_stack_pointer() on ia64 gives register
+ * stack backing store instead...
+ */
+#define current_user_stack_pointer() (current_pt_regs()->r12)
 
   /* given a pointer to a task_struct, return the user's pt_regs */
 # define task_pt_regs(t)               (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1)
index 1574bca86138c317ab70fa75d5e19fa3911ae6d9..8b3ff2f5b86167eda40544dbda0099c568eaaf0e 100644 (file)
@@ -29,7 +29,6 @@
 
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 
 #if !defined(__ASSEMBLY__) && !defined(ASSEMBLER)
 
index e531c424434cf3784b7f2104982976ba01d3877c..c0ea2855e96baccec34bd781211217300a6aa363 100644 (file)
 
 #define SA_RESTORER    0x04000000
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 /*
  * The minimum stack size needs to be fairly large because we want to
  * be sure that an app compiled for today's CPUs will continue to run
index 5183f43a2cf7c3efd720a82d38312bc7b49422c7..f807721e19a52ee1f5b619cd0a742328e4515f46 100644 (file)
@@ -15,8 +15,6 @@ config M32R
        select GENERIC_ATOMIC64
        select ARCH_USES_GETTIMEOFFSET
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
 
 config SBUS
        bool
index ba487c554dbb599427c45a8837b9fdb85f91897d..fa58ccfff865eb5e07527d0dd55a72d8927b542b 100644 (file)
@@ -32,6 +32,7 @@ extern void init_debug_traps(struct task_struct *);
 
 #define instruction_pointer(regs) ((regs)->bpc)
 #define profile_pc(regs) instruction_pointer(regs)
+#define user_stack_pointer(regs) ((regs)->spu)
 
 extern void withdraw_debug_trap(struct pt_regs *regs);
 
index 1eade32082b8cd849c48cd87aef7b18db162402b..79b063caec85953d2f622b3b3f6357df8c3db41d 100644 (file)
@@ -22,7 +22,6 @@
 #define __ARCH_WANT_SYS_OLDUMOUNT
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
index ef9788fda2ef4723adda64e28a159ee83c16d324..54acacb1f1f7f69df43bf17006c251f09a6c1abd 100644 (file)
@@ -84,12 +84,6 @@ typedef unsigned long sigset_t;
 
 #define SA_RESTORER    0x04000000
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index 953a7ba5d05025a776e5114b20acfbc56231bd3c..6710084e072abeb484cc00f93805352aa9d4099d 100644 (file)
@@ -15,8 +15,6 @@ config M68K
        select FPU if MMU
        select ARCH_WANT_IPC_PARSE_VERSION
        select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_REL
        select MODULES_USE_ELF_RELA
index 0f717045bddef4094584fe9c5be624e9ee2d4927..a45cb6894ad36c86c663ff77798c4b419db07c1f 100644 (file)
@@ -15,6 +15,7 @@
 #define profile_pc(regs) instruction_pointer(regs)
 #define current_pt_regs() \
        (struct pt_regs *)((char *)current_thread_info() + THREAD_SIZE) - 1
+#define current_user_stack_pointer() rdusp()
 
 #define arch_has_single_step() (1)
 
index a021d67cdd72202b63d86abcc74216338c1a1e06..847994ce680456d0144cf0361085728316917b54 100644 (file)
@@ -31,7 +31,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 
index 2b450f311bd93c88ca613881c1c382231b76c114..cba6f858bb46b90bc9a3d0f03ef8f60bdd4e59be 100644 (file)
@@ -80,12 +80,6 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK      SA_NODEFER
 #define SA_ONESHOT     SA_RESETHAND
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index 4bcf89148f3cec3767373776f309d47f687b8bb3..ba3b7c8c04b8150241f115696d00bd08747ac8f7 100644 (file)
@@ -26,8 +26,6 @@ config MICROBLAZE
        select GENERIC_ATOMIC64
        select GENERIC_CLOCKEVENTS
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select CLONE_BACKWARDS
 
 config SWAP
index 3732bcf186fd5b6a3438464b9a570a914501fdc0..5b18ec124e513b6476e2dcc8d808b25bbe1abe7a 100644 (file)
@@ -16,6 +16,7 @@
 
 #define instruction_pointer(regs)      ((regs)->pc)
 #define profile_pc(regs)               instruction_pointer(regs)
+#define user_stack_pointer(regs)       ((regs)->r1)
 
 static inline long regs_return_value(struct pt_regs *regs)
 {
index 99e23937a31aa05c0efec1b44588584490130808..a5f06ac97113d0aa4b8338f06ac3d6c5d5f5b411 100644 (file)
@@ -35,7 +35,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
 #define __ARCH_WANT_SYS_VFORK
 #ifdef CONFIG_MMU
index d971d1586f1cfa80828e16796c45ab2a4cca3844..b7dc39c6c849189bcc57929cef61f0abd9c4befe 100644 (file)
@@ -41,8 +41,6 @@ config MIPS
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_REL
        select MODULES_USE_ELF_RELA if 64BIT
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
 
 menu "Machine selection"
 
index cec5e125f7e466fceb8680f029de9ad040b9c4a3..a3186f2bb8a09aab56fcf5324c2bf7209b2c92c4 100644 (file)
@@ -49,6 +49,7 @@ static inline long regs_return_value(struct pt_regs *regs)
 
 #define instruction_pointer(regs) ((regs)->cp0_epc)
 #define profile_pc(regs) instruction_pointer(regs)
+#define user_stack_pointer(r) ((r)->regs[29])
 
 extern asmlinkage void syscall_trace_enter(struct pt_regs *regs);
 extern asmlinkage void syscall_trace_leave(struct pt_regs *regs);
index b306e2081cad9a4c03a66d9c82595e96581140da..9e47cc11aa263ba3991d680736bce6aeea41447e 100644 (file)
@@ -20,7 +20,6 @@
 #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_SYS_ALARM
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_GETHOSTNAME
 #define __ARCH_WANT_SYS_IPC
 #define __ARCH_WANT_SYS_PAUSE
index 3f1237c6c80e440c86c1cfd25784b6a79fd3f9c2..770732cb8d0387e6ce692b0eae45d205681608d1 100644 (file)
@@ -86,12 +86,6 @@ typedef unsigned long old_sigset_t;          /* at least 32 bits */
 
 #define SA_RESTORER    0x04000000      /* Only for o32 */
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index 72471744a9124f36ca33b9f4bbd583fd96f88c2a..aa03f2e13385fe5083a50b17ae6f8c02e3ccb269 100644 (file)
@@ -8,8 +8,6 @@ config MN10300
        select HAVE_ARCH_KGDB
        select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER
        select GENERIC_CLOCKEVENTS
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select MODULES_USE_ELF_RELA
 
 config AM33_2
index cabf8ba73b27ca050410c7c203daf9138ceac846..e6d2ed4ba68f5ac01557e4a4375da4dc016bdb04 100644 (file)
@@ -43,7 +43,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index 08dcd6a856180a52f74fd5b13f897ec112336e35..f423a08d7eeb02d8e92c120731cd7d4cf5b14574 100644 (file)
@@ -92,12 +92,6 @@ typedef unsigned long sigset_t;
 
 #define SA_RESTORER    0x04000000
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index ec37e185d20d82333c7e4f46cce5d721b99d98c2..0ac66f67521f243024a40c850ec3c4da9995a724 100644 (file)
@@ -22,8 +22,6 @@ config OPENRISC
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
 
 config MMU
        def_bool y
index 5082b8066325e7152c0a66b31696deb6f49368c9..ce40b71df0069d8516a94141556cb37ab32819ee 100644 (file)
@@ -20,7 +20,6 @@
 
 #define sys_mmap2 sys_mmap_pgoff
 
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_CLONE
 
index e688a2be30f6a78659da7a2067c82a6c1808eb52..b77feffbadea9b91f46d85be47d35a0f49d4b2f4 100644 (file)
@@ -22,8 +22,6 @@ config PARISC
        select GENERIC_STRNCPY_FROM_USER
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select CLONE_BACKWARDS
 
        help
index 1efef41659c9a570ee15e5b2bea1313f2b2b2991..3043194547cdc8d256ca5008846f836d95e6a864 100644 (file)
@@ -163,7 +163,6 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)       \
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
 #define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index b1ddaa243376e8106fd7fdfa199a1b2ecfe6f32d..a2fa297196bc19f1de4f021ebec6e5338b237313 100644 (file)
 
 #define SA_RESTORER    0x04000000 /* obsolete -- ignored */
 
-/* 
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index 951a517a1a0fbedd3d9d1ca87bbcfab24986f9a1..17903f1f356be5790d6ddcde1ff3d5eabaf2ed78 100644 (file)
@@ -141,10 +141,8 @@ config PPC
        select GENERIC_CLOCKEVENTS
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
-       select GENERIC_KERNEL_THREAD
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_EXECVE
        select CLONE_BACKWARDS
 
 config EARLY_PRINTK
index 29365e15ed7c1d3425a906459344fedd06ddb766..1d4864a40e3560fa4a61f2b7f5d22eb5607dcdc1 100644 (file)
@@ -56,7 +56,6 @@
 #define __ARCH_WANT_COMPAT_SYS_SENDFILE
 #define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
 #endif
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index 48fa8d3f2f9a56b5855b61feab313d4889cbed4f..e079fb39d5bcfc3952301b0f78b700b3d1988bbf 100644 (file)
@@ -85,12 +85,6 @@ typedef struct {
 
 #define SA_RESTORER    0x04000000U
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index 5b7d8ffbf8907933b21f9be8e4e4333c81a02e9d..baee994fe810cd494d2ab51750d880c611a318ff 100644 (file)
@@ -66,7 +66,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
        struct dentry *dentry;
        int ret;
 
-       dentry = user_path_create(AT_FDCWD, pathname, &path, 1);
+       dentry = user_path_create(AT_FDCWD, pathname, &path, LOOKUP_DIRECTORY);
        ret = PTR_ERR(dentry);
        if (!IS_ERR(dentry)) {
                ret = spufs_create(&path, dentry, flags, mode, neighbor);
index 32425af9d68d7b6379c7bba2da62cb335c8ad7be..b5ea38c2564753df883026f83fece8ab484df68c 100644 (file)
@@ -137,8 +137,6 @@ config S390
        select GENERIC_CLOCKEVENTS
        select KTIME_SCALAR if 32BIT
        select HAVE_ARCH_SECCOMP_FILTER
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_RELA
        select CLONE_BACKWARDS2
index 18cd6b592650962010b7c72f32b0d401cf572a57..f8c6df6cd1f02c93910de5fba976b1c4161879dd 100644 (file)
@@ -7,6 +7,9 @@
 #include <linux/sched.h>
 #include <linux/thread_info.h>
 
+#define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p(typeof(0?(t)0:0ULL), u64))
+#define __SC_DELOUSE(t,v) (t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v))
+
 #define PSW32_MASK_PER         0x40000000UL
 #define PSW32_MASK_DAT         0x04000000UL
 #define PSW32_MASK_IO          0x02000000UL
index 086bb8eaf6abf3a75e6df3992519f69f1513851c..636530872516a64c8f30e42cf9a0bab4cee511bf 100644 (file)
@@ -53,7 +53,6 @@
 #   define __ARCH_WANT_COMPAT_SYS_TIME
 #   define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
 # endif
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
index 8c6a49e392eeae353fe377d2da00c8992a2f455a..2f43cfbf5f1a0036e5b911d94148a745f6d415a0 100644 (file)
@@ -90,12 +90,6 @@ typedef unsigned long sigset_t;
 
 #define SA_RESTORER     0x04000000
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK      1
-#define SS_DISABLE      2
-
 #define MINSIGSTKSZ     2048
 #define SIGSTKSZ        8192
 
index 45893390c7ddb4f32052764177b3f2d01949b53c..3b1482e7afacd37969f338158468bc95bb2dc8d6 100644 (file)
@@ -13,8 +13,6 @@ config SCORE
        select GENERIC_CLOCKEVENTS
        select HAVE_MOD_ARCH_SPECIFIC
        select MODULES_USE_ELF_REL
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select CLONE_BACKWARDS
 
 choice
index 78fc538db84c70b672ba397f48a5ee659f91c6ff..abc279d96b7306858f82736ed98d1a614aef5783 100644 (file)
@@ -13,6 +13,7 @@ struct task_struct;
 
 #define instruction_pointer(regs)      ((unsigned long)(regs)->cp0_epc)
 #define profile_pc(regs)               instruction_pointer(regs)
+#define user_stack_pointer(r)          ((unsigned long)(r)->regs[0])
 
 extern void do_syscall_trace(struct pt_regs *regs, int entryexit);
 extern int read_tsk_long(struct task_struct *, unsigned long, unsigned long *);
index 56001c93095aaa7977d869e41f7866a5b0598f2c..9cb4260a5f3e3ea232fd1a328bac9f7e5ed854b3 100644 (file)
@@ -4,7 +4,6 @@
 #define __ARCH_WANT_SYSCALL_NO_FLAGS
 #define __ARCH_WANT_SYSCALL_OFF_T
 #define __ARCH_WANT_SYSCALL_DEPRECATED
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
index 8451317eed58d3b79bc7ec3df8df6eac0b20fd0d..babc2b826c5caf5f26f9a029452e5067451190c1 100644 (file)
@@ -40,8 +40,6 @@ config SUPERH
        select GENERIC_STRNLEN_USER
        select HAVE_MOD_ARCH_SPECIFIC if DWARF_UNWINDER
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        help
          The SuperH is a RISC processor targeted for use in embedded systems
          and consumer electronics; it was also used in the Sega Dreamcast
index 43d3f26b2eab4cb8c891906a1e5e206cf6abd8cd..012004ed33305b84b32f1609932ec0b0bbc321a1 100644 (file)
@@ -28,7 +28,6 @@
 # define __ARCH_WANT_SYS_SIGPENDING
 # define __ARCH_WANT_SYS_SIGPROCMASK
 # define __ARCH_WANT_SYS_RT_SIGACTION
-# define __ARCH_WANT_SYS_EXECVE
 # define __ARCH_WANT_SYS_FORK
 # define __ARCH_WANT_SYS_VFORK
 # define __ARCH_WANT_SYS_CLONE
index 0c7d365fa402d90dacbc9566ee8eb121b726b75a..9f2edb5c555179de8d00ee5d2031546df35f8a9d 100644 (file)
@@ -41,8 +41,6 @@ config SPARC
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
 
 config SPARC32
        def_bool !64BIT
index 497386a7ed28d754e5efcc2a5c9d530e8cb56142..87ce24c5eb95a479d35f5709b3d85f1bbf4c3076 100644 (file)
@@ -47,7 +47,6 @@
 #define __ARCH_WANT_COMPAT_SYS_SENDFILE
 #define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
 #endif
-#define __ARCH_WANT_SYS_EXECVE
 
 /*
  * "Conditional" syscalls
index 1a041892538f6e4a077021ad133515a9175f92d8..c4ffd6c971069cd19e2bfc2b1058c364bef44713 100644 (file)
@@ -147,12 +147,6 @@ struct sigstack {
 #define SIG_UNBLOCK        0x02        /* for unblocking signals */
 #define SIG_SETMASK        0x04        /* for setting the signal mask */
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    4096
 #define SIGSTKSZ       16384
 
index ea7f61e8bc9e14cf525d6bde75fb909433959372..875d008828b8ec619c295cf1b2d5c8923ea0389b 100644 (file)
@@ -21,8 +21,6 @@ config TILE
        select ARCH_HAVE_NMI_SAFE_CMPXCHG
        select GENERIC_CLOCKEVENTS
        select MODULES_USE_ELF_RELA
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
 
 # FIXME: investigate whether we need/want these options.
 #      select HAVE_IOREMAP_PROT
index 5ce052e16b7b1ca84c6b65af38362e14d4ea3bbf..2e83fc1b9467d2254f62db982157f3177c89934d 100644 (file)
@@ -35,6 +35,7 @@ typedef unsigned long pt_reg_t;
 
 #define instruction_pointer(regs) ((regs)->pc)
 #define profile_pc(regs) instruction_pointer(regs)
+#define user_stack_pointer(regs) ((regs)->sp)
 
 /* Does the process account for user or for system time? */
 #define user_mode(regs) (EX1_PL((regs)->ex1) == USER_PL)
index fe841e7d4963e5e88ccdf08193788d535be4da9e..6ac21034f69a695e7d38a5656c80e1bdde0bdfb6 100644 (file)
@@ -17,6 +17,5 @@
 #define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
 #endif
 #define __ARCH_WANT_SYS_NEWFSTATAT
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
 #include <uapi/asm/unistd.h>
index db18eb6124e17d8c36f2e00af8a592230df92bdc..48ccf718e290144c9dce74459dfc765846c93c55 100644 (file)
@@ -132,8 +132,3 @@ long sys_sigsuspend(int history0, int history1, old_sigset_t mask)
        siginitset(&blocked, mask);
        return sigsuspend(&blocked);
 }
-
-long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
-{
-       return do_sigaltstack(uss, uoss, PT_REGS_SP(&current->thread.regs));
-}
index c4fbb21e802b15349e7bfb09d06484b6163169cc..60651df5f95241bb063798df83e0af2545023e76 100644 (file)
@@ -16,8 +16,6 @@ config UNICORE32
        select ARCH_WANT_FRAME_POINTERS
        select GENERIC_IOMAP
        select MODULES_USE_ELF_REL
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        help
          UniCore-32 is 32-bit Instruction Set Architecture,
          including a series of low-power-consumption RISC chip
index 726749dab52fff679f6b787ff07498053f75e7e0..9df53d991c7872fba46cf23f3033ccbc3098df77 100644 (file)
@@ -54,6 +54,7 @@ static inline int valid_user_regs(struct pt_regs *regs)
 }
 
 #define instruction_pointer(regs)      ((regs)->UCreg_pc)
+#define user_stack_pointer(regs)       ((regs)->UCreg_sp)
 
 #endif /* __ASSEMBLY__ */
 #endif
index 00cf5e286fcadc1fe584c02ff67e335367db64ec..d4cc4559d8485f23838417c6f51208b4925082d3 100644 (file)
@@ -12,5 +12,4 @@
 
 /* Use the standard ABI for syscalls. */
 #include <asm-generic/unistd.h>
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
index 97f8c5ad8c2ddff2449da615e46c2faab3b9d067..79795af598105e9998f0de234b279fb6c61ca42f 100644 (file)
@@ -110,11 +110,10 @@ config X86
        select GENERIC_STRNLEN_USER
        select HAVE_CONTEXT_TRACKING if X86_64
        select HAVE_IRQ_TIME_ACCOUNTING
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select MODULES_USE_ELF_REL if X86_32
        select MODULES_USE_ELF_RELA if X86_64
        select CLONE_BACKWARDS if X86_32
+       select GENERIC_SIGALTSTACK
 
 config INSTRUCTION_DECODER
        def_bool y
index efc6a958b71d186a25ee4eadd759f886cf8670f7..a1daf4a6500926a1305415a6eb4eaba53db6b31f 100644 (file)
@@ -136,52 +136,6 @@ asmlinkage long sys32_sigsuspend(int history0, int history1, old_sigset_t mask)
        return sigsuspend(&blocked);
 }
 
-asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *uss_ptr,
-                                 stack_ia32_t __user *uoss_ptr,
-                                 struct pt_regs *regs)
-{
-       stack_t uss, uoss;
-       int ret, err = 0;
-       mm_segment_t seg;
-
-       if (uss_ptr) {
-               u32 ptr;
-
-               memset(&uss, 0, sizeof(stack_t));
-               if (!access_ok(VERIFY_READ, uss_ptr, sizeof(stack_ia32_t)))
-                       return -EFAULT;
-
-               get_user_try {
-                       get_user_ex(ptr, &uss_ptr->ss_sp);
-                       get_user_ex(uss.ss_flags, &uss_ptr->ss_flags);
-                       get_user_ex(uss.ss_size, &uss_ptr->ss_size);
-               } get_user_catch(err);
-
-               if (err)
-                       return -EFAULT;
-               uss.ss_sp = compat_ptr(ptr);
-       }
-       seg = get_fs();
-       set_fs(KERNEL_DS);
-       ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
-                            (stack_t __force __user *) &uoss, regs->sp);
-       set_fs(seg);
-       if (ret >= 0 && uoss_ptr)  {
-               if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_ia32_t)))
-                       return -EFAULT;
-
-               put_user_try {
-                       put_user_ex(ptr_to_compat(uoss.ss_sp), &uoss_ptr->ss_sp);
-                       put_user_ex(uoss.ss_flags, &uoss_ptr->ss_flags);
-                       put_user_ex(uoss.ss_size, &uoss_ptr->ss_size);
-               } put_user_catch(err);
-
-               if (err)
-                       ret = -EFAULT;
-       }
-       return ret;
-}
-
 /*
  * Do a signal return; undo the signal stack.
  */
@@ -292,7 +246,6 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs)
        struct rt_sigframe_ia32 __user *frame;
        sigset_t set;
        unsigned int ax;
-       struct pt_regs tregs;
 
        frame = (struct rt_sigframe_ia32 __user *)(regs->sp - 4);
 
@@ -306,8 +259,7 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs)
        if (ia32_restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
                goto badframe;
 
-       tregs = *regs;
-       if (sys32_sigaltstack(&frame->uc.uc_stack, NULL, &tregs) == -EFAULT)
+       if (compat_restore_altstack(&frame->uc.uc_stack))
                goto badframe;
 
        return ax;
@@ -515,10 +467,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
                else
                        put_user_ex(0, &frame->uc.uc_flags);
                put_user_ex(0, &frame->uc.uc_link);
-               put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
-               put_user_ex(sas_ss_flags(regs->sp),
-                           &frame->uc.uc_stack.ss_flags);
-               put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
+               err |= __compat_save_altstack(&frame->uc.uc_stack, regs->sp);
 
                if (ka->sa.sa_flags & SA_RESTORER)
                        restorer = ka->sa.sa_restorer;
index 32e6f05ddaaab84f71d2501c07185776055cf855..102ff7cb3e4146ef1e158d718c49c1c0a6773f7b 100644 (file)
@@ -464,7 +464,6 @@ GLOBAL(\label)
 
        PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
        PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
-       PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
        PTREGSCALL stub32_execve, compat_sys_execve, %rcx
        PTREGSCALL stub32_fork, sys_fork, %rdi
        PTREGSCALL stub32_vfork, sys_vfork, %rdi
index e6232773ce4925dc790a2b6b41152393f80b84a1..4c6da2e4bb1d3e843c057ca40158d39035150273 100644 (file)
@@ -29,16 +29,10 @@ struct old_sigaction32 {
        unsigned int sa_restorer;       /* Another 32 bit pointer */
 };
 
-typedef struct sigaltstack_ia32 {
-       unsigned int    ss_sp;
-       int             ss_flags;
-       unsigned int    ss_size;
-} stack_ia32_t;
-
 struct ucontext_ia32 {
        unsigned int      uc_flags;
        unsigned int      uc_link;
-       stack_ia32_t      uc_stack;
+       compat_stack_t    uc_stack;
        struct sigcontext_ia32 uc_mcontext;
        compat_sigset_t   uc_sigmask;   /* mask last for extensibility */
 };
@@ -46,7 +40,7 @@ struct ucontext_ia32 {
 struct ucontext_x32 {
        unsigned int      uc_flags;
        unsigned int      uc_link;
-       stack_ia32_t      uc_stack;
+       compat_stack_t    uc_stack;
        unsigned int      uc__pad0;     /* needed for alignment */
        struct sigcontext uc_mcontext;  /* the 64-bit sigcontext type */
        compat_sigset_t   uc_sigmask;   /* mask last for extensibility */
index 03ca442d8f0d6af3ec3ab0ee73413eff3d392423..942a08623a1a09db57171fa60d03c664b7e8aa46 100644 (file)
@@ -133,6 +133,13 @@ static inline bool user_64bit_mode(struct pt_regs *regs)
        return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
 #endif
 }
+
+#define current_user_stack_pointer()   this_cpu_read(old_rsp)
+/* ia32 vs. x32 difference */
+#define compat_user_stack_pointer()    \
+       (test_thread_flag(TIF_IA32)     \
+        ? current_pt_regs()->sp        \
+        : this_cpu_read(old_rsp))
 #endif
 
 #ifdef CONFIG_X86_32
index c76fae4d90be0802e6bf659d8e998e4010791c75..31f61f96e0fb370030c31ad9318660c6af60ba03 100644 (file)
@@ -69,8 +69,6 @@ asmlinkage long sys32_fallocate(int, int, unsigned,
 
 /* ia32/ia32_signal.c */
 asmlinkage long sys32_sigsuspend(int, int, old_sigset_t);
-asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *,
-                                 stack_ia32_t __user *, struct pt_regs *);
 asmlinkage long sys32_sigreturn(struct pt_regs *);
 asmlinkage long sys32_rt_sigreturn(struct pt_regs *);
 
index 2f8374718aa301b4244a51f4c1bd9ad6bd37fc25..58b7e3eac0ae50cbeb9a0582d8014de0b58cd09c 100644 (file)
@@ -25,9 +25,6 @@ asmlinkage int sys_modify_ldt(int, void __user *, unsigned long);
 
 /* kernel/signal.c */
 long sys_rt_sigreturn(struct pt_regs *);
-long sys_sigaltstack(const stack_t __user *, stack_t __user *,
-                    struct pt_regs *);
-
 
 /* kernel/tls.c */
 asmlinkage int sys_set_thread_area(struct user_desc __user *);
index 1003e69a40d9d217cf7443cea4609c3701fc7196..a0790e07ba6594305dbb14b8db687db49c71a0c9 100644 (file)
@@ -48,7 +48,6 @@
 # define __ARCH_WANT_SYS_TIME
 # define __ARCH_WANT_SYS_UTIME
 # define __ARCH_WANT_SYS_WAITPID
-# define __ARCH_WANT_SYS_EXECVE
 # define __ARCH_WANT_SYS_FORK
 # define __ARCH_WANT_SYS_VFORK
 # define __ARCH_WANT_SYS_CLONE
index 0818f9a8e889f047932ba9f78aca5a95c6c3ed39..aa7d6ae39e0e9b8629938a408ba3e7f18a5a0fca 100644 (file)
@@ -87,12 +87,6 @@ typedef unsigned long sigset_t;
 
 #define SA_RESTORER    0x04000000
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index c763116c5359c650be0a2847ebd110bd52b3b9e2..ff84d5469d772fd8ae8f5e0599e8072333eeb0c1 100644 (file)
@@ -739,7 +739,6 @@ ENTRY(ptregs_##name) ; \
 ENDPROC(ptregs_##name)
 
 PTREGSCALL1(iopl)
-PTREGSCALL2(sigaltstack)
 PTREGSCALL0(sigreturn)
 PTREGSCALL0(rt_sigreturn)
 PTREGSCALL2(vm86)
index 70641aff0c258227185b7584dfa579a9c1b4e4df..07a7a04529bc5d7849ffc21b79819edd7b23ffd9 100644 (file)
@@ -864,7 +864,6 @@ END(stub_\func)
        FORK_LIKE  clone
        FORK_LIKE  fork
        FORK_LIKE  vfork
-       PTREGSCALL stub_sigaltstack, sys_sigaltstack, %rdx
        PTREGSCALL stub_iopl, sys_iopl, %rsi
 
 ENTRY(ptregscall_common)
@@ -913,8 +912,6 @@ ENTRY(stub_rt_sigreturn)
 END(stub_rt_sigreturn)
 
 #ifdef CONFIG_X86_X32_ABI
-       PTREGSCALL stub_x32_sigaltstack, sys32_sigaltstack, %rdx
-
 ENTRY(stub_x32_rt_sigreturn)
        CFI_STARTPROC
        addq $8, %rsp
index fbbb604313a249c139298bccfcd9bfa97ea3e32b..d6bf1f34a6e90b396c11d457dec9600eb6a9af87 100644 (file)
@@ -364,10 +364,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
                else
                        put_user_ex(0, &frame->uc.uc_flags);
                put_user_ex(0, &frame->uc.uc_link);
-               put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
-               put_user_ex(sas_ss_flags(regs->sp),
-                           &frame->uc.uc_stack.ss_flags);
-               put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
+               err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
 
                /* Set up to return from userspace.  */
                restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
@@ -414,7 +411,6 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
        struct rt_sigframe __user *frame;
        void __user *fp = NULL;
        int err = 0;
-       struct task_struct *me = current;
 
        frame = get_sigframe(ka, regs, sizeof(struct rt_sigframe), &fp);
 
@@ -433,10 +429,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
                else
                        put_user_ex(0, &frame->uc.uc_flags);
                put_user_ex(0, &frame->uc.uc_link);
-               put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
-               put_user_ex(sas_ss_flags(regs->sp),
-                           &frame->uc.uc_stack.ss_flags);
-               put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
+               err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
 
                /* Set up to return from userspace.  If provided, use a stub
                   already in userspace.  */
@@ -503,10 +496,7 @@ static int x32_setup_rt_frame(int sig, struct k_sigaction *ka,
                else
                        put_user_ex(0, &frame->uc.uc_flags);
                put_user_ex(0, &frame->uc.uc_link);
-               put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
-               put_user_ex(sas_ss_flags(regs->sp),
-                           &frame->uc.uc_stack.ss_flags);
-               put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
+               err |= __compat_save_altstack(&frame->uc.uc_stack, regs->sp);
                put_user_ex(0, &frame->uc.uc__pad0);
 
                if (ka->sa.sa_flags & SA_RESTORER) {
@@ -603,13 +593,6 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
 }
 #endif /* CONFIG_X86_32 */
 
-long
-sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
-               struct pt_regs *regs)
-{
-       return do_sigaltstack(uss, uoss, regs->sp);
-}
-
 /*
  * Do a signal return; undo the signal stack.
  */
@@ -659,7 +642,7 @@ long sys_rt_sigreturn(struct pt_regs *regs)
        if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
                goto badframe;
 
-       if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
+       if (restore_altstack(&frame->uc.uc_stack))
                goto badframe;
 
        return ax;
@@ -865,7 +848,6 @@ asmlinkage long sys32_x32_rt_sigreturn(struct pt_regs *regs)
        struct rt_sigframe_x32 __user *frame;
        sigset_t set;
        unsigned long ax;
-       struct pt_regs tregs;
 
        frame = (struct rt_sigframe_x32 __user *)(regs->sp - 8);
 
@@ -879,8 +861,7 @@ asmlinkage long sys32_x32_rt_sigreturn(struct pt_regs *regs)
        if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
                goto badframe;
 
-       tregs = *regs;
-       if (sys32_sigaltstack(&frame->uc.uc_stack, NULL, &tregs) == -EFAULT)
+       if (compat_restore_altstack(&frame->uc.uc_stack))
                goto badframe;
 
        return ax;
index 05f404f53f59ceeade47d9fad8694d20599ee88b..28e3fa9056ea6de9dbf73b512e1ea7deb647d1fa 100644 (file)
 183    i386    getcwd                  sys_getcwd
 184    i386    capget                  sys_capget
 185    i386    capset                  sys_capset
-186    i386    sigaltstack             ptregs_sigaltstack              stub32_sigaltstack
+186    i386    sigaltstack             sys_sigaltstack                 compat_sys_sigaltstack
 187    i386    sendfile                sys_sendfile                    sys32_sendfile
 188    i386    getpmsg
 189    i386    putpmsg
index 7c58c84b7bc8dae578f7cee7dc2433ad46e69f03..dc97328bd90ad189f10d3f8c44684e66ac937782 100644 (file)
 128    64      rt_sigtimedwait         sys_rt_sigtimedwait
 129    64      rt_sigqueueinfo         sys_rt_sigqueueinfo
 130    common  rt_sigsuspend           sys_rt_sigsuspend
-131    64      sigaltstack             stub_sigaltstack
+131    64      sigaltstack             sys_sigaltstack
 132    common  utime                   sys_utime
 133    common  mknod                   sys_mknod
 134    64      uselib
 522    x32     rt_sigpending           sys32_rt_sigpending
 523    x32     rt_sigtimedwait         compat_sys_rt_sigtimedwait
 524    x32     rt_sigqueueinfo         sys32_rt_sigqueueinfo
-525    x32     sigaltstack             stub_x32_sigaltstack
+525    x32     sigaltstack             compat_sys_sigaltstack
 526    x32     timer_create            compat_sys_timer_create
 527    x32     mq_notify               compat_sys_mq_notify
 528    x32     kexec_load              compat_sys_kexec_load
index 983997041963840039ec12a076e9b879cfdae0c7..53c90fd412d1a4637fcb17aeaf1a5d5978a2160a 100644 (file)
@@ -13,8 +13,7 @@ endmenu
 config UML_X86
        def_bool y
        select GENERIC_FIND_FIRST_BIT
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
+       select GENERIC_SIGALTSTACK
 
 config 64BIT
        bool "64-bit kernel" if SUBARCH = "x86"
index 755133258c45bd0d1b9a1997e6ac272738c64954..54f8102ccde5d2774f375f6584c31c712f46d915 100644 (file)
@@ -86,4 +86,5 @@ extern long arch_prctl(struct task_struct *task, int code,
                       unsigned long __user *addr);
 
 #endif
+#define user_stack_pointer(regs) PT_REGS_SP(regs)
 #endif /* __UM_X86_PTRACE_H */
index bdaa08cfbcf4bc38eecc3ec57e34c5b0e62ecf2c..71cef48ea5cd5b84abb1216d24ff04b18911eaec 100644 (file)
@@ -342,9 +342,7 @@ static int copy_ucontext_to_user(struct ucontext __user *uc,
 {
        int err = 0;
 
-       err |= put_user(current->sas_ss_sp, &uc->uc_stack.ss_sp);
-       err |= put_user(sas_ss_flags(sp), &uc->uc_stack.ss_flags);
-       err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size);
+       err |= __save_altstack(&uc->uc_stack, sp);
        err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs, 0);
        err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set));
        return err;
@@ -529,10 +527,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
        /* Create the ucontext.  */
        err |= __put_user(0, &frame->uc.uc_flags);
        err |= __put_user(0, &frame->uc.uc_link);
-       err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
-       err |= __put_user(sas_ss_flags(PT_REGS_SP(regs)),
-                         &frame->uc.uc_stack.ss_flags);
-       err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
+       err |= __save_altstack(&frame->uc.uc_stack, PT_REGS_SP(regs));
        err |= copy_sc_to_user(&frame->uc.uc_mcontext, &frame->fpstate, regs,
                               set->sig[0]);
        err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate);
index 812e98c098e40eeb771212dc40f9d6955d2e7de8..a0c3b0d1a1220082a64d8c977b61e607c7db428c 100644 (file)
@@ -27,7 +27,6 @@
 #define ptregs_iopl sys_iopl
 #define ptregs_vm86old sys_vm86old
 #define ptregs_vm86 sys_vm86
-#define ptregs_sigaltstack sys_sigaltstack
 
 #define __SYSCALL_I386(nr, sym, compat) extern asmlinkage void sym(void) ;
 #include <asm/syscalls_32.h>
index 170bd926a69cd4eddbd64d03f0da41d719879bd0..f2f0723070caea848a88fe1f96863943fc3df121 100644 (file)
@@ -31,7 +31,6 @@
 #define stub_fork sys_fork
 #define stub_vfork sys_vfork
 #define stub_execve sys_execve
-#define stub_sigaltstack sys_sigaltstack
 #define stub_rt_sigreturn sys_rt_sigreturn
 
 #define __SYSCALL_COMMON(nr, sym, compat) __SYSCALL_64(nr, sym, compat)
index 73d34e77c39c136b0066236b7b8a2f43d8b9aa0c..5aab1acabf1cb4440c0b5656ecff733bc1df7b07 100644 (file)
@@ -13,8 +13,6 @@ config XTENSA
        select GENERIC_CPU_DEVICES
        select MODULES_USE_ELF_RELA
        select GENERIC_PCI_IOMAP
-       select GENERIC_KERNEL_THREAD
-       select GENERIC_KERNEL_EXECVE
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select CLONE_BACKWARDS
        select IRQ_DOMAIN
index 58bf6fd3f913d4458162c4ddef8a4234a0a7cf6e..682b1deac1f281912c6462b556ff6307ac5c2fd3 100644 (file)
@@ -63,6 +63,8 @@ struct pt_regs {
 #  define profile_pc(regs) instruction_pointer(regs)
 # endif
 
+#define user_stack_pointer(regs) ((regs)->areg[1])
+
 #else  /* __ASSEMBLY__ */
 
 # include <asm/asm-offsets.h>
index e002dbcc88b6e621bf25c8a73ce2e60641912126..eb63ea87815c9e9eba1e1ad3af11c70297e3d7c5 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef _XTENSA_UNISTD_H
 #define _XTENSA_UNISTD_H
 
-#define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
 #include <uapi/asm/unistd.h>
 
index b88ce96f2af9a71f410f86b9d61d276ca1ce2ab8..dacf716dd3e0e66e857ce27cd9fcabaed36c8b89 100644 (file)
@@ -97,12 +97,6 @@ typedef struct {
 
 #define SA_RESTORER    0x04000000
 
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK     1
-#define SS_DISABLE     2
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index 147d1a4dd2694eb05a5366cf0a47317eec729479..17cf7cad601e56840adefbd1b16a8d0cd5c8a5d8 100644 (file)
@@ -148,7 +148,7 @@ static int dev_mkdir(const char *name, umode_t mode)
        struct path path;
        int err;
 
-       dentry = kern_path_create(AT_FDCWD, name, &path, 1);
+       dentry = kern_path_create(AT_FDCWD, name, &path, LOOKUP_DIRECTORY);
        if (IS_ERR(dentry))
                return PTR_ERR(dentry);
 
index bb3d9be3b1b4eecb82ba82f8bc1045e825ff7a75..89576a0b3f2ed5b099ecf7ce675104d282b0dd48 100644 (file)
 
 #define RBD_MINORS_PER_MAJOR   256             /* max minors per blkdev */
 
-#define RBD_MAX_SNAP_NAME_LEN  32
+#define RBD_SNAP_DEV_NAME_PREFIX       "snap_"
+#define RBD_MAX_SNAP_NAME_LEN  \
+                       (NAME_MAX - (sizeof (RBD_SNAP_DEV_NAME_PREFIX) - 1))
+
 #define RBD_MAX_SNAP_COUNT     510     /* allows max snapc to fit in 4KB */
 #define RBD_MAX_OPT_LEN                1024
 
 #define RBD_SNAP_HEAD_NAME     "-"
 
+/* This allows a single page to hold an image name sent by OSD */
+#define RBD_IMAGE_NAME_LEN_MAX (PAGE_SIZE - sizeof (__le32) - 1)
 #define RBD_IMAGE_ID_LEN_MAX   64
+
 #define RBD_OBJ_PREFIX_LEN_MAX 64
 
+/* Feature bits */
+
+#define RBD_FEATURE_LAYERING      1
+
+/* Features supported by this (client software) implementation. */
+
+#define RBD_FEATURES_ALL          (0)
+
 /*
  * An RBD device name will be "rbd#", where the "rbd" comes from
  * RBD_DRV_NAME above, and # is a unique integer identifier.
@@ -101,6 +115,27 @@ struct rbd_image_header {
        u64 obj_version;
 };
 
+/*
+ * An rbd image specification.
+ *
+ * The tuple (pool_id, image_id, snap_id) is sufficient to uniquely
+ * identify an image.
+ */
+struct rbd_spec {
+       u64             pool_id;
+       char            *pool_name;
+
+       char            *image_id;
+       size_t          image_id_len;
+       char            *image_name;
+       size_t          image_name_len;
+
+       u64             snap_id;
+       char            *snap_name;
+
+       struct kref     kref;
+};
+
 struct rbd_options {
        bool    read_only;
 };
@@ -155,11 +190,8 @@ struct rbd_snap {
 };
 
 struct rbd_mapping {
-       char                    *snap_name;
-       u64                     snap_id;
        u64                     size;
        u64                     features;
-       bool                    snap_exists;
        bool                    read_only;
 };
 
@@ -173,7 +205,6 @@ struct rbd_device {
        struct gendisk          *disk;          /* blkdev's gendisk and rq */
 
        u32                     image_format;   /* Either 1 or 2 */
-       struct rbd_options      rbd_opts;
        struct rbd_client       *rbd_client;
 
        char                    name[DEV_NAME_LEN]; /* blkdev name, e.g. rbd3 */
@@ -181,17 +212,17 @@ struct rbd_device {
        spinlock_t              lock;           /* queue lock */
 
        struct rbd_image_header header;
-       char                    *image_id;
-       size_t                  image_id_len;
-       char                    *image_name;
-       size_t                  image_name_len;
+       bool                    exists;
+       struct rbd_spec         *spec;
+
        char                    *header_name;
-       char                    *pool_name;
-       int                     pool_id;
 
        struct ceph_osd_event   *watch_event;
        struct ceph_osd_request *watch_request;
 
+       struct rbd_spec         *parent_spec;
+       u64                     parent_overlap;
+
        /* protects updating the header */
        struct rw_semaphore     header_rwsem;
 
@@ -204,6 +235,7 @@ struct rbd_device {
 
        /* sysfs related */
        struct device           dev;
+       unsigned long           open_count;
 };
 
 static DEFINE_MUTEX(ctl_mutex);          /* Serialize open/close/setup/teardown */
@@ -218,7 +250,7 @@ static int rbd_dev_snaps_update(struct rbd_device *rbd_dev);
 static int rbd_dev_snaps_register(struct rbd_device *rbd_dev);
 
 static void rbd_dev_release(struct device *dev);
-static void __rbd_remove_snap_dev(struct rbd_snap *snap);
+static void rbd_remove_snap_dev(struct rbd_snap *snap);
 
 static ssize_t rbd_add(struct bus_type *bus, const char *buf,
                       size_t count);
@@ -258,17 +290,8 @@ static struct device rbd_root_dev = {
 #  define rbd_assert(expr)     ((void) 0)
 #endif /* !RBD_DEBUG */
 
-static struct device *rbd_get_dev(struct rbd_device *rbd_dev)
-{
-       return get_device(&rbd_dev->dev);
-}
-
-static void rbd_put_dev(struct rbd_device *rbd_dev)
-{
-       put_device(&rbd_dev->dev);
-}
-
-static int rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver);
+static int rbd_dev_refresh(struct rbd_device *rbd_dev, u64 *hver);
+static int rbd_dev_v2_refresh(struct rbd_device *rbd_dev, u64 *hver);
 
 static int rbd_open(struct block_device *bdev, fmode_t mode)
 {
@@ -277,8 +300,11 @@ static int rbd_open(struct block_device *bdev, fmode_t mode)
        if ((mode & FMODE_WRITE) && rbd_dev->mapping.read_only)
                return -EROFS;
 
-       rbd_get_dev(rbd_dev);
+       mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
+       (void) get_device(&rbd_dev->dev);
        set_device_ro(bdev, rbd_dev->mapping.read_only);
+       rbd_dev->open_count++;
+       mutex_unlock(&ctl_mutex);
 
        return 0;
 }
@@ -287,7 +313,11 @@ static int rbd_release(struct gendisk *disk, fmode_t mode)
 {
        struct rbd_device *rbd_dev = disk->private_data;
 
-       rbd_put_dev(rbd_dev);
+       mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
+       rbd_assert(rbd_dev->open_count > 0);
+       rbd_dev->open_count--;
+       put_device(&rbd_dev->dev);
+       mutex_unlock(&ctl_mutex);
 
        return 0;
 }
@@ -388,7 +418,7 @@ enum {
 static match_table_t rbd_opts_tokens = {
        /* int args above */
        /* string args above */
-       {Opt_read_only, "mapping.read_only"},
+       {Opt_read_only, "read_only"},
        {Opt_read_only, "ro"},          /* Alternate spelling */
        {Opt_read_write, "read_write"},
        {Opt_read_write, "rw"},         /* Alternate spelling */
@@ -441,33 +471,17 @@ static int parse_rbd_opts_token(char *c, void *private)
  * Get a ceph client with specific addr and configuration, if one does
  * not exist create it.
  */
-static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr,
-                               size_t mon_addr_len, char *options)
+static struct rbd_client *rbd_get_client(struct ceph_options *ceph_opts)
 {
-       struct rbd_options *rbd_opts = &rbd_dev->rbd_opts;
-       struct ceph_options *ceph_opts;
        struct rbd_client *rbdc;
 
-       rbd_opts->read_only = RBD_READ_ONLY_DEFAULT;
-
-       ceph_opts = ceph_parse_options(options, mon_addr,
-                                       mon_addr + mon_addr_len,
-                                       parse_rbd_opts_token, rbd_opts);
-       if (IS_ERR(ceph_opts))
-               return PTR_ERR(ceph_opts);
-
        rbdc = rbd_client_find(ceph_opts);
-       if (rbdc) {
-               /* using an existing client */
+       if (rbdc)       /* using an existing client */
                ceph_destroy_options(ceph_opts);
-       } else {
+       else
                rbdc = rbd_client_create(ceph_opts);
-               if (IS_ERR(rbdc))
-                       return PTR_ERR(rbdc);
-       }
-       rbd_dev->rbd_client = rbdc;
 
-       return 0;
+       return rbdc;
 }
 
 /*
@@ -492,10 +506,10 @@ static void rbd_client_release(struct kref *kref)
  * Drop reference to ceph client node. If it's not referenced anymore, release
  * it.
  */
-static void rbd_put_client(struct rbd_device *rbd_dev)
+static void rbd_put_client(struct rbd_client *rbdc)
 {
-       kref_put(&rbd_dev->rbd_client->kref, rbd_client_release);
-       rbd_dev->rbd_client = NULL;
+       if (rbdc)
+               kref_put(&rbdc->kref, rbd_client_release);
 }
 
 /*
@@ -524,6 +538,16 @@ static bool rbd_dev_ondisk_valid(struct rbd_image_header_ondisk *ondisk)
        if (memcmp(&ondisk->text, RBD_HEADER_TEXT, sizeof (RBD_HEADER_TEXT)))
                return false;
 
+       /* The bio layer requires at least sector-sized I/O */
+
+       if (ondisk->options.order < SECTOR_SHIFT)
+               return false;
+
+       /* If we use u64 in a few spots we may be able to loosen this */
+
+       if (ondisk->options.order > 8 * sizeof (int) - 1)
+               return false;
+
        /*
         * The size of a snapshot header has to fit in a size_t, and
         * that limits the number of snapshots.
@@ -635,6 +659,20 @@ out_err:
        return -ENOMEM;
 }
 
+static const char *rbd_snap_name(struct rbd_device *rbd_dev, u64 snap_id)
+{
+       struct rbd_snap *snap;
+
+       if (snap_id == CEPH_NOSNAP)
+               return RBD_SNAP_HEAD_NAME;
+
+       list_for_each_entry(snap, &rbd_dev->snaps, node)
+               if (snap_id == snap->id)
+                       return snap->name;
+
+       return NULL;
+}
+
 static int snap_by_name(struct rbd_device *rbd_dev, const char *snap_name)
 {
 
@@ -642,7 +680,7 @@ static int snap_by_name(struct rbd_device *rbd_dev, const char *snap_name)
 
        list_for_each_entry(snap, &rbd_dev->snaps, node) {
                if (!strcmp(snap_name, snap->name)) {
-                       rbd_dev->mapping.snap_id = snap->id;
+                       rbd_dev->spec->snap_id = snap->id;
                        rbd_dev->mapping.size = snap->size;
                        rbd_dev->mapping.features = snap->features;
 
@@ -653,26 +691,23 @@ static int snap_by_name(struct rbd_device *rbd_dev, const char *snap_name)
        return -ENOENT;
 }
 
-static int rbd_dev_set_mapping(struct rbd_device *rbd_dev, char *snap_name)
+static int rbd_dev_set_mapping(struct rbd_device *rbd_dev)
 {
        int ret;
 
-       if (!memcmp(snap_name, RBD_SNAP_HEAD_NAME,
+       if (!memcmp(rbd_dev->spec->snap_name, RBD_SNAP_HEAD_NAME,
                    sizeof (RBD_SNAP_HEAD_NAME))) {
-               rbd_dev->mapping.snap_id = CEPH_NOSNAP;
+               rbd_dev->spec->snap_id = CEPH_NOSNAP;
                rbd_dev->mapping.size = rbd_dev->header.image_size;
                rbd_dev->mapping.features = rbd_dev->header.features;
-               rbd_dev->mapping.snap_exists = false;
-               rbd_dev->mapping.read_only = rbd_dev->rbd_opts.read_only;
                ret = 0;
        } else {
-               ret = snap_by_name(rbd_dev, snap_name);
+               ret = snap_by_name(rbd_dev, rbd_dev->spec->snap_name);
                if (ret < 0)
                        goto done;
-               rbd_dev->mapping.snap_exists = true;
                rbd_dev->mapping.read_only = true;
        }
-       rbd_dev->mapping.snap_name = snap_name;
+       rbd_dev->exists = true;
 done:
        return ret;
 }
@@ -695,13 +730,13 @@ static char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
        u64 segment;
        int ret;
 
-       name = kmalloc(RBD_MAX_SEG_NAME_LEN + 1, GFP_NOIO);
+       name = kmalloc(MAX_OBJ_NAME_SIZE + 1, GFP_NOIO);
        if (!name)
                return NULL;
        segment = offset >> rbd_dev->header.obj_order;
-       ret = snprintf(name, RBD_MAX_SEG_NAME_LEN, "%s.%012llx",
+       ret = snprintf(name, MAX_OBJ_NAME_SIZE + 1, "%s.%012llx",
                        rbd_dev->header.object_prefix, segment);
-       if (ret < 0 || ret >= RBD_MAX_SEG_NAME_LEN) {
+       if (ret < 0 || ret > MAX_OBJ_NAME_SIZE) {
                pr_err("error formatting segment name for #%llu (%d)\n",
                        segment, ret);
                kfree(name);
@@ -800,77 +835,144 @@ static void zero_bio_chain(struct bio *chain, int start_ofs)
 }
 
 /*
- * bio_chain_clone - clone a chain of bios up to a certain length.
- * might return a bio_pair that will need to be released.
+ * Clone a portion of a bio, starting at the given byte offset
+ * and continuing for the number of bytes indicated.
  */
-static struct bio *bio_chain_clone(struct bio **old, struct bio **next,
-                                  struct bio_pair **bp,
-                                  int len, gfp_t gfpmask)
-{
-       struct bio *old_chain = *old;
-       struct bio *new_chain = NULL;
-       struct bio *tail;
-       int total = 0;
-
-       if (*bp) {
-               bio_pair_release(*bp);
-               *bp = NULL;
-       }
+static struct bio *bio_clone_range(struct bio *bio_src,
+                                       unsigned int offset,
+                                       unsigned int len,
+                                       gfp_t gfpmask)
+{
+       struct bio_vec *bv;
+       unsigned int resid;
+       unsigned short idx;
+       unsigned int voff;
+       unsigned short end_idx;
+       unsigned short vcnt;
+       struct bio *bio;
 
-       while (old_chain && (total < len)) {
-               struct bio *tmp;
+       /* Handle the easy case for the caller */
 
-               tmp = bio_kmalloc(gfpmask, old_chain->bi_max_vecs);
-               if (!tmp)
-                       goto err_out;
-               gfpmask &= ~__GFP_WAIT; /* can't wait after the first */
+       if (!offset && len == bio_src->bi_size)
+               return bio_clone(bio_src, gfpmask);
 
-               if (total + old_chain->bi_size > len) {
-                       struct bio_pair *bp;
+       if (WARN_ON_ONCE(!len))
+               return NULL;
+       if (WARN_ON_ONCE(len > bio_src->bi_size))
+               return NULL;
+       if (WARN_ON_ONCE(offset > bio_src->bi_size - len))
+               return NULL;
 
-                       /*
-                        * this split can only happen with a single paged bio,
-                        * split_bio will BUG_ON if this is not the case
-                        */
-                       dout("bio_chain_clone split! total=%d remaining=%d"
-                            "bi_size=%u\n",
-                            total, len - total, old_chain->bi_size);
+       /* Find first affected segment... */
 
-                       /* split the bio. We'll release it either in the next
-                          call, or it will have to be released outside */
-                       bp = bio_split(old_chain, (len - total) / SECTOR_SIZE);
-                       if (!bp)
-                               goto err_out;
+       resid = offset;
+       __bio_for_each_segment(bv, bio_src, idx, 0) {
+               if (resid < bv->bv_len)
+                       break;
+               resid -= bv->bv_len;
+       }
+       voff = resid;
 
-                       __bio_clone(tmp, &bp->bio1);
+       /* ...and the last affected segment */
 
-                       *next = &bp->bio2;
-               } else {
-                       __bio_clone(tmp, old_chain);
-                       *next = old_chain->bi_next;
-               }
+       resid += len;
+       __bio_for_each_segment(bv, bio_src, end_idx, idx) {
+               if (resid <= bv->bv_len)
+                       break;
+               resid -= bv->bv_len;
+       }
+       vcnt = end_idx - idx + 1;
+
+       /* Build the clone */
 
-               tmp->bi_bdev = NULL;
-               tmp->bi_next = NULL;
-               if (new_chain)
-                       tail->bi_next = tmp;
-               else
-                       new_chain = tmp;
-               tail = tmp;
-               old_chain = old_chain->bi_next;
+       bio = bio_alloc(gfpmask, (unsigned int) vcnt);
+       if (!bio)
+               return NULL;    /* ENOMEM */
 
-               total += tmp->bi_size;
+       bio->bi_bdev = bio_src->bi_bdev;
+       bio->bi_sector = bio_src->bi_sector + (offset >> SECTOR_SHIFT);
+       bio->bi_rw = bio_src->bi_rw;
+       bio->bi_flags |= 1 << BIO_CLONED;
+
+       /*
+        * Copy over our part of the bio_vec, then update the first
+        * and last (or only) entries.
+        */
+       memcpy(&bio->bi_io_vec[0], &bio_src->bi_io_vec[idx],
+                       vcnt * sizeof (struct bio_vec));
+       bio->bi_io_vec[0].bv_offset += voff;
+       if (vcnt > 1) {
+               bio->bi_io_vec[0].bv_len -= voff;
+               bio->bi_io_vec[vcnt - 1].bv_len = resid;
+       } else {
+               bio->bi_io_vec[0].bv_len = len;
        }
 
-       rbd_assert(total == len);
+       bio->bi_vcnt = vcnt;
+       bio->bi_size = len;
+       bio->bi_idx = 0;
+
+       return bio;
+}
+
+/*
+ * Clone a portion of a bio chain, starting at the given byte offset
+ * into the first bio in the source chain and continuing for the
+ * number of bytes indicated.  The result is another bio chain of
+ * exactly the given length, or a null pointer on error.
+ *
+ * The bio_src and offset parameters are both in-out.  On entry they
+ * refer to the first source bio and the offset into that bio where
+ * the start of data to be cloned is located.
+ *
+ * On return, bio_src is updated to refer to the bio in the source
+ * chain that contains first un-cloned byte, and *offset will
+ * contain the offset of that byte within that bio.
+ */
+static struct bio *bio_chain_clone_range(struct bio **bio_src,
+                                       unsigned int *offset,
+                                       unsigned int len,
+                                       gfp_t gfpmask)
+{
+       struct bio *bi = *bio_src;
+       unsigned int off = *offset;
+       struct bio *chain = NULL;
+       struct bio **end;
+
+       /* Build up a chain of clone bios up to the limit */
+
+       if (!bi || off >= bi->bi_size || !len)
+               return NULL;            /* Nothing to clone */
 
-       *old = old_chain;
+       end = &chain;
+       while (len) {
+               unsigned int bi_size;
+               struct bio *bio;
+
+               if (!bi)
+                       goto out_err;   /* EINVAL; ran out of bio's */
+               bi_size = min_t(unsigned int, bi->bi_size - off, len);
+               bio = bio_clone_range(bi, off, bi_size, gfpmask);
+               if (!bio)
+                       goto out_err;   /* ENOMEM */
+
+               *end = bio;
+               end = &bio->bi_next;
+
+               off += bi_size;
+               if (off == bi->bi_size) {
+                       bi = bi->bi_next;
+                       off = 0;
+               }
+               len -= bi_size;
+       }
+       *bio_src = bi;
+       *offset = off;
 
-       return new_chain;
+       return chain;
+out_err:
+       bio_chain_put(chain);
 
-err_out:
-       dout("bio_chain_clone with err\n");
-       bio_chain_put(new_chain);
        return NULL;
 }
 
@@ -988,8 +1090,9 @@ static int rbd_do_request(struct request *rq,
                req_data->coll_index = coll_index;
        }
 
-       dout("rbd_do_request object_name=%s ofs=%llu len=%llu\n", object_name,
-               (unsigned long long) ofs, (unsigned long long) len);
+       dout("rbd_do_request object_name=%s ofs=%llu len=%llu coll=%p[%d]\n",
+               object_name, (unsigned long long) ofs,
+               (unsigned long long) len, coll, coll_index);
 
        osdc = &rbd_dev->rbd_client->client->osdc;
        req = ceph_osdc_alloc_request(osdc, flags, snapc, ops,
@@ -1019,7 +1122,7 @@ static int rbd_do_request(struct request *rq,
        layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
        layout->fl_stripe_count = cpu_to_le32(1);
        layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
-       layout->fl_pg_pool = cpu_to_le32(rbd_dev->pool_id);
+       layout->fl_pg_pool = cpu_to_le32((int) rbd_dev->spec->pool_id);
        ret = ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
                                   req, ops);
        rbd_assert(ret == 0);
@@ -1154,8 +1257,6 @@ done:
 static int rbd_do_op(struct request *rq,
                     struct rbd_device *rbd_dev,
                     struct ceph_snap_context *snapc,
-                    u64 snapid,
-                    int opcode, int flags,
                     u64 ofs, u64 len,
                     struct bio *bio,
                     struct rbd_req_coll *coll,
@@ -1167,6 +1268,9 @@ static int rbd_do_op(struct request *rq,
        int ret;
        struct ceph_osd_req_op *ops;
        u32 payload_len;
+       int opcode;
+       int flags;
+       u64 snapid;
 
        seg_name = rbd_segment_name(rbd_dev, ofs);
        if (!seg_name)
@@ -1174,7 +1278,18 @@ static int rbd_do_op(struct request *rq,
        seg_len = rbd_segment_length(rbd_dev, ofs, len);
        seg_ofs = rbd_segment_offset(rbd_dev, ofs);
 
-       payload_len = (flags & CEPH_OSD_FLAG_WRITE ? seg_len : 0);
+       if (rq_data_dir(rq) == WRITE) {
+               opcode = CEPH_OSD_OP_WRITE;
+               flags = CEPH_OSD_FLAG_WRITE|CEPH_OSD_FLAG_ONDISK;
+               snapid = CEPH_NOSNAP;
+               payload_len = seg_len;
+       } else {
+               opcode = CEPH_OSD_OP_READ;
+               flags = CEPH_OSD_FLAG_READ;
+               snapc = NULL;
+               snapid = rbd_dev->spec->snap_id;
+               payload_len = 0;
+       }
 
        ret = -ENOMEM;
        ops = rbd_create_rw_ops(1, opcode, payload_len);
@@ -1201,41 +1316,6 @@ done:
        return ret;
 }
 
-/*
- * Request async osd write
- */
-static int rbd_req_write(struct request *rq,
-                        struct rbd_device *rbd_dev,
-                        struct ceph_snap_context *snapc,
-                        u64 ofs, u64 len,
-                        struct bio *bio,
-                        struct rbd_req_coll *coll,
-                        int coll_index)
-{
-       return rbd_do_op(rq, rbd_dev, snapc, CEPH_NOSNAP,
-                        CEPH_OSD_OP_WRITE,
-                        CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
-                        ofs, len, bio, coll, coll_index);
-}
-
-/*
- * Request async osd read
- */
-static int rbd_req_read(struct request *rq,
-                        struct rbd_device *rbd_dev,
-                        u64 snapid,
-                        u64 ofs, u64 len,
-                        struct bio *bio,
-                        struct rbd_req_coll *coll,
-                        int coll_index)
-{
-       return rbd_do_op(rq, rbd_dev, NULL,
-                        snapid,
-                        CEPH_OSD_OP_READ,
-                        CEPH_OSD_FLAG_READ,
-                        ofs, len, bio, coll, coll_index);
-}
-
 /*
  * Request sync osd read
  */
@@ -1304,7 +1384,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
        dout("rbd_watch_cb %s notify_id=%llu opcode=%u\n",
                rbd_dev->header_name, (unsigned long long) notify_id,
                (unsigned int) opcode);
-       rc = rbd_refresh_header(rbd_dev, &hver);
+       rc = rbd_dev_refresh(rbd_dev, &hver);
        if (rc)
                pr_warning(RBD_DRV_NAME "%d got notification but failed to "
                           " update snaps: %d\n", rbd_dev->major, rc);
@@ -1460,18 +1540,16 @@ static void rbd_rq_fn(struct request_queue *q)
 {
        struct rbd_device *rbd_dev = q->queuedata;
        struct request *rq;
-       struct bio_pair *bp = NULL;
 
        while ((rq = blk_fetch_request(q))) {
                struct bio *bio;
-               struct bio *rq_bio, *next_bio = NULL;
                bool do_write;
                unsigned int size;
-               u64 op_size = 0;
                u64 ofs;
                int num_segs, cur_seg = 0;
                struct rbd_req_coll *coll;
                struct ceph_snap_context *snapc;
+               unsigned int bio_offset;
 
                dout("fetched request\n");
 
@@ -1483,10 +1561,6 @@ static void rbd_rq_fn(struct request_queue *q)
 
                /* deduce our operation (read, write) */
                do_write = (rq_data_dir(rq) == WRITE);
-
-               size = blk_rq_bytes(rq);
-               ofs = blk_rq_pos(rq) * SECTOR_SIZE;
-               rq_bio = rq->bio;
                if (do_write && rbd_dev->mapping.read_only) {
                        __blk_end_request_all(rq, -EROFS);
                        continue;
@@ -1496,8 +1570,8 @@ static void rbd_rq_fn(struct request_queue *q)
 
                down_read(&rbd_dev->header_rwsem);
 
-               if (rbd_dev->mapping.snap_id != CEPH_NOSNAP &&
-                               !rbd_dev->mapping.snap_exists) {
+               if (!rbd_dev->exists) {
+                       rbd_assert(rbd_dev->spec->snap_id != CEPH_NOSNAP);
                        up_read(&rbd_dev->header_rwsem);
                        dout("request for non-existent snapshot");
                        spin_lock_irq(q->queue_lock);
@@ -1509,6 +1583,10 @@ static void rbd_rq_fn(struct request_queue *q)
 
                up_read(&rbd_dev->header_rwsem);
 
+               size = blk_rq_bytes(rq);
+               ofs = blk_rq_pos(rq) * SECTOR_SIZE;
+               bio = rq->bio;
+
                dout("%s 0x%x bytes at 0x%llx\n",
                     do_write ? "write" : "read",
                     size, (unsigned long long) blk_rq_pos(rq) * SECTOR_SIZE);
@@ -1528,45 +1606,37 @@ static void rbd_rq_fn(struct request_queue *q)
                        continue;
                }
 
+               bio_offset = 0;
                do {
-                       /* a bio clone to be passed down to OSD req */
+                       u64 limit = rbd_segment_length(rbd_dev, ofs, size);
+                       unsigned int chain_size;
+                       struct bio *bio_chain;
+
+                       BUG_ON(limit > (u64) UINT_MAX);
+                       chain_size = (unsigned int) limit;
                        dout("rq->bio->bi_vcnt=%hu\n", rq->bio->bi_vcnt);
-                       op_size = rbd_segment_length(rbd_dev, ofs, size);
+
                        kref_get(&coll->kref);
-                       bio = bio_chain_clone(&rq_bio, &next_bio, &bp,
-                                             op_size, GFP_ATOMIC);
-                       if (!bio) {
-                               rbd_coll_end_req_index(rq, coll, cur_seg,
-                                                      -ENOMEM, op_size);
-                               goto next_seg;
-                       }
 
+                       /* Pass a cloned bio chain via an osd request */
 
-                       /* init OSD command: write or read */
-                       if (do_write)
-                               rbd_req_write(rq, rbd_dev,
-                                             snapc,
-                                             ofs,
-                                             op_size, bio,
-                                             coll, cur_seg);
+                       bio_chain = bio_chain_clone_range(&bio,
+                                               &bio_offset, chain_size,
+                                               GFP_ATOMIC);
+                       if (bio_chain)
+                               (void) rbd_do_op(rq, rbd_dev, snapc,
+                                               ofs, chain_size,
+                                               bio_chain, coll, cur_seg);
                        else
-                               rbd_req_read(rq, rbd_dev,
-                                            rbd_dev->mapping.snap_id,
-                                            ofs,
-                                            op_size, bio,
-                                            coll, cur_seg);
-
-next_seg:
-                       size -= op_size;
-                       ofs += op_size;
+                               rbd_coll_end_req_index(rq, coll, cur_seg,
+                                                      -ENOMEM, chain_size);
+                       size -= chain_size;
+                       ofs += chain_size;
 
                        cur_seg++;
-                       rq_bio = next_bio;
                } while (size > 0);
                kref_put(&coll->kref, rbd_coll_release);
 
-               if (bp)
-                       bio_pair_release(bp);
                spin_lock_irq(q->queue_lock);
 
                ceph_put_snap_context(snapc);
@@ -1576,28 +1646,47 @@ next_seg:
 /*
  * a queue callback. Makes sure that we don't create a bio that spans across
  * multiple osd objects. One exception would be with a single page bios,
- * which we handle later at bio_chain_clone
+ * which we handle later at bio_chain_clone_range()
  */
 static int rbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bmd,
                          struct bio_vec *bvec)
 {
        struct rbd_device *rbd_dev = q->queuedata;
-       unsigned int chunk_sectors;
-       sector_t sector;
-       unsigned int bio_sectors;
-       int max;
+       sector_t sector_offset;
+       sector_t sectors_per_obj;
+       sector_t obj_sector_offset;
+       int ret;
 
-       chunk_sectors = 1 << (rbd_dev->header.obj_order - SECTOR_SHIFT);
-       sector = bmd->bi_sector + get_start_sect(bmd->bi_bdev);
-       bio_sectors = bmd->bi_size >> SECTOR_SHIFT;
+       /*
+        * Find how far into its rbd object the partition-relative
+        * bio start sector is to offset relative to the enclosing
+        * device.
+        */
+       sector_offset = get_start_sect(bmd->bi_bdev) + bmd->bi_sector;
+       sectors_per_obj = 1 << (rbd_dev->header.obj_order - SECTOR_SHIFT);
+       obj_sector_offset = sector_offset & (sectors_per_obj - 1);
+
+       /*
+        * Compute the number of bytes from that offset to the end
+        * of the object.  Account for what's already used by the bio.
+        */
+       ret = (int) (sectors_per_obj - obj_sector_offset) << SECTOR_SHIFT;
+       if (ret > bmd->bi_size)
+               ret -= bmd->bi_size;
+       else
+               ret = 0;
 
-       max =  (chunk_sectors - ((sector & (chunk_sectors - 1))
-                                + bio_sectors)) << SECTOR_SHIFT;
-       if (max < 0)
-               max = 0; /* bio_add cannot handle a negative return */
-       if (max <= bvec->bv_len && bio_sectors == 0)
-               return bvec->bv_len;
-       return max;
+       /*
+        * Don't send back more than was asked for.  And if the bio
+        * was empty, let the whole thing through because:  "Note
+        * that a block device *must* allow a single page to be
+        * added to an empty bio."
+        */
+       rbd_assert(bvec->bv_len <= PAGE_SIZE);
+       if (ret > (int) bvec->bv_len || !bmd->bi_size)
+               ret = (int) bvec->bv_len;
+
+       return ret;
 }
 
 static void rbd_free_disk(struct rbd_device *rbd_dev)
@@ -1663,13 +1752,13 @@ rbd_dev_v1_header_read(struct rbd_device *rbd_dev, u64 *version)
                        ret = -ENXIO;
                        pr_warning("short header read for image %s"
                                        " (want %zd got %d)\n",
-                               rbd_dev->image_name, size, ret);
+                               rbd_dev->spec->image_name, size, ret);
                        goto out_err;
                }
                if (!rbd_dev_ondisk_valid(ondisk)) {
                        ret = -ENXIO;
                        pr_warning("invalid header for image %s\n",
-                               rbd_dev->image_name);
+                               rbd_dev->spec->image_name);
                        goto out_err;
                }
 
@@ -1707,19 +1796,32 @@ static int rbd_read_header(struct rbd_device *rbd_dev,
        return ret;
 }
 
-static void __rbd_remove_all_snaps(struct rbd_device *rbd_dev)
+static void rbd_remove_all_snaps(struct rbd_device *rbd_dev)
 {
        struct rbd_snap *snap;
        struct rbd_snap *next;
 
        list_for_each_entry_safe(snap, next, &rbd_dev->snaps, node)
-               __rbd_remove_snap_dev(snap);
+               rbd_remove_snap_dev(snap);
+}
+
+static void rbd_update_mapping_size(struct rbd_device *rbd_dev)
+{
+       sector_t size;
+
+       if (rbd_dev->spec->snap_id != CEPH_NOSNAP)
+               return;
+
+       size = (sector_t) rbd_dev->header.image_size / SECTOR_SIZE;
+       dout("setting size to %llu sectors", (unsigned long long) size);
+       rbd_dev->mapping.size = (u64) size;
+       set_capacity(rbd_dev->disk, size);
 }
 
 /*
  * only read the first part of the ondisk header, without the snaps info
  */
-static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
+static int rbd_dev_v1_refresh(struct rbd_device *rbd_dev, u64 *hver)
 {
        int ret;
        struct rbd_image_header h;
@@ -1730,17 +1832,9 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
 
        down_write(&rbd_dev->header_rwsem);
 
-       /* resized? */
-       if (rbd_dev->mapping.snap_id == CEPH_NOSNAP) {
-               sector_t size = (sector_t) h.image_size / SECTOR_SIZE;
-
-               if (size != (sector_t) rbd_dev->mapping.size) {
-                       dout("setting size to %llu sectors",
-                               (unsigned long long) size);
-                       rbd_dev->mapping.size = (u64) size;
-                       set_capacity(rbd_dev->disk, size);
-               }
-       }
+       /* Update image size, and check for resize of mapped image */
+       rbd_dev->header.image_size = h.image_size;
+       rbd_update_mapping_size(rbd_dev);
 
        /* rbd_dev->header.object_prefix shouldn't change */
        kfree(rbd_dev->header.snap_sizes);
@@ -1768,12 +1862,16 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
        return ret;
 }
 
-static int rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
+static int rbd_dev_refresh(struct rbd_device *rbd_dev, u64 *hver)
 {
        int ret;
 
+       rbd_assert(rbd_image_format_valid(rbd_dev->image_format));
        mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
-       ret = __rbd_refresh_header(rbd_dev, hver);
+       if (rbd_dev->image_format == 1)
+               ret = rbd_dev_v1_refresh(rbd_dev, hver);
+       else
+               ret = rbd_dev_v2_refresh(rbd_dev, hver);
        mutex_unlock(&ctl_mutex);
 
        return ret;
@@ -1885,7 +1983,7 @@ static ssize_t rbd_pool_show(struct device *dev,
 {
        struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
 
-       return sprintf(buf, "%s\n", rbd_dev->pool_name);
+       return sprintf(buf, "%s\n", rbd_dev->spec->pool_name);
 }
 
 static ssize_t rbd_pool_id_show(struct device *dev,
@@ -1893,7 +1991,8 @@ static ssize_t rbd_pool_id_show(struct device *dev,
 {
        struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
 
-       return sprintf(buf, "%d\n", rbd_dev->pool_id);
+       return sprintf(buf, "%llu\n",
+               (unsigned long long) rbd_dev->spec->pool_id);
 }
 
 static ssize_t rbd_name_show(struct device *dev,
@@ -1901,7 +2000,10 @@ static ssize_t rbd_name_show(struct device *dev,
 {
        struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
 
-       return sprintf(buf, "%s\n", rbd_dev->image_name);
+       if (rbd_dev->spec->image_name)
+               return sprintf(buf, "%s\n", rbd_dev->spec->image_name);
+
+       return sprintf(buf, "(unknown)\n");
 }
 
 static ssize_t rbd_image_id_show(struct device *dev,
@@ -1909,7 +2011,7 @@ static ssize_t rbd_image_id_show(struct device *dev,
 {
        struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
 
-       return sprintf(buf, "%s\n", rbd_dev->image_id);
+       return sprintf(buf, "%s\n", rbd_dev->spec->image_id);
 }
 
 /*
@@ -1922,7 +2024,50 @@ static ssize_t rbd_snap_show(struct device *dev,
 {
        struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
 
-       return sprintf(buf, "%s\n", rbd_dev->mapping.snap_name);
+       return sprintf(buf, "%s\n", rbd_dev->spec->snap_name);
+}
+
+/*
+ * For an rbd v2 image, shows the pool id, image id, and snapshot id
+ * for the parent image.  If there is no parent, simply shows
+ * "(no parent image)".
+ */
+static ssize_t rbd_parent_show(struct device *dev,
+                            struct device_attribute *attr,
+                            char *buf)
+{
+       struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
+       struct rbd_spec *spec = rbd_dev->parent_spec;
+       int count;
+       char *bufp = buf;
+
+       if (!spec)
+               return sprintf(buf, "(no parent image)\n");
+
+       count = sprintf(bufp, "pool_id %llu\npool_name %s\n",
+                       (unsigned long long) spec->pool_id, spec->pool_name);
+       if (count < 0)
+               return count;
+       bufp += count;
+
+       count = sprintf(bufp, "image_id %s\nimage_name %s\n", spec->image_id,
+                       spec->image_name ? spec->image_name : "(unknown)");
+       if (count < 0)
+               return count;
+       bufp += count;
+
+       count = sprintf(bufp, "snap_id %llu\nsnap_name %s\n",
+                       (unsigned long long) spec->snap_id, spec->snap_name);
+       if (count < 0)
+               return count;
+       bufp += count;
+
+       count = sprintf(bufp, "overlap %llu\n", rbd_dev->parent_overlap);
+       if (count < 0)
+               return count;
+       bufp += count;
+
+       return (ssize_t) (bufp - buf);
 }
 
 static ssize_t rbd_image_refresh(struct device *dev,
@@ -1933,7 +2078,7 @@ static ssize_t rbd_image_refresh(struct device *dev,
        struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
        int ret;
 
-       ret = rbd_refresh_header(rbd_dev, NULL);
+       ret = rbd_dev_refresh(rbd_dev, NULL);
 
        return ret < 0 ? ret : size;
 }
@@ -1948,6 +2093,7 @@ static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL);
 static DEVICE_ATTR(image_id, S_IRUGO, rbd_image_id_show, NULL);
 static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
 static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
+static DEVICE_ATTR(parent, S_IRUGO, rbd_parent_show, NULL);
 
 static struct attribute *rbd_attrs[] = {
        &dev_attr_size.attr,
@@ -1959,6 +2105,7 @@ static struct attribute *rbd_attrs[] = {
        &dev_attr_name.attr,
        &dev_attr_image_id.attr,
        &dev_attr_current_snap.attr,
+       &dev_attr_parent.attr,
        &dev_attr_refresh.attr,
        NULL
 };
@@ -2047,6 +2194,74 @@ static struct device_type rbd_snap_device_type = {
        .release        = rbd_snap_dev_release,
 };
 
+static struct rbd_spec *rbd_spec_get(struct rbd_spec *spec)
+{
+       kref_get(&spec->kref);
+
+       return spec;
+}
+
+static void rbd_spec_free(struct kref *kref);
+static void rbd_spec_put(struct rbd_spec *spec)
+{
+       if (spec)
+               kref_put(&spec->kref, rbd_spec_free);
+}
+
+static struct rbd_spec *rbd_spec_alloc(void)
+{
+       struct rbd_spec *spec;
+
+       spec = kzalloc(sizeof (*spec), GFP_KERNEL);
+       if (!spec)
+               return NULL;
+       kref_init(&spec->kref);
+
+       rbd_spec_put(rbd_spec_get(spec));       /* TEMPORARY */
+
+       return spec;
+}
+
+static void rbd_spec_free(struct kref *kref)
+{
+       struct rbd_spec *spec = container_of(kref, struct rbd_spec, kref);
+
+       kfree(spec->pool_name);
+       kfree(spec->image_id);
+       kfree(spec->image_name);
+       kfree(spec->snap_name);
+       kfree(spec);
+}
+
+struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
+                               struct rbd_spec *spec)
+{
+       struct rbd_device *rbd_dev;
+
+       rbd_dev = kzalloc(sizeof (*rbd_dev), GFP_KERNEL);
+       if (!rbd_dev)
+               return NULL;
+
+       spin_lock_init(&rbd_dev->lock);
+       INIT_LIST_HEAD(&rbd_dev->node);
+       INIT_LIST_HEAD(&rbd_dev->snaps);
+       init_rwsem(&rbd_dev->header_rwsem);
+
+       rbd_dev->spec = spec;
+       rbd_dev->rbd_client = rbdc;
+
+       return rbd_dev;
+}
+
+static void rbd_dev_destroy(struct rbd_device *rbd_dev)
+{
+       rbd_spec_put(rbd_dev->parent_spec);
+       kfree(rbd_dev->header_name);
+       rbd_put_client(rbd_dev->rbd_client);
+       rbd_spec_put(rbd_dev->spec);
+       kfree(rbd_dev);
+}
+
 static bool rbd_snap_registered(struct rbd_snap *snap)
 {
        bool ret = snap->dev.type == &rbd_snap_device_type;
@@ -2057,7 +2272,7 @@ static bool rbd_snap_registered(struct rbd_snap *snap)
        return ret;
 }
 
-static void __rbd_remove_snap_dev(struct rbd_snap *snap)
+static void rbd_remove_snap_dev(struct rbd_snap *snap)
 {
        list_del(&snap->node);
        if (device_is_registered(&snap->dev))
@@ -2073,7 +2288,7 @@ static int rbd_register_snap_dev(struct rbd_snap *snap,
        dev->type = &rbd_snap_device_type;
        dev->parent = parent;
        dev->release = rbd_snap_dev_release;
-       dev_set_name(dev, "snap_%s", snap->name);
+       dev_set_name(dev, "%s%s", RBD_SNAP_DEV_NAME_PREFIX, snap->name);
        dout("%s: registering device for snapshot %s\n", __func__, snap->name);
 
        ret = device_register(dev);
@@ -2189,6 +2404,7 @@ static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev)
        dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret);
        if (ret < 0)
                goto out;
+       ret = 0;    /* rbd_req_sync_exec() can return positive */
 
        p = reply_buf;
        rbd_dev->header.object_prefix = ceph_extract_encoded_string(&p,
@@ -2216,6 +2432,7 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
                __le64 features;
                __le64 incompat;
        } features_buf = { 0 };
+       u64 incompat;
        int ret;
 
        ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
@@ -2226,6 +2443,11 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
        dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret);
        if (ret < 0)
                return ret;
+
+       incompat = le64_to_cpu(features_buf.incompat);
+       if (incompat & ~RBD_FEATURES_ALL)
+               return -ENXIO;
+
        *snap_features = le64_to_cpu(features_buf.features);
 
        dout("  snap_id 0x%016llx features = 0x%016llx incompat = 0x%016llx\n",
@@ -2242,6 +2464,183 @@ static int rbd_dev_v2_features(struct rbd_device *rbd_dev)
                                                &rbd_dev->header.features);
 }
 
+static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
+{
+       struct rbd_spec *parent_spec;
+       size_t size;
+       void *reply_buf = NULL;
+       __le64 snapid;
+       void *p;
+       void *end;
+       char *image_id;
+       u64 overlap;
+       size_t len = 0;
+       int ret;
+
+       parent_spec = rbd_spec_alloc();
+       if (!parent_spec)
+               return -ENOMEM;
+
+       size = sizeof (__le64) +                                /* pool_id */
+               sizeof (__le32) + RBD_IMAGE_ID_LEN_MAX +        /* image_id */
+               sizeof (__le64) +                               /* snap_id */
+               sizeof (__le64);                                /* overlap */
+       reply_buf = kmalloc(size, GFP_KERNEL);
+       if (!reply_buf) {
+               ret = -ENOMEM;
+               goto out_err;
+       }
+
+       snapid = cpu_to_le64(CEPH_NOSNAP);
+       ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
+                               "rbd", "get_parent",
+                               (char *) &snapid, sizeof (snapid),
+                               (char *) reply_buf, size,
+                               CEPH_OSD_FLAG_READ, NULL);
+       dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret);
+       if (ret < 0)
+               goto out_err;
+
+       ret = -ERANGE;
+       p = reply_buf;
+       end = (char *) reply_buf + size;
+       ceph_decode_64_safe(&p, end, parent_spec->pool_id, out_err);
+       if (parent_spec->pool_id == CEPH_NOPOOL)
+               goto out;       /* No parent?  No problem. */
+
+       image_id = ceph_extract_encoded_string(&p, end, &len, GFP_KERNEL);
+       if (IS_ERR(image_id)) {
+               ret = PTR_ERR(image_id);
+               goto out_err;
+       }
+       parent_spec->image_id = image_id;
+       parent_spec->image_id_len = len;
+       ceph_decode_64_safe(&p, end, parent_spec->snap_id, out_err);
+       ceph_decode_64_safe(&p, end, overlap, out_err);
+
+       rbd_dev->parent_overlap = overlap;
+       rbd_dev->parent_spec = parent_spec;
+       parent_spec = NULL;     /* rbd_dev now owns this */
+out:
+       ret = 0;
+out_err:
+       kfree(reply_buf);
+       rbd_spec_put(parent_spec);
+
+       return ret;
+}
+
+static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
+{
+       size_t image_id_size;
+       char *image_id;
+       void *p;
+       void *end;
+       size_t size;
+       void *reply_buf = NULL;
+       size_t len = 0;
+       char *image_name = NULL;
+       int ret;
+
+       rbd_assert(!rbd_dev->spec->image_name);
+
+       image_id_size = sizeof (__le32) + rbd_dev->spec->image_id_len;
+       image_id = kmalloc(image_id_size, GFP_KERNEL);
+       if (!image_id)
+               return NULL;
+
+       p = image_id;
+       end = (char *) image_id + image_id_size;
+       ceph_encode_string(&p, end, rbd_dev->spec->image_id,
+                               (u32) rbd_dev->spec->image_id_len);
+
+       size = sizeof (__le32) + RBD_IMAGE_NAME_LEN_MAX;
+       reply_buf = kmalloc(size, GFP_KERNEL);
+       if (!reply_buf)
+               goto out;
+
+       ret = rbd_req_sync_exec(rbd_dev, RBD_DIRECTORY,
+                               "rbd", "dir_get_name",
+                               image_id, image_id_size,
+                               (char *) reply_buf, size,
+                               CEPH_OSD_FLAG_READ, NULL);
+       if (ret < 0)
+               goto out;
+       p = reply_buf;
+       end = (char *) reply_buf + size;
+       image_name = ceph_extract_encoded_string(&p, end, &len, GFP_KERNEL);
+       if (IS_ERR(image_name))
+               image_name = NULL;
+       else
+               dout("%s: name is %s len is %zd\n", __func__, image_name, len);
+out:
+       kfree(reply_buf);
+       kfree(image_id);
+
+       return image_name;
+}
+
+/*
+ * When a parent image gets probed, we only have the pool, image,
+ * and snapshot ids but not the names of any of them.  This call
+ * is made later to fill in those names.  It has to be done after
+ * rbd_dev_snaps_update() has completed because some of the
+ * information (in particular, snapshot name) is not available
+ * until then.
+ */
+static int rbd_dev_probe_update_spec(struct rbd_device *rbd_dev)
+{
+       struct ceph_osd_client *osdc;
+       const char *name;
+       void *reply_buf = NULL;
+       int ret;
+
+       if (rbd_dev->spec->pool_name)
+               return 0;       /* Already have the names */
+
+       /* Look up the pool name */
+
+       osdc = &rbd_dev->rbd_client->client->osdc;
+       name = ceph_pg_pool_name_by_id(osdc->osdmap, rbd_dev->spec->pool_id);
+       if (!name)
+               return -EIO;    /* pool id too large (>= 2^31) */
+
+       rbd_dev->spec->pool_name = kstrdup(name, GFP_KERNEL);
+       if (!rbd_dev->spec->pool_name)
+               return -ENOMEM;
+
+       /* Fetch the image name; tolerate failure here */
+
+       name = rbd_dev_image_name(rbd_dev);
+       if (name) {
+               rbd_dev->spec->image_name_len = strlen(name);
+               rbd_dev->spec->image_name = (char *) name;
+       } else {
+               pr_warning(RBD_DRV_NAME "%d "
+                       "unable to get image name for image id %s\n",
+                       rbd_dev->major, rbd_dev->spec->image_id);
+       }
+
+       /* Look up the snapshot name. */
+
+       name = rbd_snap_name(rbd_dev, rbd_dev->spec->snap_id);
+       if (!name) {
+               ret = -EIO;
+               goto out_err;
+       }
+       rbd_dev->spec->snap_name = kstrdup(name, GFP_KERNEL);
+       if(!rbd_dev->spec->snap_name)
+               goto out_err;
+
+       return 0;
+out_err:
+       kfree(reply_buf);
+       kfree(rbd_dev->spec->pool_name);
+       rbd_dev->spec->pool_name = NULL;
+
+       return ret;
+}
+
 static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev, u64 *ver)
 {
        size_t size;
@@ -2328,7 +2727,6 @@ static char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which)
        int ret;
        void *p;
        void *end;
-       size_t snap_name_len;
        char *snap_name;
 
        size = sizeof (__le32) + RBD_MAX_SNAP_NAME_LEN;
@@ -2348,9 +2746,7 @@ static char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which)
 
        p = reply_buf;
        end = (char *) reply_buf + size;
-       snap_name_len = 0;
-       snap_name = ceph_extract_encoded_string(&p, end, &snap_name_len,
-                               GFP_KERNEL);
+       snap_name = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL);
        if (IS_ERR(snap_name)) {
                ret = PTR_ERR(snap_name);
                goto out;
@@ -2397,6 +2793,41 @@ static char *rbd_dev_snap_info(struct rbd_device *rbd_dev, u32 which,
        return ERR_PTR(-EINVAL);
 }
 
+static int rbd_dev_v2_refresh(struct rbd_device *rbd_dev, u64 *hver)
+{
+       int ret;
+       __u8 obj_order;
+
+       down_write(&rbd_dev->header_rwsem);
+
+       /* Grab old order first, to see if it changes */
+
+       obj_order = rbd_dev->header.obj_order,
+       ret = rbd_dev_v2_image_size(rbd_dev);
+       if (ret)
+               goto out;
+       if (rbd_dev->header.obj_order != obj_order) {
+               ret = -EIO;
+               goto out;
+       }
+       rbd_update_mapping_size(rbd_dev);
+
+       ret = rbd_dev_v2_snap_context(rbd_dev, hver);
+       dout("rbd_dev_v2_snap_context returned %d\n", ret);
+       if (ret)
+               goto out;
+       ret = rbd_dev_snaps_update(rbd_dev);
+       dout("rbd_dev_snaps_update returned %d\n", ret);
+       if (ret)
+               goto out;
+       ret = rbd_dev_snaps_register(rbd_dev);
+       dout("rbd_dev_snaps_register returned %d\n", ret);
+out:
+       up_write(&rbd_dev->header_rwsem);
+
+       return ret;
+}
+
 /*
  * Scan the rbd device's current snapshot list and compare it to the
  * newly-received snapshot context.  Remove any existing snapshots
@@ -2436,12 +2867,12 @@ static int rbd_dev_snaps_update(struct rbd_device *rbd_dev)
 
                        /* Existing snapshot not in the new snap context */
 
-                       if (rbd_dev->mapping.snap_id == snap->id)
-                               rbd_dev->mapping.snap_exists = false;
-                       __rbd_remove_snap_dev(snap);
+                       if (rbd_dev->spec->snap_id == snap->id)
+                               rbd_dev->exists = false;
+                       rbd_remove_snap_dev(snap);
                        dout("%ssnap id %llu has been removed\n",
-                               rbd_dev->mapping.snap_id == snap->id ?
-                                                               "mapped " : "",
+                               rbd_dev->spec->snap_id == snap->id ?
+                                                       "mapped " : "",
                                (unsigned long long) snap->id);
 
                        /* Done with this list entry; advance */
@@ -2559,7 +2990,7 @@ static int rbd_init_watch_dev(struct rbd_device *rbd_dev)
        do {
                ret = rbd_req_sync_watch(rbd_dev);
                if (ret == -ERANGE) {
-                       rc = rbd_refresh_header(rbd_dev, NULL);
+                       rc = rbd_dev_refresh(rbd_dev, NULL);
                        if (rc < 0)
                                return rc;
                }
@@ -2621,8 +3052,8 @@ static void rbd_dev_id_put(struct rbd_device *rbd_dev)
                struct rbd_device *rbd_dev;
 
                rbd_dev = list_entry(tmp, struct rbd_device, node);
-               if (rbd_id > max_id)
-                       max_id = rbd_id;
+               if (rbd_dev->dev_id > max_id)
+                       max_id = rbd_dev->dev_id;
        }
        spin_unlock(&rbd_dev_list_lock);
 
@@ -2722,73 +3153,140 @@ static inline char *dup_token(const char **buf, size_t *lenp)
 }
 
 /*
- * This fills in