linux-2.6.18: cleanup to blkback and blktap
PATCH 1/1 linux-2.6.18: cleanup to blkback and blktap
Remove unused/unneccessary fields of their pending_req_t structures, and reduce the width of those structures' nr_pages field.
Move loop-invariant grant table flags calculation out of loops (also in scsiback).
drivers/xen/blkback/blkback.c +11 -12
@@ -75,10 +75,9 @@ module_param(debug_lvl, int, 0644);typedef struct {blkif_t *blkif;u64 id; -int nr_pages;atomic_t pendcnt; +unsigned short nr_pages;unsigned short operation; -int status;struct list_head free_list; }pending_req_t ;
@@ -257,22 +256,24 @@ int blkif_schedule(void *arg)static void __end_block_io_op (pending_req_t *pending_req,int error) { +int status =BLKIF_RSP_OKAY ; +/* An error fails the entire request. */ if ((pending_req->operation ==BLKIF_OP_WRITE_BARRIER ) && (error == -EOPNOTSUPP )) {DPRINTK ("blkback: write barrier op failed, not supported\n" );blkback_barrier (XBT_NIL , pending_req->blkif->be,0 ); - pending_req->status =BLKIF_RSP_EOPNOTSUPP ; + status =BLKIF_RSP_EOPNOTSUPP ; }else if (error) {DPRINTK ("Buffer not up-to-date at end of operation, " "error=%d\n" , error); - pending_req->status =BLKIF_RSP_ERROR ; + status =BLKIF_RSP_ERROR ; }if (atomic_dec_and_test (&pending_req->pendcnt)) {fast_flush_area (pending_req);make_response (pending_req->blkif, pending_req->id, - pending_req->operation, pending_req->status); + pending_req->operation, status);blkif_put (pending_req->blkif);free_req (pending_req); }
@@ -389,7 +390,6 @@ static void dispatch_rw_block_io(blkif_t blkif_request_t *req, pending_req_t *pending_req) { -extern void ll_rw_block (int rw,int nr,struct buffer_head * bhs[]);struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST ];struct phys_req preq; struct {
@@ -397,6 +397,7 @@ static void dispatch_rw_block_io(blkif_t } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST ];unsigned int nseg;struct bio *bio =NULL ; +uint32_t flags;int ret, i;int operation;
@@ -430,12 +431,13 @@ static void dispatch_rw_block_io(blkif_t pending_req->blkif = blkif; pending_req->id = req->id; pending_req->operation = req->operation; - pending_req->status =BLKIF_RSP_OKAY ; pending_req->nr_pages = nseg; -for (i =0 ; i < nseg; i++) { -uint32_t flags; + flags = GNTMAP_host_map; +if (operation !=READ ) + flags |= GNTMAP_readonly; +for (i =0 ; i < nseg; i++) { seg[i].nsec = req->seg[i].last_sect - req->seg[i].first_sect +1 ;
@@ -444,9 +446,6 @@ static void dispatch_rw_block_io(blkif_t goto fail_response; preq.nr_sects += seg[i].nsec; - flags = GNTMAP_host_map; -if (operation !=READ ) - flags |= GNTMAP_readonly;gnttab_set_map_op (&map[i],vaddr (pending_req, i), flags, req->seg[i].gref, blkif->domid); }
drivers/xen/blktap/blktap.c +18 -28
115 lines not on this page · raw message
drivers/xen/scsiback/scsiback.c +5 -5
@@ -274,14 +274,14 @@ static int scsiback_gnttab_data_map(vscsreturn -ENOMEM ; } -for (i =0 ; i < nr_segments; i++) { - flags = GNTMAP_host_map; -if (write) - flags |= GNTMAP_readonly; + flags = GNTMAP_host_map; +if (write) + flags |= GNTMAP_readonly; + +for (i =0 ; i < nr_segments; i++)gnttab_set_map_op (&map[i],vaddr (pending_req, i), flags, ring_req->seg[i].gref, info->domid); - } err =HYPERVISOR_grant_table_op (GNTTABOP_map_grant_ref, map, nr_segments);BUG_ON (err);
Subject: cleanup to blkback and blktap
Remove unused/unneccessary fields of their pending_req_t structures, and reduce the width of those structures' nr_pages field.
Move loop-invariant grant table flags calculation out of loops (also in scsiback).
drivers/xen/blkback/blkback.c +11 -12
@@ -75,10 +75,9 @@ module_param(debug_lvl, int, 0644);typedef struct {blkif_t *blkif;u64 id; -int nr_pages;atomic_t pendcnt; +unsigned short nr_pages;unsigned short operation; -int status;struct list_head free_list; }pending_req_t ;
@@ -257,22 +256,24 @@ int blkif_schedule(void *arg)static void __end_block_io_op (pending_req_t *pending_req,int error) { +int status =BLKIF_RSP_OKAY ; +/* An error fails the entire request. */ if ((pending_req->operation ==BLKIF_OP_WRITE_BARRIER ) && (error == -EOPNOTSUPP )) {DPRINTK ("blkback: write barrier op failed, not supported\n" );blkback_barrier (XBT_NIL , pending_req->blkif->be,0 ); - pending_req->status =BLKIF_RSP_EOPNOTSUPP ; + status =BLKIF_RSP_EOPNOTSUPP ; }else if (error) {DPRINTK ("Buffer not up-to-date at end of operation, " "error=%d\n" , error); - pending_req->status =BLKIF_RSP_ERROR ; + status =BLKIF_RSP_ERROR ; }if (atomic_dec_and_test (&pending_req->pendcnt)) {fast_flush_area (pending_req);make_response (pending_req->blkif, pending_req->id, - pending_req->operation, pending_req->status); + pending_req->operation, status);blkif_put (pending_req->blkif);free_req (pending_req); }
@@ -389,7 +390,6 @@ static void dispatch_rw_block_io(blkif_t blkif_request_t *req, pending_req_t *pending_req) { -extern void ll_rw_block (int rw,int nr,struct buffer_head * bhs[]);struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST ];struct phys_req preq; struct {
@@ -397,6 +397,7 @@ static void dispatch_rw_block_io(blkif_t } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST ];unsigned int nseg;struct bio *bio =NULL ; +uint32_t flags;int ret, i;int operation;
@@ -430,12 +431,13 @@ static void dispatch_rw_block_io(blkif_t pending_req->blkif = blkif; pending_req->id = req->id; pending_req->operation = req->operation; - pending_req->status =BLKIF_RSP_OKAY ; pending_req->nr_pages = nseg; -for (i =0 ; i < nseg; i++) { -uint32_t flags; + flags = GNTMAP_host_map; +if (operation !=READ ) + flags |= GNTMAP_readonly; +for (i =0 ; i < nseg; i++) { seg[i].nsec = req->seg[i].last_sect - req->seg[i].first_sect +1 ;
@@ -444,9 +446,6 @@ static void dispatch_rw_block_io(blkif_t goto fail_response; preq.nr_sects += seg[i].nsec; - flags = GNTMAP_host_map; -if (operation !=READ ) - flags |= GNTMAP_readonly;gnttab_set_map_op (&map[i],vaddr (pending_req, i), flags, req->seg[i].gref, blkif->domid); }
drivers/xen/blktap/blktap.c +18 -28
115 lines not on this page · raw message
drivers/xen/scsiback/scsiback.c +5 -5
@@ -274,14 +274,14 @@ static int scsiback_gnttab_data_map(vscsreturn -ENOMEM ; } -for (i =0 ; i < nr_segments; i++) { - flags = GNTMAP_host_map; -if (write) - flags |= GNTMAP_readonly; + flags = GNTMAP_host_map; +if (write) + flags |= GNTMAP_readonly; + +for (i =0 ; i < nr_segments; i++)gnttab_set_map_op (&map[i],vaddr (pending_req, i), flags, ring_req->seg[i].gref, info->domid); - } err =HYPERVISOR_grant_table_op (GNTTABOP_map_grant_ref, map, nr_segments);BUG_ON (err);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · Jan Beulich
Remove unused/unneccessary fields of their
pending_req_tstructures, and reduce the width of those structures'nr_pagesfield.Move loop-invariant grant table flags calculation out of loops (also in scsiback).
Signed-off-by Jan Beulich <[email protected]>
Ack, but just been looking. Regarding blktap, 2.6.32 and later even looks similar regarding the pending_req_t (now blktap_request).
Daniel