From patchwork Wed May 30 15:07:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jeff.liu" X-Patchwork-Id: 162006 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CCEDAB704D for ; Thu, 31 May 2012 01:10:47 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752903Ab2E3PKo (ORCPT ); Wed, 30 May 2012 11:10:44 -0400 Received: from rcsinet15.oracle.com ([148.87.113.117]:39091 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751517Ab2E3PKo (ORCPT ); Wed, 30 May 2012 11:10:44 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q4UF9ukr004545 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 May 2012 15:09:56 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q4UF9t5h025427 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 30 May 2012 15:09:55 GMT Received: from abhmt106.oracle.com (abhmt106.oracle.com [141.146.116.58]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q4UF9t8S021720; Wed, 30 May 2012 10:09:55 -0500 Received: from localhost.localdomain (/123.119.107.100) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 30 May 2012 08:09:54 -0700 From: jeff.liu@oracle.com To: containers@lists.linux-foundation.org Cc: cgroups@vger.kernel.org, jack@suse.cz, glommer@parallels.com, daniel.lezcano@free.fr, tytso@mit.edu, bpm@sgi.com, chris.mason@oracle.com, hch@infradead.org, christopher.jones@oracle.com, david@fromorbit.com, tinguely@sgi.com, tm@tao.ma, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jie Liu Subject: [PATCH 2/3] container quota tool: add quotaio for lxc Date: Wed, 30 May 2012 23:07:57 +0800 Message-Id: <1338390478-13951-2-git-send-email-jeff.liu@oracle.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1338390478-13951-1-git-send-email-jeff.liu@oracle.com> References: <1338390478-13951-1-git-send-email-jeff.liu@oracle.com> X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Add quotaio_lxc.c[.h] to isolate container quotactl operations. Signed-off-by: Jie Liu --- quotaio_lxc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ quotaio_lxc.h | 4 +++ 2 files changed, 82 insertions(+), 0 deletions(-) create mode 100644 quotaio_lxc.c create mode 100644 quotaio_lxc.h diff --git a/quotaio_lxc.c b/quotaio_lxc.c new file mode 100644 index 0000000..b3a8144 --- /dev/null +++ b/quotaio_lxc.c @@ -0,0 +1,78 @@ +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#include "pot.h" +#include "common.h" +#include "quotaio.h" +#include "quotaio_generic.h" +#include "quota.h" +#include "quotasys.h" +#include "dqblk_lxc.h" + +int lxc_init_io(struct quota_handle *h); +int lxc_write_info(struct quota_handle *h); +struct dquot *lxc_read_dquot(struct quota_handle *h, qid_t id); +int lxc_commit_dquot(struct dquot *dquot, int flags); +int lxc_scan_dquots(struct quota_handle *h, int (*process_dquot)(struct +dquot *dquot, char *dqname)); + +struct quotafile_ops quotafile_ops_lxc = { +init_io: lxc_init_io, +write_info: lxc_write_info, +read_dquot: lxc_read_dquot, +commit_dquot: lxc_commit_dquot, +scan_dquots: lxc_scan_dquots +}; + +/* + * Initialize container quota information + */ +int lxc_init_io(struct quota_handle *h) +{ + /* + * FIXME: at first, before turning LXC quota on, + * call vfs_get_info() will failed as ENOSCH, so + * just return 0 is ok. + * Should we consider to call vfs_get_info(h) here? + */ + return 0; +} + +/* + * Write information (grace times) + */ +int lxc_write_info(struct quota_handle *h) +{ + return vfs_set_info(h, IIF_BGRACE | IIF_IGRACE); +} + +struct dquot *lxc_read_dquot(struct quota_handle *h, qid_t id) +{ + struct dquot *dquot = get_empty_dquot(); + + dquot->dq_id = id; + dquot->dq_h = h; + memset(&dquot->dq_dqb, 0, sizeof(struct util_dqblk)); + if (vfs_get_dquot(dquot) < 0) { + free(dquot); + return NULL; + } + return dquot; +} + +int lxc_commit_dquot(struct dquot *dquot, int flags) +{ + return vfs_set_dquot(dquot, flags); +} + +int lxc_scan_dquots(struct quota_handle *h, int (*process_dquot)(struct +dquot *dquot, char *dqname)) +{ + return generic_scan_dquots(h, process_dquot, vfs_get_dquot); +} diff --git a/quotaio_lxc.h b/quotaio_lxc.h new file mode 100644 index 0000000..2ae2899 --- /dev/null +++ b/quotaio_lxc.h @@ -0,0 +1,4 @@ +#ifndef GUARD_QUOTAIO_GENERIC_H +#define GUARD_QUOTAIO_GENERIC_H + +#endif