Whamcloud - gitweb
LU-5577 ptlrpc: fix comparison between signed and unsigned
[fs/lustre-release.git] / lustre / lov / lov_offset.c
index a2fa0dc..d713907 100644 (file)
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_LOV
 
-#ifdef __KERNEL__
 #include <libcfs/libcfs.h>
-#else
-#include <liblustre.h>
-#endif
 
 #include <obd_class.h>
-#include <obd_lov.h>
 
 #include "lov_internal.h"
 
@@ -75,6 +69,19 @@ obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size,
         RETURN(lov_size);
 }
 
+/**
+ * Compute file level page index by stripe level page offset
+ */
+pgoff_t lov_stripe_pgoff(struct lov_stripe_md *lsm, pgoff_t stripe_index,
+                        int stripe)
+{
+       obd_off offset;
+
+       offset = lov_stripe_size(lsm, stripe_index << PAGE_CACHE_SHIFT,
+                                stripe);
+       return offset >> PAGE_CACHE_SHIFT;
+}
+
 /* we have an offset in file backed by an lov and want to find out where
  * that offset lands in our given stripe of the file.  for the easy
  * case where the offset is within the stripe, we just have to scale the