drbd: Move write_ordering from connection to resource
authorPhilipp Reisner <philipp.reisner@linbit.com>
Fri, 22 Nov 2013 14:53:41 +0000 (15:53 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 10 Jul 2014 13:22:19 +0000 (15:22 +0200)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_nl.c
drivers/block/drbd/drbd_proc.c
drivers/block/drbd/drbd_receiver.c

index a76ceb344d64e9411bbfd39c4db9189e519fac72..1ef2474e8f1137c6b230c4c4cbe90c0c154ef200 100644 (file)
@@ -594,6 +594,8 @@ struct drbd_resource {
        unsigned susp_nod:1;            /* IO suspended because no data */
        unsigned susp_fen:1;            /* IO suspended because fence peer handler runs */
 
+       enum write_ordering_e write_ordering;
+
        cpumask_var_t cpu_mask;
 };
 
@@ -636,7 +638,6 @@ struct drbd_connection {
        struct drbd_epoch *current_epoch;
        spinlock_t epoch_lock;
        unsigned int epochs;
-       enum write_ordering_e write_ordering;
        atomic_t current_tle_nr;        /* transfer log epoch number */
        unsigned current_tle_writes;    /* writes seen within this tl epoch */
 
@@ -1478,7 +1479,7 @@ static inline void drbd_generic_make_request(struct drbd_device *device,
                generic_make_request(bio);
 }
 
-void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ordering_e wo);
+void drbd_bump_write_ordering(struct drbd_resource *resource, enum write_ordering_e wo);
 
 /* drbd_proc.c */
 extern struct proc_dir_entry *drbd_proc;
index 960645c26e6fc1b107e0db1ae016fd15800d3514..17b9a237f2e676967cbc94c430b02490d9244083 100644 (file)
@@ -2579,6 +2579,7 @@ struct drbd_resource *drbd_create_resource(const char *name)
        kref_init(&resource->kref);
        idr_init(&resource->devices);
        INIT_LIST_HEAD(&resource->connections);
+       resource->write_ordering = WO_bdev_flush;
        list_add_tail_rcu(&resource->resources, &drbd_resources);
        mutex_init(&resource->conf_update);
        mutex_init(&resource->adm_mutex);
@@ -2617,7 +2618,6 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts)
        INIT_LIST_HEAD(&connection->current_epoch->list);
        connection->epochs = 1;
        spin_lock_init(&connection->epoch_lock);
-       connection->write_ordering = WO_bdev_flush;
 
        connection->send.seen_any_write_yet = false;
        connection->send.current_epoch_nr = 0;
index 1b35c45c92b75d7f01fd3fcda7a861ae099b4c7e..43fad2c1ba0160c1a6ebe59a4dcbff949cebefa2 100644 (file)
@@ -1399,7 +1399,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
        else
                set_bit(MD_NO_FUA, &device->flags);
 
-       drbd_bump_write_ordering(first_peer_device(device)->connection, WO_bdev_flush);
+       drbd_bump_write_ordering(device->resource, WO_bdev_flush);
 
        drbd_md_sync(device);
 
@@ -1704,7 +1704,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
        new_disk_conf = NULL;
        new_plan = NULL;
 
-       drbd_bump_write_ordering(first_peer_device(device)->connection, WO_bdev_flush);
+       drbd_bump_write_ordering(device->resource, WO_bdev_flush);
 
        if (drbd_md_test_flag(device->ldev, MDF_CRASHED_PRIMARY))
                set_bit(CRASHED_PRIMARY, &device->flags);
index 89736bdbbc7044aedaaacbd5dc9c858ca3933596..f11e57308104ef6b687b6e62a36692f1a22429ae 100644 (file)
@@ -281,7 +281,7 @@ static int drbd_seq_show(struct seq_file *seq, void *v)
                           atomic_read(&device->unacked_cnt),
                           atomic_read(&device->ap_bio_cnt),
                           first_peer_device(device)->connection->epochs,
-                          write_ordering_chars[first_peer_device(device)->connection->write_ordering]
+                          write_ordering_chars[device->resource->write_ordering]
                        );
                        seq_printf(seq, " oos:%llu\n",
                                   Bit2KB((unsigned long long)
index 5b17ec88ea058e766071e66eeadf3d8fca3f4940..c7084188c2ae256edf5e648ad2a594d00557b2a8 100644 (file)
@@ -1151,7 +1151,7 @@ static void drbd_flush(struct drbd_connection *connection)
        struct drbd_peer_device *peer_device;
        int vnr;
 
-       if (connection->write_ordering >= WO_bdev_flush) {
+       if (connection->resource->write_ordering >= WO_bdev_flush) {
                rcu_read_lock();
                idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
                        struct drbd_device *device = peer_device->device;
@@ -1168,7 +1168,7 @@ static void drbd_flush(struct drbd_connection *connection)
                                /* would rather check on EOPNOTSUPP, but that is not reliable.
                                 * don't try again for ANY return value != 0
                                 * if (rv == -EOPNOTSUPP) */
-                               drbd_bump_write_ordering(connection, WO_drain_io);
+                               drbd_bump_write_ordering(connection->resource, WO_drain_io);
                        }
                        put_ldev(device);
                        kref_put(&device->kref, drbd_destroy_device);
@@ -1262,10 +1262,10 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
  * @connection:        DRBD connection.
  * @wo:                Write ordering method to try.
  */
-void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ordering_e wo)
+void drbd_bump_write_ordering(struct drbd_resource *resource, enum write_ordering_e wo)
 {
        struct disk_conf *dc;
-       struct drbd_peer_device *peer_device;
+       struct drbd_device *device;
        enum write_ordering_e pwo;
        int vnr;
        static char *write_ordering_str[] = {
@@ -1274,12 +1274,10 @@ void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ord
                [WO_bdev_flush] = "flush",
        };
 
-       pwo = connection->write_ordering;
+       pwo = resource->write_ordering;
        wo = min(pwo, wo);
        rcu_read_lock();
-       idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
-               struct drbd_device *device = peer_device->device;
-
+       idr_for_each_entry(&resource->devices, device, vnr) {
                if (!get_ldev_if_state(device, D_ATTACHING))
                        continue;
                dc = rcu_dereference(device->ldev->disk_conf);
@@ -1291,9 +1289,9 @@ void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ord
                put_ldev(device);
        }
        rcu_read_unlock();
-       connection->write_ordering = wo;
-       if (pwo != connection->write_ordering || wo == WO_bdev_flush)
-               drbd_info(connection, "Method to ensure write ordering: %s\n", write_ordering_str[connection->write_ordering]);
+       resource->write_ordering = wo;
+       if (pwo != resource->write_ordering || wo == WO_bdev_flush)
+               drbd_info(resource, "Method to ensure write ordering: %s\n", write_ordering_str[resource->write_ordering]);
 }
 
 /**
@@ -1471,7 +1469,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
         * R_PRIMARY crashes now.
         * Therefore we must send the barrier_ack after the barrier request was
         * completed. */
-       switch (connection->write_ordering) {
+       switch (connection->resource->write_ordering) {
        case WO_none:
                if (rv == FE_RECYCLED)
                        return 0;
@@ -1498,7 +1496,8 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
 
                return 0;
        default:
-               drbd_err(connection, "Strangeness in connection->write_ordering %d\n", connection->write_ordering);
+               drbd_err(connection, "Strangeness in connection->write_ordering %d\n",
+                        connection->resource->write_ordering);
                return -EIO;
        }