* [PATCH v2 1/3] btrfs: replace open-coded kernel_write
2014-09-30 22:01 [PATCH v2 0/3] btrfs: fix several sparse warnings Omar Sandoval
@ 2014-09-30 22:01 ` Omar Sandoval
2014-09-30 22:19 ` Zach Brown
2014-09-30 22:01 ` [PATCH v2 2/3] btrfs: fix sparse address space warnings Omar Sandoval
2014-09-30 22:01 ` [PATCH v2 3/3] btrfs: fix sparse lock context warnings Omar Sandoval
2 siblings, 1 reply; 5+ messages in thread
From: Omar Sandoval @ 2014-09-30 22:01 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, linux-btrfs, linux-kernel
Cc: David Sterba, Zach Brown
write_buf used by btrfs send has what is more or less a reimplementation of
kernel_write. This also gets rid of a sparse address space warning.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
---
fs/btrfs/send.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 6528aa6..f6b2ec3 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -508,32 +508,23 @@ static struct btrfs_path *alloc_path_for_send(void)
static int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off)
{
int ret;
- mm_segment_t old_fs;
u32 pos = 0;
- old_fs = get_fs();
- set_fs(KERNEL_DS);
-
while (pos < len) {
- ret = vfs_write(filp, (char *)buf + pos, len - pos, off);
+ ret = kernel_write(filp, buf + pos, len - pos, *off);
/* TODO handle that correctly */
/*if (ret == -ERESTARTSYS) {
continue;
}*/
if (ret < 0)
- goto out;
- if (ret == 0) {
- ret = -EIO;
- goto out;
- }
+ return ret;
+ if (ret == 0)
+ return -EIO;
pos += ret;
+ *off += ret;
}
- ret = 0;
-
-out:
- set_fs(old_fs);
- return ret;
+ return 0;
}
static int tlv_put(struct send_ctx *sctx, u16 attr, const void *data, int len)
--
2.1.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 2/3] btrfs: fix sparse address space warnings
2014-09-30 22:01 [PATCH v2 0/3] btrfs: fix several sparse warnings Omar Sandoval
2014-09-30 22:01 ` [PATCH v2 1/3] btrfs: replace open-coded kernel_write Omar Sandoval
@ 2014-09-30 22:01 ` Omar Sandoval
2014-09-30 22:01 ` [PATCH v2 3/3] btrfs: fix sparse lock context warnings Omar Sandoval
2 siblings, 0 replies; 5+ messages in thread
From: Omar Sandoval @ 2014-09-30 22:01 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, linux-btrfs, linux-kernel
Cc: David Sterba, Zach Brown
Several casts of ioctl fields from userspace are missing the __user annotation.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
---
fs/btrfs/ioctl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 8a8e298..0f9a5a1 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2176,7 +2176,7 @@ static noinline int btrfs_ioctl_tree_search_v2(struct file *file,
inode = file_inode(file);
ret = search_ioctl(inode, &args.key, &buf_size,
- (char *)(&uarg->buf[0]));
+ (char __user *)(&uarg->buf[0]));
if (ret == 0 && copy_to_user(&uarg->key, &args.key, sizeof(args.key)))
ret = -EFAULT;
else if (ret == -EOVERFLOW &&
@@ -4247,7 +4247,7 @@ static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg)
ipath->fspath->val[i] = rel_ptr;
}
- ret = copy_to_user((void *)(unsigned long)ipa->fspath,
+ ret = copy_to_user((void __user *)(unsigned long)ipa->fspath,
(void *)(unsigned long)ipath->fspath, size);
if (ret) {
ret = -EFAULT;
@@ -4322,7 +4322,7 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_root *root,
if (ret < 0)
goto out;
- ret = copy_to_user((void *)(unsigned long)loi->inodes,
+ ret = copy_to_user((void __user *)(unsigned long)loi->inodes,
(void *)(unsigned long)inodes, size);
if (ret)
ret = -EFAULT;
--
2.1.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 3/3] btrfs: fix sparse lock context warnings
2014-09-30 22:01 [PATCH v2 0/3] btrfs: fix several sparse warnings Omar Sandoval
2014-09-30 22:01 ` [PATCH v2 1/3] btrfs: replace open-coded kernel_write Omar Sandoval
2014-09-30 22:01 ` [PATCH v2 2/3] btrfs: fix sparse address space warnings Omar Sandoval
@ 2014-09-30 22:01 ` Omar Sandoval
2 siblings, 0 replies; 5+ messages in thread
From: Omar Sandoval @ 2014-09-30 22:01 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, linux-btrfs, linux-kernel
Cc: David Sterba, Zach Brown
Fix several sparse warnings that can easily be addressed with context
annotations. These annotations also provide some sort of documentation for the
internal helper functions.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
---
fs/btrfs/extent-tree.c | 1 +
fs/btrfs/extent_io.c | 2 +-
fs/btrfs/free-space-cache.c | 1 +
fs/btrfs/locking.c | 1 +
4 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3efe1c3..281f30f 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6387,6 +6387,7 @@ static struct btrfs_block_group_cache *
btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
struct btrfs_free_cluster *cluster,
int delalloc)
+__acquires(&cluster->refill_lock)
{
struct btrfs_block_group_cache *used_bg;
bool locked = false;
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index af0359d..cc6b1fc 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4775,8 +4775,8 @@ static inline void btrfs_release_extent_buffer_rcu(struct rcu_head *head)
__free_extent_buffer(eb);
}
-/* Expects to have eb->eb_lock already held */
static int release_extent_buffer(struct extent_buffer *eb)
+__releases(&eb->refs_lock)
{
WARN_ON(atomic_read(&eb->refs) == 0);
if (atomic_dec_and_test(&eb->refs)) {
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 2b0a627..41c6cd5 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1838,6 +1838,7 @@ static struct btrfs_free_space_op free_space_op = {
static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl,
struct btrfs_free_space *info)
+__must_hold(&ctl->tree_lock)
{
struct btrfs_free_space *bitmap_info;
struct btrfs_block_group_cache *block_group = NULL;
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 5665d21..47bdc2c 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -222,6 +222,7 @@ void btrfs_tree_read_unlock_blocking(struct extent_buffer *eb)
* blocking readers or writers
*/
void btrfs_tree_lock(struct extent_buffer *eb)
+__acquires(&eb->lock)
{
again:
wait_event(eb->read_lock_wq, atomic_read(&eb->blocking_readers) == 0);
--
2.1.1
^ permalink raw reply related [flat|nested] 5+ messages in thread