diff mbox

[2/2] block/nfs: refuse readahead if cache.direct is on

Message ID 1463494315-12578-3-git-send-email-pl@kamp.de
State New
Headers show

Commit Message

Peter Lieven May 17, 2016, 2:11 p.m. UTC
Signed-off-by: Peter Lieven <pl@kamp.de>
---
 block/nfs.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jeff Cody May 18, 2016, 1:28 p.m. UTC | #1
On Tue, May 17, 2016 at 04:11:55PM +0200, Peter Lieven wrote:
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  block/nfs.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/block/nfs.c b/block/nfs.c
> index 975510f..8b73a35 100644
> --- a/block/nfs.c
> +++ b/block/nfs.c
> @@ -331,6 +331,11 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,
>              nfs_set_tcp_syncnt(client->context, val);
>  #ifdef LIBNFS_FEATURE_READAHEAD
>          } else if (!strcmp(qp->p[i].name, "readahead")) {
> +            if (open_flags & BDRV_O_NOCACHE) {
> +                error_setg(errp, "Cannot enable NFS readahead "
> +                                 "if cache.direct = on");
> +                goto fail;
> +            }
>              if (val > QEMU_NFS_MAX_READAHEAD_SIZE) {
>                  error_report("NFS Warning: Truncating NFS readahead"
>                               " size to %d", QEMU_NFS_MAX_READAHEAD_SIZE);
> -- 
> 1.9.1
>

Do we to check for cache mode changes now in nfs_reopen_prepare()?
Peter Lieven May 19, 2016, 6:03 a.m. UTC | #2
Am 18.05.2016 um 15:28 schrieb Jeff Cody:
> On Tue, May 17, 2016 at 04:11:55PM +0200, Peter Lieven wrote:
>> Signed-off-by: Peter Lieven <pl@kamp.de>
>> ---
>>   block/nfs.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/block/nfs.c b/block/nfs.c
>> index 975510f..8b73a35 100644
>> --- a/block/nfs.c
>> +++ b/block/nfs.c
>> @@ -331,6 +331,11 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,
>>               nfs_set_tcp_syncnt(client->context, val);
>>   #ifdef LIBNFS_FEATURE_READAHEAD
>>           } else if (!strcmp(qp->p[i].name, "readahead")) {
>> +            if (open_flags & BDRV_O_NOCACHE) {
>> +                error_setg(errp, "Cannot enable NFS readahead "
>> +                                 "if cache.direct = on");
>> +                goto fail;
>> +            }
>>               if (val > QEMU_NFS_MAX_READAHEAD_SIZE) {
>>                   error_report("NFS Warning: Truncating NFS readahead"
>>                                " size to %d", QEMU_NFS_MAX_READAHEAD_SIZE);
>> -- 
>> 1.9.1
>>
> Do we to check for cache mode changes now in nfs_reopen_prepare()?

Good point. I guess I have to error out in bdrv_reopen_prepare if we change the cache.direct from off to on and
have readahead or pagecache enabled. Will send an update.

Thanks,
Peter
diff mbox

Patch

diff --git a/block/nfs.c b/block/nfs.c
index 975510f..8b73a35 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -331,6 +331,11 @@  static int64_t nfs_client_open(NFSClient *client, const char *filename,
             nfs_set_tcp_syncnt(client->context, val);
 #ifdef LIBNFS_FEATURE_READAHEAD
         } else if (!strcmp(qp->p[i].name, "readahead")) {
+            if (open_flags & BDRV_O_NOCACHE) {
+                error_setg(errp, "Cannot enable NFS readahead "
+                                 "if cache.direct = on");
+                goto fail;
+            }
             if (val > QEMU_NFS_MAX_READAHEAD_SIZE) {
                 error_report("NFS Warning: Truncating NFS readahead"
                              " size to %d", QEMU_NFS_MAX_READAHEAD_SIZE);