Skip to contentSkip to conversation

Ocfs2: Move ocfs2 ioctl definitions from ocfs2_fs.h to new added ocfs2_ioctl.h.

PATCH New Tiger Yang 3 participants 8 messages Feb 24, 2010 – Mar 2, 2010

Subsystems (2)
lore
Share & tools
lore

Tiger Yang

author
#0 lore raw

PATCH 1/2 Ocfs2: Move ocfs2 ioctl definitions from ocfs2_fs.h to new added ocfs2_ioctl.h.

From: Tristan Ye <[email protected]>

Currently we were adding ioctl cmds/structures for ocfs2 into ocfs2_fs.h which was used for define ocfs2 on-disk layout. That sounds a little bit confusing, and it may be quickly polluted espcially when growing the ocfs2_info_request ioctls afterwards(it will grow i bet).

As a result, such OCFS2 IOCs do need to be placed somewhere other than ocfs2_fs.h, a separated ocfs2_ioctl.h will be added to store such ioctl structures and definitions which could also be used from userspace to invoke ioctls call.

---
 fs/ocfs2/file.h        |    2 +
 fs/ocfs2/ioctl.c       |    1 +
 fs/ocfs2/ioctl.h       |    6 ++--
 fs/ocfs2/ocfs2_fs.h    |   57 ----------------------------------
 fs/ocfs2/ocfs2_ioctl.h |   79 ++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/resize.c      |    1 +
 6 files changed, 86 insertions(+), 60 deletions(-)
 create mode 100644 fs/ocfs2/ocfs2_ioctl.h
fs/ocfs2/file.h +2 -0
index d66cf4f..eb891db 100644
@@ -26,6 +26,8 @@
 #ifndef OCFS2_FILE_H
 #define OCFS2_FILE_H
 
+#include "ocfs2_ioctl.h"
+
 extern const struct file_operations ocfs2_fops;
 extern const struct file_operations ocfs2_dops;
 extern const struct file_operations ocfs2_fops_no_plocks;
fs/ocfs2/ioctl.c +1 -0
index 7d9d9c1..d88e5f0 100644
@@ -21,6 +21,7 @@
 
 #include "ocfs2_fs.h"
 #include "ioctl.h"
+#include "ocfs2_ioctl.h"
 #include "resize.h"
 #include "refcounttree.h"
 
fs/ocfs2/ioctl.h +3 -3
index cf9a5ee..0cd5323 100644
@@ -7,10 +7,10 @@
  *
  */
 
-#ifndef OCFS2_IOCTL_H
-#define OCFS2_IOCTL_H
+#ifndef OCFS2_IOCTL_PROTO_H
+#define OCFS2_IOCTL_PROTO_H
 
 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
 
-#endif /* OCFS2_IOCTL_H */
+#endif /* OCFS2_IOCTL_PROTO_H */
fs/ocfs2/ocfs2_fs.h +0 -57

63 lines not on this page · raw message

fs/ocfs2/ocfs2_ioctl.h new file +79 -0

79 lines not on this page · raw message

fs/ocfs2/resize.c +1 -0
index 3c3d673..f2b3c4b 100644
@@ -31,6 +31,7 @@
 #include <cluster/masklog.h>
 
 #include "ocfs2.h"
+#include "ocfs2_ioctl.h"
 
 #include "alloc.h"
 #include "dlmglue.h"
Signature · 1 line
1.5.4.4
author
#1 lore raw

PATCH 2/2 Ocfs2: Add new OCFS2_IOC_INFO ioctl for ocfs2 v6.

Now the ocfs2_info patches has been generated atop of joel's fixes branch.

Major changes from v5 to v6:

1. Fix a ptr passing bug on PPC machine, that is, 32bits binary running on 64bits kernel needs to use compat_ptr() to reterive the right ptr address from userspace if we use u64 as a pointer.

2. Use enum instead of flag bits for o2info type.

====================================================================
The reason why we need this ioctl is to offer the none-privileged end-user a possibility to get filesys info gathering.

We use OCFS2_IOC_INFO to manipulate the new ioctl, userspace passes a structure to kernel containing an array of request pointers and request count, such as,

* From userspace:

