Merge branch 'fixes' of git://git.linaro.org/people/rmk/linux-arm
[firefly-linux-kernel-4.4.55.git] / drivers / block / drbd / drbd_nl.c
index d31a0261e83e1721b737e2861e5ead4d8ad24e00..2af26fc9528083d23cbde63fbe42128a26757599 100644 (file)
@@ -155,8 +155,7 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info,
        memset(&adm_ctx, 0, sizeof(adm_ctx));
 
        /* genl_rcv_msg only checks for CAP_NET_ADMIN on "GENL_ADMIN_PERM" :( */
-       if (cmd != DRBD_ADM_GET_STATUS
-       && security_netlink_recv(skb, CAP_SYS_ADMIN))
+       if (cmd != DRBD_ADM_GET_STATUS && !capable(CAP_NET_ADMIN))
               return -EPERM;
 
        adm_ctx.reply_skb = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
@@ -341,7 +340,7 @@ int drbd_khelper(struct drbd_conf *mdev, char *cmd)
        sib.sib_reason = SIB_HELPER_PRE;
        sib.helper_name = cmd;
        drbd_bcast_event(mdev, &sib);
-       ret = call_usermodehelper(usermode_helper, argv, envp, 1);
+       ret = call_usermodehelper(usermode_helper, argv, envp, UMH_WAIT_PROC);
        if (ret)
                dev_warn(DEV, "helper command: %s %s %s exit code %u (0x%x)\n",
                                usermode_helper, cmd, mb,
@@ -363,22 +362,6 @@ int drbd_khelper(struct drbd_conf *mdev, char *cmd)
        return ret;
 }
 
