All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Chinner <dgc@sgi.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [xfs-masters] Re: [PATCH] fs/xfs: remove duplicated defines
Date: Tue, 13 Nov 2007 21:30:13 +0000	[thread overview]
Message-ID: <20071113213013.GZ995458@sgi.com> (raw)
In-Reply-To: <20071111134351.106efb98@lucky.kitzblitz>

On Tue, Nov 13, 2007 at 04:35:40PM +1100, Timothy Shimmin wrote:
> David Chinner wrote:
> > Perhaps we should look at cleaning up the cusers of offtoc, offtoct, etc
> > and killing BPCSHIFT altogether....
> > 
> Yeah, I had a quick look before, but I will look closer again ;-)
> 
>  > egrep -Ir 'offtoc|ctoooff' . | egrep -v "anot|tag"
> ./linux-2.6/xfs_lrw.c:                                  ctooff(offtoct(*offset)),
> ./linux-2.6/xfs_lrw.c:                                  ctooff(offtoct(pos)), -1);
> ./linux-2.6/xfs_lrw.c:                                  ctooff(offtoct(pos)),
> ./linux-2.6/xfs_linux.h:#define offtoc(x)       (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT)
> ./linux-2.6/xfs_linux.h:#define offtoct(x)      ((xfs_off_t)(x)>>BPCSHIFT)
> ./xfs_vnodeops.c:                               ctooff(offtoct(ioffset)), -1);
> ./xfs_vnodeops.c:                               ctooff(offtoct(ioffset)),
> 
> So we basically just use:
> 
> ctooff(offtoct(pos))
> 
> where
> #define	ctooff(x)	((xfs_off_t)(x)<<BPCSHIFT)
> #define offtoct(x)      ((xfs_off_t)(x)>>BPCSHIFT)
> #define BPCSHIFT        PAGE_SHIFT      /* LOG2(NBPC) if exact */
> 
> seems basically to be a:
> 
> #define round_down_page(x) ((x) & ~(PAGE_SIZE - 1))
> 
> or just use a
> round_down(x, PAGE_SIZE)
> and
> define the round_down for size which is power of 2.
> 
> Like in asm-x86_64/proto.h
> #define round_up(x,y) (((x) + (y) - 1) & ~((y)-1))
> #define round_down(x,y) ((x) & ~((y)-1))
> 
> What way do you reckon?

Neither ;)

Just replace them with (val & PAGE_CACHE_MASK)

Actually, the code in xfs_vnodeops.c culd probably just be removed; the
ioffset variable is already rounded to a multiple of page size....

Cheers,

dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

  parent reply	other threads:[~2007-11-13 21:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-11 12:43 [PATCH] fs/xfs: remove duplicated defines Nicolas Kaiser
2007-11-11 23:57 ` [xfs-masters] " Eric Sandeen
2007-11-11 23:57   ` Eric Sandeen
2007-11-12  0:09   ` Timothy Shimmin
2007-11-12  0:09     ` Timothy Shimmin
2007-11-12  0:28 ` Timothy Shimmin
2007-11-12  0:33 ` [xfs-masters] " Timothy Shimmin
2007-11-12  2:04 ` David Chinner
2007-11-13  5:35 ` Timothy Shimmin
2007-11-13 21:30 ` David Chinner [this message]
2007-11-14  2:46 ` Timothy Shimmin
2007-11-14  5:41 ` David Chinner
2007-11-15  0:54 ` Timothy Shimmin
2007-11-15  6:27 ` David Chinner
2007-11-16  5:34   ` [PATCH] remove BPCSHIFT and NB?P? macros - was fs/xfs: remove duplicated Timothy Shimmin
2007-11-16  6:15     ` [xfs-masters] [PATCH] remove BPCSHIFT and NB?P? macros - was Lachlan McIlroy
2007-11-16  6:15       ` [xfs-masters] [PATCH] remove BPCSHIFT and NB?P? macros - was fs/xfs: remove duplicated defines Lachlan McIlroy

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=20071113213013.GZ995458@sgi.com \
    --to=dgc@sgi.com \
    --cc=kernel-janitors@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.