struct ocfs2_info_blocksize brq = {
        .ir_request = {
                .ir_magic = OCFS2_INFO_MAGIC,
                .ir_code = OCFS2_INFO_BLOCKSIZE,
                ...
        }
        ...
}
struct ocfs2_info_clustersize crq = {
        ...
}

uint64_t reqs[2] = {(unsigned long)&brq,

                    (unsigned long)&crq};

struct ocfs2_info info = {
.ir_requests = reqs,
.ir_count = 2,
}

ret = ioctl(fd, OCFS2_IOC_INFO, &info);

* In kernel:

Get the request pointers from *info*, then handle each request one bye one.

Idea here is to make the spearated request small enough to guarantee a better backward&forward compatibility since a small piece of request would be less likely to be broken if filesys on raw disk get changed.

Currently, following 8 ioctls get implemented per the requirement from userspace tool o2info, and I believe it will grow over time:-)

OCFS2_INFO_CLUSTERSIZE
OCFS2_INFO_BLOCKSIZE
OCFS2_INFO_SLOTNUM
OCFS2_INFO_LABEL
OCFS2_INFO_UUID
OCFS2_INFO_FS_FEATURES
OCFS2_INFO_FREEFRAG
OCFS2_INFO_FREEINODE

This ioctl is only specific to OCFS2.

---
 Makefile               |    2 +-
 fs/ocfs2/ioctl.c       |  677 ++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/ocfs2_ioctl.h |  117 +++++++++
 3 files changed, 795 insertions(+), 1 deletions(-)
Makefile +1 -1
index 1231094..e5d6b02 100644
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 33
-EXTRAVERSION = -rc3
+EXTRAVERSION = -o2info
 NAME = Man-Eating Seals of Antiquity
 
 # *DOCUMENTATION*
fs/ocfs2/ioctl.c +677 -0

715 lines not on this page · raw message

fs/ocfs2/ocfs2_ioctl.h +117 -0

121 lines not on this page · raw message

Signature · 1 line
1.5.4.4
#2 lore raw

PATCH 1/2 Ocfs2: Move ocfs2 ioctl definitions from ocfs2_fs.h to new added ocfs2_ioctl.h.

In reply to Tiger Yang

fs/ocfs2/file.h line 29

Quoted 9 lines · Tiger Yang
fs/ocfs2/file.h +1 -0
index d66cf4f..eb891db 100644
@@ -26,6 +26,8 @@
 #ifndef OCFS2_FILE_H
 #define OCFS2_FILE_H
 
+#include "ocfs2_ioctl.h"

I wanted to grab this for the merge window, but I see that
file.h is still including the new header. The header should be included in the appropriate C file, not here. Please clean this up.

Joel

Signature · 10 lines
"It is not the function of our government to keep the citizen from
 falling into error; it is the function of the citizen to keep the
 government from falling into error."
	- Robert H. Jackson

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#3 lore raw

PATCH 1/2 Ocfs2: Move ocfs2 ioctl definitions from ocfs2_fs.h to new added ocfs2_ioctl.h.

Quoted 10 lines · Joel Becker
Quoted 8 lines · Tiger Yang
fs/ocfs2/file.h +0 -0
index d66cf4f..eb891db 100644
@@ -26,6 +26,8 @@
 #ifndef OCFS2_FILE_H
 #define OCFS2_FILE_H
 
Quoted 7 lines

fs/ocfs2/file.h line 30

Quoted 2 lines
fs/ocfs2/file.h +1 -0
+#include "ocfs2_ioctl.h"
 

I wanted to grab this for the merge window, but I see that
file.h is still including the new header. The header should be included in the appropriate C file, not here. Please clean this up.

Currently 'resize.h' and 'file.h' are using ioctl structures from 'ocfs2_ioctl.h', don't like 'resize.h', which only was included in 'resize.c', 'file.h' instead was referred everywhere:

fs/ocfs2/quota_global.c:22:#include "file.h"
fs/ocfs2/dir.c:56:#include "file.h"
fs/ocfs2/locks.c:35:#include "file.h"
fs/ocfs2/aops.c:41:#include "file.h"
fs/ocfs2/inode.c:45:#include "file.h"
fs/ocfs2/symlink.c:49:#include "file.h"
fs/ocfs2/mmap.c:42:#include "file.h"
fs/ocfs2/dcache.c:39:#include "file.h"
fs/ocfs2/file.c:51:#include "file.h"
fs/ocfs2/namei.c:55:#include "file.h"
fs/ocfs2/alloc.c:48:#include "file.h"
fs/ocfs2/ioctl.c:18:#include "file.h"
fs/ocfs2/xattr.c:47:#include "file.h"
fs/ocfs2/quota_local.c:17:#include "file.h"
fs/ocfs2/dlmglue.c:47:#include "file.h"
fs/ocfs2/acl.c:32:#include "file.h"

