Hi Harry, On Sat, Nov 9, 2013 at 17: 24 PM, harryxiyou wrote: > On Sat, Nov 9, 2013 at 3:59 PM, Jeff Liu <jeff.liu@xxxxxxxxxx> 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 <stdio.h> > #include <unistd.h> > #include <sys/types.h> > #include <sys/stat.h> > #include <fcntl.h> > #include <xfs/xfs.h> > #include <xfs/xfs_fs.h> > > #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@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs