CEPH filesystem development
 help / color / mirror / Atom feed
From: Loic Dachary <loic@dachary.org>
To: Alexandre Oliva <oliva@gnu.org>, ceph-devel@vger.kernel.org
Subject: Re: rados.py: add tmap_to_omap method
Date: Fri, 10 Oct 2014 08:51:34 +0200	[thread overview]
Message-ID: <543781F6.2020702@dachary.org> (raw)
In-Reply-To: <ork348a2mc.fsf@free.home>

[-- Attachment #1: Type: text/plain, Size: 2754 bytes --]

Hi,

This patch is improving

http://tracker.ceph.com/issues/9532

which is part of

http://tracker.ceph.com/issues/6114

But I do not know the answer to the bool question ;-)

Cheers

On 10/10/2014 07:57, Alexandre Oliva wrote:
> I wanted to script a tmap_to_omap conversion of a few million dirs, but
> running the rados program for each inode would have made it take too
> long, so I wrote the attached python script, that I'm now running in
> multiple copies in parallel with GNU parallel.
> 
> Before it would run, however, I found out python bindings of rados's
> tmap_to_omap hadn't been implemented.  It might have been because it
> takes a bool argument, and I couldn't find out how to pass it as such.
> 
> I ended up forcing the bool argument to False and passing it as an int
> 0.  This could fail on machines whose ABIs pass bools differently from
> ints, but IIRC bools are just aliases to char in C, at least within GCC,
> and since char is promoted to int for argument passing, passing an int
> should work, especially if it's zero.  For nonzero values, endianness
> could matter if the argument is passed on the stack, so I settled for
> forcing it to zero.
> 
> If anyone knows better, please let me know.
> 
> 
> 
> 
> ---
> 
> Add tmap_to_omap method to rados python bindings, without the bool
> argument: it is forced to false.
> 
> Signed-off-by: Alexandre Oliva <oliva@gnu.org>
> ---
>  src/pybind/rados.py |   18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/src/pybind/rados.py b/src/pybind/rados.py
> index 93e5040..a2394aa 100644
> --- a/src/pybind/rados.py
> +++ b/src/pybind/rados.py
> @@ -1438,6 +1438,24 @@ returned %d, but should return zero on success." % (self.name, ret))
>              raise make_ex(ret, "Failed to stat %r" % key)
>          return psize.value, time.localtime(pmtime.value)
>  
> +    def tmap_to_omap(self, key):
> +        """
> +        Convert a dir from tmap to omap.
> +
> +        :param key: the name of the object to convert
> +        :type key: str
> +
> +        :raises: :class:`TypeError`
> +        :raises: :class:`Error`
> +        :returns: int - 0 on success, otherwise raises an error
> +        """
> +        self.require_ioctx_open()
> +        ret = run_in_thread(self.librados.rados_tmap_to_omap,
> +                            (self.io, c_char_p(key), c_int(0)))
> +        if ret < 0:
> +            raise make_ex(ret, "Failed to convert %s from tmap to omap" % key)
> +        return 0
> +
>      def get_xattr(self, key, xattr_name):
>          """
>          Get the value of an extended attribute on an object.
> 
> 

-- 
Loïc Dachary, Artisan Logiciel Libre


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

      reply	other threads:[~2014-10-10  6:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10  5:57 rados.py: add tmap_to_omap method Alexandre Oliva
2014-10-10  6:51 ` Loic Dachary [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=543781F6.2020702@dachary.org \
    --to=loic@dachary.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=oliva@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox