aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_int.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/drbd/drbd_int.h')
-rw-r--r--drivers/block/drbd/drbd_int.h58
1 files changed, 39 insertions, 19 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 32517a0cbc62..85e2f4b56a06 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -483,7 +483,7 @@ struct drbd_backing_dev {
483 struct block_device *backing_bdev; 483 struct block_device *backing_bdev;
484 struct block_device *md_bdev; 484 struct block_device *md_bdev;
485 struct drbd_md md; 485 struct drbd_md md;
486 struct disk_conf *disk_conf; /* RCU, for updates: device->connection->conf_update */ 486 struct disk_conf *disk_conf; /* RCU, for updates: first_peer_device(device)->connection->conf_update */
487 sector_t known_size; /* last known size of that backing device */ 487 sector_t known_size; /* last known size of that backing device */
488}; 488};
489 489
@@ -617,8 +617,14 @@ struct submit_worker {
617 struct list_head writes; 617 struct list_head writes;
618}; 618};
619 619
620struct drbd_device { 620struct drbd_peer_device {
621 struct list_head peer_devices;
622 struct drbd_device *device;
621 struct drbd_connection *connection; 623 struct drbd_connection *connection;
624};
625
626struct drbd_device {
627 struct list_head peer_devices;
622 int vnr; /* volume number within the connection */ 628 int vnr; /* volume number within the connection */
623 struct kref kref; 629 struct kref kref;
624 630
@@ -744,7 +750,7 @@ struct drbd_device {
744 struct bm_io_work bm_io_work; 750 struct bm_io_work bm_io_work;
745 u64 ed_uuid; /* UUID of the exposed data */ 751 u64 ed_uuid; /* UUID of the exposed data */
746 struct mutex own_state_mutex; 752 struct mutex own_state_mutex;
747 struct mutex *state_mutex; /* either own_state_mutex or device->connection->cstate_mutex */ 753 struct mutex *state_mutex; /* either own_state_mutex or first_peer_device(device)->connection->cstate_mutex */
748 char congestion_reason; /* Why we where congested... */ 754 char congestion_reason; /* Why we where congested... */
749 atomic_t rs_sect_in; /* for incoming resync data rate, SyncTarget */ 755 atomic_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
750 atomic_t rs_sect_ev; /* for submitted resync data rate, both */ 756 atomic_t rs_sect_ev; /* for submitted resync data rate, both */
@@ -768,6 +774,20 @@ static inline struct drbd_device *minor_to_device(unsigned int minor)
768 return (struct drbd_device *)idr_find(&minors, minor); 774 return (struct drbd_device *)idr_find(&minors, minor);
769} 775}
770 776
777static inline struct drbd_peer_device *first_peer_device(struct drbd_device *device)
778{
779 return list_first_entry(&device->peer_devices, struct drbd_peer_device, peer_devices);
780}
781
782#define for_each_peer_device(peer_device, device) \
783 list_for_each_entry(peer_device, &device->peer_devices, peer_devices)
784
785#define for_each_peer_device_rcu(peer_device, device) \
786 list_for_each_entry_rcu(peer_device, &device->peer_devices, peer_devices)
787
788#define for_each_peer_device_safe(peer_device, tmp, device) \
789 list_for_each_entry_safe(peer_device, tmp, &device->peer_devices, peer_devices)
790
771static inline unsigned int device_to_minor(struct drbd_device *device) 791static inline unsigned int device_to_minor(struct drbd_device *device)
772{ 792{
773 return device->minor; 793 return device->minor;
@@ -1154,7 +1174,7 @@ extern struct bio *bio_alloc_drbd(gfp_t gfp_mask);
1154extern rwlock_t global_state_lock; 1174extern rwlock_t global_state_lock;
1155 1175
1156extern int conn_lowest_minor(struct drbd_connection *connection); 1176extern int conn_lowest_minor(struct drbd_connection *connection);
1157enum drbd_ret_code conn_new_minor(struct drbd_connection *connection, unsigned int minor, int vnr); 1177enum drbd_ret_code drbd_create_minor(struct drbd_connection *connection, unsigned int minor, int vnr);
1158extern void drbd_minor_destroy(struct kref *kref); 1178extern void drbd_minor_destroy(struct kref *kref);
1159 1179
1160extern int set_resource_options(struct drbd_connection *connection, struct res_opts *res_opts); 1180extern int set_resource_options(struct drbd_connection *connection, struct res_opts *res_opts);
@@ -1275,7 +1295,7 @@ extern void conn_flush_workqueue(struct drbd_connection *connection);
1275extern int drbd_connected(struct drbd_device *device); 1295extern int drbd_connected(struct drbd_device *device);
1276static inline void drbd_flush_workqueue(struct drbd_device *device) 1296static inline void drbd_flush_workqueue(struct drbd_device *device)
1277{ 1297{
1278 conn_flush_workqueue(device->connection); 1298 conn_flush_workqueue(first_peer_device(device)->connection);
1279} 1299}
1280 1300
1281/* Yes, there is kernel_setsockopt, but only since 2.6.18. 1301/* Yes, there is kernel_setsockopt, but only since 2.6.18.
@@ -1421,9 +1441,9 @@ static inline union drbd_state drbd_read_state(struct drbd_device *device)
1421 union drbd_state rv; 1441 union drbd_state rv;
1422 1442
1423 rv.i = device->state.i; 1443 rv.i = device->state.i;
1424 rv.susp = device->connection->susp; 1444 rv.susp = first_peer_device(device)->connection->susp;
1425 rv.susp_nod = device->connection->susp_nod; 1445 rv.susp_nod = first_peer_device(device)->connection->susp_nod;
1426 rv.susp_fen = device->connection->susp_fen; 1446 rv.susp_fen = first_peer_device(device)->connection->susp_fen;
1427 1447
1428 return rv; 1448 return rv;
1429} 1449}
@@ -1505,9 +1525,9 @@ static inline void drbd_chk_io_error_(struct drbd_device *device,
1505{ 1525{
1506 if (error) { 1526 if (error) {
1507 unsigned long flags; 1527 unsigned long flags;
1508 spin_lock_irqsave(&device->connection->req_lock, flags); 1528 spin_lock_irqsave(&first_peer_device(device)->connection->req_lock, flags);
1509 __drbd_chk_io_error_(device, forcedetach, where); 1529 __drbd_chk_io_error_(device, forcedetach, where);
1510 spin_unlock_irqrestore(&device->connection->req_lock, flags); 1530 spin_unlock_irqrestore(&first_peer_device(device)->connection->req_lock, flags);
1511 } 1531 }
1512} 1532}
1513 1533
@@ -1783,7 +1803,7 @@ static inline void put_ldev(struct drbd_device *device)
1783 if (device->state.disk == D_FAILED) { 1803 if (device->state.disk == D_FAILED) {
1784 /* all application IO references gone. */ 1804 /* all application IO references gone. */
1785 if (!test_and_set_bit(GO_DISKLESS, &device->flags)) 1805 if (!test_and_set_bit(GO_DISKLESS, &device->flags))
1786 drbd_queue_work(&device->connection->sender_work, &device->go_diskless); 1806 drbd_queue_work(&first_peer_device(device)->connection->sender_work, &device->go_diskless);
1787 } 1807 }
1788 wake_up(&device->misc_wait); 1808 wake_up(&device->misc_wait);
1789 } 1809 }
@@ -1865,7 +1885,7 @@ static inline int drbd_get_max_buffers(struct drbd_device *device)
1865 int mxb; 1885 int mxb;
1866 1886
1867 rcu_read_lock(); 1887 rcu_read_lock();
1868 nc = rcu_dereference(device->connection->net_conf); 1888 nc = rcu_dereference(first_peer_device(device)->connection->net_conf);
1869 mxb = nc ? nc->max_buffers : 1000000; /* arbitrary limit on open requests */ 1889 mxb = nc ? nc->max_buffers : 1000000; /* arbitrary limit on open requests */
1870 rcu_read_unlock(); 1890 rcu_read_unlock();
1871 1891
@@ -1908,7 +1928,7 @@ static inline int drbd_state_is_stable(struct drbd_device *device)
1908 1928
1909 /* Allow IO in BM exchange states with new protocols */ 1929 /* Allow IO in BM exchange states with new protocols */
1910 case C_WF_BITMAP_S: 1930 case C_WF_BITMAP_S:
1911 if (device->connection->agreed_pro_version < 96) 1931 if (first_peer_device(device)->connection->agreed_pro_version < 96)
1912 return 0; 1932 return 0;
1913 break; 1933 break;
1914 1934
@@ -1944,7 +1964,7 @@ static inline int drbd_state_is_stable(struct drbd_device *device)
1944 1964
1945static inline int drbd_suspended(struct drbd_device *device) 1965static inline int drbd_suspended(struct drbd_device *device)
1946{ 1966{
1947 struct drbd_connection *connection = device->connection; 1967 struct drbd_connection *connection = first_peer_device(device)->connection;
1948 1968
1949 return connection->susp || connection->susp_fen || connection->susp_nod; 1969 return connection->susp || connection->susp_fen || connection->susp_nod;
1950} 1970}
@@ -1979,11 +1999,11 @@ static inline bool inc_ap_bio_cond(struct drbd_device *device)
1979{ 1999{
1980 bool rv = false; 2000 bool rv = false;
1981 2001
1982 spin_lock_irq(&device->connection->req_lock); 2002 spin_lock_irq(&first_peer_device(device)->connection->req_lock);
1983 rv = may_inc_ap_bio(device); 2003 rv = may_inc_ap_bio(device);
1984 if (rv) 2004 if (rv)
1985 atomic_inc(&device->ap_bio_cnt); 2005 atomic_inc(&device->ap_bio_cnt);
1986 spin_unlock_irq(&device->connection->req_lock); 2006 spin_unlock_irq(&first_peer_device(device)->connection->req_lock);
1987 2007
1988 return rv; 2008 return rv;
1989} 2009}
@@ -2010,7 +2030,7 @@ static inline void dec_ap_bio(struct drbd_device *device)
2010 2030
2011 if (ap_bio == 0 && test_bit(BITMAP_IO, &device->flags)) { 2031 if (ap_bio == 0 && test_bit(BITMAP_IO, &device->flags)) {
2012 if (!test_and_set_bit(BITMAP_IO_QUEUED, &device->flags)) 2032 if (!test_and_set_bit(BITMAP_IO_QUEUED, &device->flags))
2013 drbd_queue_work(&device->connection->sender_work, &device->bm_io_work.w); 2033 drbd_queue_work(&first_peer_device(device)->connection->sender_work, &device->bm_io_work.w);
2014 } 2034 }
2015 2035
2016 /* this currently does wake_up for every dec_ap_bio! 2036 /* this currently does wake_up for every dec_ap_bio!
@@ -2022,8 +2042,8 @@ static inline void dec_ap_bio(struct drbd_device *device)
2022 2042
2023static inline bool verify_can_do_stop_sector(struct drbd_device *device) 2043static inline bool verify_can_do_stop_sector(struct drbd_device *device)
2024{ 2044{
2025 return device->connection->agreed_pro_version >= 97 && 2045 return first_peer_device(device)->connection->agreed_pro_version >= 97 &&
2026 device->connection->agreed_pro_version != 100; 2046 first_peer_device(device)->connection->agreed_pro_version != 100;
2027} 2047}
2028 2048
2029static inline int drbd_set_ed_uuid(struct drbd_device *device, u64 val) 2049static inline int drbd_set_ed_uuid(struct drbd_device *device, u64 val)