X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ffid%2Flproc_fid.c;h=7040c492f461e314a06e09323dbec4be365315ab;hp=fd6499339319afda0e35bd5312ecef51d59142d6;hb=d821adb626e050206f1b4605f1159cf65ad22af5;hpb=70e80ade90af09300396706b8910e196a7928520 diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c index fd64993..7040c49 100644 --- a/lustre/fid/lproc_fid.c +++ b/lustre/fid/lproc_fid.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -16,8 +14,8 @@ * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see [sun.com URL with a - * copy of GPLv2]. + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or @@ -26,8 +24,10 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -40,9 +40,6 @@ * Author: Yury Umanets */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_FID #ifdef __KERNEL__ @@ -69,15 +66,17 @@ static int seq_proc_write_common(struct file *file, const char *buffer, unsigned long count, void *data, - struct lu_range *range) + struct lu_seq_range *range) { - struct lu_range tmp; + struct lu_seq_range tmp; int rc; ENTRY; LASSERT(range != NULL); - rc = sscanf(buffer, "[%Lx - %Lx]\n", &tmp.lr_start, &tmp.lr_end); + rc = sscanf(buffer, "[%llx - %llx]\n", + (long long unsigned *)&tmp.lsr_start, + (long long unsigned *)&tmp.lsr_end); if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp)) RETURN(-EINVAL); *range = tmp; @@ -87,14 +86,14 @@ seq_proc_write_common(struct file *file, const char *buffer, static int seq_proc_read_common(char *page, char **start, off_t off, int count, int *eof, void *data, - struct lu_range *range) + struct lu_seq_range *range) { int rc; ENTRY; *eof = 1; - rc = snprintf(page, count, "[%Lx - %Lx]\n", - PRANGE(range)); + rc = snprintf(page, count, "["LPX64" - "LPX64"]:%x:%s\n", + PRANGE(range)); RETURN(rc); } @@ -111,16 +110,16 @@ seq_server_proc_write_space(struct file *file, const char *buffer, LASSERT(seq != NULL); - down(&seq->lss_sem); + mutex_lock(&seq->lss_mutex); rc = seq_proc_write_common(file, buffer, count, data, &seq->lss_space); if (rc == 0) { CDEBUG(D_INFO, "%s: Space: "DRANGE"\n", seq->lss_name, PRANGE(&seq->lss_space)); } - - up(&seq->lss_sem); - + + mutex_unlock(&seq->lss_mutex); + RETURN(count); } @@ -134,11 +133,11 @@ seq_server_proc_read_space(char *page, char **start, off_t off, LASSERT(seq != NULL); - down(&seq->lss_sem); + mutex_lock(&seq->lss_mutex); rc = seq_proc_read_common(page, start, off, count, eof, data, &seq->lss_space); - up(&seq->lss_sem); - + mutex_unlock(&seq->lss_mutex); + RETURN(rc); } @@ -166,7 +165,7 @@ seq_server_proc_read_server(char *page, char **start, off_t off, } else { rc = snprintf(page, count, "\n"); } - + RETURN(rc); } @@ -180,21 +179,21 @@ seq_server_proc_write_width(struct file *file, const char *buffer, LASSERT(seq != NULL); - down(&seq->lss_sem); + mutex_lock(&seq->lss_mutex); - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - RETURN(rc); + rc = lprocfs_write_helper(buffer, count, &val); + if (rc != 0) { + CERROR("%s: invalid width.\n", seq->lss_name); + GOTO(out_unlock, rc); + } - seq->lss_width = val; + seq->lss_width = val; + + CDEBUG(D_INFO, "%s: Width: "LPU64"\n", + seq->lss_name, seq->lss_width); +out_unlock: + mutex_unlock(&seq->lss_mutex); - if (rc == 0) { - CDEBUG(D_INFO, "%s: Width: "LPU64"\n", - seq->lss_name, seq->lss_width); - } - - up(&seq->lss_sem); - RETURN(count); } @@ -208,10 +207,10 @@ seq_server_proc_read_width(char *page, char **start, off_t off, LASSERT(seq != NULL); - down(&seq->lss_sem); + mutex_lock(&seq->lss_mutex); rc = snprintf(page, count, LPU64"\n", seq->lss_width); - up(&seq->lss_sem); - + mutex_unlock(&seq->lss_mutex); + RETURN(rc); } @@ -226,7 +225,7 @@ seq_client_proc_write_space(struct file *file, const char *buffer, LASSERT(seq != NULL); - down(&seq->lcs_sem); + mutex_lock(&seq->lcs_mutex); rc = seq_proc_write_common(file, buffer, count, data, &seq->lcs_space); @@ -234,9 +233,9 @@ seq_client_proc_write_space(struct file *file, const char *buffer, CDEBUG(D_INFO, "%s: Space: "DRANGE"\n", seq->lcs_name, PRANGE(&seq->lcs_space)); } - - up(&seq->lcs_sem); - + + mutex_unlock(&seq->lcs_mutex); + RETURN(count); } @@ -250,11 +249,11 @@ seq_client_proc_read_space(char *page, char **start, off_t off, LASSERT(seq != NULL); - down(&seq->lcs_sem); + mutex_lock(&seq->lcs_mutex); rc = seq_proc_read_common(page, start, off, count, eof, data, &seq->lcs_space); - up(&seq->lcs_sem); - + mutex_unlock(&seq->lcs_mutex); + RETURN(rc); } @@ -263,28 +262,36 @@ seq_client_proc_write_width(struct file *file, const char *buffer, unsigned long count, void *data) { struct lu_client_seq *seq = (struct lu_client_seq *)data; + __u64 max; int rc, val; ENTRY; LASSERT(seq != NULL); - down(&seq->lcs_sem); + mutex_lock(&seq->lcs_mutex); rc = lprocfs_write_helper(buffer, count, &val); - if (rc) + if (rc) { + mutex_unlock(&seq->lcs_mutex); RETURN(rc); + } - if (val <= LUSTRE_SEQ_MAX_WIDTH && val > 0) { - seq->lcs_width = val; + if (seq->lcs_type == LUSTRE_SEQ_DATA) + max = LUSTRE_DATA_SEQ_MAX_WIDTH; + else + max = LUSTRE_METADATA_SEQ_MAX_WIDTH; + + if (val <= max && val > 0) { + seq->lcs_width = val; + + if (rc == 0) { + CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n", + seq->lcs_name, seq->lcs_width); + } + } + + mutex_unlock(&seq->lcs_mutex); - if (rc == 0) { - CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n", - seq->lcs_name, seq->lcs_width); - } - } - - up(&seq->lcs_sem); - RETURN(count); } @@ -298,10 +305,10 @@ seq_client_proc_read_width(char *page, char **start, off_t off, LASSERT(seq != NULL); - down(&seq->lcs_sem); + mutex_lock(&seq->lcs_mutex); rc = snprintf(page, count, LPU64"\n", seq->lcs_width); - up(&seq->lcs_sem); - + mutex_unlock(&seq->lcs_mutex); + RETURN(rc); } @@ -315,10 +322,10 @@ seq_client_proc_read_fid(char *page, char **start, off_t off, LASSERT(seq != NULL); - down(&seq->lcs_sem); + mutex_lock(&seq->lcs_mutex); rc = snprintf(page, count, DFID"\n", PFID(&seq->lcs_fid)); - up(&seq->lcs_sem); - + mutex_unlock(&seq->lcs_mutex); + RETURN(rc); }