xfs
[Top] [All Lists]

Re: How to feel the real time feature of XFS from userspace

To: harryxiyou <harryxiyou@xxxxxxxxx>
Subject: Re: How to feel the real time feature of XFS from userspace
From: Jeff Liu <jeff.liu@xxxxxxxxxx>
Date: Sat, 09 Nov 2013 18:13:58 +0800
Cc: Zhi Yong Wu <zwu.kernel@xxxxxxxxx>, xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <CAD+1EGNxBnSSXGqi7edgdu7uquOOiPWVd7v-avRrJxzKhSY_UQ@xxxxxxxxxxxxxx>
References: <CAD+1EGPf=ddMP4vdDxkkWnJH2q9fCSa5uTT-eRAxYLAEtPrLwg@xxxxxxxxxxxxxx> <527DEB69.8050502@xxxxxxxxxx> <CAD+1EGNxBnSSXGqi7edgdu7uquOOiPWVd7v-avRrJxzKhSY_UQ@xxxxxxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
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

<Prev in Thread] Current Thread [Next in Thread>