diff mbox

KVM: set no_llseek in stat_fops_per_vm

Message ID ad61d4443d93fcfb442bd6367eefde3e04201bef.1493801155.git.geliangtang@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Geliang Tang May 6, 2017, 3:37 p.m. UTC
In vm_stat_get_per_vm_fops and vcpu_stat_get_per_vm_fops, since we
use nonseekable_open() to open, we should use no_llseek() to seek,
not generic_file_llseek().

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 virt/kvm/kvm_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini May 9, 2017, 9:46 a.m. UTC | #1
On 06/05/2017 17:37, Geliang Tang wrote:
> In vm_stat_get_per_vm_fops and vcpu_stat_get_per_vm_fops, since we
> use nonseekable_open() to open, we should use no_llseek() to seek,
> not generic_file_llseek().
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

This is not strictly necessary, nonseekable_open bypasses f_op->llseek
due to this code in vfs_llseek:

        fn = no_llseek;
        if (file->f_mode & FMODE_LSEEK) {
                if (file->f_op->llseek)
                        fn = file->f_op->llseek;
        }
        return fn(file, offset, whence);

But it's a good thing to do anyway, so I'm applying it.

Paolo

> ---
>  virt/kvm/kvm_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index c2bb6ab..798f567 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3689,7 +3689,7 @@ static const struct file_operations vm_stat_get_per_vm_fops = {
>  	.release = kvm_debugfs_release,
>  	.read    = simple_attr_read,
>  	.write   = simple_attr_write,
> -	.llseek  = generic_file_llseek,
> +	.llseek  = no_llseek,
>  };
>  
>  static int vcpu_stat_get_per_vm(void *data, u64 *val)
> @@ -3734,7 +3734,7 @@ static const struct file_operations vcpu_stat_get_per_vm_fops = {
>  	.release = kvm_debugfs_release,
>  	.read    = simple_attr_read,
>  	.write   = simple_attr_write,
> -	.llseek  = generic_file_llseek,
> +	.llseek  = no_llseek,
>  };
>  
>  static const struct file_operations *stat_fops_per_vm[] = {
>
diff mbox

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index c2bb6ab..798f567 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3689,7 +3689,7 @@  static const struct file_operations vm_stat_get_per_vm_fops = {
 	.release = kvm_debugfs_release,
 	.read    = simple_attr_read,
 	.write   = simple_attr_write,
-	.llseek  = generic_file_llseek,
+	.llseek  = no_llseek,
 };
 
 static int vcpu_stat_get_per_vm(void *data, u64 *val)
@@ -3734,7 +3734,7 @@  static const struct file_operations vcpu_stat_get_per_vm_fops = {
 	.release = kvm_debugfs_release,
 	.read    = simple_attr_read,
 	.write   = simple_attr_write,
-	.llseek  = generic_file_llseek,
+	.llseek  = no_llseek,
 };
 
 static const struct file_operations *stat_fops_per_vm[] = {