aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/block/dcssblk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/block/dcssblk.c')
-rw-r--r--drivers/s390/block/dcssblk.c72
1 files changed, 33 insertions, 39 deletions
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index b1b204c448ed..26ffc6ab441d 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -4,6 +4,9 @@
4 * Authors: Carsten Otte, Stefan Weinhuber, Gerald Schaefer 4 * Authors: Carsten Otte, Stefan Weinhuber, Gerald Schaefer
5 */ 5 */
6 6
7#define KMSG_COMPONENT "dcssblk"
8#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
9
7#include <linux/module.h> 10#include <linux/module.h>
8#include <linux/moduleparam.h> 11#include <linux/moduleparam.h>
9#include <linux/ctype.h> 12#include <linux/ctype.h>
@@ -17,21 +20,11 @@
17#include <linux/interrupt.h> 20#include <linux/interrupt.h>
18#include <asm/s390_rdev.h> 21#include <asm/s390_rdev.h>
19 22
20//#define DCSSBLK_DEBUG /* Debug messages on/off */
21#define DCSSBLK_NAME "dcssblk" 23#define DCSSBLK_NAME "dcssblk"
22#define DCSSBLK_MINORS_PER_DISK 1 24#define DCSSBLK_MINORS_PER_DISK 1
23#define DCSSBLK_PARM_LEN 400 25#define DCSSBLK_PARM_LEN 400
24#define DCSS_BUS_ID_SIZE 20 26#define DCSS_BUS_ID_SIZE 20
25 27
26#ifdef DCSSBLK_DEBUG
27#define PRINT_DEBUG(x...) printk(KERN_DEBUG DCSSBLK_NAME " debug: " x)
28#else
29#define PRINT_DEBUG(x...) do {} while (0)
30#endif
31#define PRINT_INFO(x...) printk(KERN_INFO DCSSBLK_NAME " info: " x)
32#define PRINT_WARN(x...) printk(KERN_WARNING DCSSBLK_NAME " warning: " x)
33#define PRINT_ERR(x...) printk(KERN_ERR DCSSBLK_NAME " error: " x)
34
35static int dcssblk_open(struct block_device *bdev, fmode_t mode); 28static int dcssblk_open(struct block_device *bdev, fmode_t mode);
36static int dcssblk_release(struct gendisk *disk, fmode_t mode); 29static int dcssblk_release(struct gendisk *disk, fmode_t mode);
37static int dcssblk_make_request(struct request_queue *q, struct bio *bio); 30static int dcssblk_make_request(struct request_queue *q, struct bio *bio);
@@ -262,10 +255,9 @@ dcssblk_is_continuous(struct dcssblk_dev_info *dev_info)
262 /* check continuity */ 255 /* check continuity */
263 for (i = 0; i < dev_info->num_of_segments - 1; i++) { 256 for (i = 0; i < dev_info->num_of_segments - 1; i++) {
264 if ((sort_list[i].end + 1) != sort_list[i+1].start) { 257 if ((sort_list[i].end + 1) != sort_list[i+1].start) {
265 PRINT_ERR("Segment %s is not contiguous with " 258 pr_err("Adjacent DCSSs %s and %s are not "
266 "segment %s\n", 259 "contiguous\n", sort_list[i].segment_name,
267 sort_list[i].segment_name, 260 sort_list[i+1].segment_name);
268 sort_list[i+1].segment_name);
269 rc = -EINVAL; 261 rc = -EINVAL;
270 goto out; 262 goto out;
271 } 263 }
@@ -276,10 +268,10 @@ dcssblk_is_continuous(struct dcssblk_dev_info *dev_info)
276 !(sort_list[i+1].segment_type & 268 !(sort_list[i+1].segment_type &
277 SEGMENT_EXCLUSIVE) || 269 SEGMENT_EXCLUSIVE) ||
278 (sort_list[i+1].segment_type == SEG_TYPE_ER)) { 270 (sort_list[i+1].segment_type == SEG_TYPE_ER)) {
279 PRINT_ERR("Segment %s has different type from " 271 pr_err("DCSS %s and DCSS %s have "
280 "segment %s\n", 272 "incompatible types\n",
281 sort_list[i].segment_name, 273 sort_list[i].segment_name,
282 sort_list[i+1].segment_name); 274 sort_list[i+1].segment_name);
283 rc = -EINVAL; 275 rc = -EINVAL;
284 goto out; 276 goto out;
285 } 277 }
@@ -381,8 +373,9 @@ dcssblk_shared_store(struct device *dev, struct device_attribute *attr, const ch
381 } else if (inbuf[0] == '0') { 373 } else if (inbuf[0] == '0') {
382 /* reload segments in exclusive mode */ 374 /* reload segments in exclusive mode */
383 if (dev_info->segment_type == SEG_TYPE_SC) { 375 if (dev_info->segment_type == SEG_TYPE_SC) {
384 PRINT_ERR("Segment type SC (%s) cannot be loaded in " 376 pr_err("DCSS %s is of type SC and cannot be "
385 "non-shared mode\n", dev_info->segment_name); 377 "loaded as exclusive-writable\n",
378 dev_info->segment_name);
386 rc = -EINVAL; 379 rc = -EINVAL;
387 goto out; 380 goto out;
388 } 381 }
@@ -405,9 +398,8 @@ dcssblk_shared_store(struct device *dev, struct device_attribute *attr, const ch
405 goto out; 398 goto out;
406 399
407removeseg: 400removeseg:
408 PRINT_ERR("Could not reload segment(s) of the device %s, removing " 401 pr_err("DCSS device %s is removed after a failed access mode "
409 "segment(s) now!\n", 402 "change\n", dev_info->segment_name);
410 dev_info->segment_name);
411 temp = entry; 403 temp = entry;
412 list_for_each_entry(entry, &dev_info->seg_list, lh) { 404 list_for_each_entry(entry, &dev_info->seg_list, lh) {
413 if (entry != temp) 405 if (entry != temp)
@@ -455,17 +447,17 @@ dcssblk_save_store(struct device *dev, struct device_attribute *attr, const char
455 if (inbuf[0] == '1') { 447 if (inbuf[0] == '1') {
456 if (atomic_read(&dev_info->use_count) == 0) { 448 if (atomic_read(&dev_info->use_count) == 0) {
457 // device is idle => we save immediately 449 // device is idle => we save immediately
458 PRINT_INFO("Saving segment(s) of the device %s\n", 450 pr_info("All DCSSs that map to device %s are "
459 dev_info->segment_name); 451 "saved\n", dev_info->segment_name);
460 list_for_each_entry(entry, &dev_info->seg_list, lh) { 452 list_for_each_entry(entry, &dev_info->seg_list, lh) {
461 segment_save(entry->segment_name); 453 segment_save(entry->segment_name);
462 } 454 }
463 } else { 455 } else {
464 // device is busy => we save it when it becomes 456 // device is busy => we save it when it becomes
465 // idle in dcssblk_release 457 // idle in dcssblk_release
466 PRINT_INFO("Device %s is currently busy, segment(s) " 458 pr_info("Device %s is in use, its DCSSs will be "
467 "will be saved when it becomes idle...\n", 459 "saved when it becomes idle\n",
468 dev_info->segment_name); 460 dev_info->segment_name);
469 dev_info->save_pending = 1; 461 dev_info->save_pending = 1;
470 } 462 }
471 } else if (inbuf[0] == '0') { 463 } else if (inbuf[0] == '0') {
@@ -473,9 +465,9 @@ dcssblk_save_store(struct device *dev, struct device_attribute *attr, const char
473 // device is busy & the user wants to undo his save 465 // device is busy & the user wants to undo his save
474 // request 466 // request
475 dev_info->save_pending = 0; 467 dev_info->save_pending = 0;
476 PRINT_INFO("Pending save for segment(s) of the device " 468 pr_info("A pending save request for device %s "
477 "%s deactivated\n", 469 "has been canceled\n",
478 dev_info->segment_name); 470 dev_info->segment_name);
479 } 471 }
480 } else { 472 } else {
481 up_write(&dcssblk_devices_sem); 473 up_write(&dcssblk_devices_sem);
@@ -615,9 +607,8 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
615 607
616 seg_byte_size = (dev_info->end - dev_info->start + 1); 608 seg_byte_size = (dev_info->end - dev_info->start + 1);
617 set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors 609 set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors
618 PRINT_INFO("Loaded segment(s) %s, size = %lu Byte, " 610 pr_info("Loaded %s with total size %lu bytes and capacity %lu "
619 "capacity = %lu (512 Byte) sectors\n", local_buf, 611 "sectors\n", local_buf, seg_byte_size, seg_byte_size >> 9);
620 seg_byte_size, seg_byte_size >> 9);
621 612
622 dev_info->save_pending = 0; 613 dev_info->save_pending = 0;
623 dev_info->is_shared = 1; 614 dev_info->is_shared = 1;
@@ -745,13 +736,15 @@ dcssblk_remove_store(struct device *dev, struct device_attribute *attr, const ch
745 dev_info = dcssblk_get_device_by_name(local_buf); 736 dev_info = dcssblk_get_device_by_name(local_buf);
746 if (dev_info == NULL) { 737 if (dev_info == NULL) {
747 up_write(&dcssblk_devices_sem); 738 up_write(&dcssblk_devices_sem);
748 PRINT_WARN("Device %s is not loaded!\n", local_buf); 739 pr_warning("Device %s cannot be removed because it is not a "
740 "known device\n", local_buf);
749 rc = -ENODEV; 741 rc = -ENODEV;
750 goto out_buf; 742 goto out_buf;
751 } 743 }
752 if (atomic_read(&dev_info->use_count) != 0) { 744 if (atomic_read(&dev_info->use_count) != 0) {
753 up_write(&dcssblk_devices_sem); 745 up_write(&dcssblk_devices_sem);
754 PRINT_WARN("Device %s is in use!\n", local_buf); 746 pr_warning("Device %s cannot be removed while it is in "
747 "use\n", local_buf);
755 rc = -EBUSY; 748 rc = -EBUSY;
756 goto out_buf; 749 goto out_buf;
757 } 750 }
@@ -808,8 +801,8 @@ dcssblk_release(struct gendisk *disk, fmode_t mode)
808 down_write(&dcssblk_devices_sem); 801 down_write(&dcssblk_devices_sem);
809 if (atomic_dec_and_test(&dev_info->use_count) 802 if (atomic_dec_and_test(&dev_info->use_count)
810 && (dev_info->save_pending)) { 803 && (dev_info->save_pending)) {
811 PRINT_INFO("Device %s became idle and is being saved now\n", 804 pr_info("Device %s has become idle and is being saved "
812 dev_info->segment_name); 805 "now\n", dev_info->segment_name);
813 list_for_each_entry(entry, &dev_info->seg_list, lh) { 806 list_for_each_entry(entry, &dev_info->seg_list, lh) {
814 segment_save(entry->segment_name); 807 segment_save(entry->segment_name);
815 } 808 }
@@ -852,7 +845,8 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio)
852 case SEG_TYPE_SC: 845 case SEG_TYPE_SC:
853 /* cannot write to these segments */ 846 /* cannot write to these segments */
854 if (bio_data_dir(bio) == WRITE) { 847 if (bio_data_dir(bio) == WRITE) {
855 PRINT_WARN("rejecting write to ro device %s\n", 848 pr_warning("Writing to %s failed because it "
849 "is a read-only device\n",
856 dev_name(&dev_info->dev)); 850 dev_name(&dev_info->dev));
857 goto fail; 851 goto fail;
858 } 852 }