diff mbox

[23/23] vfs: Teach readahead to use the file_hotplug_lock

Message ID 1243893048-17031-23-git-send-email-ebiederm@xmission.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Eric W. Biederman June 1, 2009, 9:50 p.m. UTC
From: Eric W. Biederman <ebiederm@maxwell.aristanetworks.com>

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
 mm/filemap.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

Comments

Badari Pulavarty June 3, 2009, 11:25 p.m. UTC | #1
On Mon, 2009-06-01 at 14:50 -0700, Eric W. Biederman wrote:
> From: Eric W. Biederman <ebiederm@maxwell.aristanetworks.com>
> 
> Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
> ---
>  mm/filemap.c |   25 ++++++++++++++++---------
>  1 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 379ff0b..5016aa5 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1402,16 +1402,23 @@ SYSCALL_DEFINE(readahead)(int fd, loff_t offset, size_t count)
>  
>  	ret = -EBADF;
>  	file = fget(fd);
> -	if (file) {
> -		if (file->f_mode & FMODE_READ) {
> -			struct address_space *mapping = file->f_mapping;
> -			pgoff_t start = offset >> PAGE_CACHE_SHIFT;
> -			pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
> -			unsigned long len = end - start + 1;
> -			ret = do_readahead(mapping, file, start, len);
> -		}
> -		fput(file);
> +	if (!file)
> +		goto out;
> +
> +	if (!(file->f_mode & FMODE_READ))
> +		goto out_fput;
> +

To be consistent with others, don't you want to do
	  ret = -EIO;
here ?
> +	if (file_hotplug_read_trylock(file)) {
> +		struct address_space *mapping = file->f_mapping;
> +		pgoff_t start = offset >> PAGE_CACHE_SHIFT;
> +		pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
> +		unsigned long len = end - start + 1;
> +		ret = do_readahead(mapping, file, start, len);
> +		file_hotplug_read_unlock(file);
>  	}
> +out_fput:
> +	fput(file);
> +out:
>  	return ret;
>  }
>  #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS

Thanks,
Badari

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/mm/filemap.c b/mm/filemap.c
index 379ff0b..5016aa5 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1402,16 +1402,23 @@  SYSCALL_DEFINE(readahead)(int fd, loff_t offset, size_t count)
 
 	ret = -EBADF;
 	file = fget(fd);
-	if (file) {
-		if (file->f_mode & FMODE_READ) {
-			struct address_space *mapping = file->f_mapping;
-			pgoff_t start = offset >> PAGE_CACHE_SHIFT;
-			pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
-			unsigned long len = end - start + 1;
-			ret = do_readahead(mapping, file, start, len);
-		}
-		fput(file);
+	if (!file)
+		goto out;
+
+	if (!(file->f_mode & FMODE_READ))
+		goto out_fput;
+
+	if (file_hotplug_read_trylock(file)) {
+		struct address_space *mapping = file->f_mapping;
+		pgoff_t start = offset >> PAGE_CACHE_SHIFT;
+		pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
+		unsigned long len = end - start + 1;
+		ret = do_readahead(mapping, file, start, len);
+		file_hotplug_read_unlock(file);
 	}
+out_fput:
+	fput(file);
+out:
 	return ret;
 }
 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS