All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: viro@zeniv.linux.org.uk
Cc: arve@android.com, riandrews@android.com,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 06/16] fs: fix kernel_write prototype
Date: Wed, 30 Aug 2017 16:59:57 +0200	[thread overview]
Message-ID: <20170830150007.3953-7-hch@lst.de> (raw)
In-Reply-To: <20170830150007.3953-1-hch@lst.de>

Make the position an in/out argument like all the other read/write
helpers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/mtd/nand/nandsim.c        | 2 +-
 drivers/target/target_core_alua.c | 3 ++-
 drivers/target/target_core_file.c | 3 +--
 drivers/target/target_core_pr.c   | 3 ++-
 fs/ecryptfs/read_write.c          | 2 +-
 fs/read_write.c                   | 4 ++--
 include/linux/fs.h                | 2 +-
 kernel/sysctl_binary.c            | 9 ++++++---
 security/keys/big_key.c           | 3 ++-
 9 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index a8089656879a..3300a77667fb 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -1395,7 +1395,7 @@ static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size
 	if (err)
 		return err;
 	noreclaim_flag = memalloc_noreclaim_save();
-	tx = kernel_write(file, buf, count, pos);
+	tx = kernel_write(file, buf, count, &pos);
 	memalloc_noreclaim_restore(noreclaim_flag);
 	put_pages(ns);
 	return tx;
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index a91b7c25ffd4..928127642574 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -896,13 +896,14 @@ static int core_alua_write_tpg_metadata(
 	u32 md_buf_len)
 {
 	struct file *file = filp_open(path, O_RDWR | O_CREAT | O_TRUNC, 0600);
+	loff_t pos = 0;
 	int ret;
 
 	if (IS_ERR(file)) {
 		pr_err("filp_open(%s) for ALUA metadata failed\n", path);
 		return -ENODEV;
 	}
-	ret = kernel_write(file, md_buf, md_buf_len, 0);
+	ret = kernel_write(file, md_buf, md_buf_len, &pos);
 	if (ret < 0)
 		pr_err("Error writing ALUA metadata file: %s\n", path);
 	fput(file);
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 24cf11d9e50a..21e65d69ab2e 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -443,13 +443,12 @@ fd_do_prot_fill(struct se_device *se_dev, sector_t lba, sector_t nolb,
 
 	for (prot = 0; prot < prot_length;) {
 		sector_t len = min_t(sector_t, bufsize, prot_length - prot);
-		ssize_t ret = kernel_write(prot_fd, buf, len, pos + prot);
+		ssize_t ret = kernel_write(prot_fd, buf, len, &pos);
 
 		if (ret != len) {
 			pr_err("vfs_write to prot file failed: %zd\n", ret);
 			return ret < 0 ? ret : -ENODEV;
 		}
-		prot += ret;
 	}
 
 	return 0;
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 6d5def64db61..dd2cd8048582 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1974,6 +1974,7 @@ static int __core_scsi3_write_aptpl_to_file(
 	char path[512];
 	u32 pr_aptpl_buf_len;
 	int ret;
+	loff_t pos = 0;
 
 	memset(path, 0, 512);
 
@@ -1993,7 +1994,7 @@ static int __core_scsi3_write_aptpl_to_file(
 
 	pr_aptpl_buf_len = (strlen(buf) + 1); /* Add extra for NULL */
 
-	ret = kernel_write(file, buf, pr_aptpl_buf_len, 0);
+	ret = kernel_write(file, buf, pr_aptpl_buf_len, &pos);
 
 	if (ret < 0)
 		pr_debug("Error writing APTPL metadata file: %s\n", path);
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index d8af0e99bfaf..c596e7c03424 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -47,7 +47,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
 	lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file;
 	if (!lower_file)
 		return -EIO;
-	rc = kernel_write(lower_file, data, size, offset);
+	rc = kernel_write(lower_file, data, size, &offset);
 	mark_inode_dirty_sync(ecryptfs_inode);
 	return rc;
 }
diff --git a/fs/read_write.c b/fs/read_write.c
index 1966fd6e03ce..82f0111b98cf 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -513,7 +513,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
 EXPORT_SYMBOL(__kernel_write);
 
 ssize_t kernel_write(struct file *file, const char *buf, size_t count,
-			    loff_t pos)
+			    loff_t *pos)
 {
 	mm_segment_t old_fs;
 	ssize_t res;
@@ -521,7 +521,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
 	old_fs = get_fs();
 	set_fs(get_ds());
 	/* The cast to a user pointer is valid due to the set_fs() */
-	res = vfs_write(file, (__force const char __user *)buf, count, &pos);
+	res = vfs_write(file, (__force const char __user *)buf, count, pos);
 	set_fs(old_fs);
 
 	return res;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1b9d083adf94..86f50568b758 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2779,7 +2779,7 @@ extern int kernel_read_file_from_path(char *, void **, loff_t *, loff_t,
 extern int kernel_read_file_from_fd(int, void **, loff_t *, loff_t,
 				    enum kernel_read_file_id);
 extern ssize_t kernel_read(struct file *, char *, size_t, loff_t *);
-extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t);
+extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t *);
 extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *);
 extern struct file * open_exec(const char *);
  
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index 243fa1c28b4a..58ea8c03662e 100644
--- a/kernel/sysctl_binary.c
+++ b/kernel/sysctl_binary.c
@@ -1017,6 +1017,7 @@ static ssize_t bin_intvec(struct file *file,
 		size_t length = newlen / sizeof(*vec);
 		char *str, *end;
 		int i;
+		loff_t pos = 0;
 
 		str = buffer;
 		end = str + BUFSZ;
@@ -1030,7 +1031,7 @@ static ssize_t bin_intvec(struct file *file,
 			str += scnprintf(str, end - str, "%lu\t", value);
 		}
 
-		result = kernel_write(file, buffer, str - buffer, 0);
+		result = kernel_write(file, buffer, str - buffer, &pos);
 		if (result < 0)
 			goto out_kfree;
 	}
@@ -1089,6 +1090,7 @@ static ssize_t bin_ulongvec(struct file *file,
 		size_t length = newlen / sizeof(*vec);
 		char *str, *end;
 		int i;
+		loff_t pos = 0;
 
 		str = buffer;
 		end = str + BUFSZ;
@@ -1102,7 +1104,7 @@ static ssize_t bin_ulongvec(struct file *file,
 			str += scnprintf(str, end - str, "%lu\t", value);
 		}
 
-		result = kernel_write(file, buffer, str - buffer, 0);
+		result = kernel_write(file, buffer, str - buffer, &pos);
 		if (result < 0)
 			goto out_kfree;
 	}
@@ -1192,6 +1194,7 @@ static ssize_t bin_dn_node_address(struct file *file,
 		__le16 dnaddr;
 		char buf[15];
 		int len;
+		loff_t pos = 0;
 
 		result = -EINVAL;
 		if (newlen != sizeof(dnaddr))
@@ -1205,7 +1208,7 @@ static ssize_t bin_dn_node_address(struct file *file,
 				le16_to_cpu(dnaddr) >> 10,
 				le16_to_cpu(dnaddr) & 0x3ff);
 
-		result = kernel_write(file, buf, len, 0);
+		result = kernel_write(file, buf, len, &pos);
 		if (result < 0)
 			goto out;
 	}
diff --git a/security/keys/big_key.c b/security/keys/big_key.c
index 9f4c86cade8e..6acb00f6f22c 100644
--- a/security/keys/big_key.c
+++ b/security/keys/big_key.c
@@ -147,6 +147,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
 		 * File content is stored encrypted with randomly generated key.
 		 */
 		size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher));