-static void conn_md_sync(struct drbd_tconn *tconn)
-{
-       struct drbd_conf *mdev;
-       int vnr;
-
-       rcu_read_lock();
-       idr_for_each_entry(&tconn->volumes, mdev, vnr) {
-               kref_get(&mdev->kref);
-               rcu_read_unlock();
-               drbd_md_sync(mdev);
-               kref_put(&mdev->kref, &drbd_minor_destroy);
-               rcu_read_lock();
-       }
-       rcu_read_unlock();
-}
-
 int conn_khelper(struct drbd_tconn *tconn, char *cmd)
 {
        char *envp[] = { "HOME=/",
@@ -396,7 +379,7 @@ int conn_khelper(struct drbd_tconn *tconn, char *cmd)
        conn_info(tconn, "helper command: %s %s %s\n", usermode_helper, cmd, tconn->name);
        /* TODO: conn_bcast_event() ?? */
 
-       ret = call_usermodehelper(usermode_helper, argv, envp, 1);
+       ret = call_usermodehelper(usermode_helper, argv, envp, UMH_WAIT_PROC);
        if (ret)
                conn_warn(tconn, "helper command: %s %s %s exit code %u (0x%x)\n",
                          usermode_helper, cmd, tconn->name,
@@ -1018,8 +1001,8 @@ static int drbd_check_al_size(struct drbd_conf *mdev, struct disk_conf *dc)
 static void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int max_bio_size)
 {
        struct request_queue * const q = mdev->rq_queue;
-       int max_hw_sectors = max_bio_size >> 9;
-       int max_segments = 0;
+       unsigned int max_hw_sectors = max_bio_size >> 9;
+       unsigned int max_segments = 0;
 
        if (get_ldev_if_state(mdev, D_ATTACHING)) {
                struct request_queue * const b = mdev->ldev->backing_bdev->bd_disk->queue;
@@ -1054,7 +1037,7 @@ static void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int max_bio_
 
 void drbd_reconsider_max_bio_size(struct drbd_conf *mdev)
 {
-       int now, new, local, peer;
+       unsigned int now, new, local, peer;
 
        now = queue_max_hw_sectors(mdev->rq_queue) << 9;
        local = mdev->local_max_bio_size; /* Eventually last known value, from volatile memory */
@@ -1065,13 +1048,14 @@ void drbd_reconsider_max_bio_size(struct drbd_conf *mdev)
                mdev->local_max_bio_size = local;
                put_ldev(mdev);
        }
+       local = min(local, DRBD_MAX_BIO_SIZE);
 
        /* We may ignore peer limits if the peer is modern enough.
           Because new from 8.3.8 onwards the peer can use multiple
           BIOs for a single peer_request */
        if (mdev->state.conn >= C_CONNECTED) {
                if (mdev->tconn->agreed_pro_version < 94)
-                       peer = min_t(int, mdev->peer_max_bio_size, DRBD_MAX_SIZE_H80_PACKET);
+                       peer = min( mdev->peer_max_bio_size, DRBD_MAX_SIZE_H80_PACKET);
                        /* Correct old drbd (up to 8.3.7) if it believes it can do more than 32KiB */
                else if (mdev->tconn->agreed_pro_version == 94)
                        peer = DRBD_MAX_SIZE_H80_PACKET;
@@ -1081,10 +1065,10 @@ void drbd_reconsider_max_bio_size(struct drbd_conf *mdev)
                        peer = DRBD_MAX_BIO_SIZE;
        }
 
-       new = min_t(int, local, peer);
+       new = min(local, peer);
 
        if (mdev->state.role == R_PRIMARY && new < now)
-               dev_err(DEV, "ASSERT FAILED new < now; (%d < %d)\n", new, now);
+               dev_err(DEV, "ASSERT FAILED new < now; (%u < %u)\n", new, now);
 
        if (new != now)
                dev_info(DEV, "max BIO size = %u\n", new);
@@ -1210,11 +1194,13 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
                }
        }
 
+       drbd_suspend_io(mdev);
        wait_event(mdev->al_wait, lc_try_lock(mdev->act_log));
        drbd_al_shrink(mdev);
        err = drbd_check_al_size(mdev, new_disk_conf);
        lc_unlock(mdev->act_log);
        wake_up(&mdev->al_wait);
+       drbd_resume_io(mdev);
 
        if (err) {
                retcode = ERR_NOMEM;
@@ -1240,10 +1226,15 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
        mutex_unlock(&mdev->tconn->conf_update);
 
        if (new_disk_conf->al_updates)
-               mdev->ldev->md.flags &= MDF_AL_DISABLED;
+               mdev->ldev->md.flags &= ~MDF_AL_DISABLED;
        else
                mdev->ldev->md.flags |= MDF_AL_DISABLED;
 
+       if (new_disk_conf->md_flushes)
+               clear_bit(MD_NO_FUA, &mdev->flags);
+       else
+               set_bit(MD_NO_FUA, &mdev->flags);
+
        drbd_bump_write_ordering(mdev->tconn, WO_bdev_flush);
 
        drbd_md_sync(mdev);
@@ -1308,6 +1299,8 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
 
        /* make sure there is no leftover from previous force-detach attempts */
        clear_bit(FORCE_DETACH, &mdev->flags);
+       clear_bit(WAS_IO_ERROR, &mdev->flags);
+       clear_bit(WAS_READ_ERROR, &mdev->flags);
 
        /* and no leftover from previously aborted resync or verify, either */
        mdev->rs_total = 0;
@@ -1627,7 +1620,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
           flags. */
 
        if (rcu_dereference(mdev->ldev->disk_conf)->al_updates)
-               mdev->ldev->md.flags &= MDF_AL_DISABLED;
+               mdev->ldev->md.flags &= ~MDF_AL_DISABLED;
        else
                mdev->ldev->md.flags |= MDF_AL_DISABLED;
 
@@ -1807,9 +1800,6 @@ _check_net_options(struct drbd_tconn *tconn, struct net_conf *old_conf, struct n
                if (new_conf->two_primaries != old_conf->two_primaries)
                        return ERR_NEED_APV_100;
 
-               if (!new_conf->integrity_alg != !old_conf->integrity_alg)
-                       return ERR_NEED_APV_100;
-
                if (strcmp(new_conf->integrity_alg, old_conf->integrity_alg))
                        return ERR_NEED_APV_100;
        }
@@ -2819,7 +2809,7 @@ next_tconn:
                        }
                }
 
-               dh = genlmsg_put(skb, NETLINK_CB(cb->skb).pid,
+               dh = genlmsg_put(skb, NETLINK_CB(cb->skb).portid,
                                cb->nlh->nlmsg_seq, &drbd_genl_family,
                                NLM_F_MULTI, DRBD_ADM_GET_STATUS);
                if (!dh)
@@ -3307,6 +3297,13 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
        unsigned seq;
        int err = -ENOMEM;
 
+       if (sib->sib_reason == SIB_SYNC_PROGRESS) {
+               if (time_after(jiffies, mdev->rs_last_bcast + HZ))
+                       mdev->rs_last_bcast = jiffies;
+               else
+                       return;
+       }
+
        seq = atomic_inc_return(&drbd_genl_seq);
        msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
        if (!msg)