All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 12/28] lustre: lov: remove lsm_stripe_by_[index|offset]_plain
Date: Mon, 17 Dec 2018 11:29:46 -0500	[thread overview]
Message-ID: <1545064202-22483-13-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1545064202-22483-1-git-send-email-jsimmons@infradead.org>

From: Bobi Jam <bobijam@hotmail.com>

Since both lsm_stripe_by_index() and lsm_stripe_by_offset() are
the same for lsm_operations replace them with a new universal
function stripe_width().

Signed-off-by: Jinshan Xiong <jinshan.xiong@gmail.com>
Signed-off-by: Bobi Jam <bobijam@hotmail.com>
Signed-off-by: Niu Yawei <yawei.niu@intel.com>
WC-bug-id: https://jira.whamcloud.com/browse/LU-8998
Reviewed-on: https://review.whamcloud.com/24850
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/lov/lov_ea.c       | 24 ------------------------
 drivers/staging/lustre/lustre/lov/lov_internal.h |  4 ----
 drivers/staging/lustre/lustre/lov/lov_offset.c   | 23 +++++++++++++----------
 3 files changed, 13 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c
index 3a8d79e..f0ea895 100644
--- a/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -309,24 +309,6 @@ void lsm_free(struct lov_stripe_md *lsm)
 	return lsm;
 }
 
-static void
-lsm_stripe_by_index_plain(struct lov_stripe_md *lsm, int *stripeno,
-			  loff_t *lov_off, loff_t *swidth)
-{
-	if (swidth)
-		*swidth = (loff_t)lsm->lsm_entries[0]->lsme_stripe_size *
-			  lsm->lsm_entries[0]->lsme_stripe_count;
-}
-
-static void
-lsm_stripe_by_offset_plain(struct lov_stripe_md *lsm, int *stripeno,
-			   loff_t *lov_off, loff_t *swidth)
-{
-	if (swidth)
-		*swidth = (loff_t)lsm->lsm_entries[0]->lsme_stripe_size *
-			  lsm->lsm_entries[0]->lsme_stripe_count;
-}
-
 static struct lov_stripe_md *
 lsm_unpackmd_v1(struct lov_obd *lov, void *buf, size_t buf_size)
 {
@@ -336,8 +318,6 @@ void lsm_free(struct lov_stripe_md *lsm)
 }
 
 const static struct lsm_operations lsm_v1_ops = {
-	.lsm_stripe_by_index	= lsm_stripe_by_index_plain,
-	.lsm_stripe_by_offset	= lsm_stripe_by_offset_plain,
 	.lsm_unpackmd		= lsm_unpackmd_v1,
 };
 
@@ -351,8 +331,6 @@ void lsm_free(struct lov_stripe_md *lsm)
 }
 
 const static struct lsm_operations lsm_v3_ops = {
-	.lsm_stripe_by_index	= lsm_stripe_by_index_plain,
-	.lsm_stripe_by_offset	= lsm_stripe_by_offset_plain,
 	.lsm_unpackmd		= lsm_unpackmd_v3,
 };
 
@@ -502,8 +480,6 @@ static int lsm_verify_comp_md_v1(struct lov_comp_md_v1 *lcm,
 }
 
 const static struct lsm_operations lsm_comp_md_v1_ops = {
-	.lsm_stripe_by_index	= lsm_stripe_by_index_plain,
-	.lsm_stripe_by_offset	= lsm_stripe_by_offset_plain,
 	.lsm_unpackmd		= lsm_unpackmd_comp_md_v1,
 };
 
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
index 4c9e324..ebe5890 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -80,10 +80,6 @@ static inline bool lsm_has_objects(struct lov_stripe_md *lsm)
 }
 
 struct lsm_operations {
-	void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, loff_t *,
-				    loff_t *);
-	void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, loff_t *,
-				     loff_t *);
 	struct lov_stripe_md *(*lsm_unpackmd)(struct lov_obd *obd, void *buf,
 					      size_t buf_len);
 };
diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c
index d817aa5..513f1fd 100644
--- a/drivers/staging/lustre/lustre/lov/lov_offset.c
+++ b/drivers/staging/lustre/lustre/lov/lov_offset.c
@@ -37,6 +37,15 @@
 
 #include "lov_internal.h"
 
+static u64 stripe_width(struct lov_stripe_md *lsm, unsigned int index)
+{
+	struct lov_stripe_md_entry *entry = lsm->lsm_entries[index];
+
+	LASSERT(index < lsm->lsm_entry_count);
+
+	return entry->lsme_stripe_size * entry->lsme_stripe_count;
+}
+
 /* compute object size given "stripeno" and the ost size */
 u64 lov_stripe_size(struct lov_stripe_md *lsm, int index, u64 ost_size,
 		    int stripeno)
@@ -45,12 +54,11 @@ u64 lov_stripe_size(struct lov_stripe_md *lsm, int index, u64 ost_size,
 	unsigned long stripe_size;
 	u64 swidth;
 	u64 lov_size;
-	int magic = lsm->lsm_magic;
 
 	if (ost_size == 0)
 		return 0;
 
-	lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, NULL, &swidth);
+	swidth = stripe_width(lsm, index);
 
 	/* lov_do_div64(a, b) returns a % b, and a = a / b */
 	stripe_size = lov_do_div64(ost_size, ssize);
