dm.c (143773965b4677bd72dbbf71f52bea0df2ed4e18) dm.c (9a1fb46448cac50e93115322ad28f417936f7852)
1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * This file is released under the GPL.
6 */
7
8#include "dm.h"

--- 88 unchanged lines hidden (view full) ---

97#define DMF_NOFLUSH_SUSPENDING 5
98
99/*
100 * Work processed by per-device workqueue.
101 */
102struct dm_wq_req {
103 struct work_struct work;
104 struct mapped_device *md;
1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * This file is released under the GPL.
6 */
7
8#include "dm.h"

--- 88 unchanged lines hidden (view full) ---

97#define DMF_NOFLUSH_SUSPENDING 5
98
99/*
100 * Work processed by per-device workqueue.
101 */
102struct dm_wq_req {
103 struct work_struct work;
104 struct mapped_device *md;
105 void *context;
106};
107
108struct mapped_device {
109 struct rw_semaphore io_lock;
110 struct mutex suspend_lock;
111 spinlock_t pushback_lock;
112 rwlock_t map_lock;
113 atomic_t holders;

--- 1316 unchanged lines hidden (view full) ---

1430 struct dm_wq_req *req = container_of(work, struct dm_wq_req, work);
1431 struct mapped_device *md = req->md;
1432
1433 down_write(&md->io_lock);
1434 __flush_deferred_io(md);
1435 up_write(&md->io_lock);
1436}
1437
105};
106
107struct mapped_device {
108 struct rw_semaphore io_lock;
109 struct mutex suspend_lock;
110 spinlock_t pushback_lock;
111 rwlock_t map_lock;
112 atomic_t holders;

--- 1316 unchanged lines hidden (view full) ---

1429 struct dm_wq_req *req = container_of(work, struct dm_wq_req, work);
1430 struct mapped_device *md = req->md;
1431
1432 down_write(&md->io_lock);
1433 __flush_deferred_io(md);
1434 up_write(&md->io_lock);
1435}
1436
1438static void dm_wq_queue(struct mapped_device *md, void *context,
1439 struct dm_wq_req *req)
1437static void dm_wq_queue(struct mapped_device *md, struct dm_wq_req *req)
1440{
1441 req->md = md;
1438{
1439 req->md = md;
1442 req->context = context;
1443 INIT_WORK(&req->work, dm_wq_work);
1444 queue_work(md->wq, &req->work);
1445}
1446
1440 INIT_WORK(&req->work, dm_wq_work);
1441 queue_work(md->wq, &req->work);
1442}
1443
1447static void dm_queue_flush(struct mapped_device *md, void *context)
1444static void dm_queue_flush(struct mapped_device *md)
1448{
1449 struct dm_wq_req req;
1450
1445{
1446 struct dm_wq_req req;
1447
1451 dm_wq_queue(md, context, &req);
1448 dm_wq_queue(md, &req);
1452 flush_workqueue(md->wq);
1453}
1454
1455/*
1456 * Swap in a new table (destroying old one).
1457 */
1458int dm_swap_table(struct mapped_device *md, struct dm_table *table)
1459{

--- 129 unchanged lines hidden (view full) ---

1589 remove_wait_queue(&md->wait, &wait);
1590
1591 if (noflush)
1592 __merge_pushback_list(md);
1593 up_write(&md->io_lock);
1594
1595 /* were we interrupted ? */
1596 if (r < 0) {
1449 flush_workqueue(md->wq);
1450}
1451
1452/*
1453 * Swap in a new table (destroying old one).
1454 */
1455int dm_swap_table(struct mapped_device *md, struct dm_table *table)
1456{

--- 129 unchanged lines hidden (view full) ---

1586 remove_wait_queue(&md->wait, &wait);
1587
1588 if (noflush)
1589 __merge_pushback_list(md);
1590 up_write(&md->io_lock);
1591
1592 /* were we interrupted ? */
1593 if (r < 0) {
1597 dm_queue_flush(md, NULL);
1594 dm_queue_flush(md);
1598
1599 unlock_fs(md);
1600 goto out; /* pushback list is already flushed, so skip flush */
1601 }
1602
1603 dm_table_postsuspend_targets(map);
1604
1605 set_bit(DMF_SUSPENDED, &md->flags);

--- 23 unchanged lines hidden (view full) ---

1629 map = dm_get_table(md);
1630 if (!map || !dm_table_get_size(map))
1631 goto out;
1632
1633 r = dm_table_resume_targets(map);
1634 if (r)
1635 goto out;
1636
1595
1596 unlock_fs(md);
1597 goto out; /* pushback list is already flushed, so skip flush */
1598 }
1599
1600 dm_table_postsuspend_targets(map);
1601
1602 set_bit(DMF_SUSPENDED, &md->flags);

--- 23 unchanged lines hidden (view full) ---

1626 map = dm_get_table(md);
1627 if (!map || !dm_table_get_size(map))
1628 goto out;
1629
1630 r = dm_table_resume_targets(map);
1631 if (r)
1632 goto out;
1633
1637 dm_queue_flush(md, NULL);
1634 dm_queue_flush(md);
1638
1639 unlock_fs(md);
1640
1641 if (md->suspended_bdev) {
1642 bdput(md->suspended_bdev);
1643 md->suspended_bdev = NULL;
1644 }
1645

--- 115 unchanged lines hidden ---
1635
1636 unlock_fs(md);
1637
1638 if (md->suspended_bdev) {
1639 bdput(md->suspended_bdev);
1640 md->suspended_bdev = NULL;
1641 }
1642

--- 115 unchanged lines hidden ---