We therefore need to add 'ocfs2_ioctl.h' in many C sources to avoid compile warnings.

Does it worth doing this? or maybe we can just add the 'ocfs2_ioctl.h' into 'ocfs2.h', the downside is, it may cause some innocent sources start including this undesired header.

Regards,
Tristan

Quoted 6 lines

Joel

#4 lore raw

PATCH 1/2 Ocfs2: Move ocfs2 ioctl definitions from ocfs2_fs.h to new added ocfs2_ioctl.h.

Quoted 6 lines · tristan

Currently 'resize.h' and 'file.h' are using ioctl structures from 'ocfs2_ioctl.h', don't like 'resize.h', which only was included in 'resize.c', 'file.h' instead was referred everywhere:

We therefore need to add 'ocfs2_ioctl.h' in many C sources to avoid compile warnings.

That's right, you put it in the C sources. This way we know
what includes each C file has, and only the C files needing the include file actually include it.

Joel

Signature · 9 lines
"Every day I get up and look through the Forbes list of the richest
 people in America. If I'm not there, I go to work."
        - Robert Orben

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#5 lore raw

PATCH 1/2 Ocfs2: Move ocfs2 ioctl definitions from ocfs2_fs.h to new added ocfs2_ioctl.h.

Quoted 6 lines · Joel Becker
Quoted 4 lines · tristan

Currently 'resize.h' and 'file.h' are using ioctl structures from 'ocfs2_ioctl.h', don't like 'resize.h', which only was included in 'resize.c', 'file.h' instead was referred everywhere:

Quoted 8 lines
Quoted 3 lines

We therefore need to add 'ocfs2_ioctl.h' in many C sources to avoid compile warnings.

That's right, you put it in the C sources. This way we know
what includes each C file has, and only the C files needing the include file actually include it.

I'm fine with this:)

BTW, it's a bad idea to add ocfs2_ioctl.h to ocfs2.h? it's not generic enough to be there to let every C file refer it? right?

Tristan.

Quoted 3 lines

Joel

#6 lore raw

PATCH 1/2 Ocfs2: Move ocfs2 ioctl definitions from ocfs2_fs.h to new added ocfs2_ioctl.h.

Quoted 9 lines · tristan
Quoted 4 lines

That's right, you put it in the C sources. This way we know
what includes each C file has, and only the C files needing the include file actually include it.

I'm fine with this:)

BTW, it's a bad idea to add ocfs2_ioctl.h to ocfs2.h? it's not generic enough to be there to let every C file refer it? right?

I'm wavering on this. We have ocfs2_fs.h and ocfs2_lockid.h in
there, but not ocfs2_lockingver.h...

Oh, hell, put it in ocfs2.h right by the other ocfs2_*.h headers. Can't hurt.

Joel

Signature · 12 lines
"This is the end, beautiful friend.
 This is the end, my only friend the end
 Of our elaborate plans, the end
 Of everything that stands, the end
 No safety or surprise, the end
 I'll never look into your eyes again."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#7 lore raw

PATCH 1/2 Ocfs2: Move ocfs2 ioctl definitions from ocfs2_fs.h to new added ocfs2_ioctl.h.

Quoted 13 lines · Joel Becker
Quoted 10 lines · tristan
Quoted 5 lines

That's right, you put it in the C sources. This way we know
what includes each C file has, and only the C files needing the include file actually include it.

I'm fine with this:)

BTW, it's a bad idea to add ocfs2_ioctl.h to ocfs2.h? it's not generic enough to be there to let every C file refer it? right?

Quoted 6 lines

I'm wavering on this. We have ocfs2_fs.h and ocfs2_lockid.h in
there, but not ocfs2_lockingver.h...

Oh, hell, put it in ocfs2.h right by the other ocfs2_*.h headers. Can't hurt.

Yes, I'm also more pleasant with this:)

Quoted 3 lines

Joel