From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 3D16F7F9A for ; Sat, 9 Nov 2013 04:14:11 -0600 (CST) Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by relay1.corp.sgi.com (Postfix) with ESMTP id 2C4F88F804B for ; Sat, 9 Nov 2013 02:14:08 -0800 (PST) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by cuda.sgi.com with ESMTP id MHtRLa5T3OobmbKL (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO) for ; Sat, 09 Nov 2013 02:14:06 -0800 (PST) Message-ID: <527E0AE6.6010202@oracle.com> Date: Sat, 09 Nov 2013 18:13:58 +0800 From: Jeff Liu MIME-Version: 1.0 Subject: Re: How to feel the real time feature of XFS from userspace References: <527DEB69.8050502@oracle.com> In-Reply-To: List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com To: harryxiyou Cc: Zhi Yong Wu , xfs@oss.sgi.com Hi Harry, On Sat, Nov 9, 2013 at 17: 24 PM, harryxiyou wrote: > On Sat, Nov 9, 2013 at 3:59 PM, Jeff Liu wrote: > > Hi Jeff Liu, > > Thanks for your reply ;-) > >> Mount your realtime device at first: >> mount -o rtdev=/dev/sda3 /dev/sda4 /mount_point >> >> Then you need to mark the attribute bit set with XFS_XFLAG_REALTIME via xfsctl(3) >> after file creation before writing any data to the file, hence your demo code >> would looks like: >> >> struct fsxattr attr; >> >> attr.fsx_xflags |= XFS_XFLAG_REALTIME; >> xfs_ret = xfsctl(target_file_path, fd, XFS_IOC_FSSETXATTR, &attr); >> ... > Yeah, it's right. I have mounted as you said and changed my codes as follows. > > #include > #include > #include > #include > #include > #include > #include > > #define F_PATH "./rtxfs.txt" > #define EXTSIZE (0x00001000U) > > int main(int argc, char **argv) { > int fd; > int ret = 0; > struct fsxattr fsxattr; > > fd = open(F_PATH, O_RDWR|O_CREAT, 0666); > if (fd < 0) { > fprintf(stderr, "open error!\n"); > return -1; > } > fsxattr.fsx_xflags = XFS_XFLAG_REALTIME; > fsxattr.fsx_extsize = EXTSIZE; > if (xfsctl(F_PATH, fd, XFS_IOC_FSSETXATTR, &fsxattr)) { > fprintf(stderr, "Set XFS attributes error!\n"); > ret = -1; > goto out; > } > out: > close(fd); > return ret; > } > >> I would suggest you take a look at the source of xfs_rctp(8) at xfsprogs to get >> more info. > xfs_rtcp really helps me a lot. > >> BTW, I remember Dave once mentioned that the realtime feature on Linux is not widely >> tested and not recommended for production use. >> > However, I am wondering, now, I have created a XFS real-time file > named "rtfs.txt" and how I > could do some real-time stuffs on this file, which is different from > other common files. As this inode has been marked to realtime, the subsequent write via directIO will allocate extents via it's specific allocation algorithm rather than the general approach, and the extent length is specified with fsx_extsize. AFAICS, the realtime file data will be allocated on realtime volume while the metadata will still be allocated from the data volume. Thanks, -Jeff _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs