All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@dreamhost.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 2/5] ceph: make ceph file layout helpers take a pointer
Date: Mon, 12 Mar 2012 17:57:45 -0500	[thread overview]
Message-ID: <4F5E7F69.5090502@dreamhost.com> (raw)
In-Reply-To: <4F5E7DA5.4040802@dreamhost.com>

Make the helpers for accessing the fields of an on-disk ceph file
layout structure take the address of a layout structure rather than
the structure itself.  It's more useful (and to my eye a bit more
normal).

Use the result in ceph_file_layout_stripe_width() and
ceph_file_layout_period(), since it's now possible.

Rename ceph_file_layout_su() to be ceph_file_layout_stripe_unit().

Signed-off-by: Alex Elder <elder@dreamhost.com>
---
  fs/ceph/ioctl.c              |   16 ++++++++--------
  fs/ceph/xattr.c              |   10 +++++-----
  include/linux/ceph/ceph_fs.h |   28 +++++++++++++++-------------
  3 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 790914a59..23cb78b 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -22,9 +22,9 @@ static long ceph_ioctl_get_layout(struct file *file, 
void __user *arg)

  	err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT);
  	if (!err) {
-		l.stripe_unit = ceph_file_layout_su(ci->i_layout);
-		l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
-		l.object_size = ceph_file_layout_object_size(ci->i_layout);
+		l.stripe_unit = ceph_file_layout_stripe_unit(&ci->i_layout);
+		l.stripe_count = ceph_file_layout_stripe_count(&ci->i_layout);
+		l.object_size = ceph_file_layout_object_size(&ci->i_layout);
  		l.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);
  		l.preferred_osd =
  			(s32)le32_to_cpu(ci->i_layout.fl_pg_preferred);
@@ -52,9 +52,9 @@ static long ceph_ioctl_set_layout(struct file *file, 
void __user *arg)
  	/* validate changed params against current layout */
  	err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT);
  	if (!err) {
-		nl.stripe_unit = ceph_file_layout_su(ci->i_layout);
-		nl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
-		nl.object_size = ceph_file_layout_object_size(ci->i_layout);
+		nl.stripe_unit = ceph_file_layout_stripe_unit(&ci->i_layout);
+		nl.stripe_count = ceph_file_layout_stripe_count(&ci->i_layout);
+		nl.object_size = ceph_file_layout_object_size(&ci->i_layout);
  		nl.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);
  		nl.preferred_osd =
  				(s32)le32_to_cpu(ci->i_layout.fl_pg_preferred);
@@ -203,8 +203,8 @@ static long ceph_ioctl_get_dataloc(struct file 
*file, void __user *arg)
  	ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, &len,
  				      &dl.object_no, &dl.object_offset, &olen);
  	dl.file_offset -= dl.object_offset;
-	dl.object_size = ceph_file_layout_object_size(ci->i_layout);
-	dl.block_size = ceph_file_layout_su(ci->i_layout);
+	dl.object_size = ceph_file_layout_object_size(&ci->i_layout);
+	dl.block_size = ceph_file_layout_stripe_unit(&ci->i_layout);

  	/* block_offset = object_offset % block_size */
  	tmp = dl.object_offset;
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 715cfc6..75960b1 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -115,16 +115,16 @@ static size_t ceph_vxattrcb_file_layout(struct 
ceph_inode_info *ci, char *val,

  	ret = snprintf(val, size,
  		"chunk_bytes=%lld\nstripe_count=%lld\nobject_size=%lld\n",
-		(unsigned long long)ceph_file_layout_su(ci->i_layout),
-		(unsigned long long)ceph_file_layout_stripe_count(ci->i_layout),
-		(unsigned long long)ceph_file_layout_object_size(ci->i_layout));
+		(unsigned long long)ceph_file_layout_su(&ci->i_layout),
+		(unsigned long long)ceph_file_layout_stripe_count(&ci->i_layout),
+		(unsigned long long)ceph_file_layout_object_size(&ci->i_layout));

