All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V2.
@ 2011-01-30  6:25 Tristan Ye
  2011-01-30  6:25 ` [Ocfs2-devel] [PATCH 1/3] Ocfs2: Using macro to set/clear *FILLED* flags in info handler Tristan Ye
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Tristan Ye @ 2011-01-30  6:25 UTC (permalink / raw)
  To: ocfs2-devel

This patch set is an attempt to add the last two codes for OCFS2_IOC_INFO, it
hopes with luck, to be committed upstream in next merge-window.

It has been in following remote branch:

git://oss.oracle.com/git/tye/linux-2.6.git o2info

Tristan

^ permalink raw reply	[flat|nested] 26+ messages in thread
* [Ocfs2-devel] [PATCH 0/3] Ocfs2: Complete rest of o2info patches(v5).
@ 2011-05-24 10:07 Tristan Ye
  2011-05-24 10:07 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
  0 siblings, 1 reply; 26+ messages in thread
From: Tristan Ye @ 2011-05-24 10:07 UTC (permalink / raw)
  To: ocfs2-devel

Joel,
	Please take the following three patches as the final version for the rest
of o2info patches, it's applicable atop latest 2.6.39 kernel, and has been well-
tested.
	Btw, move_exts patches series will be coming soon, which should be applied
right after o2info patches, so apply o2info first, then move_exts into your merge_
window.

Tristan.

^ permalink raw reply	[flat|nested] 26+ messages in thread
* [Ocfs2-devel] [PATCH 0/3] Ocfs2: Complete rest of o2info patches.
@ 2011-03-29  2:11 Tristan Ye
  2011-03-29  2:11 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
  0 siblings, 1 reply; 26+ messages in thread
From: Tristan Ye @ 2011-03-29  2:11 UTC (permalink / raw)
  To: ocfs2-devel

Joel,
	Please take the following two patches as the final version for the rest
of o2info patches, actually there are three patches for all in this series, while
the first one "Ocfs2: Using macro to set/clear *FILLED* flags in info handler."
has been already kept in your merge_window, hope they are not too late for 2.6.39
window.

Tristan.

^ permalink raw reply	[flat|nested] 26+ messages in thread
* [Ocfs2-devel] [PATCH 2/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEINODE' for o2info ioctl.
@ 2011-02-22  4:59 Tristan Ye
  2011-02-22  4:59 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' " Tristan Ye
  0 siblings, 1 reply; 26+ messages in thread
From: Tristan Ye @ 2011-02-22  4:59 UTC (permalink / raw)
  To: ocfs2-devel

The new code is dedicated to calculate free inodes number of all inode_allocs,
then return the info to userpace in terms of an array.

Specially, flag 'OCFS2_INFO_FL_NON_COHERENT', manipulated by '--cluster-coherent'
from userspace, is now going to be involved. setting the flag on means no cluster
coherency considered, usually, userspace tools choose none-coherency strategy by
default for the sake of performace.

Signed-off-by: Tristan Ye <tristan.ye@oracle.com>
---
 fs/ocfs2/ioctl.c       |  129 ++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/ocfs2_ioctl.h |   11 ++++
 2 files changed, 140 insertions(+), 0 deletions(-)

diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index fa09ded..ae7f89d 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -23,6 +23,9 @@
 #include "ioctl.h"
 #include "resize.h"
 #include "refcounttree.h"
+#include "sysfile.h"
+#include "dir.h"
+#include "buffer_head_io.h"
 
 #include <linux/ext2_fs.h>
 
@@ -53,6 +56,11 @@ static inline void o2info_clear_request_filled(struct ocfs2_info_request *req)
 	req->ir_flags &= ~OCFS2_INFO_FL_FILLED;
 }
 
+static inline int o2info_coherent(struct ocfs2_info_request *req)
+{
+	return (!(req->ir_flags & OCFS2_INFO_FL_NON_COHERENT));
+}
+
 static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags)
 {
 	int status;
@@ -312,6 +320,123 @@ bail:
 	return status;
 }
 
+int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb,
+				struct inode *inode_alloc, u64 blkno,
+				struct ocfs2_info_freeinode *fi, u32 slot)
+{
+	int status = 0, unlock = 0;
+
+	struct buffer_head *bh = NULL;
+	struct ocfs2_dinode *dinode_alloc = NULL;
+
+	if (inode_alloc)
+		mutex_lock(&inode_alloc->i_mutex);
+
+	if (o2info_coherent(&fi->ifi_req)) {
+		status = ocfs2_inode_lock(inode_alloc, &bh, 0);
+		if (status < 0) {
+			mlog_errno(status);
+			goto bail;
+		}
+		unlock = 1;
+	} else {
+		status = ocfs2_read_blocks_sync(osb, blkno, 1, &bh);
+		if (status < 0) {
+			mlog_errno(status);
+			goto bail;
+		}
+	}
+
+	dinode_alloc = (struct ocfs2_dinode *)bh->b_data;
+
+	fi->ifi_stat[slot].lfi_total =
+		le32_to_cpu(dinode_alloc->id1.bitmap1.i_total);
+	fi->ifi_stat[slot].lfi_free =
+		le32_to_cpu(dinode_alloc->id1.bitmap1.i_total) -
+		le32_to_cpu(dinode_alloc->id1.bitmap1.i_used);
+
+bail:
+	if (unlock)
+		ocfs2_inode_unlock(inode_alloc, 0);
+
+	if (inode_alloc)
+		mutex_unlock(&inode_alloc->i_mutex);
+
+	brelse(bh);
+
+	mlog_exit(status);
+	return status;
+}
+
+int ocfs2_info_handle_freeinode(struct inode *inode,
+				struct ocfs2_info_request __user *req)
+{
+	u32 i;
+	u64 blkno = -1;
+	char namebuf[40];
+	int status = -EFAULT, type = INODE_ALLOC_SYSTEM_INODE;
+	struct ocfs2_info_freeinode *oifi = NULL;
+	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct inode *inode_alloc = NULL;
+
+	oifi = kzalloc(sizeof(struct ocfs2_info_freeinode), GFP_NOFS);
+	if (!oifi) {
+		status = -ENOMEM;
+		mlog_errno(status);
+		goto bail;
+	}
+
+	if (o2info_from_user(*oifi, req))
+		goto bail;
+
+	oifi->ifi_slotnum = osb->max_slots;
+
+	for (i = 0; i < oifi->ifi_slotnum; i++) {
+		if (o2info_coherent(&oifi->ifi_req)) {
+			inode_alloc = ocfs2_get_system_file_inode(osb, type, i);
+			if (!inode_alloc) {
+				mlog(ML_ERROR, "unable to get alloc inode in "
+				    "slot %u\n", i);
+				status = -EIO;
+				goto bail;
+			}
+		} else {
+			ocfs2_sprintf_system_inode_name(namebuf,
+							sizeof(namebuf),
+							type, i);
+			status = ocfs2_lookup_ino_from_name(osb->sys_root_inode,
+							    namebuf,
+							    strlen(namebuf),
+							    &blkno);
+			if (status < 0) {
+				status = -ENOENT;
+				goto bail;
+			}
+		}
+
+		status = ocfs2_info_scan_inode_alloc(osb, inode_alloc, blkno, oifi, i);
+		if (status < 0)
+			goto bail;
+
+		iput(inode_alloc);
+		inode_alloc = NULL;
+	}
+
+	o2info_set_request_filled(&oifi->ifi_req);
+
+	if (o2info_to_user(*oifi, req))
+		goto bail;
+
+	status = 0;
+bail:
+	if (status)
+		o2info_set_request_error(&oifi->ifi_req, req);
+
+	kfree(oifi);
+
+	return status;
+}
+
 int ocfs2_info_handle_unknown(struct inode *inode,
 			      struct ocfs2_info_request __user *req)
 {
@@ -383,6 +508,10 @@ int ocfs2_info_handle_request(struct inode *inode,
 		if (oir.ir_size == sizeof(struct ocfs2_info_journal_size))
 			status = ocfs2_info_handle_journal_size(inode, req);
 		break;
+	case OCFS2_INFO_FREEINODE:
+		if (oir.ir_size == sizeof(struct ocfs2_info_freeinode))
+			status = ocfs2_info_handle_freeinode(inode, req);
+		break;
 	default:
 		status = ocfs2_info_handle_unknown(inode, req);
 		break;
diff --git a/fs/ocfs2/ocfs2_ioctl.h b/fs/ocfs2/ocfs2_ioctl.h
index b46f39b..6b4b39a 100644
--- a/fs/ocfs2/ocfs2_ioctl.h
+++ b/fs/ocfs2/ocfs2_ioctl.h
@@ -142,6 +142,16 @@ struct ocfs2_info_journal_size {
 	__u64 ij_journal_size;
 };
 
+struct ocfs2_info_freeinode {
+	struct ocfs2_info_request ifi_req;
+	struct ocfs2_info_local_freeinode {
+		__u64 lfi_total;
+		__u64 lfi_free;
+	} ifi_stat[OCFS2_MAX_SLOTS];
+	__u32 ifi_slotnum; /* out */
+	__u32 ifi_pad;
+};
+
 /* Codes for ocfs2_info_request */
 enum ocfs2_info_type {
 	OCFS2_INFO_CLUSTERSIZE = 1,
@@ -151,6 +161,7 @@ enum ocfs2_info_type {
 	OCFS2_INFO_UUID,
 	OCFS2_INFO_FS_FEATURES,
 	OCFS2_INFO_JOURNAL_SIZE,
+	OCFS2_INFO_FREEINODE,
 	OCFS2_INFO_NUM_TYPES
 };
 
-- 
1.5.5

^ permalink raw reply related	[flat|nested] 26+ messages in thread
* [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V3.
@ 2011-02-18  4:26 Tristan Ye
  2011-02-18  4:26 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
  0 siblings, 1 reply; 26+ messages in thread
From: Tristan Ye @ 2011-02-18  4:26 UTC (permalink / raw)
  To: ocfs2-devel

This patch set is an attempt to add the last two codes for OCFS2_IOC_INFO, it
hopes with luck, to be committed upstream in next merge-window.

Changes since V2:
	* incorporate mark's comments.

It has been in following remote branch:

git://oss.oracle.com/git/tye/linux-2.6.git o2info

Tristan

^ permalink raw reply	[flat|nested] 26+ messages in thread
* [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V2.
@ 2010-11-16 10:13 Tristan Ye
  2010-11-16 10:13 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
  0 siblings, 1 reply; 26+ messages in thread
From: Tristan Ye @ 2010-11-16 10:13 UTC (permalink / raw)
  To: ocfs2-devel

This set of patch series includes three patches:

1. Using marco to simplize duplicated codes.

2. Adding new code 'OCFS2_INODE_FREEINODE'

3. Adding new code 'OCFS2_INFO_FREEFRAG'

Changes since v1:

1. Incorporate Joel's comments to take cluster coherency into account when
   lookuping the inode/inode_blkno.

2. Using helpers somewhere to improve the readability of codes.



Tristan.

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2011-05-24 10:07 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-30  6:25 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V2 Tristan Ye
2011-01-30  6:25 ` [Ocfs2-devel] [PATCH 1/3] Ocfs2: Using macro to set/clear *FILLED* flags in info handler Tristan Ye
2011-01-31 22:15   ` Mark Fasheh
2011-02-01  1:10     ` Joel Becker
2011-02-01  3:06       ` Mark Fasheh
2011-02-01  6:01         ` Joel Becker
2011-02-01  7:53           ` Tristan Ye
2011-02-01 17:37           ` Mark Fasheh
2011-02-01  7:48     ` Tristan Ye
2011-02-20 12:08   ` Joel Becker
2011-01-30  6:26 ` [Ocfs2-devel] [PATCH 2/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEINODE' for o2info ioctl Tristan Ye
2011-01-31 22:57   ` Mark Fasheh
2011-02-01  7:52     ` Tristan Ye
2011-02-20 12:07   ` Joel Becker
2011-02-20 12:59     ` Tristan Ye
2011-02-21  2:04       ` Joel Becker
2011-02-21 18:17       ` Sunil Mushran
2011-01-30  6:26 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' " Tristan Ye
  -- strict thread matches above, loose matches on Subject: below --
2011-05-24 10:07 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Complete rest of o2info patches(v5) Tristan Ye
2011-05-24 10:07 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
2011-03-29  2:11 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Complete rest of o2info patches Tristan Ye
2011-03-29  2:11 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
2011-02-22  4:59 [Ocfs2-devel] [PATCH 2/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEINODE' " Tristan Ye
2011-02-22  4:59 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' " Tristan Ye
2011-02-18  4:26 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V3 Tristan Ye
2011-02-18  4:26 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
2010-11-16 10:13 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V2 Tristan Ye
2010-11-16 10:13 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
2010-12-07  1:11   ` Joel Becker
2010-12-07  1:45     ` Tristan Ye
2010-12-07  3:36       ` Joel Becker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.