xfs
[Top] [All Lists]

Re: [DMAPI] code error in dm_ip_to_handle()

To: Dean Roehrich <roehrich@xxxxxxx>
Subject: Re: [DMAPI] code error in dm_ip_to_handle()
From: Aurelien Degremont - Stagiaire <degremont@xxxxxxxxxxx>
Date: Mon, 16 May 2005 15:24:33 +0200
Cc: linux-xfs@xxxxxxxxxxx
In-reply-to: <20050513152947.909404FE8A@chewtoy.americas.sgi.com>
References: <20050513152947.909404FE8A@chewtoy.americas.sgi.com>
Sender: linux-xfs-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.2.1) Gecko/20030225
Dean Roehrich a écrit:
Ok. So, do we remove the dm_fsfid_t ? Replace it by a dm_fid as you proposed ? I think it's a good idea.


I would like to see how it works out, if you're willing to do the code.

Have you been able to try that fsid patch yet?

Here is a very small patch that change the parameter of fh_to_inode() and inode_to_fh().
I just replace the dm_fsfid_t by a dm_fid_t.
As the code still used those data and copied them simply, it did not need much changes.
I just adapted the XFS code in order be compatible with those changes, but I do not modify some function like xfs_fid2(). This could be needed but I prefer that you directly modify the XFS-part if you wish it.


Aurelien
diff -ru fs/dmapi/dmapi_kern.h ../linux-2.6-xfs.cvs/fs/dmapi/dmapi_kern.h
--- fs/dmapi/dmapi_kern.h       2005-03-30 20:16:37.000000000 +0200
+++ ../linux-2.6-xfs.cvs/fs/dmapi/dmapi_kern.h  2005-05-16 12:54:08.000000000 
+0200
@@ -78,9 +78,9 @@
 struct filesystem_dmapi_operations {
        int (*get_fsys_vector)(struct super_block *sb, void *addr);
        int (*fh_to_inode)(struct super_block *sb, struct inode **ip,
-                          struct dm_fsfid *fid);
+                          dm_fid_t *fid);
        struct file_operations * (*get_invis_ops)(struct inode *ip);
-       int (*inode_to_fh)(struct inode *ip, struct dm_fsfid *fid,
+       int (*inode_to_fh)(struct inode *ip, dm_fid_t *fid,
                           dm_fsid_t *fsid );
        void (*get_fsid)(struct super_block *sb, dm_fsid_t *fsid);
 #define HAVE_DM_QUEUE_FLUSH
diff -ru fs/dmapi/dmapi_register.c 
../linux-2.6-xfs.cvs/fs/dmapi/dmapi_register.c
--- fs/dmapi/dmapi_register.c   2005-03-30 20:10:03.000000000 +0200
+++ ../linux-2.6-xfs.cvs/fs/dmapi/dmapi_register.c      2005-05-16 
13:14:40.000000000 +0200
@@ -503,7 +508,7 @@
        short           type;
        unsigned long   lc;                     /* lock cookie */
        int             error = 0;
-       dm_fsfid_t      *fidp;
+       dm_fid_t        *fidp;
        struct super_block *sb;
        struct inode    *ip;
        int             filetype;
@@ -512,12 +517,12 @@
        if ((fsrp = dm_find_fsreg_and_lock(&handlep->ha_fsid, &lc)) == NULL)
                return(NULL);
 
-       fidp = (dm_fsfid_t*)&handlep->ha_fid;
+       fidp = (dm_fid_t*)&handlep->ha_fid;
        /* If mounting, and we are not asking for a filesystem handle,
-        * then fail the request.  (fid_len==0 for fshandle)
+        * then fail the request.  (dm_fid_len==0 for fshandle)
         */
        if ((fsrp->fr_state == DM_STATE_MOUNTING) &&
-           (fidp->fid_len != 0)) {
+           (fidp->dm_fid_len != 0)) {
                mutex_spinunlock(&fsrp->fr_lock, lc);
                return(NULL);
        }
@@ -567,7 +572,7 @@
                return(NULL);
 
        filetype = ip->i_mode & S_IFMT;
-       if (fidp->fid_len == 0) {
+       if (fidp->dm_fid_len == 0) {
                type = DM_TDT_VFS;
        } else if (filetype == S_IFREG) {
                type = DM_TDT_REG;
@@ -589,7 +594,7 @@
        dm_handle_t     *handlep)
 {
        int             error;
-       struct dm_fsfid fid;
+       dm_fid_t        fid;
        dm_fsid_t       fsid;
        int             hsize;
        struct filesystem_dmapi_operations *dops;
@@ -602,7 +607,7 @@
                return(error);
 
        memcpy(&handlep->ha_fsid, &fsid, sizeof(fsid));
-       memcpy(&handlep->ha_fid, &fid, fid.fid_len + sizeof fid.fid_len);
+       memcpy(&handlep->ha_fid, &fid, fid.dm_fid_len + sizeof fid.dm_fid_len);
        hsize = DM_HSIZE(*handlep);
        memset((char *)handlep + hsize, 0, sizeof(*handlep) - hsize);
        return(0);
diff -ru fs/xfs/xfs_dmapi.c ../linux-2.6-xfs.cvs/fs/xfs/xfs_dmapi.c
--- fs/xfs/xfs_dmapi.c  2005-04-08 04:46:25.000000000 +0200
+++ ../linux-2.6-xfs.cvs/fs/xfs/xfs_dmapi.c     2005-05-16 13:09:46.000000000 
+0200
@@ -3382,7 +3382,7 @@
 xfs_dm_fh_to_inode(
        struct super_block      *sb,
        struct inode            **ip,
-       struct dm_fsfid         *dmfsfid)
+       dm_fid_t                *dmfid)
 {
        vnode_t *vp = NULL;
        vfs_t   *vfsp = LINVFS_GET_VFS(sb);
@@ -3392,7 +3392,7 @@
        /* Returns negative errors to DMAPI */
 
        *ip = NULL;
-       memcpy(&fid, dmfsfid, sizeof(*dmfsfid));
+       memcpy(&fid, dmfid, sizeof(*dmfid));
        if (fid.fid_len) {      /* file object handle */
                VFS_VGET(vfsp, &vp, &fid, error);
        }
@@ -3407,7 +3407,7 @@
 static int
 xfs_dm_inode_to_fh(
        struct inode            *ip,
-       struct dm_fsfid         *dmfsfid,
+       dm_fid_t                *dmfid,
        dm_fsid_t               *dmfsid)
 {
        vnode_t *vp = LINVFS_GET_VP(ip);
@@ -3421,7 +3421,14 @@
        VOP_FID2(vp, &fid, error);
        if (error)
                return -error; /* Return negative error to DMAPI */
-       memcpy(dmfsfid, &fid, sizeof(*dmfsfid));
+
+       /* 
+        * VOP_FID2 returns a fid_t structure but we know
+        * it is filled with a xfs_fid2_t. So we can copy it
+        * directly in a dm_fid_t. Maybe this part of the XFS
+        * code could be fixed (enhanced).
+        */
+       memcpy(dmfid, &fid, sizeof(*dmfid));
        memcpy(dmfsid, vp->v_vfsp->vfs_altfsid, sizeof(*dmfsid));
        return 0;
 }
<Prev in Thread] Current Thread [Next in Thread>