rbd: split up rbd_get_segment()
authorAlex Elder <elder@inktank.com>
Thu, 9 Aug 2012 17:33:26 +0000 (10:33 -0700)
committerAlex Elder <elder@inktank.com>
Mon, 1 Oct 2012 19:30:50 +0000 (14:30 -0500)
commit65ccfe21dd8fb402547bb1c50bbc2737c4ef37b8
treedc2406bae46fd943deee2ca03e4edacaa0cd65bf
parentdf111be6310fc41d059a485368e3c51a684859c2
rbd: split up rbd_get_segment()

There are two places where rbd_get_segment() is called.  One, in
rbd_rq_fn(), only needs to know the length within a segment that an
I/O request should be.  The other, in rbd_do_op(), also needs the
name of the object and the offset within it for the I/O request.

Split out rbd_segment_name() into three dedicated functions:
    - rbd_segment_name() allocates and formats the name of the
      object for a segment containing a given rbd image offset
    - rbd_segment_offset() computes the offset within a segment for
      a given rbd image offset
    - rbd_segment_length() computes the length to use for I/O within
      a segment for a request, not to exceed the end of a segment
      object.

In the new functions be a bit more careful, checking for possible
error conditions:
    - watch for errors or overflows returned by snprintf()
    - catch (using BUG_ON()) potential overflow conditions
      when computing segment length

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
drivers/block/rbd.c
This page took 0.024411 seconds and 5 git commands to generate.