dm: tidy dm_suspend
Tidy dm_suspend function - change return value logic in dm_suspend - use atomic_read only once. - move DMF_BLOCK_IO clearing into one place Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
This commit is contained in:
parent
6d6f10df89
commit
73d410c013
|
@ -1270,6 +1270,8 @@ static void __flush_deferred_io(struct mapped_device *md)
|
||||||
if (__split_bio(md, c))
|
if (__split_bio(md, c))
|
||||||
bio_io_error(c);
|
bio_io_error(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear_bit(DMF_BLOCK_IO, &md->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __merge_pushback_list(struct mapped_device *md)
|
static void __merge_pushback_list(struct mapped_device *md)
|
||||||
|
@ -1355,14 +1357,16 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
|
||||||
{
|
{
|
||||||
struct dm_table *map = NULL;
|
struct dm_table *map = NULL;
|
||||||
DECLARE_WAITQUEUE(wait, current);
|
DECLARE_WAITQUEUE(wait, current);
|
||||||
int r = -EINVAL;
|
int pending, r = 0;
|
||||||
int do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG ? 1 : 0;
|
int do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG ? 1 : 0;
|
||||||
int noflush = suspend_flags & DM_SUSPEND_NOFLUSH_FLAG ? 1 : 0;
|
int noflush = suspend_flags & DM_SUSPEND_NOFLUSH_FLAG ? 1 : 0;
|
||||||
|
|
||||||
mutex_lock(&md->suspend_lock);
|
mutex_lock(&md->suspend_lock);
|
||||||
|
|
||||||
if (dm_suspended(md))
|
if (dm_suspended(md)) {
|
||||||
|
r = -EINVAL;
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
map = dm_get_table(md);
|
map = dm_get_table(md);
|
||||||
|
|
||||||
|
@ -1417,7 +1421,8 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
|
|
||||||
smp_mb();
|
smp_mb();
|
||||||
if (!atomic_read(&md->pending) || signal_pending(current))
|
pending = atomic_read(&md->pending);
|
||||||
|
if (!pending || signal_pending(current))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
io_schedule();
|
io_schedule();
|
||||||
|
@ -1431,12 +1436,12 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
|
||||||
__merge_pushback_list(md);
|
__merge_pushback_list(md);
|
||||||
|
|
||||||
/* were we interrupted ? */
|
/* were we interrupted ? */
|
||||||
r = -EINTR;
|
if (pending) {
|
||||||
if (atomic_read(&md->pending)) {
|
|
||||||
clear_bit(DMF_BLOCK_IO, &md->flags);
|
|
||||||
__flush_deferred_io(md);
|
__flush_deferred_io(md);
|
||||||
up_write(&md->io_lock);
|
up_write(&md->io_lock);
|
||||||
|
|
||||||
unlock_fs(md);
|
unlock_fs(md);
|
||||||
|
r = -EINTR;
|
||||||
goto out; /* pushback list is already flushed, so skip flush */
|
goto out; /* pushback list is already flushed, so skip flush */
|
||||||
}
|
}
|
||||||
up_write(&md->io_lock);
|
up_write(&md->io_lock);
|
||||||
|
@ -1445,8 +1450,6 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
|
||||||
|
|
||||||
set_bit(DMF_SUSPENDED, &md->flags);
|
set_bit(DMF_SUSPENDED, &md->flags);
|
||||||
|
|
||||||
r = 0;
|
|
||||||
|
|
||||||
flush_and_out:
|
flush_and_out:
|
||||||
if (r && noflush) {
|
if (r && noflush) {
|
||||||
/*
|
/*
|
||||||
|
@ -1490,8 +1493,6 @@ int dm_resume(struct mapped_device *md)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
down_write(&md->io_lock);
|
down_write(&md->io_lock);
|
||||||
clear_bit(DMF_BLOCK_IO, &md->flags);
|
|
||||||
|
|
||||||
__flush_deferred_io(md);
|
__flush_deferred_io(md);
|
||||||
up_write(&md->io_lock);
|
up_write(&md->io_lock);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue