From: David Howells <dhowells@redhat.com>
To: viro@ftp.linux.org.uk
Cc: kwc@citi.umich.edu, Trond.Myklebust@netapp.com,
linux-kernel@vger.kernel.org, dhowells@redhat.com
Subject: [PATCH 13/52] CRED: Make block_prepare_write() and co take a credentials pointer
Date: Fri, 12 Oct 2007 17:06:25 +0100 [thread overview]
Message-ID: <20071012160625.15119.6170.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20071012160519.15119.69608.stgit@warthog.procyon.org.uk>
Make block_prepare_write() and co take a credentials pointer.
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/block_dev.c | 2 +-
fs/buffer.c | 23 +++++++++++++----------
fs/ext3/inode.c | 8 +++++---
fs/fat/inode.c | 3 ++-
include/linux/buffer_head.h | 8 +++++---
5 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1a51716..ef70bba 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -382,7 +382,7 @@ static int blkdev_readpage(struct file * file, struct page * page)
static int blkdev_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to)
{
- return block_prepare_write(page, from, to, blkdev_get_block);
+ return block_prepare_write(page, from, to, blkdev_get_block, file->f_cred);
}
static int blkdev_commit_write(struct file *file, struct page *page, unsigned from, unsigned to)
diff --git a/fs/buffer.c b/fs/buffer.c
index c5b2ebc..bb6ab45 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1759,9 +1759,9 @@ recover:
}
static int __block_prepare_write(struct inode *inode, struct page *page,
- unsigned from, unsigned to, get_block_t *get_block)
+ unsigned from, unsigned to, get_block_t *get_block,
+ struct cred *cred)
{
- struct cred *cred = current->cred;
unsigned block_start, block_end;
sector_t block;
int err = 0;
@@ -2089,7 +2089,8 @@ int generic_cont_expand_simple(struct inode *inode, loff_t size)
*/
int cont_prepare_write(struct page *page, unsigned offset,
- unsigned to, get_block_t *get_block, loff_t *bytes)
+ unsigned to, get_block_t *get_block, loff_t *bytes,
+ struct cred *cred)
{
struct address_space *mapping = page->mapping;
struct inode *inode = mapping->host;
@@ -2116,7 +2117,8 @@ int cont_prepare_write(struct page *page, unsigned offset,
(*bytes)++;
}
status = __block_prepare_write(inode, new_page, zerofrom,
- PAGE_CACHE_SIZE, get_block);
+ PAGE_CACHE_SIZE, get_block,
+ cred);
if (status)
goto out_unmap;
zero_user_page(new_page, zerofrom, PAGE_CACHE_SIZE - zerofrom,
@@ -2143,7 +2145,8 @@ int cont_prepare_write(struct page *page, unsigned offset,
if (offset <= zerofrom)
zerofrom = offset;
}
- status = __block_prepare_write(inode, page, zerofrom, to, get_block);
+ status = __block_prepare_write(inode, page, zerofrom, to, get_block,
+ cred);
if (status)
goto out1;
if (zerofrom < offset) {
@@ -2164,10 +2167,10 @@ out:
}
int block_prepare_write(struct page *page, unsigned from, unsigned to,
- get_block_t *get_block)
+ get_block_t *get_block, struct cred *cred)
{
struct inode *inode = page->mapping->host;
- int err = __block_prepare_write(inode, page, from, to, get_block);
+ int err = __block_prepare_write(inode, page, from, to, get_block, cred);
if (err)
ClearPageUptodate(page);
return err;
@@ -2217,6 +2220,7 @@ block_page_mkwrite(struct vm_area_struct *vma, struct page *page,
get_block_t get_block)
{
struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
+ struct cred *cred = vma->vm_file->f_cred;
unsigned long end;
loff_t size;
int ret = -EINVAL;
@@ -2235,7 +2239,7 @@ block_page_mkwrite(struct vm_area_struct *vma, struct page *page,
else
end = PAGE_CACHE_SIZE;
- ret = block_prepare_write(page, 0, end, get_block);
+ ret = block_prepare_write(page, 0, end, get_block, cred);
if (!ret)
ret = block_commit_write(page, 0, end);
@@ -2270,9 +2274,8 @@ static void end_buffer_read_nobh(struct buffer_head *bh, int uptodate)
* On exit the page is fully uptodate in the areas outside (from,to)
*/
int nobh_prepare_write(struct page *page, unsigned from, unsigned to,
- get_block_t *get_block)
+ get_block_t *get_block, struct cred *cred)
{
- struct cred *cred = current->cred;
struct inode *inode = page->mapping->host;
const unsigned blkbits = inode->i_blkbits;
const unsigned blocksize = 1 << blkbits;
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 70e9e6f..d7e1390 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1158,6 +1158,7 @@ static int ext3_prepare_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
struct inode *inode = page->mapping->host;
+ struct cred *cred = file->f_cred;
int ret, needed_blocks = ext3_writepage_trans_blocks(inode);
handle_t *handle;
int retries = 0;
@@ -1169,9 +1170,9 @@ retry:
goto out;
}
if (test_opt(inode->i_sb, NOBH) && ext3_should_writeback_data(inode))
- ret = nobh_prepare_write(page, from, to, ext3_get_block);
+ ret = nobh_prepare_write(page, from, to, ext3_get_block, cred);
else
- ret = block_prepare_write(page, from, to, ext3_get_block);
+ ret = block_prepare_write(page, from, to, ext3_get_block, cred);
if (ret)
goto prepare_write_failed;
@@ -1525,6 +1526,7 @@ static int ext3_journalled_writepage(struct page *page,
struct writeback_control *wbc)
{
struct inode *inode = page->mapping->host;
+ struct cred *cred = current->cred;
handle_t *handle = NULL;
int ret = 0;
int err;
@@ -1545,7 +1547,7 @@ static int ext3_journalled_writepage(struct page *page,
*/
ClearPageChecked(page);
ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
- ext3_get_block);
+ ext3_get_block, cred);
if (ret != 0) {
ext3_journal_stop(handle);
goto out_unlock;
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 2745ce2..955ccaf 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -147,7 +147,8 @@ static int fat_prepare_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
return cont_prepare_write(page, from, to, fat_get_block,
- &MSDOS_I(page->mapping->host)->mmu_private);
+ &MSDOS_I(page->mapping->host)->mmu_private,
+ file->f_cred);
}
static int fat_commit_write(struct file *file, struct page *page,
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 35cadad..fe059f8 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -203,9 +203,10 @@ void block_invalidatepage(struct page *page, unsigned long offset);
int block_write_full_page(struct page *page, get_block_t *get_block,
struct writeback_control *wbc);
int block_read_full_page(struct page*, get_block_t*);
-int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
+int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
+ struct cred *);
int cont_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
- loff_t *);
+ loff_t *, struct cred *);
int generic_cont_expand(struct inode *inode, loff_t size);
int generic_cont_expand_simple(struct inode *inode, loff_t size);
int block_commit_write(struct page *page, unsigned from, unsigned to);
@@ -216,7 +217,8 @@ sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);
int generic_commit_write(struct file *, struct page *, unsigned, unsigned);
int block_truncate_page(struct address_space *, loff_t, get_block_t *);
int file_fsync(struct file *, struct dentry *, int);
-int nobh_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
+int nobh_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
+ struct cred *);
int nobh_commit_write(struct file *, struct page *, unsigned, unsigned);
int nobh_truncate_page(struct address_space *, loff_t);
int nobh_writepage(struct page *page, get_block_t *get_block,
next prev parent reply other threads:[~2007-10-12 16:12 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-12 16:05 [PATCH 00/52] Introduce credential record David Howells
2007-10-12 16:05 ` [PATCH 01/52] CRED: Introduce a COW credentials record David Howells
2007-10-15 1:53 ` David Chinner
2007-10-12 16:05 ` [PATCH 02/52] CRED: Give in_group_p() a cred pointer David Howells
2007-10-12 16:05 ` [PATCH 03/52] CRED: Pass credentials down to ext3 block allocator David Howells
2007-10-12 16:05 ` [PATCH 04/52] CRED: Pass credentials down to ext3 inode allocator David Howells
2007-10-12 16:05 ` [PATCH 05/52] CRED: Prepare TMPFS for cred passing David Howells
2007-10-12 16:05 ` [PATCH 06/52] CRED: Prepare RAMFS " David Howells
2007-10-12 16:05 ` [PATCH 07/52] CRED: Pass credentials down to ext2 block allocator David Howells
2007-10-12 16:06 ` [PATCH 08/52] CRED: Pass credentials down to ext2 inode allocator David Howells
2007-10-12 16:06 ` [PATCH 09/52] CRED: Pass credentials down to ext4 block allocator David Howells
2007-10-12 16:06 ` [PATCH 10/52] CRED: Pass credentials down to ext4 inode allocator David Howells
2007-10-12 16:06 ` [PATCH 11/52] CRED: Give the get_block() callback a credentials pointer David Howells
2007-10-12 16:06 ` [PATCH 12/52] CRED: Make mpage read functions take " David Howells
2007-10-12 16:06 ` David Howells [this message]
2007-10-12 16:06 ` [PATCH 14/52] CRED: Provide a writeback credentials record David Howells
2007-10-12 16:06 ` [PATCH 15/52] CRED: Make Ext3 use the writeback credentials David Howells
2007-10-12 16:06 ` [PATCH 16/52] CRED: Pass credentials through the internals of ext3 truncation David Howells
2007-10-12 16:06 ` [PATCH 17/52] CRED: Make rpcauth_lookupcred() take a credentials pointer David Howells
2007-10-12 16:06 ` [PATCH 18/52] CRED: Make rpcauth_bindcred() " David Howells
2007-10-12 16:06 ` [PATCH 19/52] CRED: Add a credentials pointer to struct rpc_task David Howells
2007-10-12 16:07 ` [PATCH 20/52] CRED: Pass credentials into rpc_init_task() David Howells
2007-10-12 16:07 ` [PATCH 21/52] CRED: Pass credentials through the truncate() inode operation David Howells
2007-10-12 16:07 ` [PATCH 22/52] CRED: Pass credentials to nfs_setattr_update_inode() David Howells
2007-10-12 16:07 ` [PATCH 23/52] CRED: Pass credentials to the setattr() inode operation David Howells
2007-10-12 16:07 ` [PATCH 24/52] CRED: Pass credentials through inode_setattr() David Howells
2007-10-12 16:07 ` [PATCH 25/52] CRED: Give the mknod() inode op a credentials pointer David Howells
2007-10-12 16:07 ` [PATCH 26/52] CRED: Give the mkdir() " David Howells
2007-10-12 16:07 ` [PATCH 27/52] CRED: Give the create() " David Howells
2007-10-12 16:07 ` [PATCH 28/52] CRED: Give the link() " David Howells
2007-10-12 16:07 ` [PATCH 29/52] CRED: Give the unlink() " David Howells
2007-10-12 16:07 ` [PATCH 30/52] CRED: Give the rmdir() " David Howells
2007-10-12 16:07 ` [PATCH 31/52] CRED: Give the rename() " David Howells
2007-10-12 16:08 ` [PATCH 32/52] CRED: Give the symlink() " David Howells
2007-10-12 16:08 ` [PATCH 33/52] CRED: Make the get_parent() export op take a credential pointer David Howells
2007-10-12 16:08 ` [PATCH 34/52] CRED: Make Ext3 ACL set handlers pass credentials down David Howells
2007-10-12 16:08 ` [PATCH 35/52] CRED: Make the ACL set() handler take a credentials pointer David Howells
2007-10-12 16:08 ` [PATCH 36/52] CRED: Make ext3_fill_super() pass credentials down David Howells
2007-10-12 16:08 ` [PATCH 37/52] CRED: Pass credentials to the get_sb() op and various fill_super() ops David Howells
2007-10-12 16:08 ` [PATCH 38/52] CRED: Pass credentials through the quota_read() op David Howells
2007-10-12 16:08 ` [PATCH 39/52] CRED: Pass credentials through the quota_write() op David Howells
2007-10-12 16:08 ` [PATCH 40/52] CRED: Give the lookup() inode op a credentials pointer David Howells
2007-10-12 16:08 ` [PATCH 41/52] CRED: Pass credentials through d_revalidate() David Howells
2007-10-12 16:08 ` [PATCH 42/52] CRED: Pass credentials through the permission() inode op David Howells
2007-10-12 16:08 ` [PATCH 43/52] CRED: Pass credentials through the statfs() superblock op David Howells
2007-10-12 16:09 ` [PATCH 44/52] CRED: Pass credentials through the follow_link() inode op David Howells
2007-10-12 16:09 ` [PATCH 45/52] CRED: Pass credentials through the getattr() " David Howells
2007-10-12 16:09 ` [PATCH 46/52] CRED: Pass credentials through the setxattr() " David Howells
2007-10-12 16:09 ` [PATCH 47/52] CRED: Pass credentials through the xattr get() handler David Howells
2007-10-12 16:09 ` [PATCH 48/52] CRED: Pass credentials through the getxattr() inode op David Howells
2007-10-12 16:09 ` [PATCH 49/52] CRED: Pass credentials through the xattr list() handler David Howells
2007-10-12 16:09 ` [PATCH 50/52] CRED: Pass credentials through the listxattr() inode op David Howells
2007-10-12 16:09 ` [PATCH 51/52] CRED: Pass credentials through the removexattr() " David Howells
2007-10-12 16:09 ` [PATCH 52/52] CRED: Pass credentials through vfs_mkdir() David Howells
2007-10-13 18:11 ` [PATCH 00/52] Introduce credential record Theodore Tso
2007-10-13 18:19 ` Al Viro
2007-10-13 21:46 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071012160625.15119.6170.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=Trond.Myklebust@netapp.com \
--cc=kwc@citi.umich.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®