Received: with ECARTIS (v1.0.0; list linux-xfs); Wed, 11 May 2005 09:21:06 -0700 (PDT) Received: from cirse.extra.cea.fr (cirse.extra.cea.fr [132.166.172.102]) by oss.sgi.com (8.12.10/8.12.10/SuSE Linux 0.7) with ESMTP id j4BGKmOv018965 for ; Wed, 11 May 2005 09:20:50 -0700 Received: from argiope.saclay.cea.fr (argiope.saclay.cea.fr [132.166.192.108]) by cirse.extra.cea.fr (8.12.10/8.12.10/CEAnet-Internet.4.0) with ESMTP id j4BGKMAN025085 for ; Wed, 11 May 2005 18:20:22 +0200 (MEST) Received: from pisaure.intra.cea.fr (unverified) by argiope.saclay.cea.fr (Content Technologies SMTPRS 4.3.17) with ESMTP id ; Wed, 11 May 2005 18:20:21 +0200 Received: from nenuphar.saclay.cea.fr (nenuphar.saclay.cea.fr [132.166.192.7]) by pisaure.intra.cea.fr (8.12.11/8.12.11) with ESMTP id j4BGITFr003133; Wed, 11 May 2005 18:18:29 +0200 (envelope-from degremont@ocre.cea.fr) Received: from ocre.cea.fr ([132.165.65.70]) by nenuphar.saclay.cea.fr (8.12.10/8.12.10/CEAnet-internes.4.0) with ESMTP id j4BGKIZa002384; Wed, 11 May 2005 18:20:18 +0200 (MEST) Message-ID: <428230C2.5050406@ocre.cea.fr> Date: Wed, 11 May 2005 18:20:18 +0200 From: Aurelien Degremont - Stagiaire User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.2.1) Gecko/20030225 X-Accept-Language: en-us MIME-Version: 1.0 To: linux-xfs@oss.sgi.com, Dean Roehrich Subject: [DMAPI] code error in dm_ip_to_handle() Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-archive-position: 5194 X-ecartis-version: Ecartis v1.0.0 Sender: linux-xfs-bounce@oss.sgi.com Errors-to: linux-xfs-bounce@oss.sgi.com X-original-sender: degremont@ocre.cea.fr Precedence: bulk X-list: linux-xfs Content-Length: 2226 Lines: 66 Hello, I'm still working on DMAPI code and I found a problem in dm_ip_to_handle() function. In fact, the problem is not specific to this function, I just found it here. To sum up, I found, in the XFS+DMAPI code, along all the different calls, you successively cast some structures and recopy data without verifying their content. With XFS, all is ok because 2 errors fix each others, but, when i try adding dmapi support to ext3, the problem appears. In order to create a dmapi handle, you must call dm_ip_to_handle(). This function will fill a dm_handle_t structure. The data recopied came from a dm_fsfid structure which do not have the same fields. ex: memcpy( &[DM_HANDLE_T], &[DM_FSID_T], ...) This copy the content of the len field without errors. **But the first byte of the fid_data buffer will be recopied in the padding field (dm_fid_pad) of the dm_fid structure !** (which is not what is expected) When DMAPI will try to extract the inode number, it will be wrong ! This code works correctly with XFS because XFS uses the same kind of structure as DMAPI, and so, when the datas are copied, the padding is ok. XFS will copied the data from : xfs_fid2_t --> fid_t -//pad error//-> dm_fsfid_t -//pad error//-> dm_fid_t Their 2 errors with byte alignement when data are cast and copied, but the first is the opposite of the second, so the data are correct at the end. This is not true when you correctly fill the dm_fsfid_t structure :) ________________________________________________________ #define MAXDMFSFIDSZ 46 typedef struct dm_fsfid { __u16 fid_len; /* length of data in bytes */ unsigned char fid_data[MAXDMFSFIDSZ]; /* data (fid_len worth) */ } dm_fsfid_t; struct dm_fid { __u16 dm_fid_len; /* length of remainder */ __u16 dm_fid_pad; __u32 dm_fid_gen; /* generation number */ __u64 dm_fid_ino; /* 64 bits inode number */ }; typedef struct dm_fid dm_fid_t; struct dm_handle { union { __s64 align; /* force alignment of ha_fid */ dm_fsid_t _ha_fsid; /* unique file system identifier */ } ha_u; dm_fid_t ha_fid; /* file system specific file ID */ }; typedef struct dm_handle dm_handle_t; ________________________________________________________ Aurélien