+		loff_t pos = 0;
 
 		/* prepare aligned data to encrypt */
 		data = kmalloc(enclen, GFP_KERNEL);
@@ -179,7 +180,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
 			goto err_enckey;
 		}
 
-		written = kernel_write(file, data, enclen, 0);
+		written = kernel_write(file, data, enclen, &pos);
 		if (written != enclen) {
 			ret = written;
 			if (written >= 0)
-- 
2.11.0

  parent reply	other threads:[~2017-08-30 15:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 14:59 switch in-kernel read/write calls to kernel_read/write Christoph Hellwig
2017-08-30 14:59 ` [PATCH 01/16] ashmem: switch to ->read_iter Christoph Hellwig
2017-08-30 15:28   ` Al Viro
2017-09-01 10:20     ` Christoph Hellwig
2017-08-30 14:59 ` [PATCH 02/16] autofs4: switch autofs4_write to __kernel_write Christoph Hellwig
2017-08-30 15:30   ` Al Viro
2017-09-01 10:22     ` Christoph Hellwig
2017-08-30 14:59 ` [PATCH 03/16] fs: move kernel_write to fs/read_write.c Christoph Hellwig
2017-08-30 14:59 ` [PATCH 04/16] fs: move kernel_read " Christoph Hellwig
2017-08-30 14:59 ` [PATCH 05/16] fs: fix kernel_read prototype Christoph Hellwig
2017-08-30 15:37   ` Al Viro
2017-09-01 10:37     ` Christoph Hellwig
2017-08-30 14:59 ` Christoph Hellwig [this message]
2017-08-30 15:39   ` [PATCH 06/16] fs: fix kernel_write prototype Al Viro
2017-09-01 10:40     ` Christoph Hellwig
2017-08-30 14:59 ` [PATCH 07/16] serial2002: switch serial2002_tty_write to kernel_{read/write} Christoph Hellwig
2017-08-30 14:59 ` [PATCH 08/16] mm/nommu: switch do_mmap_private to kernel_read Christoph Hellwig
2017-08-30 15:41   ` Al Viro
2017-09-01 10:41     ` Christoph Hellwig
2017-08-30 15:00 ` [PATCH 09/16] net/9p: switch p9_fd_read to kernel_write Christoph Hellwig
2017-08-30 15:00 ` [PATCH 10/16] btrfs: switch write_buf " Christoph Hellwig
2017-08-30 15:35   ` Nikolay Borisov
2017-08-30 15:00 ` [PATCH 11/16] mconsole: switch to kernel_read Christoph Hellwig
2017-08-30 15:00 ` [PATCH 12/16] gadget/f_mass_storage: stop messing with the address limit Christoph Hellwig
2017-08-30 15:00 ` [PATCH 13/16] lustre: switch to kernel_write Christoph Hellwig
2017-08-30 15:00 ` [PATCH 14/16] fs: unexport __vfs_read/__vfs_write Christoph Hellwig
2017-08-30 15:00 ` [PATCH 15/16] fs: unexport vfs_read and vfs_write Christoph Hellwig
2017-08-30 15:00 ` [PATCH 16/16] fs: unexport vfs_readv and vfs_writev Christoph Hellwig

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=20170830150007.3953-7-hch@lst.de \
    --to=hch@lst.de \
    --cc=arve@android.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=riandrews@android.com \
    --cc=viro@zeniv.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.