diff options
Diffstat (limited to 'drivers/block/drbd/drbd_int.h')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 92 |
1 files changed, 85 insertions, 7 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index e7093d4291f1..a76ceb344d64 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -382,6 +382,12 @@ enum { | |||
382 | __EE_CALL_AL_COMPLETE_IO, | 382 | __EE_CALL_AL_COMPLETE_IO, |
383 | __EE_MAY_SET_IN_SYNC, | 383 | __EE_MAY_SET_IN_SYNC, |
384 | 384 | ||
385 | /* is this a TRIM aka REQ_DISCARD? */ | ||
386 | __EE_IS_TRIM, | ||
387 | /* our lower level cannot handle trim, | ||
388 | * and we want to fall back to zeroout instead */ | ||
389 | __EE_IS_TRIM_USE_ZEROOUT, | ||
390 | |||
385 | /* In case a barrier failed, | 391 | /* In case a barrier failed, |
386 | * we need to resubmit without the barrier flag. */ | 392 | * we need to resubmit without the barrier flag. */ |
387 | __EE_RESUBMITTED, | 393 | __EE_RESUBMITTED, |
@@ -405,7 +411,9 @@ enum { | |||
405 | }; | 411 | }; |
406 | #define EE_CALL_AL_COMPLETE_IO (1<<__EE_CALL_AL_COMPLETE_IO) | 412 | #define EE_CALL_AL_COMPLETE_IO (1<<__EE_CALL_AL_COMPLETE_IO) |
407 | #define EE_MAY_SET_IN_SYNC (1<<__EE_MAY_SET_IN_SYNC) | 413 | #define EE_MAY_SET_IN_SYNC (1<<__EE_MAY_SET_IN_SYNC) |
408 | #define EE_RESUBMITTED (1<<__EE_RESUBMITTED) | 414 | #define EE_IS_TRIM (1<<__EE_IS_TRIM) |
415 | #define EE_IS_TRIM_USE_ZEROOUT (1<<__EE_IS_TRIM_USE_ZEROOUT) | ||
416 | #define EE_RESUBMITTED (1<<__EE_RESUBMITTED) | ||
409 | #define EE_WAS_ERROR (1<<__EE_WAS_ERROR) | 417 | #define EE_WAS_ERROR (1<<__EE_WAS_ERROR) |
410 | #define EE_HAS_DIGEST (1<<__EE_HAS_DIGEST) | 418 | #define EE_HAS_DIGEST (1<<__EE_HAS_DIGEST) |
411 | #define EE_RESTART_REQUESTS (1<<__EE_RESTART_REQUESTS) | 419 | #define EE_RESTART_REQUESTS (1<<__EE_RESTART_REQUESTS) |
@@ -579,6 +587,7 @@ struct drbd_resource { | |||
579 | struct list_head resources; | 587 | struct list_head resources; |
580 | struct res_opts res_opts; | 588 | struct res_opts res_opts; |
581 | struct mutex conf_update; /* mutex for ready-copy-update of net_conf and disk_conf */ | 589 | struct mutex conf_update; /* mutex for ready-copy-update of net_conf and disk_conf */ |
590 | struct mutex adm_mutex; /* mutex to serialize administrative requests */ | ||
582 | spinlock_t req_lock; | 591 | spinlock_t req_lock; |
583 | 592 | ||
584 | unsigned susp:1; /* IO suspended by user */ | 593 | unsigned susp:1; /* IO suspended by user */ |
@@ -609,6 +618,7 @@ struct drbd_connection { | |||
609 | struct drbd_socket data; /* data/barrier/cstate/parameter packets */ | 618 | struct drbd_socket data; /* data/barrier/cstate/parameter packets */ |
610 | struct drbd_socket meta; /* ping/ack (metadata) packets */ | 619 | struct drbd_socket meta; /* ping/ack (metadata) packets */ |
611 | int agreed_pro_version; /* actually used protocol version */ | 620 | int agreed_pro_version; /* actually used protocol version */ |
621 | u32 agreed_features; | ||
612 | unsigned long last_received; /* in jiffies, either socket */ | 622 | unsigned long last_received; /* in jiffies, either socket */ |
613 | unsigned int ko_count; | 623 | unsigned int ko_count; |
614 | 624 | ||
@@ -814,6 +824,28 @@ struct drbd_device { | |||
814 | struct submit_worker submit; | 824 | struct submit_worker submit; |
815 | }; | 825 | }; |
816 | 826 | ||
827 | struct drbd_config_context { | ||
828 | /* assigned from drbd_genlmsghdr */ | ||
829 | unsigned int minor; | ||
830 | /* assigned from request attributes, if present */ | ||
831 | unsigned int volume; | ||
832 | #define VOLUME_UNSPECIFIED (-1U) | ||
833 | /* pointer into the request skb, | ||
834 | * limited lifetime! */ | ||
835 | char *resource_name; | ||
836 | struct nlattr *my_addr; | ||
837 | struct nlattr *peer_addr; | ||
838 | |||
839 | /* reply buffer */ | ||
840 | struct sk_buff *reply_skb; | ||
841 | /* pointer into reply buffer */ | ||
842 | struct drbd_genlmsghdr *reply_dh; | ||
843 | /* resolved from attributes, if possible */ | ||
844 | struct drbd_device *device; | ||
845 | struct drbd_resource *resource; | ||
846 | struct drbd_connection *connection; | ||
847 | }; | ||
848 | |||
817 | static inline struct drbd_device *minor_to_device(unsigned int minor) | 849 | static inline struct drbd_device *minor_to_device(unsigned int minor) |
818 | { | 850 | { |
819 | return (struct drbd_device *)idr_find(&drbd_devices, minor); | 851 | return (struct drbd_device *)idr_find(&drbd_devices, minor); |
@@ -821,7 +853,7 @@ static inline struct drbd_device *minor_to_device(unsigned int minor) | |||
821 | 853 | ||
822 | static inline struct drbd_peer_device *first_peer_device(struct drbd_device *device) | 854 | static inline struct drbd_peer_device *first_peer_device(struct drbd_device *device) |
823 | { | 855 | { |
824 | return list_first_entry(&device->peer_devices, struct drbd_peer_device, peer_devices); | 856 | return list_first_entry_or_null(&device->peer_devices, struct drbd_peer_device, peer_devices); |
825 | } | 857 | } |
826 | 858 | ||
827 | #define for_each_resource(resource, _resources) \ | 859 | #define for_each_resource(resource, _resources) \ |
@@ -1139,6 +1171,12 @@ struct bm_extent { | |||
1139 | #define DRBD_MAX_SIZE_H80_PACKET (1U << 15) /* Header 80 only allows packets up to 32KiB data */ | 1171 | #define DRBD_MAX_SIZE_H80_PACKET (1U << 15) /* Header 80 only allows packets up to 32KiB data */ |
1140 | #define DRBD_MAX_BIO_SIZE_P95 (1U << 17) /* Protocol 95 to 99 allows bios up to 128KiB */ | 1172 | #define DRBD_MAX_BIO_SIZE_P95 (1U << 17) /* Protocol 95 to 99 allows bios up to 128KiB */ |
1141 | 1173 | ||
1174 | /* For now, don't allow more than one activity log extent worth of data | ||
1175 | * to be discarded in one go. We may need to rework drbd_al_begin_io() | ||
1176 | * to allow for even larger discard ranges */ | ||
1177 | #define DRBD_MAX_DISCARD_SIZE AL_EXTENT_SIZE | ||
1178 | #define DRBD_MAX_DISCARD_SECTORS (DRBD_MAX_DISCARD_SIZE >> 9) | ||
1179 | |||
1142 | extern int drbd_bm_init(struct drbd_device *device); | 1180 | extern int drbd_bm_init(struct drbd_device *device); |
1143 | extern int drbd_bm_resize(struct drbd_device *device, sector_t sectors, int set_new_bits); | 1181 | extern int drbd_bm_resize(struct drbd_device *device, sector_t sectors, int set_new_bits); |
1144 | extern void drbd_bm_cleanup(struct drbd_device *device); | 1182 | extern void drbd_bm_cleanup(struct drbd_device *device); |
@@ -1229,9 +1267,9 @@ extern struct bio *bio_alloc_drbd(gfp_t gfp_mask); | |||
1229 | extern rwlock_t global_state_lock; | 1267 | extern rwlock_t global_state_lock; |
1230 | 1268 | ||
1231 | extern int conn_lowest_minor(struct drbd_connection *connection); | 1269 | extern int conn_lowest_minor(struct drbd_connection *connection); |
1232 | enum drbd_ret_code drbd_create_device(struct drbd_resource *resource, unsigned int minor, int vnr); | 1270 | extern enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsigned int minor); |
1233 | extern void drbd_destroy_device(struct kref *kref); | 1271 | extern void drbd_destroy_device(struct kref *kref); |
1234 | extern void drbd_delete_device(struct drbd_device *mdev); | 1272 | extern void drbd_delete_device(struct drbd_device *device); |
1235 | 1273 | ||
1236 | extern struct drbd_resource *drbd_create_resource(const char *name); | 1274 | extern struct drbd_resource *drbd_create_resource(const char *name); |
1237 | extern void drbd_free_resource(struct drbd_resource *resource); | 1275 | extern void drbd_free_resource(struct drbd_resource *resource); |
@@ -1257,7 +1295,7 @@ extern int is_valid_ar_handle(struct drbd_request *, sector_t); | |||
1257 | 1295 | ||
1258 | 1296 | ||
1259 | /* drbd_nl.c */ | 1297 | /* drbd_nl.c */ |
1260 | extern int drbd_msg_put_info(const char *info); | 1298 | extern int drbd_msg_put_info(struct sk_buff *skb, const char *info); |
1261 | extern void drbd_suspend_io(struct drbd_device *device); | 1299 | extern void drbd_suspend_io(struct drbd_device *device); |
1262 | extern void drbd_resume_io(struct drbd_device *device); | 1300 | extern void drbd_resume_io(struct drbd_device *device); |
1263 | extern char *ppsize(char *buf, unsigned long long size); | 1301 | extern char *ppsize(char *buf, unsigned long long size); |
@@ -1283,6 +1321,10 @@ extern void conn_try_outdate_peer_async(struct drbd_connection *connection); | |||
1283 | extern int drbd_khelper(struct drbd_device *device, char *cmd); | 1321 | extern int drbd_khelper(struct drbd_device *device, char *cmd); |
1284 | 1322 | ||
1285 | /* drbd_worker.c */ | 1323 | /* drbd_worker.c */ |
1324 | /* bi_end_io handlers */ | ||
1325 | extern void drbd_md_io_complete(struct bio *bio, int error); | ||
1326 | extern void drbd_peer_request_endio(struct bio *bio, int error); | ||
1327 | extern void drbd_request_endio(struct bio *bio, int error); | ||
1286 | extern int drbd_worker(struct drbd_thread *thi); | 1328 | extern int drbd_worker(struct drbd_thread *thi); |
1287 | enum drbd_ret_code drbd_resync_after_valid(struct drbd_device *device, int o_minor); | 1329 | enum drbd_ret_code drbd_resync_after_valid(struct drbd_device *device, int o_minor); |
1288 | void drbd_resync_after_changed(struct drbd_device *device); | 1330 | void drbd_resync_after_changed(struct drbd_device *device); |
@@ -1332,16 +1374,20 @@ extern int w_start_resync(struct drbd_work *, int); | |||
1332 | extern void resync_timer_fn(unsigned long data); | 1374 | extern void resync_timer_fn(unsigned long data); |
1333 | extern void start_resync_timer_fn(unsigned long data); | 1375 | extern void start_resync_timer_fn(unsigned long data); |
1334 | 1376 | ||
1377 | extern void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req); | ||
1378 | |||
1335 | /* drbd_receiver.c */ | 1379 | /* drbd_receiver.c */ |
1336 | extern int drbd_receiver(struct drbd_thread *thi); | 1380 | extern int drbd_receiver(struct drbd_thread *thi); |
1337 | extern int drbd_asender(struct drbd_thread *thi); | 1381 | extern int drbd_asender(struct drbd_thread *thi); |
1338 | extern int drbd_rs_should_slow_down(struct drbd_device *device, sector_t sector); | 1382 | extern bool drbd_rs_c_min_rate_throttle(struct drbd_device *device); |
1383 | extern bool drbd_rs_should_slow_down(struct drbd_device *device, sector_t sector); | ||
1339 | extern int drbd_submit_peer_request(struct drbd_device *, | 1384 | extern int drbd_submit_peer_request(struct drbd_device *, |
1340 | struct drbd_peer_request *, const unsigned, | 1385 | struct drbd_peer_request *, const unsigned, |
1341 | const int); | 1386 | const int); |
1342 | extern int drbd_free_peer_reqs(struct drbd_device *, struct list_head *); | 1387 | extern int drbd_free_peer_reqs(struct drbd_device *, struct list_head *); |
1343 | extern struct drbd_peer_request *drbd_alloc_peer_req(struct drbd_peer_device *, u64, | 1388 | extern struct drbd_peer_request *drbd_alloc_peer_req(struct drbd_peer_device *, u64, |
1344 | sector_t, unsigned int, | 1389 | sector_t, unsigned int, |
1390 | bool, | ||
1345 | gfp_t) __must_hold(local); | 1391 | gfp_t) __must_hold(local); |
1346 | extern void __drbd_free_peer_req(struct drbd_device *, struct drbd_peer_request *, | 1392 | extern void __drbd_free_peer_req(struct drbd_device *, struct drbd_peer_request *, |
1347 | int); | 1393 | int); |
@@ -1401,6 +1447,37 @@ static inline void drbd_tcp_quickack(struct socket *sock) | |||
1401 | (char*)&val, sizeof(val)); | 1447 | (char*)&val, sizeof(val)); |
1402 | } | 1448 | } |
1403 | 1449 | ||
1450 | /* sets the number of 512 byte sectors of our virtual device */ | ||
1451 | static inline void drbd_set_my_capacity(struct drbd_device *device, | ||
1452 | sector_t size) | ||
1453 | { | ||
1454 | /* set_capacity(device->this_bdev->bd_disk, size); */ | ||
1455 | set_capacity(device->vdisk, size); | ||
1456 | device->this_bdev->bd_inode->i_size = (loff_t)size << 9; | ||
1457 | } | ||
1458 | |||
1459 | /* | ||
1460 | * used to submit our private bio | ||
1461 | */ | ||
1462 | static inline void drbd_generic_make_request(struct drbd_device *device, | ||
1463 | int fault_type, struct bio *bio) | ||
1464 | { | ||
1465 | __release(local); | ||
1466 | if (!bio->bi_bdev) { | ||
1467 | printk(KERN_ERR "drbd%d: drbd_generic_make_request: " | ||
1468 | "bio->bi_bdev == NULL\n", | ||
1469 | device_to_minor(device)); | ||
1470 | dump_stack(); | ||
1471 | bio_endio(bio, -ENODEV); | ||
1472 | return; | ||
1473 | } | ||
1474 | |||
1475 | if (drbd_insert_fault(device, fault_type)) | ||
1476 | bio_endio(bio, -EIO); | ||
1477 | else | ||
1478 | generic_make_request(bio); | ||
1479 | } | ||
1480 | |||
1404 | void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ordering_e wo); | 1481 | void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ordering_e wo); |
1405 | 1482 | ||
1406 | /* drbd_proc.c */ | 1483 | /* drbd_proc.c */ |
@@ -1410,6 +1487,7 @@ extern const char *drbd_conn_str(enum drbd_conns s); | |||
1410 | extern const char *drbd_role_str(enum drbd_role s); | 1487 | extern const char *drbd_role_str(enum drbd_role s); |
1411 | 1488 | ||
1412 | /* drbd_actlog.c */ | 1489 | /* drbd_actlog.c */ |
1490 | extern bool drbd_al_begin_io_prepare(struct drbd_device *device, struct drbd_interval *i); | ||
1413 | extern int drbd_al_begin_io_nonblock(struct drbd_device *device, struct drbd_interval *i); | 1491 | extern int drbd_al_begin_io_nonblock(struct drbd_device *device, struct drbd_interval *i); |
1414 | extern void drbd_al_begin_io_commit(struct drbd_device *device, bool delegate); | 1492 | extern void drbd_al_begin_io_commit(struct drbd_device *device, bool delegate); |
1415 | extern bool drbd_al_begin_io_fastpath(struct drbd_device *device, struct drbd_interval *i); | 1493 | extern bool drbd_al_begin_io_fastpath(struct drbd_device *device, struct drbd_interval *i); |
@@ -2144,7 +2222,7 @@ static inline void drbd_md_flush(struct drbd_device *device) | |||
2144 | 2222 | ||
2145 | static inline struct drbd_connection *first_connection(struct drbd_resource *resource) | 2223 | static inline struct drbd_connection *first_connection(struct drbd_resource *resource) |
2146 | { | 2224 | { |
2147 | return list_first_entry(&resource->connections, | 2225 | return list_first_entry_or_null(&resource->connections, |
2148 | struct drbd_connection, connections); | 2226 | struct drbd_connection, connections); |
2149 | } | 2227 | } |
2150 | 2228 | ||