diff options
author | Dan Williams <dan.j.williams@intel.com> | 2008-06-16 15:36:41 -0700 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2008-06-16 15:36:41 -0700 |
commit | 272f648fb00c58989a17651f2eb9c1cf9c807d59 (patch) | |
tree | 8cfad7f26eca6497722e8437494aebe3eda74d6d /super-intel.c | |
parent | 551c80c1c16545b0daaac74d770e5bedf1ad4f0a (diff) | |
download | mdadm-272f648fb00c58989a17651f2eb9c1cf9c807d59.tar.gz mdadm-272f648fb00c58989a17651f2eb9c1cf9c807d59.tar.xz mdadm-272f648fb00c58989a17651f2eb9c1cf9c807d59.zip |
imsm: write anchor last
Ensure that newly written anchors reflect a consistent metadata block.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'super-intel.c')
-rw-r--r-- | super-intel.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/super-intel.c b/super-intel.c index c8419f0..3a85e2c 100644 --- a/super-intel.c +++ b/super-intel.c @@ -1795,24 +1795,23 @@ static int store_imsm_mpb(int fd, struct intel_super *super) get_dev_size(fd, NULL, &dsize); - /* first block is stored on second to last sector of the disk */ - if (lseek64(fd, dsize - (512 * 2), SEEK_SET) < 0) - return 1; + if (mpb_size > 512) { + /* -1 to account for anchor */ + sectors = mpb_sectors(mpb) - 1; - if (write(fd, super->buf, 512) != 512) - return 1; - - if (mpb_size <= 512) - return 0; + /* write the extended mpb to the sectors preceeding the anchor */ + if (lseek64(fd, dsize - (512 * (2 + sectors)), SEEK_SET) < 0) + return 1; - /* -1 because we already wrote a sector */ - sectors = mpb_sectors(mpb) - 1; + if (write(fd, super->buf + 512, mpb_size - 512) != mpb_size - 512) + return 1; + } - /* write the extended mpb to the sectors preceeding the anchor */ - if (lseek64(fd, dsize - (512 * (2 + sectors)), SEEK_SET) < 0) + /* first block is stored on second to last sector of the disk */ + if (lseek64(fd, dsize - (512 * 2), SEEK_SET) < 0) return 1; - if (write(fd, super->buf + 512, mpb_size - 512) != mpb_size - 512) + if (write(fd, super->buf, 512) != 512) return 1; fsync(fd); |