Change uint32_t into chunk_t to remove 32-bit limitation on the
number of chunks on systems with 64-bit sector numbers.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
* Used to keep track of which metadata area the data in
* 'chunk' refers to.
*/
* Used to keep track of which metadata area the data in
* 'chunk' refers to.
*/
/*
* The next free chunk for an exception.
*/
/*
* The next free chunk for an exception.
*/
/*
* The index of next free exception in the current
/*
* The index of next free exception in the current
/*
* Read or write a chunk aligned and sized block of data from a device.
*/
/*
* Read or write a chunk aligned and sized block of data from a device.
*/
-static int chunk_io(struct pstore *ps, uint32_t chunk, int rw, int metadata)
+static int chunk_io(struct pstore *ps, chunk_t chunk, int rw, int metadata)
{
struct dm_io_region where = {
.bdev = ps->snap->cow->bdev,
{
struct dm_io_region where = {
.bdev = ps->snap->cow->bdev,
* Read or write a metadata area. Remembering to skip the first
* chunk which holds the header.
*/
* Read or write a metadata area. Remembering to skip the first
* chunk which holds the header.
*/
-static int area_io(struct pstore *ps, uint32_t area, int rw)
+static int area_io(struct pstore *ps, chunk_t area, int rw)
chunk = area_location(ps, area);
chunk = area_location(ps, area);
-static int zero_area(struct pstore *ps, uint32_t area)
+static int zero_area(struct pstore *ps, chunk_t area)
{
memset(ps->area, 0, ps->snap->chunk_size << SECTOR_SHIFT);
return area_io(ps, area, WRITE);
{
memset(ps->area, 0, ps->snap->chunk_size << SECTOR_SHIFT);
return area_io(ps, area, WRITE);
static int read_exceptions(struct pstore *ps)
{
static int read_exceptions(struct pstore *ps)
{
{
struct pstore *ps = get_info(store);
uint32_t stride;
{
struct pstore *ps = get_info(store);
uint32_t stride;
sector_t size = get_dev_size(store->snap->cow->bdev);
/* Is there enough room ? */
sector_t size = get_dev_size(store->snap->cow->bdev);
/* Is there enough room ? */
* into account the location of the metadata chunks.
*/
stride = (ps->exceptions_per_area + 1);
* into account the location of the metadata chunks.
*/
stride = (ps->exceptions_per_area + 1);
- if ((++ps->next_free % stride) == 1)
+ next_free = ++ps->next_free;
+ if (sector_div(next_free, stride) == 1)
ps->next_free++;
atomic_inc(&ps->pending_count);
ps->next_free++;
atomic_inc(&ps->pending_count);