kill boilerplate around posix_acl_chmod_masq()

new helper: posix_acl_chmod(&acl, gfp, mode).  Replaces acl with modified
clone or with NULL if that has failed; returns 0 or -ve on error.  All
callers of posix_acl_chmod_masq() switched to that - they'd been doing
exactly the same thing.

[alex: trimmed down to cover only posix_acl.{c,h} for 3.0]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Alejandro Martinez Ruiz <alex@flawedcode.org>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
kill boilerplates around posix_acl_create_masq()

new helper: posix_acl_create(&acl, gfp, mode_p).  Replaces acl with
modified clone, on failure releases acl and replaces with NULL.
Returns 0 or -ve on error.  All callers of posix_acl_create_masq()
switched.

[alex: trimmed down to cover only posix_acl.{c,h} for 3.0]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Alejandro Martinez Ruiz <alex@flawedcode.org>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: use mode_t instead of umode_t for posix_acl_{create,chmod}()

Introducing the prototype change to umode_t may just break other file
systems, so we implicitly cast the umode_t to mode_t before calling
these functions.

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: cast to mode_t before calling posix_acl_equiv_mode()

We are not updating the prototype of posix_acl_equiv_mode() to avoid
conflicts with other file systems, so cast it and update the result.

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: provide ->check_acl() handler instead of ->get_acl()

Upstream commit 4e34e719e fs: take the ACL checks to common code
replaced the check_acl() handler of inode_operations with get_acl().

Fortunately, check_acl() is usually implemented in terms of get_acl(),
so use that.

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: restore ->check_acl() RCU MAY_NOT_BLOCK check

Upstream commit e77819e vfs: move ACL cache lookup into generic code
moved away from fs check_acl() handlers the RCU walking check.
Restore it and refactor the code.

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: retore flags argument to ->check_acl()

This basically reverts upstream commit 7e40145 ->permission()
sanitizing: don't pass flags to ->check_acl().

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: add ->check_acl() test for IPERM_FLAG_RCU

This reverts the effect of upstream commit 9c2c703 ->permission()
sanitizing: pass MAY_NOT_BLOCK to ->check_acl().

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: return to old style ->fsync()

Upstream commit 02c24a821 fs: push i_mutex and filemap_write_and_wait
down into ->fsync() handlers changed the implementation of fsync so that
it is now responsible for locking i_mutex and calling
filemap_write_and_wait_range().

Remove those from f2fs for pre-3.1 kernels.

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
filesystems: add set_nlink()

Replace remaining direct i_nlink updates with a new set_nlink()
updater function.

[alex: trimmed down to just add the function to fs.h]

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Tested-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alejandro Martinez Ruiz <alex@flawedcode.org>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: adapt to previous blockdev_direct_IO prototype

The prototype change was introduced in upstream commit aacfc19 fs:
simplify the blockdev_direct_IO prototype.

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
security: new security_inode_init_security API adds function callback

This patch changes the security_inode_init_security API by adding a
filesystem specific callback to write security extended attributes.
This change is in preparation for supporting the initialization of
multiple LSM xattrs and the EVM xattr.  Initially the callback function
walks an array of xattrs, writing each xattr separately, but could be
optimized to write multiple xattrs at once.

For existing security_inode_init_security() calls, which have not yet
been converted to use the new callback function, such as those in
reiserfs and ocfs2, this patch defines security_old_inode_init_security().

[alex: instead of renaming old prototype, just rename new one]
[alex: include further fixups to the original commit in this same patch]

Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>
f2fs: rename call to security_inode_init_security to use new prototype on old kernels

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Randall Rushing <randall.rushing@gmail.com>