~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/block/xen-blkfront.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
        struct blk_shadow shadow[BLK_MAX_RING_SIZE];
100
100
        unsigned long shadow_free;
101
101
        unsigned int feature_flush;
 
102
        unsigned int flush_op;
102
103
        int is_ready;
103
104
};
104
105
 
124
125
#define BLKIF_MINOR_EXT(dev) ((dev)&(~EXTENDED))
125
126
#define EMULATED_HD_DISK_MINOR_OFFSET (0)
126
127
#define EMULATED_HD_DISK_NAME_OFFSET (EMULATED_HD_DISK_MINOR_OFFSET / 256)
127
 
#define EMULATED_SD_DISK_MINOR_OFFSET (EMULATED_HD_DISK_MINOR_OFFSET + (4 * 16))
128
 
#define EMULATED_SD_DISK_NAME_OFFSET (EMULATED_HD_DISK_NAME_OFFSET + 4)
 
128
#define EMULATED_SD_DISK_MINOR_OFFSET (0)
 
129
#define EMULATED_SD_DISK_NAME_OFFSET (EMULATED_SD_DISK_MINOR_OFFSET / 256)
129
130
 
130
131
#define DEV_NAME        "xvd"   /* name in /dev */
131
132
 
253
254
 
254
255
/*
255
256
 * Generate a Xen blkfront IO request from a blk layer request.  Reads
256
 
 * and writes are handled as expected.  Since we lack a loose flush
257
 
 * request, we map flushes into a full ordered barrier.
 
257
 * and writes are handled as expected.
258
258
 *
259
259
 * @req: a request struct
260
260
 */
296
296
 
297
297
        if (req->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
298
298
                /*
299
 
                 * Ideally we could just do an unordered
300
 
                 * flush-to-disk, but all we have is a full write
301
 
                 * barrier at the moment.  However, a barrier write is
 
299
                 * Ideally we can do an unordered flush-to-disk. In case the
 
300
                 * backend onlysupports barriers, use that. A barrier request
302
301
                 * a superset of FUA, so we can implement it the same
303
302
                 * way.  (It's also a FLUSH+FUA, since it is
304
303
                 * guaranteed ordered WRT previous writes.)
305
304
                 */
306
 
                ring_req->operation = BLKIF_OP_WRITE_BARRIER;
 
305
                ring_req->operation = info->flush_op;
307
306
        }
308
307
 
309
308
        ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg);
436
435
static void xlvbd_flush(struct blkfront_info *info)
437
436
{
438
437
        blk_queue_flush(info->rq, info->feature_flush);
439
 
        printk(KERN_INFO "blkfront: %s: barriers %s\n",
 
438
        printk(KERN_INFO "blkfront: %s: %s: %s\n",
440
439
               info->gd->disk_name,
 
440
               info->flush_op == BLKIF_OP_WRITE_BARRIER ?
 
441
                "barrier" : (info->flush_op == BLKIF_OP_FLUSH_DISKCACHE ?
 
442
                "flush diskcache" : "barrier or flush"),
441
443
               info->feature_flush ? "enabled" : "disabled");
442
444
}
443
445
 
530
532
                minor = BLKIF_MINOR_EXT(info->vdevice);
531
533
                nr_parts = PARTS_PER_EXT_DISK;
532
534
                offset = minor / nr_parts;
533
 
                if (xen_hvm_domain() && offset <= EMULATED_HD_DISK_NAME_OFFSET + 4)
 
535
                if (xen_hvm_domain() && offset < EMULATED_HD_DISK_NAME_OFFSET + 4)
534
536
                        printk(KERN_WARNING "blkfront: vdevice 0x%x might conflict with "
535
537
                                        "emulated IDE disks,\n\t choose an xvd device name"
536
538
                                        "from xvde on\n", info->vdevice);
732
734
 
733
735
                error = (bret->status == BLKIF_RSP_OKAY) ? 0 : -EIO;
734
736
                switch (bret->operation) {
 
737
                case BLKIF_OP_FLUSH_DISKCACHE:
735
738
                case BLKIF_OP_WRITE_BARRIER:
736
739
                        if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) {
737
 
                                printk(KERN_WARNING "blkfront: %s: write barrier op failed\n",
 
740
                                printk(KERN_WARNING "blkfront: %s: write %s op failed\n",
 
741
                                       info->flush_op == BLKIF_OP_WRITE_BARRIER ?
 
742
                                       "barrier" :  "flush disk cache",
738
743
                                       info->gd->disk_name);
739
744
                                error = -EOPNOTSUPP;
740
745
                        }
741
746
                        if (unlikely(bret->status == BLKIF_RSP_ERROR &&
742
747
                                     info->shadow[id].req.nr_segments == 0)) {
743
 
                                printk(KERN_WARNING "blkfront: %s: empty write barrier op failed\n",
 
748
                                printk(KERN_WARNING "blkfront: %s: empty write %s op failed\n",
 
749
                                       info->flush_op == BLKIF_OP_WRITE_BARRIER ?
 
750
                                       "barrier" :  "flush disk cache",
744
751
                                       info->gd->disk_name);
745
752
                                error = -EOPNOTSUPP;
746
753
                        }
748
755
                                if (error == -EOPNOTSUPP)
749
756
                                        error = 0;
750
757
                                info->feature_flush = 0;
 
758
                                info->flush_op = 0;
751
759
                                xlvbd_flush(info);
752
760
                        }
753
761
                        /* fall through */
1155
1163
        unsigned long sector_size;
1156
1164
        unsigned int binfo;
1157
1165
        int err;
1158
 
        int barrier;
 
1166
        int barrier, flush;
1159
1167
 
1160
1168
        switch (info->connected) {
1161
1169
        case BLKIF_STATE_CONNECTED:
1195
1203
                return;
1196
1204
        }
1197
1205
 
 
1206
        info->feature_flush = 0;
 
1207
        info->flush_op = 0;
 
1208
 
1198
1209
        err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1199
 
                            "feature-barrier", "%lu", &barrier,
 
1210
                            "feature-barrier", "%d", &barrier,
1200
1211
                            NULL);
1201
1212
 
1202
1213
        /*
1206
1217
         *
1207
1218
         * If there are barriers, then we use flush.
1208
1219
         */
1209
 
        info->feature_flush = 0;
1210
 
 
1211
 
        if (!err && barrier)
 
1220
        if (!err && barrier) {
1212
1221
                info->feature_flush = REQ_FLUSH | REQ_FUA;
 
1222
                info->flush_op = BLKIF_OP_WRITE_BARRIER;
 
1223
        }
 
1224
        /*
 
1225
         * And if there is "feature-flush-cache" use that above
 
1226
         * barriers.
 
1227
         */
 
1228
        err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
 
1229
                            "feature-flush-cache", "%d", &flush,
 
1230
                            NULL);
1213
1231
 
 
1232
        if (!err && flush) {
 
1233
                info->feature_flush = REQ_FLUSH;
 
1234
                info->flush_op = BLKIF_OP_FLUSH_DISKCACHE;
 
1235
        }
 
1236
                
1214
1237
        err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size);
1215
1238
        if (err) {
1216
1239
                xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s",