]> sourceware.org Git - lvm2.git/commit
bcache: use indirection table for fd
authorDavid Teigland <teigland@redhat.com>
Thu, 17 Sep 2020 14:40:18 +0000 (09:40 -0500)
committerDavid Teigland <teigland@redhat.com>
Fri, 18 Sep 2020 20:10:11 +0000 (15:10 -0500)
commit1570e76233398957911c3559b40de6e03c37df9a
tree2d64924ac2d75363f18534e91f523389211d7744
parent4b07ae55f1a1e7ad33b2fb0067112ed074f30bf4
bcache: use indirection table for fd

Add a "device index" (di) for each device, and use this
in the bcache api to the rest of lvm.  This replaces the
file descriptor (fd) in the api.  The rest of lvm uses
new functions bcache_set_fd(), bcache_clear_fd(), and
bcache_change_fd() to control which fd bcache uses for
io to a particular device.

. lvm opens a dev and gets and fd.
  fd = open(dev);

. lvm passes fd to the bcache layer and gets a di
  to use in the bcache api for the dev.
  di = bcache_set_fd(fd);

. lvm uses bcache functions, passing di for the dev.
  bcache_write_bytes(di, ...), etc.

. bcache translates di to fd to do io.

. lvm closes the device and clears the di/fd bcache state.
  close(fd);
  bcache_clear_fd(di);

In the bcache layer, a di-to-fd translation table
(int *_fd_table) is added.  When bcache needs to
perform io on a di, it uses _fd_table[di].

In the following commit, lvm will make use of the new
bcache_change_fd() function to change the fd that
bcache uses for the dev, without dropping cached blocks.
lib/device/bcache-utils.c
lib/device/bcache.c
lib/device/bcache.h
lib/device/dev-cache.c
lib/device/device.h
lib/label/label.c
lib/metadata/metadata.c
test/unit/bcache_t.c
test/unit/bcache_utils_t.c
test/unit/io_engine_t.c
tools/toollib.c
This page took 0.035293 seconds and 5 git commands to generate.