-	if (ceph_file_layout_pg_preferred(ci->i_layout) >= 0) {
+	if (ceph_file_layout_pg_preferred(&ci->i_layout) >= 0) {
  		val += ret;
  		size -= ret;
  		ret += snprintf(val, size, "preferred_osd=%lld\n",
  			    (unsigned long long)ceph_file_layout_pg_preferred(
-				    ci->i_layout));
+				    &ci->i_layout));
  	}

  	return ret;
diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h
index 62e3bb3..2645704 100644
--- a/include/linux/ceph/ceph_fs.h
+++ b/include/linux/ceph/ceph_fs.h
@@ -74,32 +74,34 @@ struct ceph_file_layout {
   */

  #define CEPH_MIN_STRIPE_UNIT 65536
-#define ceph_file_layout_su(l) ((__s32)le32_to_cpu((l).fl_stripe_unit))
+#define ceph_file_layout_stripe_unit(l) \
+		((__s32) le32_to_cpu((l)->fl_stripe_unit))
  #define ceph_file_layout_stripe_count(l) \
-	((__s32)le32_to_cpu((l).fl_stripe_count))
-#define ceph_file_layout_object_size(l) 
((__s32)le32_to_cpu((l).fl_object_size))
-#define ceph_file_layout_cas_hash(l) ((__s32)le32_to_cpu((l).fl_cas_hash))
-#define ceph_file_layout_object_su(l) \
-	((__s32)le32_to_cpu((l).fl_object_stripe_unit))
+		((__s32) le32_to_cpu((l)->fl_stripe_count))
+#define ceph_file_layout_object_size(l) \
+		((__s32) le32_to_cpu((l)->fl_object_size))
+#define ceph_file_layout_cas_hash(l) \
+		((__s32) le32_to_cpu((l)->fl_cas_hash))
+#define ceph_file_layout_object_stripe_unit(l) \
+		((__s32) le32_to_cpu((l)->fl_object_stripe_unit))
  #define ceph_file_layout_pg_preferred(l) \
-	((__s32)le32_to_cpu((l).fl_pg_preferred))
+		((__s32) le32_to_cpu((l)->fl_pg_preferred))
  #define ceph_file_layout_pg_pool(l) \
-	((__s32)le32_to_cpu((l).fl_pg_pool))
+		((__s32) le32_to_cpu((l)->fl_pg_pool))

  static inline unsigned ceph_file_layout_stripe_width(struct 
ceph_file_layout *l)
  {
-	return le32_to_cpu(l->fl_stripe_unit) *
-		le32_to_cpu(l->fl_stripe_count);
+	return (unsigned) (ceph_file_layout_stripe_unit(l) *
+				ceph_file_layout_stripe_count(l));
  }

  /* "period" == bytes before i start on a new set of objects */
  static inline unsigned ceph_file_layout_period(struct ceph_file_layout *l)
  {
-	return le32_to_cpu(l->fl_object_size) *
-		le32_to_cpu(l->fl_stripe_count);
+	return (unsigned) (ceph_file_layout_object_size(l) *
+				ceph_file_layout_stripe_count(l));
  }

-
  int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);

  struct ceph_dir_layout {
-- 
1.7.5.4


  parent reply	other threads:[~2012-03-12 22:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-12 22:50 [PATCH 0/5] ceph: ceph file layout helper fixes Alex Elder
2012-03-12 22:57 ` [PATCH 1/5] ceph: move file layout helpers to ceph_fs.h Alex Elder
2012-03-12 22:57 ` Alex Elder [this message]
2012-03-12 22:57 ` [PATCH 3/5] ceph: make use of ceph file layout helpers Alex Elder
2012-03-16  5:59   ` Sage Weil
2012-03-30 19:55     ` Alex Elder
2012-03-12 22:57 ` [PATCH 4/5] ceph: use 64-bit math in ceph_calc_file_object_mapping() Alex Elder
2012-03-16  6:17   ` Sage Weil
2012-03-16 13:25     ` Alex Elder
2012-03-12 22:57 ` [PATCH 5/5] ceph: fix up the types of the file layout helpers Alex Elder
2012-03-16  6:10   ` Sage Weil
2012-03-30 19:55     ` Alex Elder

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=4F5E7F69.5090502@dreamhost.com \
    --to=elder@dreamhost.com \
    --cc=ceph-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.