[Top] [All Lists]

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

To: Jeff Liu <jeff.liu@xxxxxxxxxx>
Subject: Re: How to feel the real time feature of XFS from userspace
From: harryxiyou <harryxiyou@xxxxxxxxx>
Date: Sat, 9 Nov 2013 17:24:24 +0800
Cc: xfs@xxxxxxxxxxx, Zhi Yong Wu <zwu.kernel@xxxxxxxxx>, Dave Chinner <david@xxxxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=V5o6/9BwUuuHhZLhHoEPtUsszH3/u2duuuCHAUbgqLs=; b=nWw3VodLBDQD04M4eAlw1/eTKhivYQet1irBwrcEPpKJGqhwaH8f/T2+t+dqu4K1LQ f1bvi15QG+gsc7xPqZ+H5/l3eeF2iIDilDpqPvevbrPjn4dv5qf0ArnEcfIKY8O+0eKC cyTwnkn1ipWjQkTvO6ZubOKwl5NbStaxo7IcHI6VWtsCjaTZ/jz8L0f0wC6LLUABjbnG 48ukNntsWSJTVICJpf2JNhBQ4uNmYyCDrYbuSU1w0x4wIR5QZ7/MT2bVRjolOTiU3wWQ 20MP8eOPVoE37JzSwvWbM9IQchZzIKa0SJoT8y0gTnQSguByRjX/1JIALYVe0cOLFl2+ OJOA==
In-reply-to: <527DEB69.8050502@xxxxxxxxxx>
References: <CAD+1EGPf=ddMP4vdDxkkWnJH2q9fCSa5uTT-eRAxYLAEtPrLwg@xxxxxxxxxxxxxx> <527DEB69.8050502@xxxxxxxxxx>
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;
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.

Weiwei  Jia (Harry Wei)

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