/* Sets all bits in the bitmap and writes the whole bitmap to stable storage.  */
int drbd_bmio_set_n_write(struct drbd_conf *mdev)
/* Sets all bits in the bitmap and writes the whole bitmap to stable storage.  */
int drbd_bmio_set_n_write(struct drbd_conf *mdev)
{
	int rv = -EIO;
	if (get_ldev_if_state(mdev, D_ATTACHING)) {
		drbd_md_set_flag(mdev, MDF_FULL_SYNC);
		drbd_md_sync(mdev);
		drbd_bm_set_all(mdev);
		rv = drbd_bm_write(mdev);
		if (!rv) {
			drbd_md_clear_flag(mdev, MDF_FULL_SYNC);
			drbd_md_sync(mdev);
		}
		put_ldev(mdev);
	}
	return rv;
}