@@ -129,7 +137,6 @@ int lov_stripe_offset(struct lov_stripe_md *lsm, int index, u64 lov_off,
 {
 	unsigned long ssize  = lsm->lsm_entries[index]->lsme_stripe_size;
 	u64 stripe_off, this_stripe, swidth;
-	int magic = lsm->lsm_magic;
 	int ret = 0;
 
 	if (lov_off == OBD_OBJECT_EOF) {
@@ -137,8 +144,7 @@ int lov_stripe_offset(struct lov_stripe_md *lsm, int index, u64 lov_off,
 		return 0;
 	}
 
-	lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, &lov_off,
-						&swidth);
+	swidth = stripe_width(lsm, index);
 
 	/* lov_do_div64(a, b) returns a % b, and a = a / b */
 	stripe_off = lov_do_div64(lov_off, swidth);
@@ -184,13 +190,11 @@ u64 lov_size_to_stripe(struct lov_stripe_md *lsm, int index, u64 file_size,
 {
 	unsigned long ssize  = lsm->lsm_entries[index]->lsme_stripe_size;
 	u64 stripe_off, this_stripe, swidth;
-	int magic = lsm->lsm_magic;
 
 	if (file_size == OBD_OBJECT_EOF)
 		return OBD_OBJECT_EOF;
 
-	lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, &file_size,
-						&swidth);
+	swidth = stripe_width(lsm, index);
 
 	/* lov_do_div64(a, b) returns a % b, and a = a / b */
 	stripe_off = lov_do_div64(file_size, swidth);
@@ -258,9 +262,8 @@ int lov_stripe_number(struct lov_stripe_md *lsm, int index, u64 lov_off)
 {
 	unsigned long ssize  = lsm->lsm_entries[index]->lsme_stripe_size;
 	u64 stripe_off, swidth;
-	int magic = lsm->lsm_magic;
 
-	lsm_op_find(magic)->lsm_stripe_by_offset(lsm, NULL, &lov_off, &swidth);
+	swidth = stripe_width(lsm, index);
 
 	stripe_off = lov_do_div64(lov_off, swidth);
 
-- 
1.8.3.1

  parent reply	other threads:[~2018-12-17 16:29 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-17 16:29 [lustre-devel] [PATCH RFC 00/28] lustre: PFL port to linux client James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 01/28] lustre: pfl: Basic data structures for composite layout James Simmons
2018-12-17 23:54   ` NeilBrown
2018-12-18  1:47     ` Patrick Farrell
2018-12-27  1:57     ` James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 02/28] lustre: lov: move code for PFL work James Simmons
2018-12-18  0:00   ` NeilBrown
2018-12-27  1:59     ` James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 03/28] lustre: lov: merge lov_mds_md_v3 and lov_mds_md_v1 handling James Simmons
2018-12-18  0:09   ` NeilBrown
2018-12-18  1:49     ` Patrick Farrell
2018-12-27  2:10       ` James Simmons
2018-12-27  2:04     ` James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 04/28] lustre: lov: fold lmm_verify() handling into lmm_unpackmd() James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 05/28] lustre: lov: create struct lov_stripe_md_entry James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 06/28] lustre: lov: add composite layout unpacking James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 07/28] lustre: lov: embedded raid0 in struct lov_layout_composite James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 08/28] lustre: lov: migrate lov raid0 to future PFL component handling James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 09/28] lustre: lov: reduce code indentation James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 10/28] lustre: lov: change lo_entries to array James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 11/28] lustre: lov: move around PFL code and cleanups James Simmons
2018-12-17 16:29 ` James Simmons [this message]
2018-12-17 16:29 ` [lustre-devel] [PATCH 13/28] lustre: lov: add looping lsm_entry_count times James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 14/28] lustre: lov: create lov_comp_* wrappers James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 15/28] lustre: clio: client side implementation for PFL James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 16/28] lustre: clio: getstripe support comp layout James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 17/28] lustre: pfl: enhance PFID EA for PFL James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 18/28] lustre: pfl: dynamic layout modification with write/truncate James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 19/28] lustre: pfl: calculate PFL file LOVEA correctly James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 20/28] lustre: lov: keep minimum LOVEA size James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 21/28] lustre: pfl: Read should not trigger layout write intent James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 22/28] lustre: pfl: fix hang with grouplocks James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 23/28] lustre: pfl: fix ost pool op->size handling James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 24/28] lustre: lov: readahead shouldn't exceed component boundary James Simmons
2018-12-17 16:29 ` [lustre-devel] [PATCH 25/28] lustre: uapi: support negative flags James Simmons
2018-12-17 16:30 ` [lustre-devel] [PATCH 26/28] lustre: llite: return v1/v3 layout for legacy app James Simmons
2018-12-17 16:30 ` [lustre-devel] [PATCH 27/28] lustre: llite: restore ll_file_getstripe in ll_lov_setstripe James Simmons
2018-12-17 16:30 ` [lustre-devel] [PATCH 28/28] lustre: lov: do not split IO for single striped file James Simmons
2018-12-18  6:21 ` [lustre-devel] [PATCH RFC 00/28] lustre: PFL port to linux client NeilBrown
2018-12-20  1:39   ` NeilBrown
2018-12-27  1:53     ` James Simmons

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=1545064202-22483-13-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=lustre-devel@lists.lustre.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.