[pnfs] [PATCH 2/5] pnfs: Only execute a layoutreturn if necessary.

William A. (Andy) Adamson andros at citi.umich.edu
Wed May 7 17:40:39 EDT 2008


On Wed, May 7, 2008 at 4:23 PM, Benny Halevy <bhalevy at panasas.com> wrote:

> On May. 06, 2008, 16:45 -0700, Dean Hildebrand <seattleplus at gmail.com>
> wrote:
> > Signed-off-by: Dean Hildebrand <dhildeb at us.ibm.com>
> > ---
> >  fs/nfs/pnfs.c |    8 ++++++--
> >  1 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> > index a17d2ba..27e37be 100644
> > --- a/fs/nfs/pnfs.c
> > +++ b/fs/nfs/pnfs.c
> > @@ -562,15 +562,19 @@ out:
> >
> >  int
> >  pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment
> *range,
> > -             enum pnfs_layoutrecall_type type)
> > +                enum pnfs_layoutrecall_type type)
> >  {
> >       struct pnfs_layout_type *lo;
> >       struct nfs_inode *nfsi = NFS_I(ino);
> > +     struct nfs_server *nfss = NFS_SERVER(ino);
> >       struct nfs4_pnfs_layout_segment arg;
> > -     int status;
> > +     int status = 0;
> >
> >       dprintk("--> %s\n", __func__);
> >
> > +     if (!pnfs_enabled_sb(nfss)  || !nfsi->current_layout)
> > +             goto out;
>
> the current_layout check is valid (and is an optimization)
> only if type == RECALL_FILE.


I have a patch for this. We need to revisit this WRT the layout stateid.

>
>
> > +
> >       if (range)
> >               arg = *range;
> >       else {
>
> I suggest that we also make pnfs_return_layout inline
> and do the quick checks in the inline wrapper.  This
> way we don't need to ifdef it in some call sites.


>
> Here's a cumulative of two patches in my tree:
> The first inlines pnfs_enabled_sb and the second -
> pnfs_return_layout
>
> Benny
>
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 94a5240..52c7443 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -1159,9 +1159,7 @@ void nfs4_clear_inode(struct inode *inode)
>        nfs_inode_return_delegation_noreclaim(inode);
>        /* First call standard NFS clear_inode() code */
>        nfs_clear_inode(inode);
> -#ifdef CONFIG_PNFS
>        pnfs_return_layout(inode, NULL, RECALL_FILE);
> -#endif /* CONFIG_PNFS */
>  }
>  #endif
>
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index f49eb38..d3045db 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -561,8 +561,8 @@ out:
>  }
>
>  int
> -pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment
> *range,
> -               enum pnfs_layoutrecall_type type)
> +_pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment
> *range,
> +                   enum pnfs_layoutrecall_type type)
>  {
>        struct pnfs_layout_type *lo;
>        struct nfs_inode *nfsi = NFS_I(ino);
> @@ -990,16 +990,6 @@ get_out:
>        return;
>  }
>
> -/* Return true if a layout driver is being used for this mountpoint */
> -int
> -pnfs_enabled_sb(struct nfs_server *nfss)
> -{
> -       if (!nfss->pnfs_curr_ld)
> -               return 0;
> -
> -       return 1;
> -}
> -
>  size_t
>  pnfs_getthreshold(struct inode *inode, int iswrite)
>  {
> diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
> index acbce4b..6ae238f 100644
> --- a/fs/nfs/pnfs.h
> +++ b/fs/nfs/pnfs.h
> @@ -28,9 +28,8 @@ int pnfs_update_layout(struct inode *ino, struct
> nfs_open_context *ctx,
>        size_t count, loff_t pos, enum pnfs_iomode access_type,
>        struct pnfs_layout_segment **lsegpp);
>
> -int pnfs_return_layout(struct inode *, struct nfs4_pnfs_layout_segment *,
> -                      enum pnfs_layoutrecall_type);
> -int pnfs_return_layout_rpc(struct nfs_server *server, struct
> nfs4_pnfs_layoutreturn_arg *argp);
> +int _pnfs_return_layout(struct inode *, struct nfs4_pnfs_layout_segment
> *,
> +                       enum pnfs_layoutrecall_type);
>  void set_pnfs_layoutdriver(struct super_block *sb, struct nfs_fh *fh, u32
> id);
>  void unmount_pnfs_layoutdriver(struct super_block *sb);
>  int pnfs_use_read(struct inode *inode, ssize_t count);
> @@ -45,7 +44,6 @@ void pnfs_layoutcommit_done(struct
> pnfs_layoutcommit_data *data, int status);
>  int pnfs_layoutcommit_inode(struct inode *inode, int sync);
>  void pnfs_update_last_write(struct nfs_inode *nfsi, loff_t offset, size_t
> extent);
>  void pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct
> nfs_open_context *ctx);
> -int pnfs_enabled_sb(struct nfs_server *nfss);
>  unsigned int pnfs_getiosize(struct nfs_server *server);
>  void pnfs_set_ds_iosize(struct nfs_server *server);
>  int pnfs_commit(struct nfs_write_data *data, int sync);
> @@ -77,6 +75,12 @@ void _pnfs_modify_new_write_request(struct nfs_page
> *req,
>                                     (srv)->pnfs_curr_ld->ld_policy_ops &&
> \
>
> (srv)->pnfs_curr_ld->ld_policy_ops->opname)
>
> +/* Return true if a layout driver is being used for this mountpoint */
> +static inline int pnfs_enabled_sb(struct nfs_server *nfss)
> +{
> +       return nfss->pnfs_curr_ld != NULL;
> +}
> +
>  static inline int pnfs_try_to_read_data(struct nfs_read_data *data,
>                                        const struct rpc_call_ops
> *call_ops)
>  {
> @@ -181,6 +185,20 @@ static inline void pnfs_modify_new_request(struct
> nfs_page *req,
>        /* Should we do something (like set PG_USE_PNFS) if !fsdata ? */
>  }
>
> +static inline int pnfs_return_layout(struct inode *ino,
> +                                    struct nfs4_pnfs_layout_segment
> *lseg,
> +                                    enum pnfs_layoutrecall_type type)
> +{
> +       struct nfs_inode *nfsi = NFS_I(ino);
> +       struct nfs_server *nfss = NFS_SERVER(ino);
> +
> +       if (pnfs_enabled_sb(nfss) &&
> +           (nfsi->current_layout || type != RECALL_FILE))
> +               return _pnfs_return_layout(ino, lseg, type);
> +
> +       return 0;
> +}
> +
>  #else  /* CONFIG_PNFS */
>
>  static inline int pnfs_try_to_read_data(struct nfs_read_data *data,
> @@ -232,6 +250,13 @@ static inline void pnfs_modify_new_request(struct
> nfs_page *req,
>  {
>  }
>
> +static inline int pnfs_return_layout(struct inode *ino,
> +                                    struct nfs4_pnfs_layout_segment
> *lseg,
> +                                    enum pnfs_layoutrecall_type type);
> +{
> +       return 0;
> +}
> +
>  #endif /* CONFIG_PNFS */
>
>  #endif /* FS_NFS_PNFS_H */
>
> _______________________________________________
> pNFS mailing list
> pNFS at linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://linux-nfs.org/pipermail/pnfs/attachments/20080507/3c440046/attachment.htm 


More information about the pNFS mailing list