dm snapshot: only take lock for statustype info not table
[firefly-linux-kernel-4.4.55.git] / drivers / md / dm-snap.c
index 3a3ba46e6d4b68fc9f70b87b7ad322a8ca2c9846..d135212958f1567a24c58ddcb1de9a0cfb0610e5 100644 (file)
@@ -1152,10 +1152,11 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
        unsigned sz = 0;
        struct dm_snapshot *snap = ti->private;
 
-       down_write(&snap->lock);
-
        switch (type) {
        case STATUSTYPE_INFO:
+
+               down_write(&snap->lock);
+
                if (!snap->valid)
                        DMEMIT("Invalid");
                else {
@@ -1171,6 +1172,9 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
                        else
                                DMEMIT("Unknown");
                }
+
+               up_write(&snap->lock);
+
                break;
 
        case STATUSTYPE_TABLE:
@@ -1185,8 +1189,6 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
                break;
        }
 
-       up_write(&snap->lock);
-
        return 0;
 }