block/nfs: add knob to set readahead
v3 cover block/nfs: add knob to set readahead
upcoming libnfs will feature internal readahead support. Add a knob to pass the optional readahead value as a URL parameter.
This series fixes also the incorrect usage of strncmp and atoi.
v2->v3: - use parse_uint_full [Eric]
- split patch [Eric]
v1->v2: use strtol instead of atoi [Eric]
Peter Lieven (2):
block/nfs: fix url parameter checking
block/nfs: add knob to set readahead
block/nfs.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v3 1/2 block/nfs: fix url parameter checking
this patch fixes the incorrect usage of strncmp and adds simple error checking by means of parse_uint_full instead of atoi for the supplied URL parameters.
--- block/nfs.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
block/nfs.c +12 -6
@@ -304,17 +304,23 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename, qp =query_params_parse (uri->query);for (i =0 ; i < qp->n; i++) { +unsigned long long val;if (!qp->p[i].value) {error_setg (errp,"Value for NFS parameter expected: %s" , qp->p[i].name); goto fail; } -if (!strncmp (qp->p[i].name,"uid" ,3 )) { -nfs_set_uid (client->context,atoi (qp->p[i].value)); - }else if (!strncmp (qp->p[i].name,"gid" ,3 )) { -nfs_set_gid (client->context,atoi (qp->p[i].value)); - }else if (!strncmp (qp->p[i].name,"tcp-syncnt" ,10 )) { -nfs_set_tcp_syncnt (client->context,atoi (qp->p[i].value)); +if (parse_uint_full (qp->p[i].value, &val,0 )) { +error_setg (errp,"Illegal value for NFS parameter: %s" , + qp->p[i].name); + goto fail; + } +if (!strcmp (qp->p[i].name,"uid" )) { +nfs_set_uid (client->context, val); + }else if (!strcmp (qp->p[i].name,"gid" )) { +nfs_set_gid (client->context, val); + }else if (!strcmp (qp->p[i].name,"tcp-syncnt" )) { +nfs_set_tcp_syncnt (client->context, val); }else {error_setg (errp,"Unknown NFS parameter name: %s" , qp->p[i].name);
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCHv3 1/2] block/nfs: fix url parameter checking
block/nfs.c static int64_t nfs_client_open(NFSClient *client, const char *filename, · line 314
Quoted 12 lines · Peter Lieven
this patch fixes the incorrect usage of strncmp and adds simple error checking by means of
parse_uint_fullinstead of atoi for the supplied URL parameters.Signed-off-by Peter Lieven <[email protected]>--- block/nfs.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)block/nfs.c +2
-0+if (parse_uint_full (qp->p[i].value, &val,0 )) { + error_setg(errp, "Illegal value for NFS parameter: %s",
I prefer s/Illegal/Invalid/, as this is not a case of breaking a law.
But that's aesthetic. Whether or not you tweak that choice of wording:
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v3 2/2 block/nfs: add knob to set readahead
In reply to Peter Lievenupcoming libnfs will feature internal readahead support. Add a knob to pass the optional readahead value as a URL parameter.
--- block/nfs.c | 4 ++++ 1 file changed, 4 insertions(+)
block/nfs.c +4 -0
@@ -321,6 +321,10 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,nfs_set_gid (client->context, val); }else if (!strcmp (qp->p[i].name,"tcp-syncnt" )) {nfs_set_tcp_syncnt (client->context, val); +#ifdef LIBNFS_FEATURE_READAHEAD + }else if (!strcmp (qp->p[i].name,"readahead" )) { +nfs_set_readahead (client->context, val); +#endif }else {error_setg (errp,"Unknown NFS parameter name: %s" , qp->p[i].name);
Signature · 1 line
1.7.9.5
Quoted 8 lines · Peter Lieven
upcoming libnfs will feature internal readahead support. Add a knob to pass the optional readahead value as a URL parameter.
Signed-off-by Peter Lieven <[email protected]>--- block/nfs.c | 4 ++++ 1 file changed, 4 insertions(+)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Kevin Wolf
AppliedAm 25.06.2014 um 00:05 hat Peter Lieven geschrieben:
Quoted 6 lines
upcoming libnfs will feature internal readahead support. Add a knob to pass the optional readahead value as a URL parameter.
This series fixes also the incorrect usage of strncmp and atoi.
Thanks, applied to the block branch.
Kevin