[Y2038] [PATCH v2] usb: misc: usbtest: Remove timeval usage

2015-10-26 Thread Deepa Dinamani
timeval is deprecated and not y2038 safe.  Its size also changes according
to 32 bit/ 64 bit compilation.  Replace it with 32 and 64 bit versions of
its individual fields, giving two ioctls with different code values.
The two ioctls are necessary to maintain the 32 bit and 64 bit userspace
compatibility with a 64/32 bit kernel.

Change unsigned to __u32 types for a definitive userspace interface.
This is in accordance with the psABI that the unsigned type is always
32 bits.

Also use motonic timer instead of real time to ensure positive delta
values.

Refactor usbtest_ioctl for readability to isolate the handling of the
testing timing measurement.

The official testusb userspace tool can be changed in a separate patch
to reflect the __u32 changes as well. It can use the usbtest_param_32
struct, since 32 bit seconds is long enough for test durations.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
Changes since v1:
* Removed new ioctl interface
* Support both sizes of timeval using same ioctl code
* Use timespec64 instead of ktime_t
* Use __u32 for unsigned fields

 drivers/usb/misc/usbtest.c | 229 +
 1 file changed, 147 insertions(+), 82 deletions(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 637f3f7..d1ce881 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -22,18 +22,42 @@ static void complicated_callback(struct urb *urb);
 /*-*/
 
 /* FIXME make these public somewhere; usbdevfs.h? */
-struct usbtest_param {
+
+/* Parameter for usbtest driver. */
+struct usbtest_param_32 {
/* inputs */
-   unsignedtest_num;   /* 0..(TEST_CASES-1) */
-   unsignediterations;
-   unsignedlength;
-   unsignedvary;
-   unsignedsglen;
+   __u32   test_num;   /* 0..(TEST_CASES-1) */
+   __u32   iterations;
+   __u32   length;
+   __u32   vary;
+   __u32   sglen;
 
/* outputs */
-   struct timeval  duration;
+   __s32   duration_sec;
+   __s32   duration_usec;
 };
-#define USBTEST_REQUEST_IOWR('U', 100, struct usbtest_param)
+
+/*
+ * Compat parameter to the usbtest driver.
+ * This supports older user space binaries compiled with 64 bit compiler.
+ */
+struct usbtest_param_64 {
+   /* inputs */
+   __u32   test_num;   /* 0..(TEST_CASES-1) */
+   __u32   iterations;
+   __u32   length;
+   __u32   vary;
+   __u32   sglen;
+
+   /* outputs */
+   __s64   duration_sec;
+   __s64   duration_usec;
+};
+
+/* IOCTL interface to the driver. */
+#define USBTEST_REQUEST_32_IOWR('U', 100, struct usbtest_param_32)
+/* COMPAT IOCTL interface to the driver. */
+#define USBTEST_REQUEST_64_IOWR('U', 100, struct usbtest_param_64)
 
 /*-*/
 
@@ -1030,7 +1054,7 @@ struct ctrl_ctx {
unsignedpending;
int status;
struct urb  **urb;
-   struct usbtest_param*param;
+   struct usbtest_param_32 *param;
int last;
 };
 
@@ -1155,7 +1179,7 @@ error:
 }
 
 static int
-test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
+test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param)
 {
struct usb_device   *udev = testdev_to_usbdev(dev);
struct urb  **urb;
@@ -1930,7 +1954,7 @@ static struct urb *iso_alloc_urb(
 }
 
 static int
-test_queue(struct usbtest_dev *dev, struct usbtest_param *param,
+test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
int pipe, struct usb_endpoint_descriptor *desc, unsigned offset)
 {
struct transfer_context context;
@@ -2049,81 +2073,20 @@ static int test_unaligned_bulk(
return retval;
 }
 
-/*-*/
-
-/* We only have this one interface to user space, through usbfs.
- * User mode code can scan usbfs to find N different devices (maybe on
- * different busses) to use when testing, and allocate one thread per
- * test.  So discovery is simplified, and we have no device naming issues.
- *
- * Don't use these only as stress/load tests.  Use them along with with
- * other USB bus activity:  plugging, unplugging, mousing, mp3 playback,
- * video capture, and so on.  Run different tests at different times, in
- * different sequences.  Nothing here should interact with other devices,
- * except indirectly by consuming USB bandwidth and CPU resources for test
- * threads and request completion.  But the only way to know that for sure
- * is to test when HC queues are 

[Y2038] [PATCH] usb: usbtest: Add new ioctl interface

2015-10-23 Thread Deepa Dinamani
On Thu, Oct 22, 2015 at 1:45 PM, Arnd Bergmann <a...@arndb.de> wrote:

> On Thursday 22 October 2015 09:43:25 Deepa Dinamani wrote:
> > On Thu, Oct 22, 2015 at 2:36 AM, Arnd Bergmann <a...@arndb.de> wrote:
> > > On Wednesday 21 October 2015 18:03:02 Deepa Dinamani wrote:
> > > > On Wed, Oct 21, 2015 at 4:17 PM, Arnd Bergmann <a...@arndb.de>
> wrote:
> > > Yes, and that is the right idea. I suspect we will have to provide
> > > different definitions for kernel and user space though, in one
> > > form or another. You are right that we want to remove 'timeval'
> > > from the kernel, and in order to keep user space unchanged, this
> > > means defining the structure like
> > >
> > > struct usbtest_param_32 {
> > > /* inputs */
> > > __u32test_num;   /* 0..(TEST_CASES-1) */
> > > __u32iterations;
> > > ...
> > > __s32 duration_sec;
> > > __s32 duration_usec;
> > > };
> > >
> > > which is a well-defined binary version of what 32-bit user space
> > > sees today. We also need the 64-bit version of that, for both
> > > normal 64-bit tasks and future 32-bit tasks that are built with
> > > the old structure definition.
> > >
> > > Optionally, we can introduce a better interface with a new command
> > > number as your patch does, but that should be a separate patch,
> > > and we have to see if the USB maintainers want to do this or not.
> > >
> >
> > There are two problems with the original ioctl interface:
> >
> > 1. Because of the use of timeval, compatibility is broken between 32 bit
> > and 64 bit binaries.
> >
> > This has nothing to do with y2038 problem at all.
> > This is the case with all interfaces using timeval itself and has nothing
> > to do with this one
> > particular bad interface design.
>
> Right.
>
> > The struct you suggested above will work to map to two separate ioctls.
> > But, if this is a generic problem, shouldn't the above solution be in
> some
> > common file?
> > For instance we could have this:
> >
> > struct timeval_32 {
> > __s32 duration_sec;
> > __s32 duration_usec;
> > };
>
> This is essentially 'struct compat_timeval', which I intend to keep
> around in the kernel for backwards compatibility and will make available
> to 32-bit kernels that currently can't use it. The patches still need
> a few more review rounds though.
>
> > And, a similar struct for timeval_64.
> >
> > This would also mean adding api's to fill the structures defined above.
> > Basically an entire layer.
>
> We should really see how many drivers need this. I have shown that the
> core kernel does not need it with my patches, as all system calls that
> use timeval are already deprecated. I have a list of drivers that need
> to be converted at
>
>
> https://docs.google.com/spreadsheets/d/1HCYwHXxs48TsTb6IGUduNjQnmfRvMPzCN6T_0YiQwis/edit#gid=346406462
>
> on the second sheet. All the ones that have an ABI exposed to user space
> are marked 'uapi' or 'ioctl', and we could check which ones of these
> would be helped by having a generic set of helpers for timeval_64.
>

Ok. I can do this. I can get back to you early next week.

>
> > This is not necessary for this driver as the struct's are not exposed.
> > My guess is also that there aren't many applications using this because
> of
> > the way it needs redeclaring everything in the application.
>
> Agreed. My guess is that there is only one application using it at all,
> but it's hard to know for sure. If we could prove that there is only one,
> and we can change it to use a new ioctl command if that is present in some
> header file, all this could be simplified.
>

Ok. I can contact the usb linux mailing list if they know of any other or
just to fish around for their opinion.
I'll keep you in the cc. Let me know if you would prefer the whole 2038/
outreachy mailing list instead.

>
> > Since the original implementation is broken already, my first preference
> > was to fix the interface with the new interface itself.
>
> I wouldn't call the original implementation broken, except for the
> 64-bit compat problem. What makes it broken is that the ioctl data
> structure changes in user space when that changes the defintion of
> 'struct timeval', but since the data returned here is a difference
> of two times, the current 32-bit tv_sec variable is actually good
> enough.

[Y2038] [PATCH] usb: usbtest: Add new ioctl interface

2015-10-22 Thread Deepa Dinamani
On Thu, Oct 22, 2015 at 2:36 AM, Arnd Bergmann <a...@arndb.de> wrote:

> On Wednesday 21 October 2015 18:03:02 Deepa Dinamani wrote:
> > On Wed, Oct 21, 2015 at 4:17 PM, Arnd Bergmann <a...@arndb.de> wrote:
> > > On Wednesday 21 October 2015 15:17:14 Deepa Dinamani wrote:
> > > > Rename old ioctl and data types to COMPAT_USBTEST_REQUEST and
> > > > usbtest_param_compat, respectively.
> > > >
> > > > The change also uses monotonic time instead of real time for both
> ioctls.
> > > > This ensures that the time duration is always positive.  Also use
> ktime
> > > > api's for time routines accomodating moving all of kernel to use 64
> bit
> > > > time eventually.
> > >
> > > Changing to monotonic time is good here. Using ktime_t is often
> > > a good idea, but I think in this case it causes more problems
> > > because we end up having to convert it back into timeval.
> > >
> >
> > If we are keeping timeval in the interface, then I agree we don't need
> > ktime_t.
> > It was my understanding from the y2038 summary that you were recommending
> > eliminating timeval.
>
> It's a little more complicated: We try to avoid breaking compilation of
> user space programs if at all possible, so if they use timeval today,
> it's better not to require an API change as far as user space is
> concerned.
>
> On the other hand, we know that we have to do significant changes to
> glibc, and any interfaces that are between the kernel and libc (i.e.
> most system calls) should stop passing timeval. Instead the libc can
> provide its own helper functions and e.g. implement gettimeofday()
> by calling clock_gettime() and then converting the result.
> > > The most important point to notice here is that the definition is in a
> .c
> > > file, where user space cannot access it. This means that any program
> > > calling it already has a copy of this definition, and changing the
> > > definition here will not help you the way it would if the definition
> > > was in include/uapi/linux/*.h
> > >
> >
> > This was going to be in a follow on patch.
> > But, I was not sure if it should be done as part of outreachy.
> > The driver in the current state is self contained in this .c file.
> > All definitions should really be moved to a uapi header file as the
> > original fixme comment indicates.
> >
> > But the only current user program that seems to be using it is in the
> > kernel tools.
> > The structures and the ioctl are indeed redefined there.
> >
> > Also, the previous struct and IOCTL definitions have not changed because
> of
> > the above reason.
> > I kept them intact for compatibility with existing binaries.
>
> Yes, and that is the right idea. I suspect we will have to provide
> different definitions for kernel and user space though, in one
> form or another. You are right that we want to remove 'timeval'
> from the kernel, and in order to keep user space unchanged, this
> means defining the structure like
>
> struct usbtest_param_32 {
> /* inputs */
> __u32test_num;   /* 0..(TEST_CASES-1) */
> __u32iterations;
> ...
> __s32 duration_sec;
> __s32 duration_usec;
> };
>
> which is a well-defined binary version of what 32-bit user space
> sees today. We also need the 64-bit version of that, for both
> normal 64-bit tasks and future 32-bit tasks that are built with
> the old structure definition.
>
> Optionally, we can introduce a better interface with a new command
> number as your patch does, but that should be a separate patch,
> and we have to see if the USB maintainers want to do this or not.
>

There are two problems with the original ioctl interface:

1. Because of the use of timeval, compatibility is broken between 32 bit
and 64 bit binaries.

This has nothing to do with y2038 problem at all.
This is the case with all interfaces using timeval itself and has nothing
to do with this one
particular bad interface design.

The struct you suggested above will work to map to two separate ioctls.
But, if this is a generic problem, shouldn't the above solution be in some
common file?
For instance we could have this:

struct timeval_32 {
__s32 duration_sec;
__s32 duration_usec;
};

And, a similar struct for timeval_64.

This would also mean adding api's to fill the structures defined above.
Basically an entire layer.

This is not necessary for this driver as the struct's are not exposed.
My guess is also that there ar

[Y2038] [PATCH] drivers: md: use ktime_get_real_seconds()

2015-11-11 Thread Deepa Dinamani
get_seconds() API is not y2038 safe on 32 bit systems and the API
is deprecated. Replace it with calls to ktime_get_real_seconds()
API instead. Change mddev structure types to time64_t accordingly.

32 bit signed timestamps will overflow in the year 2038.

Change the user interface mdu_array_info_s structure timestamps:
ctime and utime values used in ioctls GET_ARRAY_INFO and
SET_ARRAY_INFO to unsigned int. This will extend the field to last
until the year 2106.
The long term plan is to get rid of ctime and utime values in
this structure as this information can be read from the on-disk
meta data directly.

Clamp the tim64_t timestamps to positive values with a max of U32_MAX
when returning from GET_ARRAY_INFO ioctl to accommodate above changes
in the data type of timestamps to unsigned int.

v0.90 on disk meta data uses u32 for maintaining time stamps.
So this will also last until year 2106.
Assumption is that the usage of v0.90 will be deprecated by
year 2106.

Timestamp fields in the on disk meta data for v1.0 version already
use 64 bit data types. Remove the truncation of the bits while
writing to or reading from these from the disk.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---

Notes:
A separate patch will update mdadm to obtain times from the metadata,
and to give a deprecation warning for use of v0.90 arrays

 drivers/md/md.c| 18 +-
 drivers/md/md.h|  2 +-
 include/uapi/linux/raid/md_u.h |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7ab9ed9..20763ea 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1196,13 +1196,13 @@ static void super_90_sync(struct mddev *mddev, struct 
md_rdev *rdev)
memcpy(>set_uuid2, mddev->uuid+8, 4);
memcpy(>set_uuid3, mddev->uuid+12,4);
 
-   sb->ctime = mddev->ctime;
+   sb->ctime = clamp_t(time64_t, mddev->ctime, 0, U32_MAX);
sb->level = mddev->level;
sb->size = mddev->dev_sectors / 2;
sb->raid_disks = mddev->raid_disks;
sb->md_minor = mddev->md_minor;
sb->not_persistent = 0;
-   sb->utime = mddev->utime;
+   sb->utime = clamp_t(time64_t, mddev->utime, 0, U32_MAX);
sb->state = 0;
sb->events_hi = (mddev->events>>32);
sb->events_lo = (u32)mddev->events;
@@ -1542,8 +1542,8 @@ static int super_1_validate(struct mddev *mddev, struct 
md_rdev *rdev)
mddev->patch_version = 0;
mddev->external = 0;
mddev->chunk_sectors = le32_to_cpu(sb->chunksize);
-   mddev->ctime = le64_to_cpu(sb->ctime) & ((1ULL << 32)-1);
-   mddev->utime = le64_to_cpu(sb->utime) & ((1ULL << 32)-1);
+   mddev->ctime = le64_to_cpu(sb->ctime);
+   mddev->utime = le64_to_cpu(sb->utime);
mddev->level = le32_to_cpu(sb->level);
mddev->clevel[0] = 0;
mddev->layout = le32_to_cpu(sb->layout);
@@ -2331,7 +2331,7 @@ repeat:
 
spin_lock(>lock);
 
-   mddev->utime = get_seconds();
+   mddev->utime = ktime_get_real_seconds();
 
if (test_and_clear_bit(MD_CHANGE_DEVS, >flags))
force_change = 1;
@@ -5828,7 +5828,7 @@ static int get_array_info(struct mddev *mddev, void 
__user *arg)
info.major_version = mddev->major_version;
info.minor_version = mddev->minor_version;
info.patch_version = MD_PATCHLEVEL_VERSION;
-   info.ctime = mddev->ctime;
+   info.ctime = clamp_t(time64_t, mddev->ctime, 0, U32_MAX);
info.level = mddev->level;
info.size  = mddev->dev_sectors / 2;
if (info.size != mddev->dev_sectors / 2) /* overflow */
@@ -5838,7 +5838,7 @@ static int get_array_info(struct mddev *mddev, void 
__user *arg)
info.md_minor  = mddev->md_minor;
info.not_persistent= !mddev->persistent;
 
-   info.utime = mddev->utime;
+   info.utime = clamp_t(time64_t, mddev->utime, 0, U32_MAX);
info.state = 0;
if (mddev->in_sync)
info.state = (1<<MD_SB_CLEAN);
@@ -6338,13 +6338,13 @@ static int set_array_info(struct mddev *mddev, 
mdu_array_info_t *info)
/* ensure mddev_put doesn't delete this now that there
 * is some minimal configuration.
 */
-   mddev->ctime = get_seconds();
+   mddev->ctime = ktime_get_real_seconds();
return 0;
}
mddev->major_version = MD_MAJOR_VERSION;
mddev->minor_version = MD_MINOR_VERSION;
mddev->patch_version = MD_PATCHLEVEL_VERSION;
-   mddev->ctime = get_seconds(

Re: [Y2038] [PATCH] drivers: md: use ktime_get_real_seconds()

2015-11-12 Thread Deepa Dinamani
On Thu, Nov 12, 2015 at 1:56 PM, Arnd Bergmann <a...@arndb.de> wrote:

> On Wednesday 11 November 2015 19:23:33 Deepa Dinamani wrote:
> > get_seconds() API is not y2038 safe on 32 bit systems and the API
> > is deprecated. Replace it with calls to ktime_get_real_seconds()
> > API instead. Change mddev structure types to time64_t accordingly.
> >
> > 32 bit signed timestamps will overflow in the year 2038.
> >
> > Change the user interface mdu_array_info_s structure timestamps:
> > ctime and utime values used in ioctls GET_ARRAY_INFO and
> > SET_ARRAY_INFO to unsigned int. This will extend the field to last
> > until the year 2106.
> > The long term plan is to get rid of ctime and utime values in
> > this structure as this information can be read from the on-disk
> > meta data directly.
> >
> > Clamp the tim64_t timestamps to positive values with a max of U32_MAX
> > when returning from GET_ARRAY_INFO ioctl to accommodate above changes
> > in the data type of timestamps to unsigned int.
> >
> > v0.90 on disk meta data uses u32 for maintaining time stamps.
> > So this will also last until year 2106.
> > Assumption is that the usage of v0.90 will be deprecated by
> > year 2106.
> >
> > Timestamp fields in the on disk meta data for v1.0 version already
> > use 64 bit data types. Remove the truncation of the bits while
> > writing to or reading from these from the disk.
> >
> > Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
>
> Reviewed-by: Arnd Bergmann <a...@arndb.de>
>
> The patch looks great, and the changelog is perfect.
>
> I didn't even know we had a clamp_t() macro for this.
>
>

Adding the maintainer lists for md.
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH 1/2] fs:hpfs:Remove internal using time_t

2015-11-17 Thread Deepa Dinamani


> On Nov 17, 2015, at 1:07 AM, Arnd Bergmann  wrote:
> 
>> On Tuesday 17 November 2015 17:04:42 deng.ch...@zte.com.cn wrote:
>> Many time_t issues in filesystems is involved with VFS i_mtime/i_ctime.
>> for example:
>> 
>>  static void hpfs_update_directory_times(struct inode *dir)
>>  {
>> -   time_t t = get_seconds();
>> +   time64_t t = ktime_get_real_seconds();
>> -   if (t == dir->i_mtime.tv_sec &&
>> -   t == dir->i_ctime.tv_sec)
>> +   if ((time_t)t == dir->i_mtime.tv_sec &&
>> +   (time_t)t == dir->i_ctime.tv_sec)
>> return;
>> Can I replace get_seconds with ktime_get_real_seconds first, and do a 
>> 64_to_32 cast so as to be compatible with VFS i_mtime/i_ctime like above?
>> Or just leave all the stuff which is involved with VFS i_mtime/i_ctime until 
>> then change of generic VFS code.
> 
> Better just leave it alone for now. Deepa is looking into the
> VFS changes, and I think it will make her work easier that way.
> 
Yes, I'm looking at vfs.
I haven't decided what to do with this yet. Let's leave it as is for now.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [Outreachy kernel] Re: [PATCH] staging: ft1000: replace timeval with ktime_t

2015-10-16 Thread Deepa Dinamani
Should I then fix this patch as per your suggestion or let it be?

-Deepa

> On Oct 16, 2015, at 4:30 PM, Arnd Bergmann  wrote:
> 
>> On Saturday 17 October 2015 00:57:45 Arnd Bergmann wrote:
>> 
>> A more likely cleanup would be the removal of the debug interface,
>> replacing it with something completely different.
> 
> A little more research shows that we can probably remove the driver
> from the kernel really soon, as the only remaining operator is
> shutting down its service:
> 
> http://www.gtigroup.org/news/ind/2015-08-18/6996.html
> 
> They just went from a nationwide service to one that is only
> available in the two largest cities of the country, and they
> already offer much faster LTE service there.
> 
>Arnd
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [Outreachy kernel] Re: [PATCH] staging: ft1000: replace timeval with ktime_t

2015-10-17 Thread Deepa Dinamani


> On Oct 17, 2015, at 04:29, Arnd Bergmann <a...@arndb.de> wrote:
> 
>> On Friday 16 October 2015 22:55:11 Greg KH wrote:
>>> On Fri, Oct 16, 2015 at 05:32:25PM -0700, Deepa Dinamani wrote:
>>> Should I then fix this patch as per your suggestion or let it be?
>> 
>> Let's just delete the driver from the tree.
> 
> Ok.
> 
> Deepa, can you send a patch to remove the driver with an explanation
> of why it's no longer used?

Sure. Will do.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC 1/4] fs: vfs: add accessors for inode times

2015-12-06 Thread Deepa Dinamani
This is in preparation for the y2038 changes for the vfs.
vfs inode timestamps overflow after 2038.

This abstracts the timestamp representation so that any logic
to convert between the struct inode timestamps and other interfaces
can be placed here.

The plan is to globally change all references to these types through
macros only. So when the actually internal representation changes,
it will be transparent everywhere outside of the macros.

The internal representation changes will support larger
timestamp range.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/fs.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 14ffad4..ab8799c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -679,6 +679,11 @@ struct inode {
void*i_private; /* fs or device private pointer */
 };
 
+#define FS_INODE_SET_XTIME(xtime, inode, ts)   \
+   ((inode)->i_##xtime = (ts))
+#define FS_INODE_GET_XTIME(xtime, inode)   \
+   ((inode)->i_##xtime)
+
 static inline int inode_unhashed(struct inode *inode)
 {
return hlist_unhashed(>i_hash);
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC 0/4] fs: support for 64-bit timestamps

2015-12-06 Thread Deepa Dinamani
This is the basic framework for the 64 bit time migration for filesystems.
There might be some changes or additions required as I start adapting to
filesystems.

This gives the basic high level concept so that we can start discussing.

Actual changes to vfs and other file systems will be in a separate
series.

Deepa Dinamani (4):
  fs: vfs: add accessors for inode times
  fs: Add new data type for inode times
  fs: Add support for 64 bit time
  fs: macros and functions support 64 bit time

 include/linux/fs.h | 42 ---
 include/linux/stat.h   | 12 +---
 include/linux/time.h   |  2 ++
 include/linux/time64.h | 53 ++
 kernel/time/time.c | 28 ++
 5 files changed, 127 insertions(+), 10 deletions(-)

-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC 3/4] fs: Add support for 64 bit time

2015-12-06 Thread Deepa Dinamani
The current representation of inode times in struct inode, struct iattr,
struct kstat: struct timespec are not y2038 safe.

Add provision to convert them to use 64 bit times in the future.

struct inode uses struct inode time to maintain same size for times
across 32 bit and 64 bit architectures. structs iattr and kstat have no
such requirement since these data types are only used to pass values in
and out of vfs layer.

In addition, inode_time is defined as packed and aligned to a 4 byte
boundary to make the structure use 12 bytes each instead of 16 bytes. This
will help save RAM space as inode structure is cached in memory. The
other structures are transient and such a change would not be beneficial.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/fs.h   | 33 ++---
 include/linux/stat.h | 12 +---
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index ab8799c..a7d4657 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -245,13 +245,19 @@ typedef void (dax_iodone_t)(struct buffer_head *bh_map, 
int uptodate);
  */
 struct iattr {
unsigned intia_valid;
-   umode_t ia_mode;
-   kuid_t  ia_uid;
-   kgid_t  ia_gid;
-   loff_t  ia_size;
-   struct timespec ia_atime;
-   struct timespec ia_mtime;
-   struct timespec ia_ctime;
+   umode_t ia_mode;
+   kuid_t  ia_uid;
+   kgid_t  ia_gid;
+   loff_t  ia_size;
+#ifdef CONFIG_FS_USES_64BIT_TIME
+   struct timespec64   ia_atime;
+   struct timespec64   ia_mtime;
+   struct timespec64   ia_ctime;
+#else
+   struct timespec ia_atime;
+   struct timespec ia_mtime;
+   struct timespec ia_ctime;
+#endif
 
/*
 * Not an attribute, but an auxiliary info for filesystems wanting to
@@ -616,9 +622,15 @@ struct inode {
};
dev_t   i_rdev;
loff_t  i_size;
+#ifdef CONFIG_FS_USES_64BIT_TIME
+   struct inode_time   i_atime;
+   struct inode_time   i_mtime;
+   struct inode_time   i_ctime;
+#else
struct timespec i_atime;
struct timespec i_mtime;
struct timespec i_ctime;
+#endif
spinlock_t  i_lock; /* i_blocks, i_bytes, maybe i_size */
unsigned short  i_bytes;
unsigned inti_blkbits;
@@ -679,10 +691,17 @@ struct inode {
void*i_private; /* fs or device private pointer */
 };
 
+#ifdef CONFIG_64BIT_INODE_TIME
+#define FS_INODE_SET_XTIME(xtime, inode, ts64) \
+   ((inode)->i_##xtime = timespec64_to_inode_time(ts64))
+#define FS_INODE_GET_XTIME(xtime, inode)   \
+   (inode_time_to_timespec64((inode)->i_##xtime))
+#else
 #define FS_INODE_SET_XTIME(xtime, inode, ts)   \
((inode)->i_##xtime = (ts))
 #define FS_INODE_GET_XTIME(xtime, inode)   \
((inode)->i_##xtime)
+#endif
 
 static inline int inode_unhashed(struct inode *inode)
 {
diff --git a/include/linux/stat.h b/include/linux/stat.h
index 075cb0c..e3443a9 100644
--- a/include/linux/stat.h
+++ b/include/linux/stat.h
@@ -27,9 +27,15 @@ struct kstat {
kgid_t  gid;
dev_t   rdev;
loff_t  size;
-   struct timespec  atime;
-   struct timespec mtime;
-   struct timespec ctime;
+#ifdef CONFIG_FS_USES_64BIT_TIME
+   struct timespec64   atime;
+   struct timespec64   mtime;
+   struct timespec64   ctime;
+#else
+   struct timespec atime;
+   struct timespec mtime;
+   struct timespec ctime;
+#endif
unsigned long   blksize;
unsigned long long  blocks;
 };
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFCv2 3/4] fs: Add support for 64 bit time

2015-12-06 Thread Deepa Dinamani
The current representation of inode times in struct inode, struct iattr,
struct kstat: struct timespec are not y2038 safe.

Add provision to convert them to use 64 bit times in the future.

struct inode uses struct inode time to maintain same size for times
across 32 bit and 64 bit architectures. structs iattr and kstat have no
such requirement since these data types are only used to pass values in
and out of vfs layer.

In addition, inode_time is defined as packed and aligned to a 4 byte
boundary to make the structure use 12 bytes each instead of 16 bytes. This
will help save RAM space as inode structure is cached in memory. The
other structures are transient and such a change would not be beneficial.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/fs.h   | 33 ++---
 include/linux/stat.h | 12 +---
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index ab8799c..c56068f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -245,13 +245,19 @@ typedef void (dax_iodone_t)(struct buffer_head *bh_map, 
int uptodate);
  */
 struct iattr {
unsigned intia_valid;
-   umode_t ia_mode;
-   kuid_t  ia_uid;
-   kgid_t  ia_gid;
-   loff_t  ia_size;
-   struct timespec ia_atime;
-   struct timespec ia_mtime;
-   struct timespec ia_ctime;
+   umode_t ia_mode;
+   kuid_t  ia_uid;
+   kgid_t  ia_gid;
+   loff_t  ia_size;
+#ifdef CONFIG_FS_USES_64BIT_TIME
+   struct timespec64   ia_atime;
+   struct timespec64   ia_mtime;
+   struct timespec64   ia_ctime;
+#else
+   struct timespec ia_atime;
+   struct timespec ia_mtime;
+   struct timespec ia_ctime;
+#endif
 
/*
 * Not an attribute, but an auxiliary info for filesystems wanting to
@@ -616,9 +622,15 @@ struct inode {
};
dev_t   i_rdev;
loff_t  i_size;
+#ifdef CONFIG_FS_USES_64BIT_TIME
+   struct inode_time   i_atime;
+   struct inode_time   i_mtime;
+   struct inode_time   i_ctime;
+#else
struct timespec i_atime;
struct timespec i_mtime;
struct timespec i_ctime;
+#endif
spinlock_t  i_lock; /* i_blocks, i_bytes, maybe i_size */
unsigned short  i_bytes;
unsigned inti_blkbits;
@@ -679,10 +691,17 @@ struct inode {
void*i_private; /* fs or device private pointer */
 };
 
+#ifdef CONFIG_FS_USES_64BIT_TIME
+#define FS_INODE_SET_XTIME(xtime, inode, ts64) \
+   ((inode)->i_##xtime = timespec64_to_inode_time(ts64))
+#define FS_INODE_GET_XTIME(xtime, inode)   \
+   (inode_time_to_timespec64((inode)->i_##xtime))
+#else
 #define FS_INODE_SET_XTIME(xtime, inode, ts)   \
((inode)->i_##xtime = (ts))
 #define FS_INODE_GET_XTIME(xtime, inode)   \
((inode)->i_##xtime)
+#endif
 
 static inline int inode_unhashed(struct inode *inode)
 {
diff --git a/include/linux/stat.h b/include/linux/stat.h
index 075cb0c..e3443a9 100644
--- a/include/linux/stat.h
+++ b/include/linux/stat.h
@@ -27,9 +27,15 @@ struct kstat {
kgid_t  gid;
dev_t   rdev;
loff_t  size;
-   struct timespec  atime;
-   struct timespec mtime;
-   struct timespec ctime;
+#ifdef CONFIG_FS_USES_64BIT_TIME
+   struct timespec64   atime;
+   struct timespec64   mtime;
+   struct timespec64   ctime;
+#else
+   struct timespec atime;
+   struct timespec mtime;
+   struct timespec ctime;
+#endif
unsigned long   blksize;
unsigned long long  blocks;
 };
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFCv2 2/4] fs: Add new data type for inode times

2015-12-06 Thread Deepa Dinamani
The current representation of inode times in struct inode:
struct timespec is not y2038 safe.

The 64 bit counterpart of struct timespec: struct timespec64
suffers from the shortcoming that the data type sizes are
different on 32 bit and 64 bit systems.

Introduce a new struct inode_time to overcome the above
limitations.

Also add time conversion api's between struct timespec64 and
struct inode_time. This is required as the 64-bit time
functions typically return struct timespec64 types.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/time64.h | 45 +
 1 file changed, 45 insertions(+)

diff --git a/include/linux/time64.h b/include/linux/time64.h
index 367d5af..bb574b8 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -13,6 +13,16 @@ typedef __s64 time64_t;
 #if __BITS_PER_LONG == 64
 # define timespec64 timespec
 #define itimerspec64 itimerspec
+
+/*
+ * Internal kernel representation of inode time fields.
+ * This structure is not exposed to userspace.
+ * Use struct timespec64 representation for all userspace.
+ */
+struct inode_time {
+   time64_ttv_sec;
+   s32 tv_nsec;
+} __aligned(4) __packed;
 #else
 struct timespec64 {
time64_ttv_sec; /* seconds */
@@ -24,6 +34,7 @@ struct itimerspec64 {
struct timespec64 it_value;
 };
 
+#define inode_time timespec64
 #endif
 
 /* Parameters used to convert the timespec values: */
@@ -42,6 +53,28 @@ struct itimerspec64 {
 
 #if __BITS_PER_LONG == 64
 
+static inline struct inode_time
+timespec64_to_inode_time(const struct timespec64 ts64)
+{
+   struct inode_time ret;
+
+   ret.tv_sec = ts64.tv_sec;
+   ret.tv_nsec = ts64.tv_nsec;
+
+   return ret;
+}
+
+static inline struct timespec64
+inode_time_to_timespec64(const struct inode_time itime)
+{
+   struct timespec64 ret;
+
+   ret.tv_sec = itime.tv_sec;
+   ret.tv_nsec = itime.tv_nsec;
+
+   return ret;
+}
+
 static inline struct timespec timespec64_to_timespec(const struct timespec64 
ts64)
 {
return ts64;
@@ -76,6 +109,18 @@ static inline struct itimerspec64 
itimerspec_to_itimerspec64(struct itimerspec *
 
 #else
 
+static inline struct inode_time
+timespec64_to_inode_time(const struct timespec64 ts64)
+{
+   return ts64;
+}
+
+static inline struct timespec64
+inode_time_to_timespec64(const struct inode_time itime)
+{
+   return itime;
+}
+
 static inline struct timespec timespec64_to_timespec(const struct timespec64 
ts64)
 {
struct timespec ret;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFCv2 4/4] fs: macros and functions support 64 bit time

2015-12-06 Thread Deepa Dinamani
The current file system macros and time functions are not y2038 safe
because of the use of struct timespec.

Change these to use timespec64.

The change will be globally enabled along with all the other 64-bit
time file system changes.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/fs.h |  4 
 include/linux/time.h   |  2 ++
 include/linux/time64.h |  5 +
 kernel/time/time.c | 28 
 4 files changed, 39 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index c56068f..27bb983 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1399,7 +1399,11 @@ struct super_block {
struct list_heads_inodes;   /* all inodes */
 };
 
+#ifdef CONFIG_FS_USES_64BIT_TIME
+extern struct timespec64 current_fs_time(struct super_block *sb);
+#else
 extern struct timespec current_fs_time(struct super_block *sb);
+#endif
 
 /*
  * Snapshotting support.
diff --git a/include/linux/time.h b/include/linux/time.h
index beebe3a..40fe4af 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -125,8 +125,10 @@ static inline bool timeval_valid(const struct timeval *tv)
 
 extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
 
+#ifndef CONFIG_FS_USES_64BIT_TIME
 #define CURRENT_TIME   (current_kernel_time())
 #define CURRENT_TIME_SEC   ((struct timespec) { get_seconds(), 0 })
+#endif
 
 /* Some architectures do not supply their own clocksource.
  * This is mainly the case in architectures that get their
diff --git a/include/linux/time64.h b/include/linux/time64.h
index bb574b8..62f2b1a 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -37,6 +37,11 @@ struct itimerspec64 {
 #define inode_time timespec64
 #endif
 
+#ifdef CONFIG_FS_USES_64BIT_TIME
+#define CURRENT_TIME   (current_kernel_time64())
+#define CURRENT_TIME_SEC   ((struct timespec64) { ktime_get_seconds(), 0 })
+#endif
+
 /* Parameters used to convert the timespec values: */
 #define MSEC_PER_SEC   1000L
 #define USEC_PER_MSEC  1000L
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 86751c6..92b6db1 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -237,11 +237,19 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
  * Return the current time truncated to the time granularity supported by
  * the fs.
  */
+#ifdef CONFIG_FS_USES_64BIT_TIME
+struct timespec64 current_fs_time(struct super_block *sb)
+{
+   struct timespec64 now = current_kernel_time64();
+   return timespec64_trunc(now, sb->s_time_gran);
+}
+#else
 struct timespec current_fs_time(struct super_block *sb)
 {
struct timespec now = current_kernel_time();
return timespec_trunc(now, sb->s_time_gran);
 }
+#endif
 EXPORT_SYMBOL(current_fs_time);
 
 /*
@@ -294,6 +302,25 @@ EXPORT_SYMBOL(jiffies_to_usecs);
  * Truncate a timespec to a granularity. Always rounds down. gran must
  * not be 0 nor greater than a second (NSEC_PER_SEC, or 10^9 ns).
  */
+#ifdef CONFIG_FS_USES_64BIT_TIME
+/* TODO: Change name to timespec64_trunc after the global switch to
+ * CONFIG_FS_USES_64BIT_TIME.
+ */
+struct timespec64 timespec_trunc(struct timespec64 t, unsigned gran)
+{
+   /* Avoid division in the common cases 1 ns and 1 s. */
+   if (gran == 1) {
+   /* nothing */
+   } else if (gran == NSEC_PER_SEC) {
+   t.tv_nsec = 0;
+   } else if (gran > 1 && gran < NSEC_PER_SEC) {
+   t.tv_nsec -= t.tv_nsec % gran;
+   } else {
+   WARN(1, "illegal file time granularity: %u", gran);
+   }
+   return t;
+}
+#else
 struct timespec timespec_trunc(struct timespec t, unsigned gran)
 {
/* Avoid division in the common cases 1 ns and 1 s. */
@@ -308,6 +335,7 @@ struct timespec timespec_trunc(struct timespec t, unsigned 
gran)
}
return t;
 }
+#endif
 EXPORT_SYMBOL(timespec_trunc);
 
 /*
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFCv2 0/4] fs: support for 64-bit timestamps

2015-12-06 Thread Deepa Dinamani
This is the basic framework for the 64 bit time migration for filesystems.
There might be some changes or additions required as I start adapting to
filesystems.

This gives the basic high level concept so that we can start discussing.

Actual changes to vfs and other file systems will be in a separate
series.

Changes since v1:
* struct inode_time added unconditionally
* uniform use of CONFIG_FS_USES_64BIT_TIME

Deepa Dinamani (4):
  fs: vfs: add accessors for inode times
  fs: Add new data type for inode times
  fs: Add support for 64 bit time
  fs: macros and functions support 64 bit time

 include/linux/fs.h | 42 +++---
 include/linux/stat.h   | 12 +---
 include/linux/time.h   |  2 ++
 include/linux/time64.h | 50 ++
 kernel/time/time.c | 28 
 5 files changed, 124 insertions(+), 10 deletions(-)

-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [RFCv2 3/4] fs: Add support for 64 bit time

2015-12-07 Thread Deepa Dinamani
On Mon, Dec 7, 2015 at 1:30 AM, Arnd Bergmann <a...@arndb.de> wrote:
> On Sunday 06 December 2015 22:04:05 Deepa Dinamani wrote:
>> The current representation of inode times in struct inode, struct iattr,
>> struct kstat: struct timespec are not y2038 safe.
>>
>> Add provision to convert them to use 64 bit times in the future.
>>
>> struct inode uses struct inode time to maintain same size for times
>> across 32 bit and 64 bit architectures. structs iattr and kstat have no
>> such requirement since these data types are only used to pass values in
>> and out of vfs layer.
>
> Ok, ignore my comment on patch 1, I should have read all the way until
> here ;-)
>
> I think you can safely merge patch 1 into patch 3, it will actually
> be clearer that way.
>

will do

>> In addition, inode_time is defined as packed and aligned to a 4 byte
>> boundary to make the structure use 12 bytes each instead of 16 bytes. This
>> will help save RAM space as inode structure is cached in memory. The
>> other structures are transient and such a change would not be beneficial.
>>
>> Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
>
> Ah, this also explains the use of inode_time: it's much nicer if we don't
> need it in the file systems but only in struct inode.
>

This is the plan. I did not have to use this inside of vfs anywhere else.


>> @@ -616,9 +622,15 @@ struct inode {
>>   };
>>   dev_t   i_rdev;
>>   loff_t  i_size;
>> +#ifdef CONFIG_FS_USES_64BIT_TIME
>> + struct inode_time   i_atime;
>> + struct inode_time   i_mtime;
>> + struct inode_time   i_ctime;
>> +#else
>>   struct timespec i_atime;
>>   struct timespec i_mtime;
>>   struct timespec i_ctime;
>> +#endif
>>   spinlock_t  i_lock; /* i_blocks, i_bytes, maybe i_size */
>>   unsigned short  i_bytes;
>>   unsigned inti_blkbits;
>> @@ -679,10 +691,17 @@ struct inode {
>>   void*i_private; /* fs or device private pointer */
>>  };
>>
>> +#ifdef CONFIG_FS_USES_64BIT_TIME
>> +#define FS_INODE_SET_XTIME(xtime, inode, ts64)   \
>> + ((inode)->i_##xtime = timespec64_to_inode_time(ts64))
>> +#define FS_INODE_GET_XTIME(xtime, inode) \
>> + (inode_time_to_timespec64((inode)->i_##xtime))
>> +#else
>>  #define FS_INODE_SET_XTIME(xtime, inode, ts) \
>>   ((inode)->i_##xtime = (ts))
>>  #define FS_INODE_GET_XTIME(xtime, inode) \
>>   ((inode)->i_##xtime)
>> +#endif
>
> So this makes a lot of sense now. If it's the only use of
> timespec64_to_inode_time/inode_time_to_timespec64, you could
> also open-code that in the macro and avoid introducing the
> macro to start with.
>

This is how I had it to begin with. But, I think having this in
separate function makes
the code more modular. Are we trying to minimize number of functions?

> We have had some discussion about limiting the range of the times
> in the inode to the range allowed by the file system at some point,
> so leaving them as inline functions will make it easier to extend
> them later that way.
>

Macros could be extended to call these functions or directly include
range checking from superblock meta data?

I do not prefer using macros in general. But, in this instance I think
it makes sense
as we can avoid having 3 functions because of ## operator.

We could also probably pass in the actual inode_times to static inline
functions and that could so away with macros.
Is this what you meant?

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [RFCv2 3/4] fs: Add support for 64 bit time

2015-12-11 Thread Deepa Dinamani
>> >> @@ -616,9 +622,15 @@ struct inode {
>> >>   };
>> >>   dev_t   i_rdev;
>> >>   loff_t  i_size;
>> >> +#ifdef CONFIG_FS_USES_64BIT_TIME
>> >> + struct inode_time   i_atime;
>> >> + struct inode_time   i_mtime;
>> >> + struct inode_time   i_ctime;
>> >> +#else
>> >>   struct timespec i_atime;
>> >>   struct timespec i_mtime;
>> >>   struct timespec i_ctime;
>> >> +#endif
>> >>   spinlock_t  i_lock; /* i_blocks, i_bytes, maybe i_size 
>> >> */
>> >>   unsigned short  i_bytes;
>> >>   unsigned inti_blkbits;
>> >> @@ -679,10 +691,17 @@ struct inode {
>> >>   void*i_private; /* fs or device private pointer 
>> >> */
>> >>  };
>> >>
>> >> +#ifdef CONFIG_FS_USES_64BIT_TIME
>> >> +#define FS_INODE_SET_XTIME(xtime, inode, ts64)   \
>> >> + ((inode)->i_##xtime = timespec64_to_inode_time(ts64))
>> >> +#define FS_INODE_GET_XTIME(xtime, inode) \
>> >> + (inode_time_to_timespec64((inode)->i_##xtime))
>> >> +#else
>> >>  #define FS_INODE_SET_XTIME(xtime, inode, ts) \
>> >>   ((inode)->i_##xtime = (ts))
>> >>  #define FS_INODE_GET_XTIME(xtime, inode) \
>> >>   ((inode)->i_##xtime)
>> >> +#endif
>> >
>> > So this makes a lot of sense now. If it's the only use of
>> > timespec64_to_inode_time/inode_time_to_timespec64, you could
>> > also open-code that in the macro and avoid introducing the
>> > macro to start with.
>> >
>>
>> This is how I had it to begin with. But, I think having this in
>> separate function makes
>> the code more modular. Are we trying to minimize number of functions?
>
> Generally the optimization should prefer readability and performance.
> I was thinking here that the code is easier to follow if there is
> only one intermediate step that we introduce rather than two.
>
> Another option would be to drop the structure entirely and put the
> members directly into the inode as i_atime_sec/i_atime_nsec/i_mtime_sec/
> etc. That would also avoid marking the 64-bit members as 'packed',
> which may be inefficient on some CPU architectures.
>
I considered this option. This would need weird way of adding the fields:
iatime_sec;
imtime_sec;
ictime_sec;
iatime_nsec;
iatime_nsec;
ictime_nsec;

And based on if anybody rearranges these fields while adding new ones,
we might have different kind of packing.
While the struct is guaranteed to have 12 bytes always.

>> > We have had some discussion about limiting the range of the times
>> > in the inode to the range allowed by the file system at some point,
>> > so leaving them as inline functions will make it easier to extend
>> > them later that way.
>> >
>>
>> Macros could be extended to call these functions or directly include
>> range checking from superblock meta data?
>>
>> I do not prefer using macros in general. But, in this instance I think
>> it makes sense
>> as we can avoid having 3 functions because of ## operator.
>>
>> We could also probably pass in the actual inode_times to static inline
>> functions and that could so away with macros.
>> Is this what you meant?
>
> Yes, that would be one way to handle it. As long as we have a macro
> or inline function abstraction, we can hide it in there.
>
> Not needing macros might actually be nice too, so we could have a set
> of inline functions instead, like
>
> static inline struct timespec64 inode_get_atime(struct inode *inode)
> {
> return (struct timespec64) {
> .tv_sec  = inode->i_atime_sec,
> .tv_nsec = inode->i_atime_nsec,
> };
> }
>
> static inline void inode_set_atime(struct inode *inode, struct timespec64 *t)
> {
> inode->i_atime_sec = t->tv_sec;
> inode->i_atime_nsec = 0;
> }
>
> There are only three of them, so it's not much more code than the
> macros, and those are certainly more readable and easier to extend.
>
I can go ahead and change it to use only inline functions instead of macros.
I was thinking of this:

static inline struct timespec64 inode_get_inode_time(struct inode_time atime)

These can have definitions similar to that of inode_time and ts64
conversions I have now.

I will pair them with the inode struct as well and not put them in time64.h.

> There is also some code already in timespec_trunc that limits the
> precision to the resolution supported by the file system in the setattr
> functions. We can extend timespec_trunc to also limit the range, as
> long as it is used consistently.
>

Ok. Yes, this seems like a good place to do the range checking.
I will keep this in mind when I post an update.

Here is my plan:

1.Update the patches according to above comments.
2.Global vfs substitutions with inline functions.
3. Will extend ext4 and fat to support these inline functions as well.
4. Will use these file systems to do some testing.
5. Send out all the above patches for review together.

-Deepa

[Y2038] [RFC 15/15] fs: Drop CONFIG_FS_USES_64BIT_TIME

2016-01-06 Thread Deepa Dinamani
All file system code is using 64 bit time already and this config
is no longer required.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/Kconfig | 10 --
 1 file changed, 10 deletions(-)

diff --git a/fs/Kconfig b/fs/Kconfig
index bfeefce..922893f 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -8,16 +8,6 @@ menu "File systems"
 config DCACHE_WORD_ACCESS
bool
 
-#use 64 bit timestamps
-config FS_USES_64BIT_TIME
-   bool
-   default y
-   help
-Temporary configuration to switch over all file systems to
-use 64 bit time.
-Need to be enabled only after all individual file system
-and vfs changes are in place.
-
 if BLOCK
 
 source "fs/ext2/Kconfig"
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC 11/15] fs: ext4: replace inode_timespec with timespec64

2016-01-06 Thread Deepa Dinamani
Substitute inode_timespec aliases with timespec64.
Since CONFIG_FS_USES_64BIT_TIME is enabled, internally
all inode_timespec references are using timespec64
already.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/ext4/ext4.h| 14 +++---
 fs/ext4/extents.c |  6 +++---
 fs/ext4/ialloc.c  |  2 +-
 fs/ext4/inline.c  |  4 ++--
 fs/ext4/inode.c   |  6 +++---
 fs/ext4/ioctl.c   |  2 +-
 fs/ext4/namei.c   | 10 +-
 fs/ext4/super.c   |  2 +-
 8 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 4bb2604..2d4bef0 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -754,14 +754,14 @@ struct move_extent {
  * affected filesystem before 2242.
  */
 
-static inline __le32 ext4_encode_extra_time(struct inode_timespec *time)
+static inline __le32 ext4_encode_extra_time(struct timespec64 *time)
 {
u32 extra = sizeof(time->tv_sec) > 4 ?
((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK : 
0;
return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS));
 }
 
-static inline void ext4_decode_extra_time(struct inode_timespec *time,
+static inline void ext4_decode_extra_time(struct timespec64 *time,
  __le32 extra)
 {
if (unlikely(sizeof(time->tv_sec) > 4 &&
@@ -787,7 +787,7 @@ static inline void ext4_decode_extra_time(struct 
inode_timespec *time,
 
 #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)  
\
 do {   
\
-   struct inode_timespec __ts = VFS_INODE_GET_XTIME(xtime, inode); 
\
+   struct timespec64 __ts = VFS_INODE_GET_XTIME(xtime, inode); 
\
(raw_inode)->xtime = cpu_to_le32(__ts.tv_sec);  
\
if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))  
\
(raw_inode)->xtime ## _extra =  
\
@@ -805,7 +805,7 @@ do {
   \
 
 #define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)  
\
 do {   
\
-   struct inode_timespec __ts = VFS_INODE_GET_XTIME(xtime, inode); 
\
+   struct timespec64 __ts = VFS_INODE_GET_XTIME(xtime, inode); 
\
__ts.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);  
\
if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))  
\
ext4_decode_extra_time(&__ts,   
\
@@ -935,9 +935,9 @@ struct ext4_inode_info {
 
/*
 * File creation time. Its function is same as that of
-* struct inode_timespec i_{a,c,m}time in the generic inode.
+* struct timespec64 i_{a,c,m}time in the generic inode.
 */
-   struct inode_timespec i_crtime;
+   struct timespec64 i_crtime;
 
/* mballoc */
struct list_head i_prealloc_list;
@@ -1445,7 +1445,7 @@ static inline struct ext4_inode_info *EXT4_I(struct inode 
*inode)
return container_of(inode, struct ext4_inode_info, vfs_inode);
 }
 
-static inline struct inode_timespec ext4_current_time(struct inode *inode)
+static inline struct timespec64 ext4_current_time(struct inode *inode)
 {
return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
current_fs_time(inode->i_sb) : current_fs_time_sec(inode->i_sb);
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 99c4800..ec1a912 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4756,7 +4756,7 @@ static long ext4_zero_range(struct file *file, loff_t 
offset,
loff_t len, int mode)
 {
struct inode *inode = file_inode(file);
-   struct inode_timespec now;
+   struct timespec64 now;
handle_t *handle = NULL;
unsigned int max_blocks;
loff_t new_size = 0;
@@ -5465,7 +5465,7 @@ int ext4_collapse_range(struct inode *inode, loff_t 
offset, loff_t len)
 {
struct super_block *sb = inode->i_sb;
ext4_lblk_t punch_start, punch_stop;
-   struct inode_timespec now;
+   struct timespec64 now;
handle_t *handle;
unsigned int credits;
loff_t new_size, ioffset;
@@ -5616,7 +5616,7 @@ int ext4_insert_range(struct inode *inode, loff_t offset, 
loff_t len)
struct ext4_ext_path *path;
struct ext4_extent *extent;
ext4_lblk_t offset_lblk, len_lblk, ee_start_lblk = 0;
-   struct inode_timespec now;
+   struct timespec64 now;
unsigned int credits, ee_len;
int ret = 0, depth, split_flag = 0;
loff_t ioffset;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 6f16598..929c092 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -7

[Y2038] [RFC 05/15] fs: cifs: Add support for cifs to use 64 bit time

2016-01-06 Thread Deepa Dinamani
Change all struct timespec references to struct inode_timespec.
Use inode timestamp accessors to access inode time fields.
This will help the switch to struct timespec64 when
CONFIG_FS_USES_64BIT_TIME is enabled.

Use current_fs_time() instead of CURRENT_TIME macros to help
range and precision checks.

Truncate and perform range checks before saving the times in
struct inode.

Switch over connection times to use SYSTEM_TIME macro instead
of CURRENT_TIME. Since SYSTEM_TIME is also under the
CONFIG_FS_USES_64BIT_TIME this will help the switch to use
timespec64.

Use long long for seconds field in cnvrtDosUnixTm(). This will
help represent 64 bit time.
Since DOS uses 1980 epoch, all the timestamps are positive when
represented in UNIX format. Change all arithmetic to unsigned.
Note that even though the theoretical max on DOS times is 2107,
its api's only support until the year 2099. This means we can
get away with 32 bit unsigned sec field. But, the  sec field uses
long long to maintain uniformity in the kernel, where everyone
uses the theoretical max.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/cifs/cache.c   | 16 -
 fs/cifs/cifsencrypt.c |  2 +-
 fs/cifs/cifsglob.h|  6 ++---
 fs/cifs/cifsproto.h   |  9 +++
 fs/cifs/cifssmb.c | 17 +-
 fs/cifs/file.c|  9 ---
 fs/cifs/inode.c   | 65 +--
 fs/cifs/netmisc.c | 26 +++--
 8 files changed, 92 insertions(+), 58 deletions(-)

diff --git a/fs/cifs/cache.c b/fs/cifs/cache.c
index 6c665bf..8d27e69b 100644
--- a/fs/cifs/cache.c
+++ b/fs/cifs/cache.c
@@ -221,8 +221,8 @@ const struct fscache_cookie_def 
cifs_fscache_super_index_def = {
  * Auxiliary data attached to CIFS inode within the cache
  */
 struct cifs_fscache_inode_auxdata {
-   struct timespec last_write_time;
-   struct timespec last_change_time;
+   struct inode_timespec   last_write_time;
+   struct inode_timespec   last_change_time;
u64 eof;
 };
 
@@ -259,8 +259,10 @@ cifs_fscache_inode_get_aux(const void *cookie_netfs_data, 
void *buffer,
 
memset(, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof;
-   auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-   auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+   auxdata.last_write_time =
+   VFS_INODE_GET_XTIME(i_mtime, >vfs_inode);
+   auxdata.last_change_time =
+   VFS_INODE_GET_XTIME(i_ctime, >vfs_inode);
 
if (maxbuf > sizeof(auxdata))
maxbuf = sizeof(auxdata);
@@ -283,8 +285,10 @@ fscache_checkaux cifs_fscache_inode_check_aux(void 
*cookie_netfs_data,
 
memset(, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof;
-   auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-   auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+   auxdata.last_write_time =
+   VFS_INODE_GET_XTIME(i_mtime, >vfs_inode);
+   auxdata.last_change_time =
+   VFS_INODE_GET_XTIME(i_ctime, >vfs_inode);
 
if (memcmp(data, , datalen) != 0)
return FSCACHE_CHECKAUX_OBSOLETE;
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index afa09fc..b0ef587 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -483,7 +483,7 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */
}
 
-   return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+   return cpu_to_le64(cifs_UnixTimeToNT(FS_TIME));
 }
 
 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index a25b251..c95dce7 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1393,9 +1393,9 @@ struct cifs_fattr {
dev_t   cf_rdev;
unsigned intcf_nlink;
unsigned intcf_dtype;
-   struct timespec cf_atime;
-   struct timespec cf_mtime;
-   struct timespec cf_ctime;
+   struct inode_timespec   cf_atime;
+   struct inode_timespec   cf_mtime;
+   struct inode_timespec   cf_ctime;
 };
 
 static inline void free_dfs_info_param(struct dfs_info3_param *param)
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index eed7ff5..9979c74 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -126,10 +126,11 @@ extern enum securityEnum select_sectype(struct 
TCP_Server_Info *server,
enum securityEnum requested);
 extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
  const struct nls_table *nls_cp);
-extern struct timespec cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
-extern u64 cifs_UnixTimeToNT(struct timespec);
-extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
- int offset);
+extern struct inode_ti

[Y2038] [RFC 04/15] vfs: Add support for vfs code to use 64 bit time

2016-01-06 Thread Deepa Dinamani
VFS currently uses struct timespec timestamps which are not
y2038 safe.

Change all the struct inode timestamps accesses through
accessor macros only. This will help the switch over
to 64 bit times seamlessly.

Use struct inode_timespec aliases everywhere.
This will change timestamp data types to  struct timespec64
when 64 bit time switch occurs.

Change all calls to CURRENT_TIME to current_fs_time().
The CURRENT_TIME macro is not accurate for file system code
as it does not perform range checks on timestamps nor does it
cater to individual file system timestamp granularity.
Change all calls to timespec_trunc() to fs_time_trunc().
The latter supports range checking on timestamps.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/attr.c| 15 +++---
 fs/bad_inode.c   | 10 +++--
 fs/binfmt_misc.c |  7 +--
 fs/inode.c   | 53 
 fs/libfs.c   | 45 
 fs/locks.c   |  5 ++---
 fs/nsfs.c|  6 +-
 fs/pipe.c|  6 +-
 fs/posix_acl.c   |  2 +-
 fs/stack.c   |  6 +++---
 fs/stat.c|  6 +++---
 fs/utimes.c  |  6 --
 include/linux/fs_stack.h |  9 
 13 files changed, 121 insertions(+), 55 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index 6530ced..4156239 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -148,14 +148,14 @@ void setattr_copy(struct inode *inode, const struct iattr 
*attr)
if (ia_valid & ATTR_GID)
inode->i_gid = attr->ia_gid;
if (ia_valid & ATTR_ATIME)
-   inode->i_atime = timespec_trunc(attr->ia_atime,
-   inode->i_sb->s_time_gran);
+   VFS_INODE_SET_XTIME(i_atime, inode,
+   fs_time_trunc(attr->ia_atime, inode->i_sb));
if (ia_valid & ATTR_MTIME)
-   inode->i_mtime = timespec_trunc(attr->ia_mtime,
-   inode->i_sb->s_time_gran);
+   VFS_INODE_SET_XTIME(i_mtime, inode,
+   fs_time_trunc(attr->ia_mtime, inode->i_sb));
if (ia_valid & ATTR_CTIME)
-   inode->i_ctime = timespec_trunc(attr->ia_ctime,
-   inode->i_sb->s_time_gran);
+   VFS_INODE_SET_XTIME(i_ctime, inode,
+   fs_time_trunc(attr->ia_ctime, inode->i_sb));
if (ia_valid & ATTR_MODE) {
umode_t mode = attr->ia_mode;
 
@@ -192,7 +192,7 @@ int notify_change(struct dentry * dentry, struct iattr * 
attr, struct inode **de
struct inode *inode = dentry->d_inode;
umode_t mode = inode->i_mode;
int error;
-   struct timespec now;
+   struct inode_timespec now;
unsigned int ia_valid = attr->ia_valid;
 
WARN_ON_ONCE(!mutex_is_locked(>i_mutex));
@@ -210,7 +210,6 @@ int notify_change(struct dentry * dentry, struct iattr * 
attr, struct inode **de
}
 
now = current_fs_time(inode->i_sb);
-
attr->ia_ctime = now;
if (!(ia_valid & ATTR_ATIME_SET))
attr->ia_atime = now;
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 103f5d7..3c51e22 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -169,11 +169,17 @@ static const struct inode_operations bad_inode_ops =
  
 void make_bad_inode(struct inode *inode)
 {
+   struct inode_timespec now;
+
remove_inode_hash(inode);
 
inode->i_mode = S_IFREG;
-   inode->i_atime = inode->i_mtime = inode->i_ctime =
-   current_fs_time(inode->i_sb);
+
+   now = current_fs_time(inode->i_sb);
+
+   VFS_INODE_SET_XTIME(i_atime, inode, now);
+   VFS_INODE_SET_XTIME(i_mtime, inode, now);
+   VFS_INODE_SET_XTIME(i_ctime, inode, now);
inode->i_op = _inode_ops;   
inode->i_fop = _file_ops;   
 }
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 78f005f..4fd4437 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -562,12 +562,15 @@ static void entry_status(Node *e, char *page)
 static struct inode *bm_get_inode(struct super_block *sb, int mode)
 {
struct inode *inode = new_inode(sb);
+   struct inode_timespec now;
 
if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode;
-   inode->i_atime = inode->i_mtime = inode->i_ctime =
-   current_fs_time(inode->i_sb);
+   now = current_fs_time(inode->i_sb);
+   VFS_INODE_SET_XTIME(i_atime, inode, now);
+   VFS_INODE_SET_XTIME(i_mtime, inode, now);
+   VFS_INODE_SET_XTIME(i_ctime, inode, now);
}
return inode;
 }
diff --git a/fs/in

[Y2038] [RFC 03/15] kernel: time: Add macros and functions to support 64 bit time

2016-01-06 Thread Deepa Dinamani
The current_fs_time function is not y2038 safe because
of the use of struct timespec.

The macros CURRENT_TIME and CURRENT_TIME_SEC do not represent
file system times correctly as they cannnot perform range checks
or truncations. These are also not y2038 safe. Add 64 bit versions
of the above macros.

Provide a new set of FS_TIME macros which will return time in
timespec or timespec64 based on CONFIG_FS_USES_64_BIT_TIME.
These are meant to be used only within file systems because of
being tied to the above config. Once the config is enabled,
the timespec version of it can be deleted and the 64 bit time version
can be used elsewhere also.

Add struct timespec64 version for current_fs_time().
Current version of current_fs_time() can be dropped after enabling
CONFIG_FS_USES_64BIT_TIME.

Provide an alternative to timespec_trunc(): fs_time_trunc().
This function takes super block as an argument in addition to
timestamp so that it can include range and precision checks.
Additionally, the function uses y2038 safe timespec64 instead of
timespec for timestamp representation.

Add function: current_fs_time_sec() to obtain only the seconds
portion of the current time(Equivalent to CURRENT_TIME_SEC).
This function has two versions selected by the config
CONFIG_FS_USES_64BIT_TIME.
The 32 bit version support can be dropped after the above config
is enabled globally.

All calls to timespec_trunc() will be eventually replaced by
fs_time_trunc(). At which point, timespec_trunc() can be deleted.

All the above function calls use fs_time_range_check() to clamp
the timestamps.

Inodes that are saved in memory and on disk always have valid
timestamps. But, the accessors can detect a clamped timestamp
while saving the timestamps into inodes.
The clamped timestamp handling is split into two seperate cases:
a. Mounting a fs that has exceeded it's current timestamp needs.
b. A mounted fs exceeds timestamps needs.
Both the above cases are handled using seperate callbacks:
superblock bad_timestamp_mount and bad_timestamp operations.

Motivation for the above callbacks being that the Linux kernel does
not internally use timestamps and it cannot decide how catastrophic
these timestamp clamps can be for the on disk file system or
user space applications that use it.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/libfs.c |   5 ++
 fs/super.c |  10 
 include/linux/fs.h |  50 ++--
 include/linux/time64.h |   4 ++
 kernel/time/time.c | 156 +
 5 files changed, 196 insertions(+), 29 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 8dc37fc..4fa2002 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -227,6 +227,9 @@ struct dentry *mount_pseudo(struct file_system_type 
*fs_type, char *name,
s->s_magic = magic;
s->s_op = ops ? ops : _super_operations;
s->s_time_gran = 1;
+   s->s_time_min = FS_DEFAULT_MIN_TIMESTAMP;
+   s->s_time_max = FS_DEFAULT_MAX_TIMESTAMP;
+
root = new_inode(s);
if (!root)
goto Enomem;
@@ -482,6 +485,8 @@ int simple_fill_super(struct super_block *s, unsigned long 
magic,
s->s_magic = magic;
s->s_op = _super_operations;
s->s_time_gran = 1;
+   s->s_time_min = FS_DEFAULT_MIN_TIMESTAMP;
+   s->s_time_max = FS_DEFAULT_MAX_TIMESTAMP;
 
inode = new_inode(s);
if (!inode)
diff --git a/fs/super.c b/fs/super.c
index 7ea56de..3f53def 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -239,6 +239,8 @@ static struct super_block *alloc_super(struct 
file_system_type *type, int flags)
s->s_maxbytes = MAX_NON_LFS;
s->s_op = _op;
s->s_time_gran = 10;
+   s->s_time_min = FS_DEFAULT_MIN_TIMESTAMP;
+   s->s_time_max = FS_DEFAULT_MAX_TIMESTAMP;
s->cleancache_poolid = CLEANCACHE_NO_POOL;
 
s->s_shrink.seeks = DEFAULT_SEEKS;
@@ -1143,6 +1145,14 @@ mount_fs(struct file_system_type *type, int flags, const 
char *name, void *data)
WARN((sb->s_maxbytes < 0), "%s set sb->s_maxbytes to "
"negative value (%lld)\n", type->name, sb->s_maxbytes);
 
+   /* check timestamp range */
+   if (unlikely(is_fs_timestamp_bad(current_fs_time(sb))) &&
+   (sb->s_op->bad_timestamp_mount)) {
+   error = sb->s_op->bad_timestamp_mount(sb);
+   if (error)
+   goto out_sb;
+   }
+
up_write(>s_umount);
free_secdata(secdata);
return root;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b9f3cee..5112bc2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -693,8 +693,14 @@ struct inode {
 #define VFS_INODE_SET_XTIME(xtime, inode, ts64)\
do {\
 

[Y2038] [RFC 06/15] fs: fat: convert fat to 64 bit time

2016-01-06 Thread Deepa Dinamani
FAT filesystem supports timestamps until the year 2099
even though the theoretical max is 2107.
But, the struct timespec overflows in the year 2038 on
32 bit systems.

Use inode_timespec throughout the file system code so
that the timestamps can switch to y2038 safe
struct timespec64 when CONFIG_FS_USES_64BIT_TIME is
turned on.

Use a larger data type for seconds in fat_time_fat2unix().
This extends timestamps beyond the year 2038.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/fat/dir.c |  7 +--
 fs/fat/fat.h |  8 +---
 fs/fat/file.c| 10 --
 fs/fat/inode.c   | 46 --
 fs/fat/misc.c|  7 ---
 fs/fat/namei_msdos.c | 40 +---
 fs/fat/namei_vfat.c  | 41 +++--
 7 files changed, 106 insertions(+), 53 deletions(-)

diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 7def96c..fa8a922 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -1034,6 +1034,7 @@ int fat_remove_entries(struct inode *dir, struct 
fat_slot_info *sinfo)
struct super_block *sb = dir->i_sb;
struct msdos_dir_entry *de;
struct buffer_head *bh;
+   struct inode_timespec now;
int err = 0, nr_slots;
 
/*
@@ -1071,7 +1072,9 @@ int fat_remove_entries(struct inode *dir, struct 
fat_slot_info *sinfo)
}
}
 
-   dir->i_mtime = dir->i_atime = CURRENT_TIME_SEC;
+   now = current_fs_time_sec(sb);
+   VFS_INODE_SET_XTIME(i_mtime, dir, now);
+   VFS_INODE_SET_XTIME(i_atime, dir, now);
if (IS_DIRSYNC(dir))
(void)fat_sync_inode(dir);
else
@@ -1130,7 +1133,7 @@ error:
return err;
 }
 
-int fat_alloc_new_dir(struct inode *dir, struct timespec *ts)
+int fat_alloc_new_dir(struct inode *dir, struct inode_timespec *ts)
 {
struct super_block *sb = dir->i_sb;
struct msdos_sb_info *sbi = MSDOS_SB(sb);
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index e6b764a..cabb0fd 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -303,7 +303,7 @@ extern int fat_scan_logstart(struct inode *dir, int 
i_logstart,
 struct fat_slot_info *sinfo);
 extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh,
struct msdos_dir_entry **de);
-extern int fat_alloc_new_dir(struct inode *dir, struct timespec *ts);
+extern int fat_alloc_new_dir(struct inode *dir, struct inode_timespec *ts);
 extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
   struct fat_slot_info *sinfo);
 extern int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo);
@@ -405,9 +405,11 @@ void fat_msg(struct super_block *sb, const char *level, 
const char *fmt, ...);
 } while (0)
 extern int fat_clusters_flush(struct super_block *sb);
 extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
-extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
+extern void fat_time_fat2unix(struct msdos_sb_info *sbi,
+ struct inode_timespec *ts,
  __le16 __time, __le16 __date, u8 time_cs);
-extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts,
+extern void fat_time_unix2fat(struct msdos_sb_info *sbi,
+ struct inode_timespec *ts,
  __le16 *time, __le16 *date, u8 *time_cs);
 extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
 
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 43d3475..e7f060f 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -188,13 +188,16 @@ static int fat_cont_expand(struct inode *inode, loff_t 
size)
 {
struct address_space *mapping = inode->i_mapping;
loff_t start = inode->i_size, count = size - inode->i_size;
+   struct inode_timespec ts;
int err;
 
err = generic_cont_expand_simple(inode, size);
if (err)
goto out;
 
-   inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
+   ts = current_fs_time_sec(inode->i_sb);
+   VFS_INODE_SET_XTIME(i_ctime, inode, ts);
+   VFS_INODE_SET_XTIME(i_mtime, inode, ts);
mark_inode_dirty(inode);
if (IS_SYNC(inode)) {
int err2;
@@ -280,6 +283,7 @@ error:
 static int fat_free(struct inode *inode, int skip)
 {
struct super_block *sb = inode->i_sb;
+   struct inode_timespec ts;
int err, wait, free_start, i_start, i_logstart;
 
if (MSDOS_I(inode)->i_start == 0)
@@ -297,7 +301,9 @@ static int fat_free(struct inode *inode, int skip)
MSDOS_I(inode)->i_logstart = 0;
}
MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
-   inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
+   ts = current_fs_time_sec(sb);
+   VFS_INODE_SET_XTIME(i_ctime, inod

[Y2038] [RFC 07/15] fs: ext4: convert to use 64 bit time

2016-01-06 Thread Deepa Dinamani
struct timespec is not y2038 safe.
The ext4 uses time_extra fields to extend {a,c,m,cr} times until
2446.

Use struct inode_timespec to replace timespec.
inode_timespec will eventually be replaced by struct timespec64
when CONFIG_FS_USES_64BIT_TIME is enabled.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/ext4/acl.c |  3 ++-
 fs/ext4/ext4.h| 44 
 fs/ext4/extents.c | 25 +++--
 fs/ext4/ialloc.c  |  9 +++--
 fs/ext4/inline.c  | 10 --
 fs/ext4/inode.c   | 16 
 fs/ext4/ioctl.c   | 16 ++--
 fs/ext4/namei.c   | 40 
 fs/ext4/super.c   |  6 +-
 fs/ext4/xattr.c   |  2 +-
 10 files changed, 116 insertions(+), 55 deletions(-)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 69b1e73..e8073d5 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -200,7 +200,8 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int 
type,
if (error < 0)
return error;
else {
-   inode->i_ctime = ext4_current_time(inode);
+   VFS_INODE_SET_XTIME(i_ctime, inode,
+   ext4_current_time(inode));
ext4_mark_inode_dirty(handle, inode);
if (error == 0)
acl = NULL;
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index c569430..4bb2604 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -754,14 +754,15 @@ struct move_extent {
  * affected filesystem before 2242.
  */
 
-static inline __le32 ext4_encode_extra_time(struct timespec *time)
+static inline __le32 ext4_encode_extra_time(struct inode_timespec *time)
 {
u32 extra = sizeof(time->tv_sec) > 4 ?
((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK : 
0;
return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS));
 }
 
-static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra)
+static inline void ext4_decode_extra_time(struct inode_timespec *time,
+ __le32 extra)
 {
if (unlikely(sizeof(time->tv_sec) > 4 &&
(extra & cpu_to_le32(EXT4_EPOCH_MASK {
@@ -784,12 +785,13 @@ static inline void ext4_decode_extra_time(struct timespec 
*time, __le32 extra)
time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> 
EXT4_EPOCH_BITS;
 }
 
-#define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \
-do {  \
-   (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec);   \
-   if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \
-   (raw_inode)->xtime ## _extra = \
-   ext4_encode_extra_time(&(inode)->xtime);   \
+#define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)  
\
+do {   
\
+   struct inode_timespec __ts = VFS_INODE_GET_XTIME(xtime, inode); 
\
+   (raw_inode)->xtime = cpu_to_le32(__ts.tv_sec);  
\
+   if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))  
\
+   (raw_inode)->xtime ## _extra =  
\
+   ext4_encode_extra_time(&__ts);  
\
 } while (0)
 
 #define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode)
   \
@@ -801,14 +803,16 @@ do {  
   \
ext4_encode_extra_time(&(einode)->xtime);  \
 } while (0)
 
-#define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode) \
-do {  \
-   (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);   \
-   if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \
-   ext4_decode_extra_time(&(inode)->xtime,\
-  raw_inode->xtime ## _extra);\
-   else   \
-   (inode)->xtime.tv_nsec = 0;\
+#define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)  
\
+do {   
\
+   struct inode_timespec __ts = VFS_INODE_GET_XTIME(xtime, inode); 
\
+   __ts.tv_sec

[Y2038] [RFC 14/15] vfs: Remove inode_timespec aliases

2016-01-06 Thread Deepa Dinamani
Now that CONFIG_FS_USES_64BIT_TIME is enabled, the aliases
for inode_timespec are no longer used and can be removed.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/time64.h | 21 -
 1 file changed, 21 deletions(-)

diff --git a/include/linux/time64.h b/include/linux/time64.h
index eb3cdc0..f30c910 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -26,27 +26,6 @@ struct itimerspec64 {
 
 #endif
 
-#ifdef CONFIG_FS_USES_64BIT_TIME
-
-/* Place holder defines until CONFIG_FS_USES_64BIT_TIME
- * is enabled.
- * timespec64 data type and functions will be used at that
- * time directly and these defines will be deleted.
- */
-#define inode_timespec timespec64
-
-#define inode_timespec_compare timespec64_compare
-#define inode_timespec_equal   timespec64_equal
-
-#else
-
-#define inode_timespec timespec
-
-#define inode_timespec_compare timespec_compare
-#define inode_timespec_equal   timespec_equal
-
-#endif
-
 #define CURRENT_TIME64 (current_kernel_time64())
 #define CURRENT_TIME64_SEC \
((struct timespec64) { ktime_get_real_seconds(), 0 })
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC 09/15] fs: cifs: replace inode_timespec with timespec64

2016-01-06 Thread Deepa Dinamani
Substitute inode_timespec aliases with timespec64.
Since CONFIG_FS_USES_64BIT_TIME is enabled, internally
all inode_timespec references are using timespec64
already.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/cifs/cache.c |  4 ++--
 fs/cifs/cifsglob.h  |  6 +++---
 fs/cifs/cifsproto.h |  6 +++---
 fs/cifs/cifssmb.c   |  4 ++--
 fs/cifs/file.c  |  2 +-
 fs/cifs/inode.c | 12 ++--
 fs/cifs/netmisc.c   | 10 +-
 7 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/fs/cifs/cache.c b/fs/cifs/cache.c
index 8d27e69b..61c21bf 100644
--- a/fs/cifs/cache.c
+++ b/fs/cifs/cache.c
@@ -221,8 +221,8 @@ const struct fscache_cookie_def 
cifs_fscache_super_index_def = {
  * Auxiliary data attached to CIFS inode within the cache
  */
 struct cifs_fscache_inode_auxdata {
-   struct inode_timespec   last_write_time;
-   struct inode_timespec   last_change_time;
+   struct timespec64   last_write_time;
+   struct timespec64   last_change_time;
u64 eof;
 };
 
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index c95dce7..7dfb0e2 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1393,9 +1393,9 @@ struct cifs_fattr {
dev_t   cf_rdev;
unsigned intcf_nlink;
unsigned intcf_dtype;
-   struct inode_timespec   cf_atime;
-   struct inode_timespec   cf_mtime;
-   struct inode_timespec   cf_ctime;
+   struct timespec64   cf_atime;
+   struct timespec64   cf_mtime;
+   struct timespec64   cf_ctime;
 };
 
 static inline void free_dfs_info_param(struct dfs_info3_param *param)
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 9979c74..663b8a4 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -126,10 +126,10 @@ extern enum securityEnum select_sectype(struct 
TCP_Server_Info *server,
enum securityEnum requested);
 extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
  const struct nls_table *nls_cp);
-extern struct inode_timespec
+extern struct timespec64
cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
-extern u64 cifs_UnixTimeToNT(struct inode_timespec);
-extern struct inode_timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
+extern u64 cifs_UnixTimeToNT(struct timespec64);
+extern struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
int offset);
 extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
 extern int cifs_get_writer(struct cifsInodeInfo *cinode);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index a813bcd..465e089 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -478,7 +478,7 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, 
NEGOTIATE_RSP *pSMBr)
 * this requirement.
 */
int val, seconds, remain, result;
-   struct inode_timespec ts, utc;
+   struct timespec64 ts, utc;
 
utc = FS_TIME;
ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
@@ -4004,7 +4004,7 @@ QInfRetry:
if (rc) {
cifs_dbg(FYI, "Send error in QueryInfo = %d\n", rc);
} else if (data) {
-   struct inode_timespec ts;
+   struct timespec64 ts;
 
__u32 time = le32_to_cpu(pSMBr->last_write_time);
 
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 2d226cf..656e799 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1839,7 +1839,7 @@ static int cifs_partialpagewrite(struct page *page, 
unsigned from, unsigned to)
int bytes_written = 0;
struct inode *inode;
struct cifsFileInfo *open_file;
-   struct inode_timespec now;
+   struct timespec64 now;
 
if (!mapping || !mapping->host)
return -EFAULT;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index bb91bf7..c65d7e3 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -92,7 +92,7 @@ static void
 cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
 {
struct cifsInodeInfo *cifs_i = CIFS_I(inode);
-   struct inode_timespec mtime;
+   struct timespec64 mtime;
 
cifs_dbg(FYI, "%s: revalidating inode %llu\n",
 __func__, cifs_i->uniqueid);
@@ -112,7 +112,7 @@ cifs_revalidate_cache(struct inode *inode, struct 
cifs_fattr *fattr)
 
 /* revalidate if mtime or size have changed */
mtime = VFS_INODE_GET_XTIME(i_mtime, inode);
-   if (inode_timespec_equal(, >cf_mtime)
+   if (timespec64_equal(, >cf_mtime)
&& cifs_i->server_eof == fattr->cf_eof) {
cifs_dbg(FYI, "%s: inode %llu is unchanged\n",
  __func__, cifs_i->uniqueid);
@@ -320,7 +320,7 @@ static void
 cifs_create_dfs_fattr(struct cifs_fattr *fattr, struc

Re: [Y2038] [RFC 13/15] kernel: time: change inode_timespec to timespec64

2016-01-07 Thread Deepa Dinamani
On Thu, Jan 07, 2016 at 09:50:30AM +0100, Michael Adam wrote:
> Hi,
> 
> the patch contains a conflict resolution artifact..
> 

Thanks, I've fixed it in my tree now.
I will wait to hear other comments before I send an update.

-Deepa

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 3/4] vfs: Add support for vfs code to use 64 bit time.

2015-12-19 Thread Deepa Dinamani
VFS currently uses struct timespec timestamps which are not
y2038 safe.

Change all the struct inode timestamps accesses through
accessor functions only. This will help the switch over
to 64 bit times seamlessly.

Change all struct iattr and struct kstat timestamps to use
struct inode_timespec. This will use struct timespec64
when 64 bit time switch occurs.

Change all calls to CURRENT_TIME to current_fs_time().
The CURRENT_TIME macro is not accurate for file system code
as it does not perform range checks on timestamps nor does it
cater to individual file system timestamp granularity.
Change all calls to timespec_trunc() to fs_time_trunc().
The later will be extended to support range checking on
timestamps.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/attr.c| 14 +++---
 fs/bad_inode.c   |  9 +++--
 fs/binfmt_misc.c |  7 +--
 fs/inode.c   | 44 ++
 fs/libfs.c   | 58 +---
 fs/locks.c   |  5 ++---
 fs/nsfs.c|  6 +-
 fs/pipe.c|  6 +-
 fs/posix_acl.c   |  2 +-
 fs/stat.c|  6 +++---
 fs/utimes.c  |  4 ++--
 11 files changed, 108 insertions(+), 53 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index 6530ced..d42af4c 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -148,14 +148,14 @@ void setattr_copy(struct inode *inode, const struct iattr 
*attr)
if (ia_valid & ATTR_GID)
inode->i_gid = attr->ia_gid;
if (ia_valid & ATTR_ATIME)
-   inode->i_atime = timespec_trunc(attr->ia_atime,
-   inode->i_sb->s_time_gran);
+   inode_set_inode_time(>i_atime, 
fs_time_trunc(attr->ia_atime,
+   inode->i_sb));
if (ia_valid & ATTR_MTIME)
-   inode->i_mtime = timespec_trunc(attr->ia_mtime,
-   inode->i_sb->s_time_gran);
+   inode_set_inode_time(>i_mtime, 
fs_time_trunc(attr->ia_mtime,
+   inode->i_sb));
if (ia_valid & ATTR_CTIME)
-   inode->i_ctime = timespec_trunc(attr->ia_ctime,
-   inode->i_sb->s_time_gran);
+   inode_set_inode_time(>i_ctime, 
fs_time_trunc(attr->ia_ctime,
+   inode->i_sb));
if (ia_valid & ATTR_MODE) {
umode_t mode = attr->ia_mode;
 
@@ -192,7 +192,7 @@ int notify_change(struct dentry * dentry, struct iattr * 
attr, struct inode **de
struct inode *inode = dentry->d_inode;
umode_t mode = inode->i_mode;
int error;
-   struct timespec now;
+   struct inode_timespec now;
unsigned int ia_valid = attr->ia_valid;
 
WARN_ON_ONCE(!mutex_is_locked(>i_mutex));
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 103f5d7..20cf831 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -169,11 +169,16 @@ static const struct inode_operations bad_inode_ops =
  
 void make_bad_inode(struct inode *inode)
 {
+   struct inode_timespec now;
+
remove_inode_hash(inode);
 
inode->i_mode = S_IFREG;
-   inode->i_atime = inode->i_mtime = inode->i_ctime =
-   current_fs_time(inode->i_sb);
+
+   now = current_fs_time(inode->i_sb);
+   inode_set_inode_time(>i_atime, now);
+   inode_set_inode_time(>i_mtime, now);
+   inode_set_inode_time(>i_ctime, now);
inode->i_op = _inode_ops;   
inode->i_fop = _file_ops;   
 }
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 78f005f..48ae5ff 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -562,12 +562,15 @@ static void entry_status(Node *e, char *page)
 static struct inode *bm_get_inode(struct super_block *sb, int mode)
 {
struct inode *inode = new_inode(sb);
+   struct inode_timespec now;
 
if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode;
-   inode->i_atime = inode->i_mtime = inode->i_ctime =
-   current_fs_time(inode->i_sb);
+   now = current_fs_time(inode->i_sb);
+   inode_set_inode_time(>i_atime, now);
+   inode_set_inode_time(>i_mtime, now);
+   inode_set_inode_time(>i_ctime, now);
}
return inode;
 }
diff --git a/fs/inode.c b/fs/inode.c
index 59e55ee..0318472 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1532,27 +1532,36 @@ EXPORT_SYMBOL(bmap);
  * passed since the last atime update.
  */
 static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
-struct timespec now)
+struct inode_ti

[Y2038] [PATCH 4/4] fs: cifs: Add support for cifs to use 64 bit time

2015-12-19 Thread Deepa Dinamani
Change all struct timespec references to struct inode_timespec.
This will help the switch to struct timespec64 when
CONFIG_FS_USES_64BIT_TIME is enabled.

Use current_fs_time() instead of CURRENT_TIME macros to help
range and precesion checks.

Truncate and perform range checks before saving the times in
struct inode.

Switch over connection times to use SYSTEM_TIME macro instead
of CURRENT_TIME. Since SYSTEM_TIME is also under the
CONFIG_FS_USES_64BIT_TIME this will help the switch to use
timespec64.

The time conversion api's will be moved to kernel/time with
more generic implementations for all file systems to share.
This will be in a separate patch series.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/cifs/cache.c   | 16 +++-
 fs/cifs/cifsencrypt.c |  2 +-
 fs/cifs/cifsglob.h|  6 ++---
 fs/cifs/cifsproto.h   |  7 +++---
 fs/cifs/cifssmb.c |  9 ---
 fs/cifs/file.c|  9 ---
 fs/cifs/inode.c   | 68 ---
 fs/cifs/netmisc.c | 10 
 8 files changed, 78 insertions(+), 49 deletions(-)

diff --git a/fs/cifs/cache.c b/fs/cifs/cache.c
index 6c665bf..b662e8a 100644
--- a/fs/cifs/cache.c
+++ b/fs/cifs/cache.c
@@ -221,8 +221,8 @@ const struct fscache_cookie_def 
cifs_fscache_super_index_def = {
  * Auxiliary data attached to CIFS inode within the cache
  */
 struct cifs_fscache_inode_auxdata {
-   struct timespec last_write_time;
-   struct timespec last_change_time;
+   struct inode_timespec   last_write_time;
+   struct inode_timespec   last_change_time;
u64 eof;
 };
 
@@ -259,8 +259,10 @@ cifs_fscache_inode_get_aux(const void *cookie_netfs_data, 
void *buffer,
 
memset(, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof;
-   auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-   auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+   auxdata.last_write_time =
+   inode_get_inode_time(>vfs_inode.i_mtime);
+   auxdata.last_change_time =
+   inode_get_inode_time(>vfs_inode.i_ctime);
 
if (maxbuf > sizeof(auxdata))
maxbuf = sizeof(auxdata);
@@ -283,8 +285,10 @@ fscache_checkaux cifs_fscache_inode_check_aux(void 
*cookie_netfs_data,
 
memset(, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof;
-   auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-   auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+   auxdata.last_write_time =
+   inode_get_inode_time(>vfs_inode.i_mtime);
+   auxdata.last_change_time =
+   inode_get_inode_time(>vfs_inode.i_ctime);
 
if (memcmp(data, , datalen) != 0)
return FSCACHE_CHECKAUX_OBSOLETE;
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index afa09fc..721676e 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -483,7 +483,7 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */
}
 
-   return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+   return cpu_to_le64(cifs_UnixTimeToNT(SYSTEM_TIME));
 }
 
 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 472daeb..a25b2e6 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1389,9 +1389,9 @@ struct cifs_fattr {
dev_t   cf_rdev;
unsigned intcf_nlink;
unsigned intcf_dtype;
-   struct timespec cf_atime;
-   struct timespec cf_mtime;
-   struct timespec cf_ctime;
+   struct inode_timespec   cf_atime;
+   struct inode_timespec   cf_mtime;
+   struct inode_timespec   cf_ctime;
 };
 
 static inline void free_dfs_info_param(struct dfs_info3_param *param)
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index eed7ff5..d2f8fd4 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -126,9 +126,10 @@ extern enum securityEnum select_sectype(struct 
TCP_Server_Info *server,
enum securityEnum requested);
 extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
  const struct nls_table *nls_cp);
-extern struct timespec cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
-extern u64 cifs_UnixTimeToNT(struct timespec);
-extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
+extern struct inode_timespec
+   cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
+extern u64 cifs_UnixTimeToNT(struct inode_timespec);
+extern struct inode_timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
  int offset);
 extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
 extern int cifs_get_writer(struct cifsInodeInfo *cinode);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 90b4f9f..2c8b550 100644
--- a/fs

[Y2038] [PATCH 1/4] vfs: Add 64 bit time support

2015-12-19 Thread Deepa Dinamani
The current representation of inode times in struct inode, struct iattr,
and struct kstat use struct timespec. timespec is not y2038 safe.

Use struct inode_time for struct inode timestamp fields to maintain
same size for times across 32 bit and 64 bit architectures.
In addition, inode_time is defined as packed and aligned to a 4 byte
boundary to make the structure use 12 bytes instead of 16 bytes. This
will help save RAM space as inode structure is cached in memory. The
other structures are transient and do not benefit from these changes.
The pahole tool shows that this also uses up a 4 byte hole(on 64 bit arch)
in the inode structure also contributing to space savings.

Add accessors for inode times.
These provide a way to access the packed structure.
Accessors abstract the timestamp representation so that any logic
to convert between the struct inode timestamps and other interfaces
can be placed here. This helps contain the inode_time structure
within the context of struct inode.

The plan is to globally change all references to these types through
these accessors only. So when the actual internal representation
changes, it will be transparent to the outside world.

Add inode_timespec aliases to help convert kstat and iattr times to use
64 bit times. These hide the internal data type.
Use uapi exposed data types here to keep minimal timstamp data type
conversions in API's interfacing with vfs.

After the CONFIG_FS_USES_64BIT_TIME is enabled, all inode_timespec
aliases will be removed and timespec64 data types and API's will
be used directly.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/fs.h | 69 ++
 include/linux/stat.h   |  6 ++---
 include/linux/time64.h | 35 +
 3 files changed, 97 insertions(+), 13 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 14ffad4..3b018c6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -245,13 +245,13 @@ typedef void (dax_iodone_t)(struct buffer_head *bh_map, 
int uptodate);
  */
 struct iattr {
unsigned intia_valid;
-   umode_t ia_mode;
-   kuid_t  ia_uid;
-   kgid_t  ia_gid;
-   loff_t  ia_size;
-   struct timespec ia_atime;
-   struct timespec ia_mtime;
-   struct timespec ia_ctime;
+   umode_t ia_mode;
+   kuid_t  ia_uid;
+   kgid_t  ia_gid;
+   loff_t  ia_size;
+   struct inode_timespec   ia_atime;
+   struct inode_timespec   ia_mtime;
+   struct inode_timespec   ia_ctime;
 
/*
 * Not an attribute, but an auxiliary info for filesystems wanting to
@@ -616,9 +616,9 @@ struct inode {
};
dev_t   i_rdev;
loff_t  i_size;
-   struct timespec i_atime;
-   struct timespec i_mtime;
-   struct timespec i_ctime;
+   struct inode_time   i_atime;
+   struct inode_time   i_mtime;
+   struct inode_time   i_ctime;
spinlock_t  i_lock; /* i_blocks, i_bytes, maybe i_size */
unsigned short  i_bytes;
unsigned inti_blkbits;
@@ -679,6 +679,55 @@ struct inode {
void*i_private; /* fs or device private pointer */
 };
 
+#ifdef CONFIG_FS_USES_64BIT_TIME
+
+#if __BITS_PER_LONG == 64
+static inline struct timespec64
+inode_get_inode_time(const struct inode_time *itime)
+{
+return (struct timespec64) {
+   .tv_sec = itime->tv_sec;
+   .tv_nsec = itime->tv_nsec;
+};
+}
+
+static inline void
+inode_set_inode_time(struct inode_time *itime, const struct timespec64 ts64)
+{
+   itime->tv_sec = ts64.tv_sec;
+   itime->tv_nsec = ts64.tv_nsec;
+}
+
+#else
+
+static inline struct timespec64
+inode_get_inode_time(const struct inode_time *itime)
+{
+   return *itime;
+}
+
+static inline void
+inode_set_inode_time(struct inode_time *itime, const struct timespec64 ts64)
+{
+   *itime = ts64;
+}
+
+#endif
+#else
+static inline struct timespec
+inode_get_inode_time(const struct timespec *itime)
+{
+   return *itime;
+}
+
+static inline void
+inode_set_inode_time(struct timespec *itime, const struct timespec ts)
+{
+   *itime = ts;
+}
+
+#endif
+
 static inline int inode_unhashed(struct inode *inode)
 {
return hlist_unhashed(>i_hash);
diff --git a/include/linux/stat.h b/include/linux/stat.h
index 075cb0c..559983f 100644
--- a/include/linux/stat.h
+++ b/include/linux/stat.h
@@ -27,9 +27,9 @@ struct kstat {
kgid_t  gid;
dev_t   rdev;
loff_t  size;
-   struct timespec  atime;
-   struct timespec mtime;
-   struct timespec ctime;
+   struct inode_timespec   atime;
+   struct inode_timespec   mtime;
+   struct inode_timespec   ctime;
un

[Y2038] [PATCH 0/4] fs: Add support 64 bit timestamps

2015-12-19 Thread Deepa Dinamani
The first two patches contain the basic framework for the 64 bit time migration
for filesystems.
The next two patches shows how the framework has been adapted to vfs layer and
cifs filesystem.

There might be some minor changes or additions required as I start adapting to
other filesystems.

The change to timestamp conversion functions(to and from unix format to others)
and range checks will be part of a separate series.

Changes since RFC:
* struct inode_time added unconditionally
* uniform use of CONFIG_FS_USES_64BIT_TIME
* struct inode_timespec added
* merged the first two patches in the previous series

Deepa Dinamani (4):
  vfs: Add 64 bit time support
  kernel: time: Add macros and functions to support 64 bit time
  vfs: Add support for vfs code to use 64 bit time.
  fs: cifs: Add support for cifs to use 64 bit time

 fs/attr.c  | 14 +-
 fs/bad_inode.c |  9 --
 fs/binfmt_misc.c   |  7 +++--
 fs/cifs/cache.c| 16 +++
 fs/cifs/cifsencrypt.c  |  2 +-
 fs/cifs/cifsglob.h |  6 ++--
 fs/cifs/cifsproto.h|  7 +++--
 fs/cifs/cifssmb.c  |  9 --
 fs/cifs/file.c |  9 --
 fs/cifs/inode.c| 68 +-
 fs/cifs/netmisc.c  | 10 +++
 fs/inode.c | 44 +++---
 fs/libfs.c | 58 +--
 fs/locks.c |  5 ++--
 fs/nsfs.c  |  6 +++-
 fs/pipe.c  |  6 +++-
 fs/posix_acl.c |  2 +-
 fs/stat.c  |  6 ++--
 fs/utimes.c|  4 +--
 include/linux/fs.h | 74 ++
 include/linux/stat.h   |  6 ++--
 include/linux/time64.h | 43 +
 kernel/time/time.c | 65 +++-
 23 files changed, 359 insertions(+), 117 deletions(-)

-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v2 0/4] fs: Add 64 bit time support

2015-12-19 Thread Deepa Dinamani
The first two patches contain the basic framework for the 64 bit time migration
for filesystems.
The next two patches shows how the framework has been adapted to vfs layer and
cifs filesystem.

There might be some minor changes or additions required as I start adapting to
other filesystems.

The change to timestamp conversion functions(to and from unix format to others)
and range checks will be part of a separate series.

Changes since v1:
* move SYSTEM_TIME macros to fs.h
* add 64 bit version of CURRENT_TIME macros.

Deepa Dinamani (4):
  vfs: Add 64 bit time support
  kernel: time: Add macros and functions to support 64 bit time
  vfs: Add support for vfs code to use 64 bit time.
  fs: cifs: Add support for cifs to use 64 bit time

 fs/attr.c  | 14 -
 fs/bad_inode.c |  9 --
 fs/binfmt_misc.c   |  7 +++--
 fs/cifs/cache.c| 16 ++
 fs/cifs/cifsencrypt.c  |  2 +-
 fs/cifs/cifsglob.h |  6 ++--
 fs/cifs/cifsproto.h|  7 +++--
 fs/cifs/cifssmb.c  |  9 --
 fs/cifs/file.c |  9 --
 fs/cifs/inode.c| 68 +---
 fs/cifs/netmisc.c  | 10 +++---
 fs/inode.c | 44 --
 fs/libfs.c | 58 +-
 fs/locks.c |  5 ++-
 fs/nsfs.c  |  6 +++-
 fs/pipe.c  |  6 +++-
 fs/posix_acl.c |  2 +-
 fs/stat.c  |  6 ++--
 fs/utimes.c|  4 +--
 include/linux/fs.h | 85 +++---
 include/linux/stat.h   |  6 ++--
 include/linux/time64.h | 39 +++
 kernel/time/time.c | 65 +-
 23 files changed, 366 insertions(+), 117 deletions(-)

-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [RFC 02/15] vfs: Change all structures to support 64 bit time

2016-01-11 Thread Deepa Dinamani
> On Jan 11, 2016, at 04:33, Dave Chinner <da...@fromorbit.com> wrote:
>
>> On Wed, Jan 06, 2016 at 09:35:59PM -0800, Deepa Dinamani wrote:
>> The current representation of inode times in struct inode, struct iattr,
>> and struct kstat use struct timespec. timespec is not y2038 safe.
>>
>> Use scalar data types (seconds and nanoseconds stored separately) to
>> represent timestamps in struct inode in order to maintain same size for
>> times across 32 bit and 64 bit architectures.
>> In addition, lay them out such that they are packed on a naturally
>> aligned boundary on 64 bit arch as 4 bytes are used to store nsec.
>> This makes each tuple(sec, nscec) use 12 bytes instead of 16 bytes.
>> This will help save RAM space as inode structure is cached in memory.
>> The other structures are transient and do not benefit from these
>> changes.
>
> IMO, this decisions sends the patch series immediately down the
> wrong path.

There are other things the patch does that I would like to get comments
on: inode_timespec aliases, range check, individual fs changes etc.
These are independent of the inode timestamp representation changes.

>TO me, this is a severe case of premature optimisation
> because everything gets way more complex just to save those 8 bytes,
> especially as those holes can be filled simply by changing the
> variable declaration order in the structure and adding a simple
> comment.

I had tried rearranging the structure and the pahole tool does not show
any difference unless you pack and align the struct to 4 bytes on 64
bit arch.  The change actually saves 16 bytes on x86_64 and adds 12
bytes on i386.

Here is the breakdown for struct inode before and after the patch:

x86_64:
/* size: 544, cachelines: 9, members: 44 */   |
/* size: 528, cachelines: 9, members: 47 */
/* sum members: 534, holes: 3, sum holes: 10 */   |
/* sum members: 522, holes: 2, sum holes: 6 */

i386:
/* size: 328, cachelines: 6, members: 45 */   |
/* size: 340, cachelines: 6, members: 48 */
/* sum members: 326, holes: 1, sum holes: 2 */|
/* sum members: 338, holes: 1, sum holes: 2 */

According to /proc/slabinfo I estimated savings of 4MB on a lightly
loaded system.

> And, really, I don't like those VFS_INODE_[GS]ET_XTIME macros at
> all; you've got to touch lots of code(*), making it all shouty and
> harder to read.  They seem only to exist because of the above
> structural change requires an abstract timestamp accessor while
> CONFIG_FS_USES_64BIT_TIME exists.
> Given that goes away at the end o
> the series, so should the macro - if we use a struct timespec64 in
> the first place, it isn't even necessary as a temporary construct

timespec64 was the first option considered here.  The problem with using
timespec64 is the long data type to represent nsec.  If it were possible
to change timespec64 nsec to int data type then it might be okay  to use
that if we are not worried about holes.  I do not see why time stamps
should have different representations on a 32 bit vs a 64 bit arch.
This left us with the option define a new data type to represent
timestamps.  I agreed with the concerns on the earlier RFC series that
there are already very many data types to represent time in the kernel.
So this left me with the option of using scalar types to represent these.
The scalar types were not used for optimization. They just happened to
serve that purpose as well.  This could be in a follow on patch, but as
long as we are changing the representation everywhere, I don't see why
there should be an intermediate step to change it to timespec64 only to
change it to this representation later.

As far as accessors are concerned, there already are accessors in the
VFS: generic_fillattr() and setattr_copy(). The problem really is that
there is more than one way of updating these attributes(timestamps in
this particular case). The side effect of this is that we don't always
call timespec_trunc() before assigning timestamps which can lead to
inconsistencies between on disk and in memory inode timestamps. Also,
since these also touch other attributes, these become more restrictive.
The accessors were an idea to streamline all accesses to timestamps in
inode.  Right now the accessor macros also figure out if the timestamps
were clamped and then call the registered callback.  But, this can be
extended to include fs_time_trunc() and then all the end users can
just use these and not worry about the right granularity or range.
As the commit text says, these can be changed to inline functions to
avoid shouty case.

> (*) I note you haven't touched XFS, which means you've probably
> broken lots of other filesystem code. e.g. in XFS, functions like
> xfs_vn_getattr() and xfs_vn_update_time() access inode->i_[acm]time
> directly and hence are not going to compile after this pat

Re: [Y2038] [PATCH 01/21] fs: Replace CURRENT_TIME_SEC with current_fs_time()

2016-06-10 Thread Deepa Dinamani
On Fri, Jun 10, 2016 at 3:21 PM, Arnd Bergmann <a...@arndb.de> wrote:
> On Wednesday, June 8, 2016 10:04:45 PM CEST Deepa Dinamani wrote:
>> CURRENT_TIME_SEC is not y2038 safe. current_fs_time() will
>> be transitioned to use 64 bit time along with vfs in a
>> separate patch.
>> There is no plan to transistion CURRENT_TIME_SEC to use
>> y2038 safe time interfaces.
>>
>> current_fs_time() will also be extended to use superblock
>> range checking parameters when range checking is introduced.
>>
>> This works because alloc_super() fills in the the s_time_gran
>> in super block to NSEC_PER_SEC.
>>
>> Also note that filesystem specific times like the birthtime,
>> creation time that were using same interfaces to obtain time
>> retain same logistics.
>>
>> Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
>
> one question:
>
> In an earlier version, you had a small optimization to
> use ktime_get_real_seconds() instead of current_kernel_time()
> when the granularity is seconds.
>
> Do you still plan to send that one, or did you decide we don't
> need it?

I was actually planning to use get_seconds() instead of current_kernel_time().
And, transition both along with vfs to y2038 safe apis.
Difference between ktime_get_real_seconds() and current_kernel_time64()
is not much because they both require sequence counter.

It didn't make sense to me to optimize current_fs_time() for seconds
only, and not optimize for 1ns granularity also.
I plan to make changes to the function depending on how we end up
using timespec_trunc()
after the addition of range checking.

Thanks for the guidance on inclusion of reviewers. I'll follow this
approach when I post v2 of the series.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH 06/21] fs: udf: Replace CURRENT_TIME with current_fs_time()

2016-06-09 Thread Deepa Dinamani
On Thu, Jun 9, 2016 at 12:41 AM, Jan Kara <j...@suse.cz> wrote:
> On Wed 08-06-16 22:04:50, Deepa Dinamani wrote:
>> Logical Volume Integrity format is described to have the
>> same timestamp format for "Recording Date and time" as
>> the other [a,c,m]timestamps.
>> Hence using current_fs_time() instead here promises to
>> maintain the same granularity as other timestamps.
>>
> Just one nit below.
>
>> @@ -2030,7 +2030,7 @@ static void udf_close_lvid(struct super_block *sb)
>> - udf_time_to_disk_stamp(>recordingDateAndTime, CURRENT_TIME);
>> + udf_time_to_disk_stamp(>recordingDateAndTime, 
>> current_fs_time(sb));
>
> Please wrap this line properly so that it does not exceed 80 characters.
> Other than that feel free to add:
>
> Reviewed-by: Jan Kara <j...@suse.cz>

Thanks, I will take care of this in v2 of the patch series.
- Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH 17/21] audit: Use timespec64 to represent audit timestamps

2016-06-09 Thread Deepa Dinamani
On Thu, Jun 9, 2016 at 7:31 AM, Steve Grubb <sgr...@redhat.com> wrote:
> On Wednesday, June 08, 2016 10:05:01 PM Deepa Dinamani wrote:
>> Audit timestamps are recorded in string format into
>> an audit buffer for a given context.
>> These mark the entry timestamps for the syscalls.
>> Use y2038 safe struct timespec64 to represent the times.
>> The log strings can handle this transition as strings can
>> hold upto 1024 characters.
>
> Have you tested this with ausearch or any audit utilities? As an aside, a time
> stamp that is up to 1024 characters long is terribly wasteful considering how
> many events we get.

/* AUDIT_BUFSIZ is the size of the temporary buffer used for formatting
 * audit records.  Since printk uses a 1024 byte buffer, this buffer
 * should be at least that large. */
#define AUDIT_BUFSIZ 1024

The commit text is pointing out that the reserve space ensured in each
call to audit_log_vformat is already much more than is needed by this
call from audit_log_start.

Also, since struct timespec64 is already the same as struct timespec
on 64-bit systems, there is really no functional change except on
32-bit machines.

Let me know if you want me to try it out on a 32-bit system.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH 02/21] fs: ext4: Use current_fs_time() for inode timestamps

2016-06-14 Thread Deepa Dinamani
On Fri, Jun 10, 2016 at 3:19 PM, Arnd Bergmann <a...@arndb.de> wrote:
> On Thursday, June 9, 2016 11:45:01 AM CEST Linus Torvalds wrote:
>> On Wed, Jun 8, 2016 at 10:04 PM, Deepa Dinamani <deepa.ker...@gmail.com> 
>> wrote:
>> > CURRENT_TIME_SEC and CURRENT_TIME are not y2038 safe.
>> > current_fs_time() will be transitioned to be y2038 safe
>> > along with vfs.
>> >
>> > current_fs_time() returns timestamps according to the
>> > granularities set in the super_block.
>>
>> All existing users and all the ones in this patch (and the others too,
>> although I didn't go through them very carefully) really would prefer
>> just passing in the inode directly, rather than the superblock.
>>
>> So I don't want to add more users of this broken interface.  It was a
>> mistake to use the superblock. The fact that the time granularity
>> exists there is pretty much irrelevant. If every single user wants to
>> use an inode pointer, then that is what the function should get.
>
> I guess it would help to give the function a new name in the process,
> if only to avoid possible conflicts. That new name of course needs to
> be at least as intuitive as the old one. How about
>
> struct timespec fs_timestamp(struct inode *);

Would moving the function to fs/ directory (filesystems.c/ super.c /
inode.c) and calling it current_time() or fs_current_time() make
sense?
The declaration is already part of fs.h.

This is actually a vfs function.
And, the time functions it uses are already exported.
Leaving it in the time.c by renaming to current_time() would be
confusing in spite of
the struct inode* argument.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH 15/21] time: Add time64_to_tm()

2016-06-15 Thread Deepa Dinamani
On Tue, Jun 14, 2016 at 2:18 PM, John Stultz <john.stu...@linaro.org> wrote:
> On Wed, Jun 8, 2016 at 10:04 PM, Deepa Dinamani <deepa.ker...@gmail.com> 
> wrote:
>> time_to_tm() takes time_t as an argument.
>> time_t is not y2038 safe.
>> Add time64_to_tm() that takes time64_t as an argument
>> which is y2038 safe.
>> The plan is to eventually replace all calls to time_to_tm()
>> by time64_to_tm().
>>
>> Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
>> Cc: John Stultz <john.stu...@linaro.org>
>> Cc: Thomas Gleixner <t...@linutronix.de>
>
> This looks sane to me. Are you hoping for me to queue this, or would
> you like i to go though the fsdev maintainers with my ack?
>
> In either case.
>
> Acked-by: John Stultz <john.stu...@linaro.org>

This is only used by the scsi fnic driver.
I will separate these 2 patches from this CURRENT_TIME series and
then both the patches can be merged through the respective trees.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 12/21] block: rbd: Replace non inode CURRENT_TIME with current_fs_time()

2016-06-08 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_fs_time() instead.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_fs_time() will be
extended to do range checks. Hence, it is necessary for all
file system timestamps to use current_fs_time().

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Ilya Dryomov <idryo...@gmail.com>
Cc: Sage Weil <s...@redhat.com>
Cc: Alex Elder <el...@kernel.org>
Cc: ceph-de...@vger.kernel.org
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 81666a5..4dcafe4 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1888,7 +1888,7 @@ static void rbd_osd_req_format_write(struct 
rbd_obj_request *obj_request)
 {
struct ceph_osd_request *osd_req = obj_request->osd_req;
 
-   osd_req->r_mtime = CURRENT_TIME;
+   osd_req->r_mtime = current_fs_time(osd_req->r_inode->i_sb);
osd_req->r_data_offset = obj_request->offset;
 }
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 02/21] fs: ext4: Use current_fs_time() for inode timestamps

2016-06-08 Thread Deepa Dinamani
CURRENT_TIME_SEC and CURRENT_TIME are not y2038 safe.
current_fs_time() will be transitioned to be y2038 safe
along with vfs.

current_fs_time() returns timestamps according to the
granularities set in the super_block.
The granularity check to call current_fs_time() or
CURRENT_TIME_SEC is not required.
Use current_fs_time() to obtain timestamps
unconditionally.

Quota files are assumed to be on the same filesystem.
Hence, use current_fs_time() for these files as well.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: "Theodore Ts'o" <ty...@mit.edu>
Cc: Andreas Dilger <adilger.ker...@dilger.ca>
Cc: linux-e...@vger.kernel.org
---
 fs/ext4/acl.c |  2 +-
 fs/ext4/ext4.h|  6 --
 fs/ext4/extents.c | 10 +-
 fs/ext4/ialloc.c  |  2 +-
 fs/ext4/inline.c  |  4 ++--
 fs/ext4/inode.c   |  6 +++---
 fs/ext4/ioctl.c   |  8 
 fs/ext4/namei.c   | 24 +---
 fs/ext4/super.c   |  2 +-
 fs/ext4/xattr.c   |  2 +-
 10 files changed, 31 insertions(+), 35 deletions(-)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index c6601a4..f9469cc 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -197,7 +197,7 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int 
type,
if (error < 0)
return error;
else {
-   inode->i_ctime = ext4_current_time(inode);
+   inode->i_ctime = current_fs_time(inode->i_sb);
ext4_mark_inode_dirty(handle, inode);
if (error == 0)
acl = NULL;
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b84aa1c..14e5cf4 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1523,12 +1523,6 @@ static inline struct ext4_inode_info *EXT4_I(struct 
inode *inode)
return container_of(inode, struct ext4_inode_info, vfs_inode);
 }
 
-static inline struct timespec ext4_current_time(struct inode *inode)
-{
-   return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
-   current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
-}
-
 static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
 {
return ino == EXT4_ROOT_INO ||
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 2a2eef9..ac303be 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4722,7 +4722,7 @@ retry:
map.m_lblk += ret;
map.m_len = len = len - ret;
epos = (loff_t)map.m_lblk << inode->i_blkbits;
-   inode->i_ctime = ext4_current_time(inode);
+   inode->i_ctime = current_fs_time(inode->i_sb);
if (new_size) {
if (epos > new_size)
epos = new_size;
@@ -4850,7 +4850,7 @@ static long ext4_zero_range(struct file *file, loff_t 
offset,
}
/* Now release the pages and zero block aligned part of pages */
truncate_pagecache_range(inode, start, end - 1);
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
 
ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
 flags, mode);
@@ -4875,7 +4875,7 @@ static long ext4_zero_range(struct file *file, loff_t 
offset,
goto out_dio;
}
 
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
if (new_size) {
ext4_update_inode_size(inode, new_size);
} else {
@@ -5574,7 +5574,7 @@ int ext4_collapse_range(struct inode *inode, loff_t 
offset, loff_t len)
up_write(_I(inode)->i_data_sem);
if (IS_SYNC(inode))
ext4_handle_sync(handle);
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
ext4_mark_inode_dirty(handle, inode);
 
 out_stop:
@@ -5684,7 +5684,7 @@ int ext4_insert_range(struct inode *inode, loff_t offset, 
loff_t len)
/* Expand file to avoid data loss if there is error while shifting */
inode->i_size += len;
EXT4_I(inode)->i_disksize += len;
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
ret = ext4_mark_inode_dirty(handle, inode);
if (ret)
goto out_stop;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 3da4cf8..152ef38 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1039,7 +1039,7 @@ got:
/* This is the optimal IO 

[Y2038] [PATCH 05/21] fs: jfs: Replace CURRENT_TIME_SEC by current_fs_time()

2016-06-08 Thread Deepa Dinamani
jfs uses nanosecond granularity for filesystem timestamps.
Only this assignemt is not using nanosecond granularity.
Use current_fs_time() to get the right nanosecond granularity.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Dave Kleikamp <sha...@kernel.org>
Cc: jfs-discuss...@lists.sourceforge.net
---
 fs/jfs/ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index 8653cac..b52aedf 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -60,6 +60,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
 {
struct inode *inode = file_inode(filp);
struct jfs_inode_info *jfs_inode = JFS_IP(inode);
+   struct super_block *sb = inode->i_sb;
unsigned int flags;
 
switch (cmd) {
@@ -121,7 +122,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, 
unsigned long arg)
 
jfs_set_inode_flags(inode);
inode_unlock(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_fs_time(sb);
mark_inode_dirty(inode);
 setflags_out:
mnt_drop_write_file(filp);
@@ -130,7 +131,6 @@ setflags_out:
 
case FITRIM:
{
-   struct super_block *sb = inode->i_sb;
struct request_queue *q = bdev_get_queue(sb->s_bdev);
struct fstrim_range range;
s64 ret = 0;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 18/21] fs: nfs: Make nfs boot time y2038 safe

2016-06-08 Thread Deepa Dinamani
boot_time is represented as a struct timespec.
struct timespec and CURRENT_TIME are not y2038 safe.
Overall, the plan is to use timespec64 for all internal
kernel representation of timestamps.
CURRENT_TIME will also be removed.
Use struct timespec64 to represent boot_time.
And, ktime_get_real_ts64() for the boot_time value.

boot_time is used to construct the nfs client boot verifier.
This will now wrap in 2106 instead of 2038 on 32-bit systems.
The server only relies on the value being persistent until
reboot so the wrapping should be fine.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Trond Myklebust <trond.mykleb...@primarydata.com>
Cc: Anna Schumaker <anna.schuma...@netapp.com>
Cc: linux-...@vger.kernel.org
---
 fs/nfs/client.c | 2 +-
 fs/nfs/netns.h  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 0c96528..406972e 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1080,7 +1080,7 @@ void nfs_clients_init(struct net *net)
idr_init(>cb_ident_idr);
 #endif
spin_lock_init(>nfs_client_lock);
-   nn->boot_time = CURRENT_TIME;
+   ktime_get_real_ts64(>boot_time);
 }
 
 #ifdef CONFIG_PROC_FS
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index f0e06e4..48d6b95 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -29,7 +29,7 @@ struct nfs_net {
int cb_users[NFS4_MAX_MINOR_VERSION + 1];
 #endif
spinlock_t nfs_client_lock;
-   struct timespec boot_time;
+   struct timespec64 boot_time;
 #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfsfs;
 #endif
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 17/21] audit: Use timespec64 to represent audit timestamps

2016-06-08 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Paul Moore <p...@paul-moore.com>
Cc: Eric Paris <epa...@redhat.com>
Cc: linux-au...@redhat.com
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c| 10 +-
 kernel/audit.h|  2 +-
 kernel/auditsc.c  |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 961a417..2f6a1123 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -335,7 +335,7 @@ static inline void audit_ptrace(struct task_struct *t)
/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial);
+ struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -510,7 +510,7 @@ static inline void __audit_seccomp(unsigned long syscall, 
long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial)
+ struct timespec64 *t, unsigned int *serial)
 {
return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index 22bb4f2..6c2f405 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1325,10 +1325,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-   *t = CURRENT_TIME;
+   ktime_get_real_ts64(t);
*serial = audit_serial();
}
 }
@@ -1370,7 +1370,7 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 int type)
 {
struct audit_buffer *ab = NULL;
-   struct timespec t;
+   struct timespec64   t;
unsigned intuninitialized_var(serial);
int reserve = 5; /* Allow atomic callers to go up to five
entries over the normal backlog limit */
@@ -1422,8 +1422,8 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 
audit_get_stamp(ab->ctx, , );
 
-   audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-t.tv_sec, t.tv_nsec/100, serial);
+   audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+(unsigned long long)t.tv_sec, t.tv_nsec/100, 
serial);
return ab;
 }
 
diff --git a/kernel/audit.h b/kernel/audit.h
index cbbe6bb..029d674 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -111,7 +111,7 @@ struct audit_context {
enum audit_statestate, current_state;
unsigned intserial; /* serial number for record */
int major;  /* syscall number */
-   struct timespec ctime;  /* time of syscall entry */
+   struct timespec64   ctime;  /* time of syscall entry */
unsigned long   argv[4];/* syscall arguments */
longreturn_code;/* syscall return code */
u64 prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 62ab53d..ecebb3c 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1523,7 +1523,7 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
return;
 
context->serial = 0;
-   context->ctime  = CURRENT_TIME;
+   ktime_get_real_ts64(>ctime);
context->in_syscall = 1;
context->current_state  = state;
context->ppid   = 0;
@@ -1932,13 +1932,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
  

[Y2038] [PATCH 20/21] libceph: Replace CURRENT_TIME with ktime_get_real_ts

2016-06-08 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.
The macro will be deleted and all the references to it
will be replaced by ktime_get_* apis.

struct timespec is also not y2038 safe.
Retain timespec for timestamp representation here as ceph
uses it internally everywhere.
These references will be changed to use struct timespec64
in a separate patch.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: "Yan, Zheng" <z...@redhat.com>
Cc: Sage Weil <s...@redhat.com>
Cc: Ilya Dryomov <idryo...@gmail.com>
Cc: ceph-de...@vger.kernel.org
---
 net/ceph/osd_client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 8946959..44eb2d0 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -3567,7 +3567,7 @@ ceph_osdc_watch(struct ceph_osd_client *osdc,
ceph_oid_copy(>t.base_oid, oid);
ceph_oloc_copy(>t.base_oloc, oloc);
lreq->t.flags = CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK;
-   lreq->mtime = CURRENT_TIME;
+   ktime_get_real_ts(>mtime);
 
lreq->reg_req = alloc_linger_request(lreq);
if (!lreq->reg_req) {
@@ -3625,7 +3625,7 @@ int ceph_osdc_unwatch(struct ceph_osd_client *osdc,
ceph_oid_copy(>r_base_oid, >t.base_oid);
ceph_oloc_copy(>r_base_oloc, >t.base_oloc);
req->r_flags = CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK;
-   req->r_mtime = CURRENT_TIME;
+   ktime_get_real_ts(>r_mtime);
osd_req_op_watch_init(req, 0, lreq->linger_id,
  CEPH_OSD_WATCH_OP_UNWATCH);
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 13/21] fs: ocfs2: Use time64_t to represent orphan scan times

2016-06-08 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Use time64_t which is y2038 safe to represent orphan
scan times.
time64_t is sufficient here as only the seconds delta
times are relevant.

Also use appropriate time functions that return time in
time64_t format. Time functions now return monotonic
time instead of real time as only delta scan times are
relevant and these values are not persistent across
reboots.

The format string for the debug print is still using long
as this is only the time elapsed since the last scan and
long is sufficient to represent this value.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Mark Fasheh <mfas...@suse.com>
Cc: Joel Becker <jl...@evilplan.org>
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/journal.c | 4 ++--
 fs/ocfs2/ocfs2.h   | 2 +-
 fs/ocfs2/super.c   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index e607419..df76e60 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1946,7 +1946,7 @@ static void ocfs2_queue_orphan_scan(struct ocfs2_super 
*osb)
 */
seqno++;
os->os_count++;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
 unlock:
ocfs2_orphan_scan_unlock(osb, seqno);
 out:
@@ -2003,7 +2003,7 @@ void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
struct ocfs2_orphan_scan *os;
 
os = >osb_orphan_scan;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
atomic_set(>os_state, ORPHAN_SCAN_INACTIVE);
else {
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index e63af7d..7e5958b 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -224,7 +224,7 @@ struct ocfs2_orphan_scan {
struct ocfs2_super  *os_osb;
struct ocfs2_lock_res   os_lockres; /* lock to synchronize scans */
struct delayed_work os_orphan_scan_work;
-   struct timespec os_scantime;  /* time this node ran the scan */
+   time64_tos_scantime;  /* time this node ran the scan */
u32 os_count;  /* tracks node specific scans */
u32 os_seqno;   /* tracks cluster wide scans */
atomic_tos_state;  /* ACTIVE or INACTIVE */
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index d7cae33..dc56f07 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -337,7 +337,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char 
*buf, int len)
out += snprintf(buf + out, len - out, "Disabled\n");
else
out += snprintf(buf + out, len - out, "%lu seconds ago\n",
-   (get_seconds() - os->os_scantime.tv_sec));
+   (unsigned long)(ktime_get_seconds() - 
os->os_scantime));
 
out += snprintf(buf + out, len - out, "%10s => %3s  %10s\n",
"Slots", "Num", "RecoGen");
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 21/21] time: Delete CURRENT_TIME_SEC and CURRENT_TIME macro

2016-06-08 Thread Deepa Dinamani
All uses of these macors have been replaced by other
time functions.
These macros are also not y2038 safe.
And, all its usecases can be fulfilled by y2038
safe ktime_get_* variants.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: John Stultz <john.stu...@linaro.org>
Cc: Thomas Gleixner <t...@linutronix.de>
---
 include/linux/time.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/time.h b/include/linux/time.h
index 4cea09d..a5a07c0 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -151,9 +151,6 @@ static inline bool timespec_inject_offset_valid(const 
struct timespec *ts)
return true;
 }
 
-#define CURRENT_TIME   (current_kernel_time())
-#define CURRENT_TIME_SEC   ((struct timespec) { get_seconds(), 0 })
-
 /* Some architectures do not supply their own clocksource.
  * This is mainly the case in architectures that get their
  * inter-tick times by reading the counter on their interval
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v2 02/24] fs: Replace CURRENT_TIME with current_time() for inode timestamps

2016-06-21 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_time() instead.

CURRENT_TIME is also not y2038 safe.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_time() will be
extended to do range checks. Hence, it is necessary for all
file system timestamps to use current_time(). Also,
current_time() will be transitioned along with vfs to be
y2038 safe.

Note that whenever a single call to current_time() is used
to change timestamps in different inodes, it is because they
share the same time granularity.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Acked-by: Felipe Balbi <ba...@kernel.org>
Acked-by: Steven Whitehouse <swhit...@redhat.com>
Acked-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp>
Reviewed-by: David Sterba <dste...@suse.com>
---
 arch/powerpc/platforms/cell/spufs/inode.c |  2 +-
 arch/s390/hypfs/inode.c   |  4 ++--
 drivers/infiniband/hw/qib/qib_fs.c|  2 +-
 drivers/misc/ibmasm/ibmasmfs.c|  2 +-
 drivers/oprofile/oprofilefs.c |  2 +-
 drivers/usb/core/devio.c  | 18 +-
 drivers/usb/gadget/function/f_fs.c|  8 
 drivers/usb/gadget/legacy/inode.c |  2 +-
 fs/9p/vfs_inode.c |  2 +-
 fs/adfs/inode.c   |  2 +-
 fs/autofs4/inode.c|  2 +-
 fs/autofs4/root.c |  6 +++---
 fs/btrfs/inode.c  |  2 +-
 fs/devpts/inode.c |  6 +++---
 fs/efivarfs/inode.c   |  2 +-
 fs/exofs/dir.c|  6 +++---
 fs/exofs/inode.c  |  4 ++--
 fs/exofs/namei.c  |  6 +++---
 fs/ext2/super.c   |  2 +-
 fs/ext4/super.c   |  2 +-
 fs/f2fs/dir.c |  8 
 fs/f2fs/file.c|  8 
 fs/f2fs/inline.c  |  2 +-
 fs/f2fs/namei.c   | 12 ++--
 fs/f2fs/xattr.c   |  2 +-
 fs/fuse/control.c |  2 +-
 fs/gfs2/bmap.c|  8 
 fs/gfs2/dir.c | 12 ++--
 fs/gfs2/inode.c   |  8 
 fs/gfs2/quota.c   |  2 +-
 fs/gfs2/xattr.c   |  8 
 fs/hugetlbfs/inode.c  | 10 +-
 fs/jfs/acl.c  |  2 +-
 fs/jfs/inode.c|  2 +-
 fs/jfs/jfs_inode.c|  2 +-
 fs/jfs/namei.c| 22 +++---
 fs/jfs/super.c|  2 +-
 fs/jfs/xattr.c|  2 +-
 fs/libfs.c| 14 +++---
 fs/logfs/dir.c|  6 +++---
 fs/logfs/file.c   |  2 +-
 fs/logfs/inode.c  |  4 ++--
 fs/logfs/readwrite.c  |  4 ++--
 fs/nilfs2/dir.c   |  6 +++---
 fs/nilfs2/inode.c |  4 ++--
 fs/nilfs2/ioctl.c |  2 +-
 fs/nilfs2/namei.c |  6 +++---
 fs/nsfs.c |  2 +-
 fs/ocfs2/acl.c|  2 +-
 fs/ocfs2/alloc.c  |  2 +-
 fs/ocfs2/aops.c   |  2 +-
 fs/ocfs2/dir.c|  4 ++--
 fs/ocfs2/dlmfs/dlmfs.c|  4 ++--
 fs/ocfs2/file.c   | 12 ++--
 fs/ocfs2/move_extents.c   |  2 +-
 fs/ocfs2/namei.c  | 16 +---
 fs/ocfs2/refcounttree.c   |  4 ++--
 fs/ocfs2/xattr.c  |  2 +-
 fs/omfs/inode.c   |  2 +-
 fs/openpromfs/inode.c |  2 +-
 fs/orangefs/file.c|  2 +-
 fs/orangefs/inode.c   |  2 +-
 fs/orangefs/namei.c   |  2 +-
 fs/pipe.c |  2 +-
 fs/posix_acl.c|  2 +-
 fs/proc/base.c|  2 +-
 fs/proc/inode.c   |  4 ++--
 fs/proc/proc_sysctl.c |  2 +-
 fs/proc/self.c|  2 +-
 fs/proc/thread_self.c |  2 +-
 fs/pstore/inode.c |  2 +-
 fs/ramfs/inode.c  |  6 +++---
 fs/reiserfs/super.c   |  2 +-
 fs/tracefs/inode.c|  2 +-
 fs/ufs/ialloc.c  

[Y2038] [PATCH 04/21] fs: Replace CURRENT_TIME with current_fs_time() for inode timestamps

2016-06-21 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_fs_time() instead.

CURRENT_TIME is also not y2038 safe.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_fs_time() will be
extended to do range checks. Hence, it is necessary for all
file system timestamps to use current_fs_time(). Also,
current_fs_time() will be transitioned along with vfs to be
y2038 safe.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Steve French <sfre...@samba.org>
Cc: linux-c...@vger.kernel.org
Cc: samba-techni...@lists.samba.org
Cc: Joern Engel <jo...@logfs.org>
Cc: Prasad Joshi <prasadjoshi.li...@gmail.com>
Cc: lo...@logfs.org
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: Julia Lawall <julia.law...@lip6.fr>
Cc: David Howells <dhowe...@redhat.com>
Cc: Firo Yang <fir...@gmail.com>
Cc: Jaegeuk Kim <jaeg...@kernel.org>
Cc: Changman Lee <cm224@samsung.com>
Cc: Chao Yu <chao2...@samsung.com>
Cc: linux-f2fs-de...@lists.sourceforge.net
Cc: Michal Hocko <mho...@suse.com>
Cc: Konstantin Khlebnikov <koc...@gmail.com>
Cc: Naoya Horiguchi <n-horigu...@ah.jp.nec.com>
Cc: "J. Bruce Fields" <bfie...@fieldses.org>
Cc: Jeff Layton <jlay...@poochiereds.net>
Cc: Trond Myklebust <trond.mykleb...@primarydata.com>
Cc: Anna Schumaker <anna.schuma...@netapp.com>
Cc: "David S. Miller" <da...@davemloft.net>
Cc: linux-...@vger.kernel.org
Cc: net...@vger.kernel.org
Cc: Steven Whitehouse <swhit...@redhat.com>
Cc: Bob Peterson <rpete...@redhat.com>
Cc: cluster-de...@redhat.com
Cc: Mark Fasheh <mfas...@suse.com>
Cc: Joel Becker <jl...@evilplan.org>
Cc: ocfs2-de...@oss.oracle.com
Cc: Anton Vorontsov <an...@enomsg.org>
Cc: Colin Cross <ccr...@android.com>
Cc: Kees Cook <keesc...@chromium.org>
Cc: Tony Luck <tony.l...@intel.com>
Cc: Chris Mason <c...@fb.com>
Cc: Josef Bacik <jba...@fb.com>
Cc: David Sterba <dste...@suse.com>
Cc: linux-bt...@vger.kernel.org
Cc: Miklos Szeredi <mik...@szeredi.hu>
Cc: fuse-de...@lists.sourceforge.net
Cc: Felipe Balbi <ba...@kernel.org>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: linux-...@vger.kernel.org
Cc: Doug Ledford <dledf...@redhat.com>
Cc: Sean Hefty <sean.he...@intel.com>
Cc: Hal Rosenstock <hal.rosenst...@gmail.com>
Cc: linux-r...@vger.kernel.org
Cc: Robert Richter <r...@kernel.org>
Cc: oprofile-l...@lists.sf.net
Cc: Alexei Starovoitov <a...@kernel.org>
Cc: Hugh Dickins <hu...@google.com>
Cc: linux...@kvack.org
Cc: Paul Moore <p...@paul-moore.com>
Cc: Stephen Smalley <s...@tycho.nsa.gov>
Cc: Eric Paris <epa...@parisplace.org>
Cc: seli...@tycho.nsa.gov
Cc: James Morris <james.l.mor...@oracle.com>
Cc: "Serge E. Hallyn" <se...@hallyn.com>
Cc: linux-security-mod...@vger.kernel.org
Cc: Eric Van Hensbergen <eri...@gmail.com>
Cc: Ron Minnich <rminn...@sandia.gov>
Cc: Latchesar Ionkov <lu...@ionkov.net>
Cc: v9fs-develo...@lists.sourceforge.net
Cc: Ian Kent <ra...@themaw.net>
Cc: aut...@vger.kernel.org
Cc: Matthew Garrett <matthew.garr...@nebula.com>
Cc: Jeremy Kerr <j...@ozlabs.org>
Cc: Matt Fleming <m...@codeblueprint.co.uk>
Cc: linux-...@vger.kernel.org
Cc: Peter Hurley <pe...@hurleysoftware.com>
Cc: Josh Triplett <j...@joshtriplett.org>
Cc: Boaz Harrosh <o...@electrozaur.com>
Cc: Benny Halevy <bhal...@primarydata.com>
Cc: osd-...@open-osd.org
Cc: Mike Marshall <hub...@omnibond.com>
Cc: pvfs2-develop...@beowulf-underground.org
Cc: Nadia Yvette Chambers <n...@holomorphy.com>
Cc: Dave Kleikamp <sha...@kernel.org>
Cc: jfs-discuss...@lists.sourceforge.net
Cc: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp>
Cc: linux-ni...@vger.kernel.org
---
 arch/powerpc/platforms/cell/spufs/inode.c |  2 +-
 arch/s390/hypfs/inode.c   |  4 ++--
 drivers/infiniband/hw/qib/qib_fs.c|  2 +-
 drivers/misc/ibmasm/ibmasmfs.c|  2 +-
 drivers/oprofile/oprofilefs.c |  2 +-
 drivers/usb/core/devio.c  | 19 +
 drivers/usb/gadget/function/f_fs.c|  2 +-
 drivers/usb/gadget/legacy/inode.c |  2 +-
 fs/9p/vfs_inode.c |  2 +-
 fs/adfs/inode.c   |  2 +-
 fs/autofs4/inode.c|  2 +-
 fs/autofs4/root.c | 19 ++---
 fs/btrfs/inode.c  |  2 +-
 fs/devpts/inode.c |  6 +++---
 fs/efivarfs/inode.c   |  2 +-
 fs/exofs/dir.c|  9 
 fs/exofs/inode.c  |  7 ---

[Y2038] [PATCH v2 00/24] Delete CURRENT_TIME and CURRENT_TIME_SEC macros

2016-06-21 Thread Deepa Dinamani
The series is aimed at getting rid of CURRENT_TIME and CURRENT_TIME_SEC macros.
The macros are not y2038 safe. There is no plan to transition them into being
y2038 safe.
ktime_get_* api's can be used in their place. And, these are y2038 safe.

Thanks to Arnd Bergmann for all the guidance and discussions.

Patches 2-4 were mostly generated using coccinelle scripts.

All filesystem timestamps use current_fs_time() for right granularity as
mentioned in the respective commit texts of patches. This has a changed
signature, renamed to current_time() and moved to the fs/inode.c.

This series also serves as a preparatory series to transition vfs to 64 bit
timestamps as outlined here: https://lkml.org/lkml/2016/2/12/104 .

As per Linus's suggestion in https://lkml.org/lkml/2016/5/24/663 , all the
inode timestamp changes have been squashed into a single patch. Also,
current_time() now is used as a single generic vfs filesystem timestamp api.
It also takes struct inode* as argument instead of struct super_block*.
Posting all patches together in a bigger series so that the big picture is
clear.

As per the suggestion in https://lwn.net/Articles/672598/, CURRENT_TIME macro
bug fixes are being handled in a series separate from transitioning vfs to use.

Changes from v1:
* Change current_fs_time(struct super_block *) to current_time(struct inode *)

* Note that change to add time64_to_tm() is already part of John's
  kernel tree: https://lkml.org/lkml/2016/6/17/875 .

Deepa Dinamani (24):
  vfs: Add current_time() api
  fs: Replace CURRENT_TIME with current_time() for inode timestamps
  fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
  fs: Replace current_fs_time() with current_time()
  fs: jfs: Replace CURRENT_TIME_SEC by current_time()
  fs: ext4: Use current_time() for inode timestamps
  fs: ubifs: Replace CURRENT_TIME_SEC with current_time
  fs: btrfs: Use ktime_get_real_ts for root ctime
  fs: udf: Replace CURRENT_TIME with current_time()
  fs: cifs: Replace CURRENT_TIME by current_time()
  fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()
  fs: cifs: Replace CURRENT_TIME by get_seconds
  fs: f2fs: Use ktime_get_real_seconds for sit_info times
  drivers: staging: lustre: Replace CURRENT_TIME with current_time()
  fs: ocfs2: Use time64_t to represent orphan scan times
  fs: ocfs2: Replace CURRENT_TIME with ktime_get_real_seconds()
  audit: Use timespec64 to represent audit timestamps
  fs: nfs: Make nfs boot time y2038 safe
  fnic: Use time64_t to represent trace timestamps
  block: Replace CURRENT_TIME with ktime_get_real_ts
  libceph: Replace CURRENT_TIME with ktime_get_real_ts
  fs: ceph: Replace current_fs_time for request stamp
  time: Delete CURRENT_TIME_SEC and CURRENT_TIME macro
  time: Delete current_fs_time() function

 arch/powerpc/platforms/cell/spufs/inode.c  |  2 +-
 arch/s390/hypfs/inode.c|  4 ++--
 drivers/block/rbd.c|  2 +-
 drivers/char/sonypi.c  |  2 +-
 drivers/infiniband/hw/qib/qib_fs.c |  2 +-
 drivers/misc/ibmasm/ibmasmfs.c |  2 +-
 drivers/oprofile/oprofilefs.c  |  2 +-
 drivers/platform/x86/sony-laptop.c |  2 +-
 drivers/scsi/fnic/fnic_trace.c |  4 ++--
 drivers/scsi/fnic/fnic_trace.h |  2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c| 16 ++---
 drivers/staging/lustre/lustre/llite/namei.c|  4 ++--
 drivers/staging/lustre/lustre/mdc/mdc_reint.c  |  6 ++---
 .../lustre/lustre/obdclass/linux/linux-obdo.c  |  6 ++---
 drivers/staging/lustre/lustre/obdclass/obdo.c  |  6 ++---
 drivers/staging/lustre/lustre/osc/osc_io.c |  2 +-
 drivers/usb/core/devio.c   | 18 +++---
 drivers/usb/gadget/function/f_fs.c |  8 +++
 drivers/usb/gadget/legacy/inode.c  |  2 +-
 fs/9p/vfs_inode.c  |  2 +-
 fs/adfs/inode.c|  2 +-
 fs/affs/amigaffs.c |  6 ++---
 fs/affs/inode.c|  2 +-
 fs/attr.c  |  2 +-
 fs/autofs4/inode.c |  2 +-
 fs/autofs4/root.c  |  6 ++---
 fs/bad_inode.c |  2 +-
 fs/bfs/dir.c   | 14 +--
 fs/binfmt_misc.c   |  2 +-
 fs/btrfs/file.c|  6 ++---
 fs/btrfs/inode.c   | 22 -
 fs/btrfs/ioctl.c   |  8 +++
 fs/btrfs/root-tree.c   |  3 ++-
 fs/btrfs/transaction.c |  4 ++--
 fs/btrfs/xattr.c   |  2 +-
 fs/ceph/file.c

[Y2038] [PATCH 01/21] fs: Replace CURRENT_TIME_SEC with current_fs_time()

2016-06-21 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe. current_fs_time() will
be transitioned to use 64 bit time along with vfs in a
separate patch.
There is no plan to transistion CURRENT_TIME_SEC to use
y2038 safe time interfaces.

current_fs_time() will also be extended to use superblock
range checking parameters when range checking is introduced.

This works because alloc_super() fills in the the s_time_gran
in super block to NSEC_PER_SEC.

Also note that filesystem specific times like the birthtime,
creation time that were using same interfaces to obtain time
retain same logistics.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Artem Bityutskiy <dedeki...@gmail.com>
Cc: Adrian Hunter <adrian.hun...@intel.com>
Cc: linux-...@lists.infradead.org
Cc: Evgeniy Dushistov <dushis...@mail.ru>
Cc: OGAWA Hirofumi <hirof...@mail.parknet.co.jp>
Cc: Jan Kara <j...@suse.com>
Cc: linux-e...@vger.kernel.org
Cc: David Howells <dhowe...@redhat.com>
Cc: linux-...@lists.infradead.org
Cc: "Tigran A. Aivazian" <tig...@aivazian.fsnet.co.uk>
Cc: linux-fsde...@vger.kernel.org
Cc: "Theodore Ts'o" <ty...@mit.edu>
Cc: Andreas Dilger <adilger.ker...@dilger.ca>
Cc: Jan Kara <j...@suse.cz>
Cc: Jan Harkes <jahar...@cs.cmu.edu>
Cc: c...@cs.cmu.edu
Cc: codal...@coda.cs.cmu.edu
Cc: Bob Copeland <m...@bobcopeland.com>
Cc: linux-karma-de...@lists.sourceforge.net
Cc: Christoph Hellwig <h...@infradead.org>
---
 fs/affs/amigaffs.c  |  6 +++---
 fs/affs/inode.c |  2 +-
 fs/afs/inode.c  |  3 +--
 fs/bfs/dir.c| 18 ++
 fs/coda/dir.c   |  2 +-
 fs/coda/file.c  |  2 +-
 fs/coda/inode.c |  2 +-
 fs/ext2/acl.c   |  2 +-
 fs/ext2/dir.c   |  6 +++---
 fs/ext2/ialloc.c|  2 +-
 fs/ext2/inode.c |  4 ++--
 fs/ext2/ioctl.c |  5 +++--
 fs/ext2/namei.c |  6 +++---
 fs/ext2/super.c |  2 +-
 fs/ext2/xattr.c |  2 +-
 fs/fat/dir.c|  2 +-
 fs/fat/file.c   |  4 ++--
 fs/fat/inode.c  |  2 +-
 fs/fat/namei_msdos.c| 13 +++--
 fs/fat/namei_vfat.c | 10 +-
 fs/hfs/catalog.c|  8 
 fs/hfs/dir.c|  2 +-
 fs/hfs/inode.c  |  2 +-
 fs/hfsplus/catalog.c|  8 
 fs/hfsplus/dir.c|  6 +++---
 fs/hfsplus/inode.c  |  2 +-
 fs/hfsplus/ioctl.c  |  2 +-
 fs/jffs2/acl.c  |  2 +-
 fs/jffs2/fs.c   |  2 +-
 fs/minix/bitmap.c   |  2 +-
 fs/minix/dir.c  | 12 +++-
 fs/minix/itree_common.c |  4 ++--
 fs/minix/namei.c|  4 ++--
 fs/omfs/dir.c   |  4 ++--
 fs/omfs/inode.c |  2 +-
 fs/reiserfs/inode.c |  2 +-
 fs/reiserfs/ioctl.c |  4 ++--
 fs/reiserfs/namei.c | 14 +++---
 fs/reiserfs/stree.c |  6 ++
 fs/reiserfs/super.c |  2 +-
 fs/reiserfs/xattr.c |  2 +-
 fs/reiserfs/xattr_acl.c |  2 +-
 fs/sysv/dir.c   |  6 +++---
 fs/sysv/ialloc.c|  2 +-
 fs/sysv/itree.c |  4 ++--
 fs/sysv/namei.c |  4 ++--
 fs/ufs/dir.c|  6 +++---
 fs/ufs/ialloc.c |  8 +---
 fs/ufs/inode.c  |  6 +++---
 fs/ufs/namei.c  |  6 +++---
 50 files changed, 118 insertions(+), 113 deletions(-)

diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index d6c7a51..015b62c 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -58,7 +58,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh)
mark_buffer_dirty_inode(dir_bh, dir);
affs_brelse(dir_bh);
 
-   dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
+   dir->i_mtime = dir->i_ctime = current_fs_time(sb);
dir->i_version++;
mark_inode_dirty(dir);
 
@@ -112,7 +112,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head 
*rem_bh)
 
affs_brelse(bh);
 
-   dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
+   dir->i_mtime = dir->i_ctime = current_fs_time(sb);
dir->i_version++;
mark_inode_dirty(dir);
 
@@ -313,7 +313,7 @@ affs_remove_header(struct dentry *dentry)
else
clear_nlink(inode);
affs_unlock_link(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_fs_time(inode->i_sb);
mark_inode_dirty(inode);
 
 done:
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 0fdb0f5..cdd6d64 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -309,7 +309,7 @@ affs_new_inode(struct inode *dir)
inode->i_gid = current_fsgid();
inode->i_ino = block;
set_nlink(inode, 1);
-   inode->i_mtime   = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_mtime   = inode->i_atime = inode->i_ctime = 
current_fs_time(sb);
atomic_set(_I(inode)->i_opencnt, 0);
AFFS_I(inode)->i_blkcnt = 0;
AFFS_I(inode)->i_lc 

[Y2038] [PATCH 00/21] Delete CURRENT_TIME and CURRENT_TIME_SEC macros

2016-06-21 Thread Deepa Dinamani
The series is aimed at getting rid of CURRENT_TIME and CURRENT_TIME_SEC macros.
The macros are not y2038 safe. There is no plan to transition them into being
y2038 safe.
ktime_get_* api's can be used in their place. And, these are y2038 safe.

All filesystem timestamps use current_fs_time() for the right granularity
as mentioned in the respective commit texts of patches.

This series also serves as a preparatory series to transition vfs to 64 bit
timestamps as outlined here: https://lkml.org/lkml/2016/2/12/104 .

As per Linus's suggestion in https://lkml.org/lkml/2016/5/24/663 , all the
inode timestamp changes have been squashed into a single patch. Also,
current_fs_time() now is used as a single generic filesystem timestamp api.
Posting all patches together in a bigger series so that the big picture is
clear.

As per the suggestion in https://lwn.net/Articles/672598/ , CURRENT_TIME
macro bug fixes are being handled in a series separate from transitioning
vfs to use 64 bit timestamps.

Some reviewers have requested not to change line wrapping only for the
longer function call names, so checkpatch warnings for such cases are
ignored in the patch series.

Deepa Dinamani (21):
  fs: Replace CURRENT_TIME_SEC with current_fs_time()
  fs: ext4: Use current_fs_time() for inode timestamps
  fs: ubifs: Use current_fs_time() for inode timestamps
  fs: Replace CURRENT_TIME with current_fs_time() for inode timestamps
  fs: jfs: Replace CURRENT_TIME_SEC by current_fs_time()
  fs: udf: Replace CURRENT_TIME with current_fs_time()
  fs: cifs: Replace CURRENT_TIME by current_fs_time()
  fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()
  fs: cifs: Replace CURRENT_TIME by get_seconds
  fs: f2fs: Use ktime_get_real_seconds for sit_info times
  drivers: staging: lustre: Replace CURRENT_TIME with current_fs_time()
  block: rbd: Replace non inode CURRENT_TIME with current_fs_time()
  fs: ocfs2: Use time64_t to represent orphan scan times
  fs: ocfs2: Replace CURRENT_TIME with ktime_get_real_seconds()
  time: Add time64_to_tm()
  fnic: Use time64_t to represent trace timestamps
  audit: Use timespec64 to represent audit timestamps
  fs: nfs: Make nfs boot time y2038 safe
  libceph: Remove CURRENT_TIME references
  libceph: Replace CURRENT_TIME with ktime_get_real_ts
  time: Delete CURRENT_TIME_SEC and CURRENT_TIME macro

 arch/powerpc/platforms/cell/spufs/inode.c  |  2 +-
 arch/s390/hypfs/inode.c|  4 +--
 drivers/block/rbd.c|  2 +-
 drivers/infiniband/hw/qib/qib_fs.c |  2 +-
 drivers/misc/ibmasm/ibmasmfs.c |  2 +-
 drivers/oprofile/oprofilefs.c  |  2 +-
 drivers/scsi/fnic/fnic_trace.c |  4 +--
 drivers/scsi/fnic/fnic_trace.h |  2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c| 17 ++-
 drivers/staging/lustre/lustre/llite/namei.c|  4 +--
 drivers/staging/lustre/lustre/mdc/mdc_reint.c  |  6 ++--
 .../lustre/lustre/obdclass/linux/linux-obdo.c  |  6 ++--
 drivers/staging/lustre/lustre/obdclass/obdo.c  |  6 ++--
 drivers/staging/lustre/lustre/osc/osc_io.c |  2 +-
 drivers/usb/core/devio.c   | 19 ++--
 drivers/usb/gadget/function/f_fs.c |  2 +-
 drivers/usb/gadget/legacy/inode.c  |  2 +-
 fs/9p/vfs_inode.c  |  2 +-
 fs/adfs/inode.c|  2 +-
 fs/affs/amigaffs.c |  6 ++--
 fs/affs/inode.c|  2 +-
 fs/afs/inode.c |  3 +-
 fs/autofs4/inode.c |  2 +-
 fs/autofs4/root.c  | 19 +++-
 fs/bfs/dir.c   | 18 ++-
 fs/btrfs/inode.c   |  2 +-
 fs/cifs/cifsencrypt.c  |  4 ++-
 fs/cifs/cifssmb.c  | 10 +++
 fs/cifs/inode.c| 15 +-
 fs/coda/dir.c  |  2 +-
 fs/coda/file.c |  2 +-
 fs/coda/inode.c|  2 +-
 fs/devpts/inode.c  |  6 ++--
 fs/efivarfs/inode.c|  2 +-
 fs/exofs/dir.c |  9 +++---
 fs/exofs/inode.c   |  7 +++--
 fs/exofs/namei.c   |  6 ++--
 fs/ext2/acl.c  |  2 +-
 fs/ext2/dir.c  |  6 ++--
 fs/ext2/ialloc.c   |  2 +-
 fs/ext2/inode.c|  4 +--
 fs/ext2/ioctl.c|  5 ++--
 fs/ext2/namei.c

[Y2038] [PATCH v2 05/24] fs: jfs: Replace CURRENT_TIME_SEC by current_time()

2016-06-19 Thread Deepa Dinamani
jfs uses nanosecond granularity for filesystem timestamps.
Only this assignemt is not using nanosecond granularity.
Use current_time() to get the right granularity.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Dave Kleikamp <sha...@kernel.org>
Cc: jfs-discuss...@lists.sourceforge.net
---
 fs/jfs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index 8653cac..b6fd1ff 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -121,7 +121,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, 
unsigned long arg)
 
jfs_set_inode_flags(inode);
inode_unlock(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
 setflags_out:
mnt_drop_write_file(filp);
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH v2 19/24] fnic: Use time64_t to represent trace timestamps

2016-06-22 Thread Deepa Dinamani
On Wed, Jun 22, 2016 at 7:09 AM, Arnd Bergmann <a...@arndb.de> wrote:
> On Sunday, June 19, 2016 5:27:18 PM CEST Deepa Dinamani wrote:
>> trace timestamps use struct timespec and CURRENT_TIME which
>> are not y2038 safe.
>> These timestamps are only part of the trace log on the machine
>> and are not shared with the fnic.
>> Replace then with y2038 safe struct timespec64 and
>> ktime_get_real_ts64(), respectively.
>>
>> Note that change to add time64_to_tm() is already part of John's
>> kernel tree: https://lkml.org/lkml/2016/6/17/875 .
>>
>
> While the patch looks good, I think it can't be part of this
> series now, since it has to go on top of that first patch,
> rather than merged in parallel.

Oh, I didn't realize we could merge these in parallel.
I thought the time64_to_tm() had to go in first.

> When you send a pull request, please leave it out and submit
> this one separately after 4.8-rc1.

Will do.

Thanks,
Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH v2 09/24] fs: udf: Replace CURRENT_TIME with current_time()

2016-06-22 Thread Deepa Dinamani
On Wed, Jun 22, 2016 at 6:54 AM, Arnd Bergmann <a...@arndb.de> wrote:
> On Sunday, June 19, 2016 5:27:08 PM CEST Deepa Dinamani wrote:
>> mutex_lock(>s_alloc_mutex);
>> lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
>> lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
>> +   ktime_get_real_ts();
>> udf_time_to_disk_stamp(>recordingDateAndTime,
>> -   CURRENT_TIME);
>> +   timespec_trunc(ts, sb->s_time_gran));
>> lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
>>
>> lvid->descTag.descCRC = cpu_to_le16(
>>
>
> I think we don't need the timespec_trunc here, and introducing the
> call might complicate matters in the future.

This was done so that it could be similar to inode timestamps
as both have same format and use same formatting functions.

> IMHO timespec_trunc() really only makes sense when assigning into
> an inode timestamp, whereas udf_time_to_disk_stamp() already truncates
> the resulting nanoseconds to microseconds.

I reconsidered our discussion.
I think you are correct.
I missed that the prints using microseconds format would actually
convert seconds
also to microseconds and not just nanoseconds.

I will remove the timespec_trunc here and post a v3.

Thanks,
-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [RFC 02/15] vfs: Change all structures to support 64 bit time

2016-01-13 Thread Deepa Dinamani
On Tue, Jan 12, 2016 at 07:29:57PM +1100, Dave Chinner wrote:
> On Mon, Jan 11, 2016 at 09:42:36PM -0800, Deepa Dinamani wrote:
> > > On Jan 11, 2016, at 04:33, Dave Chinner <da...@fromorbit.com> wrote:
> > >
> > >> On Wed, Jan 06, 2016 at 09:35:59PM -0800, Deepa Dinamani wrote:

Summarizing, here are the open questions that need to be sorted before another
series:
1. What should be part of the series?
a. y2038 safe data types conversion.
b. range check and clamping
2. How to achieve a seamless transition?
Is inode_timespec solution agreed upon to achieve 1a?
An alternate approach is included in the cover letter.
3. policy for handling out of range timestamps:
There was no conclusion on this from the previous series as noted in the
cover letter.
I think this can be solved by figuring out the answer to question:
who should have a say in deciding the course of action if the timestamps
are out of range:

a. sysadmin through sysctl (Arnd's suggestion)
b. have default vfs handlers with an option for individual fs to 
override.
c. clamp and ignore
d. disable expired fs at compile time (Arnd's suggestion)


> The inode_timespec alias is part of the problem - AFAICT it exists
> because you need a representation that is independent of both the
> old and new in-memory structures.

Maybe you are misunderstanding the fact that only struct inode is changed
to have individual fields. Whereas, timespec64 is used everywhere else in
the series.
inode_timespec is an alias to transition timespec references to
timespec64 without breaking anything. This is needed because we
don't want to change all references to timespec in a single patch like
the cover letter says.
The same RFC Patch 2 has more details.

> The valid timestamp range stuff in the superblock is absolutely
> necessary, but that's something that can be done completely
> independently to the changes for supporting a differnet time storage
> format.

If I'm defining new functions to support new format, then I should at
least get the function signatures right before using them.
These can be in a different patch, but should be in the same patch series,
before they are used anywhere.
For instance,
struct timespec timespec_trunc(struct timespec t, unsigned gran);
should now take superblock as an argument instead of gran.

> And the fs changes cannot really be commented on until the VFs time
> representation is sorted out properly...

Each fs is changed twice in the current approach to transition everything to
timespec64. And, there are different ways of doing this.
For instance, Arnd had an idea different from mine as to how this can be done:
He was suggesting using something like these accessor macros and incorporating
timespec64 from the beginning in the individual filesystems rather than
inode_timespec.
Again, this is independent of how timestamps are stored in struct inode.
There are others that are independent of inode timestamp representation as well


> Besides, have you looked at the existing timestamp definitions? they
> use a struct timespec, which on a 64 bit system:
> 
> struct timespeci_atime;  /*8816 */
> struct timespeci_mtime;  /*   10416 */
> struct timespeci_ctime;  /*   12016 */
> 
> use 2 longs and are identical to a timespec64 in everything but
> name. These should just be changed to a timespec64, and we suck up
> the fact it increases the size of the 32 bit inode as we have to
> increase it's size to support time > y2038 anyway.
> 
> This is what I meant about premature optimisation - you've got a
> wonderfully complex solution to a problem that we don't need to
> solve to support timestamps >y2038. It's also why it goes down the
> wrong path at this point - most of the changes are not necessary if
> all we need to do is a simple timespec -> timespec64 type change and
> the addition timestamp range limiting in the existing truncation
> function...

The pahole output I pasted in the previous email(on the left) was for
timespec.

Yes, I do know that timespec64 is same as timespec on 64 bit systems:
#if __BITS_PER_LONG == 64
# define timespec64 timespec

I think it's been agreed upon now that inode timestamps will be changed
to use timespec64 as Arnd mentioned, if I do not hear any objections.
The whole purpose of this is to gather comments.

> > The problem really is that
> > there is more than one way of updating these attributes(timestamps in
> > this particular case). The side effect of this is that we don't always
> > call timespec_trunc() before assigning timestamps which can lead to
> > inconsistencies between on disk and in memory inode timestamps.
> 
&

Re: [Y2038] [RFC 02/15] vfs: Change all structures to support 64 bit time

2016-01-17 Thread Deepa Dinamani
Based on the discussion, here is how I propose to proceed:

1. Series for timestamp range check and clamping
2. Bug fixing patches like change all CURRENT_TIME use cases to 
current_fs_time()
3. Patches for vfs to use timespec64 internally (maybe a series, if 
required)
4. Patches that change all fs that use vfs APIs using timestamp arguments
(not a series)
5. Change individual fs to use timespec64 (not a series)
6. Change back whatever time conversion APIs left in vfs or individual fs 
(maybe a series, if required)

So, I don't see a need for submitting another series as all the changes now 
are handled on a case by case basis and no longer have a generic theme.

If everyone's in sync then I can proceed with the above plan.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC 02/15] vfs: Change all structures to support 64 bit time

2016-01-18 Thread Deepa Dinamani
On Mon, Jan 18, 2016 at 2:56 AM, Arnd Bergmann <a...@arndb.de> wrote:
> On Sunday 17 January 2016 22:09:26 Deepa Dinamani wrote:
>> Based on the discussion, here is how I propose to proceed:
>>
>> 1. Series for timestamp range check and clamping
>> 2. Bug fixing patches like change all CURRENT_TIME use cases to
>> current_fs_time()
>> 3. Patches for vfs to use timespec64 internally (maybe a series, if
>> required)
>> 4. Patches that change all fs that use vfs APIs using timestamp arguments
>> (not a series)
>> 5. Change individual fs to use timespec64 (not a series)
>> 6. Change back whatever time conversion APIs left in vfs or individual fs
>> (maybe a series, if required)
>>
>> So, I don't see a need for submitting another series as all the changes now
>> are handled on a case by case basis and no longer have a generic theme.
>>
>> If everyone's in sync then I can proceed with the above plan.
>
> Sounds good to me. Step 3 of course is the hard one, and you may run into
> further problems with it, as we both have in our previous attempts to
> crack this nut, but with step 2 before it that may become manageable.

Right, I don't agree with this approach and it will get very ugly.
I was just proposing a way to move forward because it looked like we are at
a stalemate.

Maybe xfs doesn't have these problems but some of the other fs-es do.
And, these will need changing twice: before(to use 64 bit arithmetic
like cifs, use current_fs_time() like fat etc) and along with vfs.

It will unnecessarily bloat the vfs switching to timespec64 code.
Below are 3 example filesystem changes that illustrates this problem:

Ext4:
1. cr_time
2. Encode and Decode api's

Both these ext4 changes need to made along with vfs change to ext4.
Many such fs exists and will make the vfs switch over very ugly.

FAT:
1. fat_time_fat2unix, fat_time_unix2fat

Both the above 2 functions also will have to be modified along with vfs.

CIFS:
1.  struct cifs_fscache_inode_auxdata - last_write_time, last_change_time
2.  cifs_fattr
3.  cifs_NTtimeToUnix, cifs_UnixTimeToNT, cnvrtDosUnixTm

All the above cifs changes also need to be changed in the same patch as
vfs switch to timespec64.

I don't think there is any nicer way to do this without having an
encapsulation layer like inode_timespec or accessors you mentioned to
change the underlying data type in the vfs.

Also, this scheme is so outrageously ugly that you can easily miss
some change.  There is no way of verifying the approach theoretically.
Of course, I will be using kernel tests like in other cases.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 17/24] fs: ocfs2: Replace CURRENT_TIME with ktime_get_real_seconds()

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.

Use y2038 safe ktime_get_real_seconds() here for timestamps.

struct heartbeat_block's hb_seq and deletetion time are already
64 bits wide and accommodate times beyond y2038.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Mark Fasheh <mfas...@suse.com>
Cc: Joel Becker <jl...@evilplan.org>
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/cluster/heartbeat.c | 2 +-
 fs/ocfs2/inode.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 636abcb..9158c98 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -741,7 +741,7 @@ static inline void o2hb_prepare_block(struct o2hb_region 
*reg,
hb_block = (struct o2hb_disk_heartbeat_block *)slot->ds_raw_block;
memset(hb_block, 0, reg->hr_block_bytes);
/* TODO: time stuff */
-   cputime = CURRENT_TIME.tv_sec;
+   cputime = ktime_get_real_seconds();
if (!cputime)
cputime = 1;
 
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index c56a767..382401d 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -703,7 +703,7 @@ static int ocfs2_remove_inode(struct inode *inode,
goto bail_commit;
}
 
-   di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec);
+   di->i_dtime = cpu_to_le64(ktime_get_real_seconds());
di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL));
ocfs2_journal_dirty(handle, di_bh);
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 19/24] fs: nfs: Make nfs boot time y2038 safe

2016-06-25 Thread Deepa Dinamani
boot_time is represented as a struct timespec.
struct timespec and CURRENT_TIME are not y2038 safe.
Overall, the plan is to use timespec64 and ktime_t for
all internal kernel representation of timestamps.
CURRENT_TIME will also be removed.

boot_time is used to construct the nfs client boot verifier.

Use ktime_t to represent boot_time and ktime_get_real() for
the boot_time value.

Following Trond's request https://lkml.org/lkml/2016/6/9/22 ,
use ktime_t instead of converting to struct timespec64.

Use higher and lower 32 bit parts of ktime_t for the boot
verifier.

Use the lower 32 bit part of ktime_t for the authsys_parms
stamp field.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Trond Myklebust <trond.mykleb...@primarydata.com>
Cc: Anna Schumaker <anna.schuma...@netapp.com>
Cc: linux-...@vger.kernel.org
---
 fs/nfs/client.c   |  2 +-
 fs/nfs/netns.h|  2 +-
 fs/nfs/nfs4proc.c | 10 ++
 fs/nfs/nfs4xdr.c  |  2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 4849d0f..92798bb 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1078,7 +1078,7 @@ void nfs_clients_init(struct net *net)
idr_init(>cb_ident_idr);
 #endif
spin_lock_init(>nfs_client_lock);
-   nn->boot_time = CURRENT_TIME;
+   nn->boot_time = ktime_get_real();
 }
 
 #ifdef CONFIG_PROC_FS
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index f0e06e4..fbce0d8 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -29,7 +29,7 @@ struct nfs_net {
int cb_users[NFS4_MAX_MINOR_VERSION + 1];
 #endif
spinlock_t nfs_client_lock;
-   struct timespec boot_time;
+   ktime_t boot_time;
 #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfsfs;
 #endif
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 406dd3e..8d9b5a9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5062,12 +5062,14 @@ static void nfs4_init_boot_verifier(const struct 
nfs_client *clp,
if (test_bit(NFS4CLNT_PURGE_STATE, >cl_state)) {
/* An impossible timestamp guarantees this value
 * will never match a generated boot time. */
-   verf[0] = 0;
-   verf[1] = cpu_to_be32(NSEC_PER_SEC + 1);
+   verf[0] = cpu_to_be32(U32_MAX);
+   verf[1] = cpu_to_be32(U32_MAX);
} else {
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
-   verf[0] = cpu_to_be32(nn->boot_time.tv_sec);
-   verf[1] = cpu_to_be32(nn->boot_time.tv_nsec);
+   u64 ns = ktime_to_ns(nn->boot_time);
+
+   verf[0] = cpu_to_be32(ns >> 32);
+   verf[1] = cpu_to_be32(ns);
}
memcpy(bootverf->data, verf, sizeof(bootverf->data));
 }
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 661e753..5944be0 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1850,7 +1850,7 @@ static void encode_create_session(struct xdr_stream *xdr,
*p++ = cpu_to_be32(RPC_AUTH_UNIX);  /* auth_sys */
 
/* authsys_parms rfc1831 */
-   *p++ = cpu_to_be32(nn->boot_time.tv_nsec);  /* stamp */
+   *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
*p++ = cpu_to_be32(0);  /* UID */
*p++ = cpu_to_be32(0);  /* GID */
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 22/24] fs: ceph: Replace current_fs_time for request stamp

2016-06-25 Thread Deepa Dinamani
The current_fs_time() api is being changed to use vfs
struct inode* as an argument instead of struct super_block*.

Set the new mds client request r_stamp field using
ktime_get_real_ts() instead of using current_fs_time().

Also, since r_stamp is used as mtime on the server, use
timespec_trunc() to truncate the timestamp, using the right
granularity from the superblock.

This api will be transitioned to be y2038 safe along
with vfs.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: "Yan, Zheng" <z...@redhat.com>
Cc: Sage Weil <s...@redhat.com>
Cc: Ilya Dryomov <idryo...@gmail.com>
Cc: ceph-de...@vger.kernel.org
---
 fs/ceph/mds_client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 2103b82..c6cae7a 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1697,6 +1697,7 @@ struct ceph_mds_request *
 ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
 {
struct ceph_mds_request *req = kzalloc(sizeof(*req), GFP_NOFS);
+   struct timespec ts;
 
if (!req)
return ERR_PTR(-ENOMEM);
@@ -1715,7 +1716,8 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, 
int op, int mode)
init_completion(>r_safe_completion);
INIT_LIST_HEAD(>r_unsafe_item);
 
-   req->r_stamp = current_fs_time(mdsc->fsc->sb);
+   ktime_get_real_ts();
+   req->r_stamp = timespec_trunc(ts, mdsc->fsc->sb->s_time_gran);
 
req->r_op = op;
req->r_direct_mode = mode;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 23/24] time: Delete current_fs_time() function

2016-06-25 Thread Deepa Dinamani
All uses of the current_fs_time() function have been
replaced by other time interfaces.

And, its use cases can be fulfilled by current_time()
or ktime_get_* variants.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: John Stultz <john.stu...@linaro.org>
Cc: Thomas Gleixner <t...@linutronix.de>
---
 include/linux/fs.h |  1 -
 kernel/time/time.c | 14 --
 2 files changed, 15 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index d0d9b38..5befa38 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1475,7 +1475,6 @@ struct super_block {
struct list_heads_inodes_wb;/* writeback inodes */
 };
 
-extern struct timespec current_fs_time(struct super_block *sb);
 extern struct timespec current_time(struct inode *inode);
 
 static inline struct timespec current_fs_time_sec(struct super_block *sb)
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 667b933..1ef0b4d 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -230,20 +230,6 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
return copy_to_user(txc_p, , sizeof(struct timex)) ? -EFAULT : ret;
 }
 
-/**
- * current_fs_time - Return FS time
- * @sb: Superblock.
- *
- * Return the current time truncated to the time granularity supported by
- * the fs.
- */
-struct timespec current_fs_time(struct super_block *sb)
-{
-   struct timespec now = current_kernel_time();
-   return timespec_trunc(now, sb->s_time_gran);
-}
-EXPORT_SYMBOL(current_fs_time);
-
 /*
  * Convert jiffies to milliseconds and back.
  *
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 15/24] drivers: staging: lustre: Replace CURRENT_TIME with current_time()

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_time() instead.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_time() will be
extended to do range checks. Hence, it is necessary for all
file system timestamps to use current_time().

Also change format string for prints so that these are valid
when vfs is transitioned to use 64 bit timestamps.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: lustre-de...@lists.lustre.org
Acked-by: James Simmons <jsimm...@infradead.org>
---
 drivers/staging/lustre/lustre/llite/llite_lib.c  | 16 
 drivers/staging/lustre/lustre/llite/namei.c  |  4 ++--
 drivers/staging/lustre/lustre/mdc/mdc_reint.c|  6 +++---
 .../staging/lustre/lustre/obdclass/linux/linux-obdo.c|  6 +++---
 drivers/staging/lustre/lustre/obdclass/obdo.c|  6 +++---
 drivers/staging/lustre/lustre/osc/osc_io.c   |  2 +-
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 546063e..71a5b25 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1201,23 +1201,23 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr 
*attr, bool hsm_import)
 
/* We mark all of the fields "set" so MDS/OST does not re-set them */
if (attr->ia_valid & ATTR_CTIME) {
-   attr->ia_ctime = CURRENT_TIME;
+   attr->ia_ctime = current_time(inode);
attr->ia_valid |= ATTR_CTIME_SET;
}
if (!(attr->ia_valid & ATTR_ATIME_SET) &&
(attr->ia_valid & ATTR_ATIME)) {
-   attr->ia_atime = CURRENT_TIME;
+   attr->ia_atime = current_time(inode);
attr->ia_valid |= ATTR_ATIME_SET;
}
if (!(attr->ia_valid & ATTR_MTIME_SET) &&
(attr->ia_valid & ATTR_MTIME)) {
-   attr->ia_mtime = CURRENT_TIME;
+   attr->ia_mtime = current_time(inode);
attr->ia_valid |= ATTR_MTIME_SET;
}
 
if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
-   CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %llu\n",
-  LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
+   CDEBUG(D_INODE, "setting mtime %llu, ctime %llu, now = %llu\n",
+  (long long)LTIME_S(attr->ia_mtime), (long 
long)LTIME_S(attr->ia_ctime),
   (s64)ktime_get_real_seconds());
 
/* We always do an MDS RPC, even if we're only changing the size;
@@ -1503,9 +1503,9 @@ void ll_update_inode(struct inode *inode, struct 
lustre_md *md)
}
if (body->valid & OBD_MD_FLMTIME) {
if (body->mtime > LTIME_S(inode->i_mtime)) {
-   CDEBUG(D_INODE, "setting ino %lu mtime from %lu to 
%llu\n",
-  inode->i_ino, LTIME_S(inode->i_mtime),
-  body->mtime);
+   CDEBUG(D_INODE, "setting ino %lu mtime from %llu to 
%llu\n",
+  inode->i_ino, (unsigned long 
long)LTIME_S(inode->i_mtime),
+  (unsigned long long)body->mtime);
LTIME_S(inode->i_mtime) = body->mtime;
}
lli->lli_mtime = body->mtime;
diff --git a/drivers/staging/lustre/lustre/llite/namei.c 
b/drivers/staging/lustre/lustre/llite/namei.c
index 3664bfd..2c823fe 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -725,8 +725,8 @@ static void ll_update_times(struct ptlrpc_request *request,
LASSERT(body);
if (body->valid & OBD_MD_FLMTIME &&
body->mtime > LTIME_S(inode->i_mtime)) {
-   CDEBUG(D_INODE, "setting fid "DFID" mtime from %lu to %llu\n",
-  PFID(ll_inode2fid(inode)), LTIME_S(inode->i_mtime),
+   CDEBUG(D_INODE, "setting fid "DFID" mtime from %llu to %llu\n",
+  PFID(ll_inode2fid(inode)), (unsigned long 
long)LTIME_S(inode->i_mtime),
   body->mtime);
LTIME_S(inode->i_mtime) = body->mtime;
}
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c 
b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
index 5dba2c8..f78819e 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c
+++

[Y2038] [PATCH v3 16/24] fs: ocfs2: Use time64_t to represent orphan scan times

2016-06-25 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Use time64_t which is y2038 safe to represent orphan
scan times.
time64_t is sufficient here as only the seconds delta
times are relevant.

Also use appropriate time functions that return time in
time64_t format. Time functions now return monotonic
time instead of real time as only delta scan times are
relevant and these values are not persistent across
reboots.

The format string for the debug print is still using long
as this is only the time elapsed since the last scan and
long is sufficient to represent this value.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Mark Fasheh <mfas...@suse.com>
Cc: Joel Becker <jl...@evilplan.org>
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/journal.c | 4 ++--
 fs/ocfs2/ocfs2.h   | 2 +-
 fs/ocfs2/super.c   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index bc0e21e..ab68933 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1949,7 +1949,7 @@ static void ocfs2_queue_orphan_scan(struct ocfs2_super 
*osb)
 */
seqno++;
os->os_count++;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
 unlock:
ocfs2_orphan_scan_unlock(osb, seqno);
 out:
@@ -2006,7 +2006,7 @@ void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
struct ocfs2_orphan_scan *os;
 
os = >osb_orphan_scan;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
atomic_set(>os_state, ORPHAN_SCAN_INACTIVE);
else {
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index e63af7d..7e5958b 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -224,7 +224,7 @@ struct ocfs2_orphan_scan {
struct ocfs2_super  *os_osb;
struct ocfs2_lock_res   os_lockres; /* lock to synchronize scans */
struct delayed_work os_orphan_scan_work;
-   struct timespec os_scantime;  /* time this node ran the scan */
+   time64_tos_scantime;  /* time this node ran the scan */
u32 os_count;  /* tracks node specific scans */
u32 os_seqno;   /* tracks cluster wide scans */
atomic_tos_state;  /* ACTIVE or INACTIVE */
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 3971146..6992c00 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -337,7 +337,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char 
*buf, int len)
out += snprintf(buf + out, len - out, "Disabled\n");
else
out += snprintf(buf + out, len - out, "%lu seconds ago\n",
-   (get_seconds() - os->os_scantime.tv_sec));
+   (unsigned long)(ktime_get_seconds() - 
os->os_scantime));
 
out += snprintf(buf + out, len - out, "%10s => %3s  %10s\n",
"Slots", "Num", "RecoGen");
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 18/24] audit: Use timespec64 to represent audit timestamps

2016-06-25 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Paul Moore <p...@paul-moore.com>
Cc: Eric Paris <epa...@redhat.com>
Cc: linux-au...@redhat.com
Acked-by: Paul Moore <p...@paul-moore.com>
Acked-by: Richard Guy Briggs <r...@redhat.com>
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c| 10 +-
 kernel/audit.h|  2 +-
 kernel/auditsc.c  |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 961a417..2f6a1123 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -335,7 +335,7 @@ static inline void audit_ptrace(struct task_struct *t)
/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial);
+ struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -510,7 +510,7 @@ static inline void __audit_seccomp(unsigned long syscall, 
long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial)
+ struct timespec64 *t, unsigned int *serial)
 {
return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index 22bb4f2..6c2f405 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1325,10 +1325,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-   *t = CURRENT_TIME;
+   ktime_get_real_ts64(t);
*serial = audit_serial();
}
 }
@@ -1370,7 +1370,7 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 int type)
 {
struct audit_buffer *ab = NULL;
-   struct timespec t;
+   struct timespec64   t;
unsigned intuninitialized_var(serial);
int reserve = 5; /* Allow atomic callers to go up to five
entries over the normal backlog limit */
@@ -1422,8 +1422,8 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 
audit_get_stamp(ab->ctx, , );
 
-   audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-t.tv_sec, t.tv_nsec/100, serial);
+   audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+(unsigned long long)t.tv_sec, t.tv_nsec/100, 
serial);
return ab;
 }
 
diff --git a/kernel/audit.h b/kernel/audit.h
index cbbe6bb..029d674 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -111,7 +111,7 @@ struct audit_context {
enum audit_statestate, current_state;
unsigned intserial; /* serial number for record */
int major;  /* syscall number */
-   struct timespec ctime;  /* time of syscall entry */
+   struct timespec64   ctime;  /* time of syscall entry */
unsigned long   argv[4];/* syscall arguments */
longreturn_code;/* syscall return code */
u64 prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index fb1a3df..591c726 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1527,7 +1527,7 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
return;
 
context->serial = 0;
-   context->ctime  = CURRENT_TIME;
+   ktime_get_real_ts64(>ctime);
context->in_syscall = 1;
context->current_state  = state;
context->ppid   = 0;
@@ -1936,13 +1936,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned

[Y2038] [PATCH v3 20/24] block: Replace CURRENT_TIME with ktime_get_real_ts

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.
The macro will be deleted and all the references to it
will be replaced by ktime_get_* apis.

struct timespec is also not y2038 safe.
Retain timespec for timestamp representation here as ceph
uses it internally everywhere.
These references will be changed to use struct timespec64
in a separate patch.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Ilya Dryomov <idryo...@gmail.com>
Cc: Sage Weil <s...@redhat.com>
Cc: Alex Elder <el...@kernel.org>
Cc: ceph-de...@vger.kernel.org
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 4506620..14867ab 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1888,7 +1888,7 @@ static void rbd_osd_req_format_write(struct 
rbd_obj_request *obj_request)
 {
struct ceph_osd_request *osd_req = obj_request->osd_req;
 
-   osd_req->r_mtime = CURRENT_TIME;
+   ktime_get_real_ts(_req->r_mtime);
osd_req->r_data_offset = obj_request->offset;
 }
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 24/24] time: Delete CURRENT_TIME_SEC

2016-06-25 Thread Deepa Dinamani
All uses of CURRENT_TIME_SEC macro have been replaced by
other time functions.  This macro is also not y2038 safe.
And, all its use cases can be fulfilled by y2038 safe
ktime_get_* variants.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: John Stultz <john.stu...@linaro.org>
Cc: Thomas Gleixner <t...@linutronix.de>
Acked-by: John Stultz <john.stu...@linaro.org>
---
 include/linux/time.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/time.h b/include/linux/time.h
index 4cea09d..9c3f345 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -152,7 +152,6 @@ static inline bool timespec_inject_offset_valid(const 
struct timespec *ts)
 }
 
 #define CURRENT_TIME   (current_kernel_time())
-#define CURRENT_TIME_SEC   ((struct timespec) { get_seconds(), 0 })
 
 /* Some architectures do not supply their own clocksource.
  * This is mainly the case in architectures that get their
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 06/24] fs: jfs: Replace CURRENT_TIME_SEC by current_time()

2016-06-25 Thread Deepa Dinamani
jfs uses nanosecond granularity for filesystem timestamps.
Only this assignment is not using nanosecond granularity.
Use current_time() to get the right granularity.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Dave Kleikamp <sha...@kernel.org>
Cc: jfs-discuss...@lists.sourceforge.net
Acked-by: Dave Kleikamp <dave.kleik...@oracle.com>
---
 fs/jfs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index 8653cac..b6fd1ff 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -121,7 +121,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, 
unsigned long arg)
 
jfs_set_inode_flags(inode);
inode_unlock(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
 setflags_out:
mnt_drop_write_file(filp);
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 01/24] vfs: Add current_time() api

2016-06-25 Thread Deepa Dinamani
current_fs_time() is used for inode timestamps.

Change the signature of the function to take inode pointer
instead of superblock as per Linus's suggestion.

Also, move the api under vfs as per the discussion on the
thread: https://lkml.org/lkml/2016/6/9/36 . As per Arnd's
suggestion on the thread, changing the function name.

current_fs_time() will be deleted after all the references
to it are replaced by current_time().

There was a bug reported by kbuild test bot with the change
as some of the calls to current_time() were made before the
super_block was initialized. Catch these accidental assignments
as timespec_trunc() does for wrong granularities. This allows
for the function to work right even in these circumstances.
But, adds a warning to make the user aware of the bug.

A coccinelle script was used to identify all the current
.alloc_inode super_block callbacks that updated inode timestamps.
proc filesystem was the only one that was modifying inode times
as part of this callback. The series includes a patch to fix that.

Note that timespec_trunc() will also be moved to fs/inode.c
in a separate patch when this will need to be revamped for
bounds checking purposes.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/inode.c | 23 +++
 include/linux/fs.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/fs/inode.c b/fs/inode.c
index e171f7b..80b6898 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2043,3 +2043,26 @@ void inode_nohighmem(struct inode *inode)
mapping_set_gfp_mask(inode->i_mapping, GFP_USER);
 }
 EXPORT_SYMBOL(inode_nohighmem);
+
+/**
+ * current_time - Return FS time
+ * @inode: inode.
+ *
+ * Return the current time truncated to the time granularity supported by
+ * the fs.
+ *
+ * Note that inode and inode->sb cannot be NULL.
+ * Otherwise, the function warns and returns time without truncation.
+ */
+struct timespec current_time(struct inode *inode)
+{
+   struct timespec now = current_kernel_time();
+
+   if (unlikely(!inode->i_sb)) {
+   WARN(1, "current_time() called with uninitialized super_block 
in the inode");
+   return now;
+   }
+
+   return timespec_trunc(now, inode->i_sb->s_time_gran);
+}
+EXPORT_SYMBOL(current_time);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c4ab2cf..d0d9b38 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1476,6 +1476,7 @@ struct super_block {
 };
 
 extern struct timespec current_fs_time(struct super_block *sb);
+extern struct timespec current_time(struct inode *inode);
 
 static inline struct timespec current_fs_time_sec(struct super_block *sb)
 {
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 04/24] fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe. current_time() will
be transitioned to use 64 bit time along with vfs in a
separate patch.
There is no plan to transistion CURRENT_TIME_SEC to use
y2038 safe time interfaces.

current_time() will also be extended to use superblock
range checking parameters when range checking is introduced.

This works because alloc_super() fills in the the s_time_gran
in super block to NSEC_PER_SEC.

Also note that filesystem specific times like the birthtime,
creation time that were using same interfaces to obtain time
retain same logistics.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Acked-by: Jan Kara <j...@suse.cz>
---
 fs/affs/amigaffs.c  |  6 +++---
 fs/affs/inode.c |  2 +-
 fs/bfs/dir.c| 14 +++---
 fs/coda/dir.c   |  2 +-
 fs/coda/file.c  |  2 +-
 fs/coda/inode.c |  2 +-
 fs/ext2/acl.c   |  2 +-
 fs/ext2/dir.c   |  6 +++---
 fs/ext2/ialloc.c|  2 +-
 fs/ext2/inode.c |  4 ++--
 fs/ext2/ioctl.c |  4 ++--
 fs/ext2/namei.c |  6 +++---
 fs/ext2/xattr.c |  2 +-
 fs/fat/dir.c|  2 +-
 fs/fat/file.c   |  4 ++--
 fs/fat/inode.c  |  2 +-
 fs/fat/namei_msdos.c| 12 ++--
 fs/fat/namei_vfat.c | 10 +-
 fs/hfs/catalog.c|  8 
 fs/hfs/dir.c|  2 +-
 fs/hfs/inode.c  |  2 +-
 fs/hfsplus/catalog.c|  8 
 fs/hfsplus/dir.c|  6 +++---
 fs/hfsplus/inode.c  |  2 +-
 fs/hfsplus/ioctl.c  |  2 +-
 fs/jffs2/acl.c  |  2 +-
 fs/jffs2/fs.c   |  2 +-
 fs/minix/bitmap.c   |  2 +-
 fs/minix/dir.c  |  6 +++---
 fs/minix/itree_common.c |  4 ++--
 fs/minix/namei.c|  4 ++--
 fs/omfs/dir.c   |  4 ++--
 fs/reiserfs/inode.c |  2 +-
 fs/reiserfs/ioctl.c |  4 ++--
 fs/reiserfs/namei.c | 12 ++--
 fs/reiserfs/stree.c |  8 
 fs/reiserfs/xattr.c |  2 +-
 fs/reiserfs/xattr_acl.c |  2 +-
 fs/sysv/dir.c   |  6 +++---
 fs/sysv/ialloc.c|  2 +-
 fs/sysv/itree.c |  4 ++--
 fs/sysv/namei.c |  4 ++--
 fs/ufs/dir.c|  6 +++---
 fs/ufs/ialloc.c |  2 +-
 fs/ufs/inode.c  |  6 +++---
 fs/ufs/namei.c  |  6 +++---
 46 files changed, 102 insertions(+), 102 deletions(-)

diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index d6c7a51..a9004a0 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -58,7 +58,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh)
mark_buffer_dirty_inode(dir_bh, dir);
affs_brelse(dir_bh);
 
-   dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
+   dir->i_mtime = dir->i_ctime = current_time(dir);
dir->i_version++;
mark_inode_dirty(dir);
 
@@ -112,7 +112,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head 
*rem_bh)
 
affs_brelse(bh);
 
-   dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
+   dir->i_mtime = dir->i_ctime = current_time(dir);
dir->i_version++;
mark_inode_dirty(dir);
 
@@ -313,7 +313,7 @@ affs_remove_header(struct dentry *dentry)
else
clear_nlink(inode);
affs_unlock_link(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
 
 done:
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 0fdb0f5..ed120ec 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -309,7 +309,7 @@ affs_new_inode(struct inode *dir)
inode->i_gid = current_fsgid();
inode->i_ino = block;
set_nlink(inode, 1);
-   inode->i_mtime   = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_mtime   = inode->i_atime = inode->i_ctime = 
current_time(inode);
atomic_set(_I(inode)->i_opencnt, 0);
AFFS_I(inode)->i_blkcnt = 0;
AFFS_I(inode)->i_lc = NULL;
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 34a5bc2..4206419 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -97,7 +97,7 @@ static int bfs_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
set_bit(ino, info->si_imap);
info->si_freei--;
inode_init_owner(inode, dir, mode);
-   inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
inode->i_blocks = 0;
inode->i_op = _file_inops;
inode->i_fop = _file_operations;
@@ -165,7 +165,7 @@ static int bfs_link(struct dentry *old, struct inode *dir,
return err;
}
inc_nlink(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
ihold(inode);
d_instantiate(new, inode);
@@ -194,7 +194,7 @@ static int bfs_unlink(struct 

[Y2038] [PATCH v3 10/24] fs: udf: Replace CURRENT_TIME with current_time()

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.

CURRENT_TIME macro is also not appropriate for filesystems
as it doesn't use the right granularity for filesystem
timestamps.

Logical Volume Integrity format is described to have the
same timestamp format for "Recording Date and time" as
the other [a,c,m]timestamps.
The function udf_time_to_disk_format() does this conversion.
Hence the timestamp is passed directly to the function and
not truncated. This is as per Arnd's suggestion on the
thread.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_time() will be
extended to do range checks.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Jan Kara <j...@suse.com>
Reviewed-by: Jan Kara <j...@suse.cz>
---
 fs/udf/super.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4942549..967ad87 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1986,6 +1986,7 @@ static void udf_open_lvid(struct super_block *sb)
struct buffer_head *bh = sbi->s_lvid_bh;
struct logicalVolIntegrityDesc *lvid;
struct logicalVolIntegrityDescImpUse *lvidiu;
+   struct timespec ts;
 
if (!bh)
return;
@@ -1997,8 +1998,8 @@ static void udf_open_lvid(struct super_block *sb)
mutex_lock(>s_alloc_mutex);
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
-   udf_time_to_disk_stamp(>recordingDateAndTime,
-   CURRENT_TIME);
+   ktime_get_real_ts();
+   udf_time_to_disk_stamp(>recordingDateAndTime, ts);
lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
 
lvid->descTag.descCRC = cpu_to_le16(
@@ -2019,6 +2020,7 @@ static void udf_close_lvid(struct super_block *sb)
struct buffer_head *bh = sbi->s_lvid_bh;
struct logicalVolIntegrityDesc *lvid;
struct logicalVolIntegrityDescImpUse *lvidiu;
+   struct timespec ts;
 
if (!bh)
return;
@@ -2030,7 +2032,8 @@ static void udf_close_lvid(struct super_block *sb)
mutex_lock(>s_alloc_mutex);
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
-   udf_time_to_disk_stamp(>recordingDateAndTime, CURRENT_TIME);
+   ktime_get_real_ts();
+   udf_time_to_disk_stamp(>recordingDateAndTime, ts);
if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev))
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 08/24] fs: ubifs: Replace CURRENT_TIME_SEC with current_time

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe. current_time() will
be transitioned to use 64 bit time along with vfs in a
separate patch.
There is no plan to transition CURRENT_TIME_SEC to use
y2038 safe time interfaces.

current_time() returns timestamps according to the
granularities set in the inode's super_block.
The granularity check to call current_fs_time() or
CURRENT_TIME_SEC is not required.

Use current_time() directly to update inode timestamp.
Use timespec_trunc during file system creation, before
the first inode is created.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Artem Bityutskiy <dedeki...@gmail.com>
Cc: Adrian Hunter <adrian.hun...@intel.com>
Cc: linux-...@lists.infradead.org
---
 fs/ubifs/dir.c   | 10 +-
 fs/ubifs/file.c  | 12 ++--
 fs/ubifs/ioctl.c |  2 +-
 fs/ubifs/misc.h  | 10 --
 fs/ubifs/sb.c| 14 ++
 fs/ubifs/xattr.c |  6 +++---
 6 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 4b86d3a..6e2dff9 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -106,7 +106,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const 
struct inode *dir,
 
inode_init_owner(inode, dir, mode);
inode->i_mtime = inode->i_atime = inode->i_ctime =
-ubifs_current_time(inode);
+current_time(inode);
inode->i_mapping->nrpages = 0;
 
switch (mode & S_IFMT) {
@@ -529,7 +529,7 @@ static int ubifs_link(struct dentry *old_dentry, struct 
inode *dir,
lock_2_inodes(dir, inode);
inc_nlink(inode);
ihold(inode);
-   inode->i_ctime = ubifs_current_time(inode);
+   inode->i_ctime = current_time(inode);
dir->i_size += sz_change;
dir_ui->ui_size = dir->i_size;
dir->i_mtime = dir->i_ctime = inode->i_ctime;
@@ -586,7 +586,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry 
*dentry)
}
 
lock_2_inodes(dir, inode);
-   inode->i_ctime = ubifs_current_time(dir);
+   inode->i_ctime = current_time(dir);
drop_nlink(inode);
dir->i_size -= sz_change;
dir_ui->ui_size = dir->i_size;
@@ -675,7 +675,7 @@ static int ubifs_rmdir(struct inode *dir, struct dentry 
*dentry)
}
 
lock_2_inodes(dir, inode);
-   inode->i_ctime = ubifs_current_time(dir);
+   inode->i_ctime = current_time(dir);
clear_nlink(inode);
drop_nlink(dir);
dir->i_size -= sz_change;
@@ -1023,7 +1023,7 @@ static int ubifs_rename(struct inode *old_dir, struct 
dentry *old_dentry,
 * Like most other Unix systems, set the @i_ctime for inodes on a
 * rename.
 */
-   time = ubifs_current_time(old_dir);
+   time = current_time(old_dir);
old_inode->i_ctime = time;
 
/* We must adjust parent link count when renaming directories */
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 7bbf420..45e3d71 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1182,7 +1182,7 @@ static int do_truncation(struct ubifs_info *c, struct 
inode *inode,
mutex_lock(>ui_mutex);
ui->ui_size = inode->i_size;
/* Truncation changes inode [mc]time */
-   inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
/* Other attributes may be changed at the same time as well */
do_attr_changes(inode, attr);
err = ubifs_jnl_truncate(c, inode, old_size, new_size);
@@ -1229,7 +1229,7 @@ static int do_setattr(struct ubifs_info *c, struct inode 
*inode,
mutex_lock(>ui_mutex);
if (attr->ia_valid & ATTR_SIZE) {
/* Truncation changes inode [mc]time */
-   inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
/* 'truncate_setsize()' changed @i_size, update @ui_size */
ui->ui_size = inode->i_size;
}
@@ -1406,7 +1406,7 @@ int ubifs_update_time(struct inode *inode, struct 
timespec *time,
  */
 static int update_mctime(struct inode *inode)
 {
-   struct timespec now = ubifs_current_time(inode);
+   struct timespec now = current_time(inode);
struct ubifs_inode *ui = ubifs_inode(inode);
struct ubifs_info *c = inode->i_sb->s_fs_info;
 
@@ -1420,7 +1420,7 @@ static int update_mctime(struct inode *inode)
return err;
 
mutex_lock(>ui_mutex);
-   inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
release = ui->dirty;
mark_inode_dirty_sync(inode);
mutex_unlock(>ui_mutex);
@@ -1498,7 +1498,7 @@ static 

[Y2038] [PATCH v3 07/24] fs: ext4: Use current_time() for inode timestamps

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME_SEC and CURRENT_TIME are not y2038 safe.
current_time() will be transitioned to be y2038 safe
along with vfs.

current_time() returns timestamps according to the
granularities set in the super_block.
The granularity check in ext4_current_time() to call
current_time() or CURRENT_TIME_SEC is not required.
Use current_time() directly to obtain timestamps
unconditionally, and remove ext4_current_time().

Quota files are assumed to be on the same filesystem.
Hence, use current_time() for these files as well.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: "Theodore Ts'o" <ty...@mit.edu>
Cc: Andreas Dilger <adilger.ker...@dilger.ca>
Cc: linux-e...@vger.kernel.org
---
 fs/ext4/acl.c |  2 +-
 fs/ext4/ext4.h|  6 --
 fs/ext4/extents.c | 10 +-
 fs/ext4/ialloc.c  |  2 +-
 fs/ext4/inline.c  |  4 ++--
 fs/ext4/inode.c   |  6 +++---
 fs/ext4/ioctl.c   |  8 
 fs/ext4/namei.c   | 24 +---
 fs/ext4/xattr.c   |  2 +-
 9 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index c6601a4..733e2f24 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -197,7 +197,7 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int 
type,
if (error < 0)
return error;
else {
-   inode->i_ctime = ext4_current_time(inode);
+   inode->i_ctime = current_time(inode);
ext4_mark_inode_dirty(handle, inode);
if (error == 0)
acl = NULL;
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b84aa1c..14e5cf4 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1523,12 +1523,6 @@ static inline struct ext4_inode_info *EXT4_I(struct 
inode *inode)
return container_of(inode, struct ext4_inode_info, vfs_inode);
 }
 
-static inline struct timespec ext4_current_time(struct inode *inode)
-{
-   return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
-   current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
-}
-
 static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
 {
return ino == EXT4_ROOT_INO ||
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 2a2eef9..2584317 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4722,7 +4722,7 @@ retry:
map.m_lblk += ret;
map.m_len = len = len - ret;
epos = (loff_t)map.m_lblk << inode->i_blkbits;
-   inode->i_ctime = ext4_current_time(inode);
+   inode->i_ctime = current_time(inode);
if (new_size) {
if (epos > new_size)
epos = new_size;
@@ -4850,7 +4850,7 @@ static long ext4_zero_range(struct file *file, loff_t 
offset,
}
/* Now release the pages and zero block aligned part of pages */
truncate_pagecache_range(inode, start, end - 1);
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
 
ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
 flags, mode);
@@ -4875,7 +4875,7 @@ static long ext4_zero_range(struct file *file, loff_t 
offset,
goto out_dio;
}
 
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
if (new_size) {
ext4_update_inode_size(inode, new_size);
} else {
@@ -5574,7 +5574,7 @@ int ext4_collapse_range(struct inode *inode, loff_t 
offset, loff_t len)
up_write(_I(inode)->i_data_sem);
if (IS_SYNC(inode))
ext4_handle_sync(handle);
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
ext4_mark_inode_dirty(handle, inode);
 
 out_stop:
@@ -5684,7 +5684,7 @@ int ext4_insert_range(struct inode *inode, loff_t offset, 
loff_t len)
/* Expand file to avoid data loss if there is error while shifting */
inode->i_size += len;
EXT4_I(inode)->i_disksize += len;
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
ret = ext4_mark_inode_dirty(handle, inode);
if (ret)
goto out_stop;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 1e4b0b7..8b3d58f 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1039,7 +1039,7 @@ got:
/* This is the optimal IO size (for stat), not the fs block size */
inode->i_blocks = 0;
inode->i_mtime

[Y2038] [PATCH v3 09/24] fs: btrfs: Use ktime_get_real_ts for root ctime

2016-06-25 Thread Deepa Dinamani
btrfs_root_item maintains the ctime for root updates.
This is not part of vfs_inode.

Since current_time() uses struct inode* as an argument
as Linus suggested, this cannot be used to update root
times unless, we modify the signature to use inode.

Since btrfs uses nanosecond time granularity, it can also
use ktime_get_real_ts directly to obtain timestamp for
the root. It is necessary to use the timespec time api
here because the same btrfs_set_stack_timespec_*() apis
are used for vfs inode times as well. These can be
transitioned to using timespec64 when btrfs internally
changes to use timespec64 as well.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Chris Mason <c...@fb.com>
Cc: Josef Bacik <jba...@fb.com>
Cc: David Sterba <dste...@suse.com>
Cc: linux-bt...@vger.kernel.org
Acked-by: David Sterba <dste...@suse.com>
---
 fs/btrfs/root-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index f1c3086..161118b 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -496,10 +496,11 @@ void btrfs_update_root_times(struct btrfs_trans_handle 
*trans,
 struct btrfs_root *root)
 {
struct btrfs_root_item *item = >root_item;
-   struct timespec ct = current_fs_time(root->fs_info->sb);
+   struct timespec ct;
 
spin_lock(>root_item_lock);
btrfs_set_root_ctransid(item, trans->transid);
+   ktime_get_real_ts();
btrfs_set_stack_timespec_sec(>ctime, ct.tv_sec);
btrfs_set_stack_timespec_nsec(>ctime, ct.tv_nsec);
spin_unlock(>root_item_lock);
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH v2 07/24] fs: ubifs: Replace CURRENT_TIME_SEC with current_time

2016-06-24 Thread Deepa Dinamani
>> @@ -84,6 +84,8 @@ static int create_default_filesystem(struct ubifs_info *c)
>> int min_leb_cnt = UBIFS_MIN_LEB_CNT;
>> long long tmp64, main_bytes;
>> __le64 tmp_le64;
>> +   __le32 tmp_le32;
>> +   struct timespec ts;
>>
>> /* Some functions called from here depend on the @c->key_len filed */
>> c->key_len = UBIFS_SK_LEN;
>> @@ -297,13 +299,17 @@ static int create_default_filesystem(struct ubifs_info 
>> *c)
>> ino->ch.node_type = UBIFS_INO_NODE;
>> ino->creat_sqnum = cpu_to_le64(++c->max_sqnum);
>> ino->nlink = cpu_to_le32(2);
>> -   tmp_le64 = cpu_to_le64(CURRENT_TIME_SEC.tv_sec);
>> +
>> +   ktime_get_real_ts();
>> +   ts = timespec_trunc(ts, DEFAULT_TIME_GRAN);
>> +   tmp_le64 = cpu_to_le64(ts.tv_sec);
>> ino->atime_sec   = tmp_le64;
>> ino->ctime_sec   = tmp_le64;
>> ino->mtime_sec   = tmp_le64;
>> -   ino->atime_nsec  = 0;
>> -   ino->ctime_nsec  = 0;
>> -   ino->mtime_nsec  = 0;
>> +   tmp_le32 = cpu_to_le32(ts.tv_nsec);
>> +   ino->atime_nsec  = tmp_le32;
>> +   ino->ctime_nsec  = tmp_le32;
>> +   ino->mtime_nsec  = tmp_le32;
>
> This part of the patch seems independent of the rest, as you don't actually
> use current_time() here, or assign the timespec to an inode.
>
> I'd suggest either leaving this part out of the patch series for now,
> or making it a separate patch that uses timespec64 directly.

This is actually the root inode which is created and written to disk.
We actually want to use current_time() here, but this is not cached.
So we don't have a vfs inode.

struct ubifs_ino_node represents inode format on the disk.
I thought it would be odd to fill this with timespec64 only here.
My plan was to switch it over to timespec64 when all of ubifs changes
to use timespec64.
This also was helping the current series as it let me delete
CURRENT_TIME macros.
I can add a comment to suggest this in code.

But, what you suggest should also work fine since the on disk
representation is big enough to use timespec64 already.
Let me know if you want me to drop this change for now as we delete
CURRENT_TIME macros after rc1 now.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH v2 06/24] fs: ext4: Use current_time() for inode timestamps

2016-06-24 Thread Deepa Dinamani
>> @@ -3727,6 +3727,7 @@ static int ext4_cross_rename(struct inode *old_dir, 
>> struct dentry *old_dentry,
>> };
>> u8 new_file_type;
>> int retval;
>> +   struct timespec ctime;
>>
>> if ((ext4_encrypted_inode(old_dir) ||
>>  ext4_encrypted_inode(new_dir)) &&
>> @@ -3829,8 +3830,9 @@ static int ext4_cross_rename(struct inode *old_dir, 
>> struct dentry *old_dentry,
>>  * Like most other Unix systems, set the ctime for inodes on a
>>  * rename.
>>  */
>> -   old.inode->i_ctime = ext4_current_time(old.inode);
>> -   new.inode->i_ctime = ext4_current_time(new.inode);
>> +   ctime = current_time(old.inode);
>> +   old.inode->i_ctime = ctime;
>> +   new.inode->i_ctime = ctime;
>> ext4_mark_inode_dirty(handle, old.inode);
>> ext4_mark_inode_dirty(handle, new.inode);
>>
>
> Adding a local variable here looks like it is going to cause us trouble when 
> we
> change the return type of current_time() to timespec64.
>
> I'd write this as
>
> new.inode->i_ctime = old.inode->i_ctime;
>
> instead.

This should be fine.
There are already instances that use local timespecs for inode time assignments.

These can be changed this way:

+   ctime = vfs_time_to_timespec(current_time(old.inode));
+   old.inode->i_ctime = timespec_to_vfs_time(ctime);
+   new.inode->i_ctime = timespec_to_vfs_time(ctime);

This could be a little inefficient, but only temporary.
The local variable can be changed to timespec64 when the macros are deleted.

I'm trying to make minimal changes.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v2 10/10] fs: btrfs: Replace CURRENT_TIME by current_fs_time()

2016-02-06 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_fs_time() instead.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Chris Mason <c...@fb.com>
Cc: Josef Bacik <jba...@fb.com>
Cc: David Sterba <dste...@suse.com>
Cc: linux-bt...@vger.kernel.org
---
changes since v1:
btrfs_update_root_times uses root->fs_info instead of
root->ino_cache_inode to obtain struct super_block pointer
from struct btrfs_root.

The issue that was reported by the kernel tester was that
a null pointer dereference occurred. This is because the
inode cache is disabled by default and this inode pointer
was null.

Inode cache inode pointer should not be used to access super
block information.

 fs/btrfs/file.c|  4 ++--
 fs/btrfs/inode.c   | 25 +
 fs/btrfs/ioctl.c   |  8 
 fs/btrfs/root-tree.c   |  2 +-
 fs/btrfs/transaction.c |  7 +--
 fs/btrfs/xattr.c   |  2 +-
 6 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 098bb8f..610f569 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2544,7 +2544,7 @@ out_trans:
goto out_free;
 
inode_inc_iversion(inode);
-   inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
 
trans->block_rsv = >fs_info->trans_block_rsv;
ret = btrfs_update_inode(trans, root, inode);
@@ -2794,7 +2794,7 @@ static long btrfs_fallocate(struct file *file, int mode,
if (IS_ERR(trans)) {
ret = PTR_ERR(trans);
} else {
-   inode->i_ctime = CURRENT_TIME;
+   inode->i_ctime = current_fs_time(inode->i_sb);
i_size_write(inode, actual_end);
btrfs_ordered_update_i_size(inode, actual_end, NULL);
ret = btrfs_update_inode(trans, root, inode);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e28f3d4..59c0e22 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4013,7 +4013,8 @@ err:
btrfs_i_size_write(dir, dir->i_size - name_len * 2);
inode_inc_iversion(inode);
inode_inc_iversion(dir);
-   inode->i_ctime = dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+   inode->i_ctime = dir->i_mtime =
+   dir->i_ctime = current_fs_time(inode->i_sb);
ret = btrfs_update_inode(trans, root, dir);
 out:
return ret;
@@ -4156,7 +4157,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
 
btrfs_i_size_write(dir, dir->i_size - name_len * 2);
inode_inc_iversion(dir);
-   dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+   dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
ret = btrfs_update_inode_fallback(trans, root, dir);
if (ret)
btrfs_abort_transaction(trans, root, ret);
@@ -5588,7 +5589,7 @@ static struct inode *new_simple_dir(struct super_block *s,
inode->i_op = _dir_ro_inode_operations;
inode->i_fop = _dir_operations;
inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
-   inode->i_mtime = CURRENT_TIME;
+   inode->i_mtime = current_fs_time(inode->i_sb);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
BTRFS_I(inode)->i_otime = inode->i_mtime;
@@ -6160,7 +6161,7 @@ static struct inode *btrfs_new_inode(struct 
btrfs_trans_handle *trans,
inode_init_owner(inode, dir, mode);
inode_set_bytes(inode, 0);
 
-   inode->i_mtime = CURRENT_TIME;
+   inode->i_mtime = current_fs_time(inode->i_sb);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
BTRFS_I(inode)->i_otime = inode->i_mtime;
@@ -6273,7 +6274,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
btrfs_i_size_write(parent_inode, parent_inode->i_size +
   name_len * 2);
inode_inc_iversion(parent_inode);
-   parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME;
+   parent_inode->i_mtime = parent_inode->i_ctime =
+   current_fs_time(parent_inode->i_sb);
ret = btrfs_update_inode(trans, root, parent_inode);
if (ret)
btrfs_abort_transaction(trans, root, ret);
@@ -6491,7 +6493,7 @@ static int btrfs_link(struct dentry *old_dentry, struct 
inode *dir,
BTRFS_I(inode)->dir_index = 0ULL;
inc_nlink(inode);
inode_inc_iversion(inode);
-   inode->i_ctime = CURRENT_TIME;
+   inode->i_ctime = current_fs_time(inode->i_sb);
ihold(inode);
set_bit(BTRFS_INODE_C

[Y2038] [RFC v2a 11/12] net: ceph: use vfs_time data type instead of timespec

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use vfs_time aliases here to access inode times.

These timestamps are passed in as arguments to functions
using inode timestamps. Hence, these need to change along
with vfs to support 64 bit timestamps. vfs_time helps do
this transition.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/ceph/messenger.h  | 1 +
 include/linux/ceph/osd_client.h | 4 ++--
 net/ceph/osd_client.c   | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index afe886b..28bba12 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 7506b48..2b6f08b 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -322,7 +322,7 @@ extern struct ceph_osd_request 
*ceph_osdc_alloc_request(struct ceph_osd_client *
 extern void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off,
struct ceph_snap_context *snapc,
u64 snap_id,
-   struct timespec *mtime);
+   struct vfs_time *mtime);
 
 extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
  struct ceph_file_layout *layout,
@@ -364,7 +364,7 @@ extern int ceph_osdc_writepages(struct ceph_osd_client 
*osdc,
struct ceph_snap_context *sc,
u64 off, u64 len,
u32 truncate_seq, u64 truncate_size,
-   struct timespec *mtime,
+   struct vfs_time *mtime,
struct page **pages, int nr_pages);
 
 /* watch/notify events */
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index f8f2359..1273db6 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2401,7 +2401,7 @@ bad:
  */
 void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off,
struct ceph_snap_context *snapc, u64 snap_id,
-   struct timespec *mtime)
+   struct vfs_time *mtime)
 {
struct ceph_msg *msg = req->r_request;
void *p;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2a 10/12] fs: ceph: Replace timespec data type with vfs_time

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use vfs_time aliases here to access inode times.

Use vfs_time data type for accessing inode timestamps.
This is necessary as these accesses need to switch to
using 64 bit timestamps along with vfs.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/ceph/cache.c  |  2 +-
 fs/ceph/caps.c   |  6 +++---
 fs/ceph/dir.c|  4 ++--
 fs/ceph/file.c   |  6 +++---
 fs/ceph/inode.c  | 32 
 fs/ceph/mds_client.c |  2 +-
 fs/ceph/mds_client.h |  2 +-
 fs/ceph/super.h  |  8 
 fs/ceph/xattr.c  |  2 +-
 9 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/fs/ceph/cache.c b/fs/ceph/cache.c
index a351480..4b5b2da 100644
--- a/fs/ceph/cache.c
+++ b/fs/ceph/cache.c
@@ -25,7 +25,7 @@
 #include "cache.h"
 
 struct ceph_aux_inode {
-   struct timespec mtime;
+   struct vfs_time mtime;
loff_t  size;
 };
 
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index cdbf8cf..f407819 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -990,7 +990,7 @@ static int send_cap_msg(struct ceph_mds_session *session,
int caps, int wanted, int dirty,
u32 seq, u64 flush_tid, u64 oldest_flush_tid,
u32 issue_seq, u32 mseq, u64 size, u64 max_size,
-   struct timespec *mtime, struct timespec *atime,
+   struct vfs_time *mtime, struct vfs_time *atime,
u64 time_warp_seq,
kuid_t uid, kgid_t gid, umode_t mode,
u64 xattr_version,
@@ -1116,7 +1116,7 @@ static int __send_cap(struct ceph_mds_client *mdsc, 
struct ceph_cap *cap,
int held, revoking, dropping, keep;
u64 seq, issue_seq, mseq, time_warp_seq, follows;
u64 size, max_size;
-   struct timespec mtime, atime;
+   struct vfs_time mtime, atime;
int wake = 0;
umode_t mode;
kuid_t uid;
@@ -2764,7 +2764,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
int used, wanted, dirty;
u64 size = le64_to_cpu(grant->size);
u64 max_size = le64_to_cpu(grant->max_size);
-   struct timespec mtime, atime, ctime;
+   struct vfs_time mtime, atime, ctime;
int check_caps = 0;
bool wake = false;
bool writeback = false;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index fd11fb2..83e6602 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1210,7 +1210,7 @@ static ssize_t ceph_read_dir(struct file *file, char 
__user *buf, size_t size,
" rfiles:   %20lld\n"
" rsubdirs: %20lld\n"
"rbytes:%20lld\n"
-   "rctime:%10ld.%09ld\n",
+   "rctime:%10lld.%09ld\n",
ci->i_files + ci->i_subdirs,
ci->i_files,
ci->i_subdirs,
@@ -1218,7 +1218,7 @@ static ssize_t ceph_read_dir(struct file *file, char 
__user *buf, size_t size,
ci->i_rfiles,
ci->i_rsubdirs,
ci->i_rbytes,
-   (long)ci->i_rctime.tv_sec,
+   (long long)ci->i_rctime.tv_sec,
(long)ci->i_rctime.tv_nsec);
}
 
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 9b338ff..c8a6f0d 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -555,7 +555,7 @@ struct ceph_aio_request {
struct list_head osd_reqs;
unsigned num_reqs;
atomic_t pending_reqs;
-   struct timespec mtime;
+   struct vfs_time mtime;
struct ceph_cap_flush *prealloc_cf;
 };
 
@@ -783,7 +783,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter 
*iter,
int num_pages = 0;
int flags;
int ret;
-   struct timespec mtime = current_fs_time(inode->i_sb);
+   struct vfs_time mtime = current_fs_time(inode->i_sb);
size_t count = iov_iter_count(iter);
loff_t pos = iocb->ki_pos;
bool write = iov_iter_rw(iter) == WRITE;
@@ -988,7 +988,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, 
loff_t pos,
int flags;
int check_caps = 0;
int ret;
-   struct timespec mtime = current_fs_time(inode->i_sb);
+   struct vfs_time mtime = current_fs_time(inode->i_sb);
size_t count = iov_iter_count(from);
 
if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 6

[Y2038] [RFC v2a 07/12] fs: btrfs: Use vfs_time data type for btrfs_update_time()

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use vfs_time aliases here to access inode times.

This is set as a vfs callback function for inode operations.
This accepts inode timestamp as an argument.
And, needs to switch to 64 bit time representation along with vfs.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 59c0e22..6f0417b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5942,7 +5942,7 @@ static int btrfs_dirty_inode(struct inode *inode)
  * This is a copy of file_update_time.  We need this so we can return error on
  * ENOSPC for updating the inode in the case of file write and mmap writes.
  */
-static int btrfs_update_time(struct inode *inode, struct timespec *now,
+static int btrfs_update_time(struct inode *inode, struct vfs_time *now,
 int flags)
 {
struct btrfs_root *root = BTRFS_I(inode)->root;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2a 08/12] fs: btrfs: Change timespec data types to use vfs_time

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use vfs_time aliases here to access inode times.
The following needs to switch along with vfs time
representation.

1. inode times set/get.
2. For inode times comparison.
3. getting times from current_fs_time()

btrfs_timespec already uses 64 bits to represent seconds in timestamps.
The switch to 64 bit using vfs_time will allow for timestamps beyond
2038 to be represented corretly.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/btrfs/file.c| 6 +++---
 fs/btrfs/ioctl.c   | 4 ++--
 fs/btrfs/root-tree.c   | 2 +-
 fs/btrfs/transaction.c | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 610f569..f7d1e14 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1732,16 +1732,16 @@ out:
 
 static void update_time_for_write(struct inode *inode)
 {
-   struct timespec now;
+   struct vfs_time now;
 
if (IS_NOCMTIME(inode))
return;
 
now = current_fs_time(inode->i_sb);
-   if (!timespec_equal(>i_mtime, ))
+   if (!vfs_time_equal(>i_mtime, ))
inode->i_mtime = now;
 
-   if (!timespec_equal(>i_ctime, ))
+   if (!vfs_time_equal(>i_ctime, ))
inode->i_ctime = now;
 
if (IS_I_VERSION(inode))
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6f35d9c..471037f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -443,7 +443,7 @@ static noinline int create_subvol(struct inode *dir,
struct btrfs_root *root = BTRFS_I(dir)->root;
struct btrfs_root *new_root;
struct btrfs_block_rsv block_rsv;
-   struct timespec cur_time = current_fs_time(dir->i_sb);
+   struct vfs_time cur_time = current_fs_time(dir->i_sb);
struct inode *inode;
int ret;
int err;
@@ -4956,7 +4956,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file 
*file,
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_root_item *root_item = >root_item;
struct btrfs_trans_handle *trans;
-   struct timespec ct = current_fs_time(inode->i_sb);
+   struct vfs_time ct = current_fs_time(inode->i_sb);
int ret = 0;
int received_uuid_changed;
 
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index a25f3b2..0a309f6b 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -488,7 +488,7 @@ void btrfs_update_root_times(struct btrfs_trans_handle 
*trans,
 struct btrfs_root *root)
 {
struct btrfs_root_item *item = >root_item;
-   struct timespec ct = current_fs_time(root->fs_info->sb);
+   struct vfs_time ct = current_fs_time(root->fs_info->sb);
 
spin_lock(>root_item_lock);
btrfs_set_root_ctransid(item, trans->transid);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 37562d6..5481ee0 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1333,7 +1333,7 @@ static noinline int create_pending_snapshot(struct 
btrfs_trans_handle *trans,
struct dentry *dentry;
struct extent_buffer *tmp;
struct extent_buffer *old;
-   struct timespec cur_time;
+   struct vfs_time cur_time;
int ret = 0;
u64 to_reserve = 0;
u64 index = 0;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2a 12/12] fs: xfs: change inode times to use vfs_time data type

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use vfs_time aliases here to access inode times.

vfs_time is an abstraction that hides the type of timestamps
across vfs. This is necessary because we want to change the
data types of vfs timestamps to support 64 bit times.

current_fs_time() will change along with vfs timestamp data
type changes.

xfs_vn_update_time() is a .update callback for inode operations
and this needs to change along with vfs inode times.

All the accesses to or from struct inode timestamps and
current_fs_time() are also changed to vfs_time.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/xfs/xfs_inode.c   | 2 +-
 fs/xfs/xfs_iops.c| 2 +-
 fs/xfs/xfs_trans_inode.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index ceba1a8..ebf76a3 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -765,7 +765,7 @@ xfs_ialloc(
xfs_inode_t *ip;
uintflags;
int error;
-   struct timespec tv;
+   struct vfs_time tv;
 
/*
 * Call the space management code to pick
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 76b71a1..7f8a897 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -973,7 +973,7 @@ xfs_vn_setattr(
 STATIC int
 xfs_vn_update_time(
struct inode*inode,
-   struct timespec *now,
+   struct vfs_time *now,
int flags)
 {
struct xfs_inode*ip = XFS_I(inode);
diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c
index b97f1df..54fc3c4 100644
--- a/fs/xfs/xfs_trans_inode.c
+++ b/fs/xfs/xfs_trans_inode.c
@@ -68,7 +68,7 @@ xfs_trans_ichgtime(
int flags)
 {
struct inode*inode = VFS_I(ip);
-   struct timespec tv;
+   struct vfs_time tv;
 
ASSERT(tp);
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
@@ -76,13 +76,13 @@ xfs_trans_ichgtime(
tv = current_fs_time(inode->i_sb);
 
if ((flags & XFS_ICHGTIME_MOD) &&
-   !timespec_equal(>i_mtime, )) {
+   !vfs_time_equal(>i_mtime, )) {
inode->i_mtime = tv;
ip->i_d.di_mtime.t_sec = tv.tv_sec;
ip->i_d.di_mtime.t_nsec = tv.tv_nsec;
}
if ((flags & XFS_ICHGTIME_CHG) &&
-   !timespec_equal(>i_ctime, )) {
+   !vfs_time_equal(>i_ctime, )) {
inode->i_ctime = tv;
ip->i_d.di_ctime.t_sec = tv.tv_sec;
ip->i_d.di_ctime.t_nsec = tv.tv_nsec;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2c 1/8] vfs: Add vfs_time abstractions

2016-02-12 Thread Deepa Dinamani
Add vfs_time accessors to help convert vfs timestamps to use
64 bit times. These create an abstraction layer so that
vfs inode times can be switched to struct timespec64 from
struct timespec without breaking the individual filesystems
after they have incorporated these.

Add vfs_time data type aliases to help convert vfs timestamps
to use 64 bit times. These create an abstraction layer so that
vfs inode times can be switched to struct timespec64 instead
of struct timespec.

Use uapi exposed data types, timespec and timespec64 here to keep
minimal timestamp data type conversions in API's interfacing with
vfs.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 include/linux/fs.h | 21 +
 1 file changed, 21 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4af612f..56e6373 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1412,6 +1412,27 @@ static inline struct timespec current_fs_time_sec(struct 
super_block *sb)
return (struct timespec) { get_seconds(), 0 };
 }
 
+/* Place holder defines until it is safe to use timespec64
+ * in the vfs layer.
+ * timespec64 data type and functions will be used at that
+ * time directly by all filesystems and these defines will be deleted.
+ */
+static inline struct timespec64 vfs_time_to_timespec64(struct timespec 
inode_ts)
+{
+   return timespec_to_timespec64(inode_ts);
+}
+
+static inline struct timespec timespec64_to_vfs_time(struct timespec64 ts)
+{
+   return timespec64_to_timespec(ts);
+}
+
+
+#define vfs_time timespec
+
+#define vfs_time_compare timespec_compare
+#define vfs_time_equal   timespec_equal
+
 /*
  * Snapshotting support.
  */
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2a 02/12] fs: cifs: Change cifs_fscache_inode_auxdata to use vfs_time data type

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use vfs_time aliases here to access inode times.

aux data timestamps are only used to read in inode timestamps.
Hence, they need to change data type along with vfs times.

struct timespec64 is the same as struct timespec on 64 bit systems.
So it is a no-op on 64 bit systems.

The buffer length(datalen) passed in to read in auxdata in
cifs_fscache_inode_get_aux() and cifs_fscache_inode_check_aux() should
be big enough for the data type change from struct timespec to
struct timespec64 to be safe on 32 bit systems.

Following provide support for safe usage on 32 bit systems:
1. datalen already accounts for struct timespec64 on 64 bit systems.
2. datalen passed in is a constant with sufficient space to accommodate
   auxdata.
3. The keylen subtracted from datalen is a constant and also leaves in
   sufficient space for increase.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/cifs/cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/cache.c b/fs/cifs/cache.c
index 6c665bf..f0892ac 100644
--- a/fs/cifs/cache.c
+++ b/fs/cifs/cache.c
@@ -221,8 +221,8 @@ const struct fscache_cookie_def 
cifs_fscache_super_index_def = {
  * Auxiliary data attached to CIFS inode within the cache
  */
 struct cifs_fscache_inode_auxdata {
-   struct timespec last_write_time;
-   struct timespec last_change_time;
+   struct vfs_time last_write_time;
+   struct vfs_time last_change_time;
u64 eof;
 };
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2a 00/12] vfs 64 bit time transition proposal

2016-02-12 Thread Deepa Dinamani
Introduction

The series is one of the proposals on how to transition VFS timestamps
to use 64 bit time. This is the inode_timespec idea proposed in the
original RFC series. The type name has been changed to vfs_time based
on Dave Chinner’s suggestion.

Solution

This series defines a new type name for vfs timestamps: vfs_time.
All the individual file systems will use struct vfs_time to access vfs
timestamps.  Current time APIs also return vfs times and are considered
to be part of vfs as they are exclusively used for inode timestamps.

These are the steps involved:

1.Define vfs_time as an alias to timespec
2.Change individual filesystems to use only vfs_time data type
  for timestamps.  Make sure each filesystem will be safe when
  converted to use timespec64
3.Change vfs_time to be an alias for timespec64.
4.Change all filesystems to use timespec64 directly.

Note that the series only includes patches for steps 1 and 2.

Concerns

1.Before the vfs layer is done, it might be confusing to developers
  as individual filesystems now will have two options for access:
  timespec and vfs_time type.

Deepa Dinamani (12):
  vfs: Add vfs_time abstractions
  fs: cifs: Change cifs_fscache_inode_auxdata to use vfs_time data type
  fs: cifs: Change cifs_fattr timestamps data type to vfs_time
  fs: cifs: Make cnvrtDosUnixTm() y2038 safe
  fs: cifs: Use vfs_time_get_real_* time functions
  fs: btrfs: Change btrfs_inode.i_otime to use vfs_time data type
  fs: btrfs: Use vfs_time data type for btrfs_update_time()
  fs: btrfs: Change timespec data types to use vfs_time
  fs: ceph: Change encode and decode functions to use vfs_time
  fs: ceph: Replace timespec data type with vfs_time
  net: ceph: use vfs_time data type instead of timespec
  fs: xfs: change inode times to use vfs_time data type

 fs/btrfs/btrfs_inode.h  |  2 +-
 fs/btrfs/file.c |  6 +++---
 fs/btrfs/inode.c|  2 +-
 fs/btrfs/ioctl.c|  4 ++--
 fs/btrfs/root-tree.c|  2 +-
 fs/btrfs/transaction.c  |  2 +-
 fs/ceph/cache.c |  2 +-
 fs/ceph/caps.c  |  6 +++---
 fs/ceph/dir.c   |  4 ++--
 fs/ceph/file.c  |  6 +++---
 fs/ceph/inode.c | 32 
 fs/ceph/mds_client.c|  2 +-
 fs/ceph/mds_client.h|  2 +-
 fs/ceph/super.h |  8 
 fs/ceph/xattr.c |  2 +-
 fs/cifs/cache.c |  4 ++--
 fs/cifs/cifsencrypt.c   |  4 ++--
 fs/cifs/cifsglob.h  |  6 +++---
 fs/cifs/cifsproto.h |  6 +++---
 fs/cifs/cifssmb.c   | 10 +-
 fs/cifs/inode.c |  2 +-
 fs/cifs/netmisc.c   | 15 ---
 fs/xfs/xfs_inode.c  |  2 +-
 fs/xfs/xfs_iops.c   |  2 +-
 fs/xfs/xfs_trans_inode.c|  6 +++---
 include/linux/ceph/decode.h | 11 ++-
 include/linux/ceph/messenger.h  |  1 +
 include/linux/ceph/osd_client.h |  4 ++--
 include/linux/fs.h  | 19 +++
 net/ceph/osd_client.c   |  2 +-
 30 files changed, 99 insertions(+), 77 deletions(-)

-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2] vfs 64 bit time transition proposals

2016-02-12 Thread Deepa Dinamani
Introduction

This is a follow on to the series: https://lkml.org/lkml/2016/1/7/20 [1].
This is aimed at reaching a consensus on how to transition the vfs
timestamps to use 64 bit time. This demonstrates three ways (2a, 2b and
2c) of solving this problem.  Each of the proposals has its own cover
letter that explains the individual approach.  Proposals 2b and 2c also
outline variant approaches which are similar to the respective proposals.
This drives the proposal count to 5.  All the changes have been discussed
with Arnd Bergmann, who posted the original series:
https://lkml.org/lkml/2014/5/30/669 [2]

The series has been simplified to include only the 64 bit timestamp
changes as per Dave Chinner’s suggestion.

Motivation

The problem is how to change the vfs inode timestamps to use 64 bit
times to overcome the 2038 problem.

Below table [3] gives an overview of the extent/ type of changes
needed of changes needed.
The series is aimed at obtaining small manageable patches for all
the cases in [3].

Table [3]
Terminology: vfs_time – data type of timestamps used in the vfs layer.
Access type 
# of instances

1. timespec_*(struct vfs_time, struct timespec) /   
34
   timespec_*(struct vfs_time, struct vfs_time)

2. struct vfs_time = struct vfs_time
50

3. vfs_time = current_fs_time/ CURRENT_TIME/ CURRENT_TIME_SEC   
312

4. setattr vfs_time assignments 
141

5. vfs_time = other data types, outside of setattr() (timespec, s32, s64..) 
74

6. other data types, outside of getattr() (timespec, s32, s64..) = vfs_time 
85

7. internal individual fs funtions using inode timestamps as args   
80

8. extra timestamp fields in individual filesystems 
~10

9. VFS callback - int (*update_time)(struct inode *, struct timespec *, int)
3   

10. VFS function - void lease_get_mtime(struct inode *inode, struct timespec 
*time) 3

Each series is used to demonstrate how each of the above cases is solved
using their respective approaches. The example filesystems (btrfs,
xfs, cifs, and ceph) were selected in such a way so as to showcase all
these issues in table [3].

Source Tree

The tree is hosted at github.com/deepa-hub/vfs.git 

The branches for the three approaches are

2a. https://github.com/deepa-hub/vfs.git refs/heads/vfs_time
2b. https://github.com/deepa-hub/vfs.git refs/heads/vfs_time_to_timespec
2c. https://github.com/deepa-hub/vfs.git refs/heads/vfs_time_to_ts64

All the above series are based off of:
https://lkml.org/lkml/2016/2/3/34 [4]
and a couple of other patches.

Only the minimal changes are posted here to keep the series simple.

There are a couple of bug fixes like data type conversion bugs that will
be sent directly to the corresponding filesystem lists.

Next steps

The approaches 2a, 2b and 2c are posted as responses to this cover letter.

Testing

All the approaches have been compile tested only.

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2c 7/8] fs: ceph: Use vfs timestamp abstraction helpers

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use timespec64 and conversion functions here to
access inode times.

All the timestamps are converted to use struct timespec64 data
type. And, all the vfs timestamps are converted to timespec64
at the boundary of vfs.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/ceph/addr.c  | 20 ++---
 fs/ceph/cache.c |  6 +--
 fs/ceph/caps.c  | 10 ++---
 fs/ceph/dir.c   |  4 +-
 fs/ceph/file.c  | 14 +--
 fs/ceph/inode.c | 91 +++--
 fs/ceph/mds_client.c|  9 ++--
 fs/ceph/mds_client.h|  2 +-
 fs/ceph/snap.c  |  6 +--
 fs/ceph/super.h |  9 ++--
 fs/ceph/xattr.c |  2 +-
 include/linux/ceph/decode.h |  9 ++--
 include/linux/ceph/osd_client.h |  4 +-
 net/ceph/osd_client.c   |  4 +-
 14 files changed, 110 insertions(+), 80 deletions(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index c222137..09a97b5 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -479,6 +479,7 @@ static int writepage_nounlock(struct page *page, struct 
writeback_control *wbc)
struct ceph_fs_client *fsc;
struct ceph_osd_client *osdc;
struct ceph_snap_context *snapc, *oldest;
+   struct timespec64 ts;
loff_t page_off = page_offset(page);
loff_t snap_size = -1;
long writeback_stat;
@@ -540,11 +541,12 @@ static int writepage_nounlock(struct page *page, struct 
writeback_control *wbc)
ceph_readpage_to_fscache(inode, page);
 
set_page_writeback(page);
+   ts = vfs_time_to_timespec64(inode->i_mtime);
err = ceph_osdc_writepages(osdc, ceph_vino(inode),
   >i_layout, snapc,
   page_off, len,
   truncate_seq, truncate_size,
-  >i_mtime, , 1);
+  , , 1);
if (err < 0) {
dout("writepage setting page/mapping error %d %p\n", err, page);
SetPageError(page);
@@ -699,6 +701,7 @@ static int ceph_writepages_start(struct address_space 
*mapping,
int rc = 0;
unsigned wsize = 1 << inode->i_blkbits;
struct ceph_osd_request *req = NULL;
+   struct timespec64 ts;
int do_sync = 0;
loff_t snap_size, i_size;
u64 truncate_size;
@@ -978,8 +981,9 @@ get_more_pages:
osd_req_op_extent_update(req, 0, len);
 
vino = ceph_vino(inode);
+   ts = vfs_time_to_timespec64(inode->i_mtime);
ceph_osdc_build_request(req, offset, snapc, vino.snap,
-   >i_mtime);
+   );
 
rc = ceph_osdc_start_request(>client->osdc, req, true);
BUG_ON(rc);
@@ -1465,6 +1469,7 @@ int ceph_uninline_data(struct file *filp, struct page 
*locked_page)
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
struct ceph_osd_request *req;
struct page *page = NULL;
+   struct timespec64 ts;
u64 len, inline_version;
int err = 0;
bool from_pagecache = false;
@@ -1528,7 +1533,8 @@ int ceph_uninline_data(struct file *filp, struct page 
*locked_page)
goto out;
}
 
-   ceph_osdc_build_request(req, 0, NULL, CEPH_NOSNAP, >i_mtime);
+   ts = vfs_time_to_timespec64(inode->i_mtime);
+   ceph_osdc_build_request(req, 0, NULL, CEPH_NOSNAP, );
err = ceph_osdc_start_request(>client->osdc, req, false);
if (!err)
err = ceph_osdc_wait_request(>client->osdc, req);
@@ -1572,7 +1578,7 @@ int ceph_uninline_data(struct file *filp, struct page 
*locked_page)
goto out_put;
}
 
-   ceph_osdc_build_request(req, 0, NULL, CEPH_NOSNAP, >i_mtime);
+   ceph_osdc_build_request(req, 0, NULL, CEPH_NOSNAP, );
err = ceph_osdc_start_request(>client->osdc, req, false);
if (!err)
err = ceph_osdc_wait_request(>client->osdc, req);
@@ -1622,6 +1628,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info 
*ci, u32 pool)
struct ceph_osd_request *rd_req = NULL, *wr_req = NULL;
struct rb_node **p, *parent;
struct ceph_pool_perm *perm;
+   struct timespec64 ts;
struct page **pages;
int err = 0, err2 = 0, have = 0;
 
@@ -1701,12 +1708,13 @@ static int __ceph_pool_perm_get(struct ceph_inode_info 
*ci, u32 pool)
 
osd_req_op_raw_data_in_pages(rd_req, 0, pages, PAGE_SIZE,
 

[Y2038] [RFC v2c 5/8] fs: btrfs: Change btrfs_inode.i_otime to vfs_time data type

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use timespec64 and conversion functions here to
access inode times.

struct btrfs_inode is the in memory inode structure for btrfs.
i_otime is a member of the btrfs_inode that represents file
creation times. Use struct timespec64 to represent this
timestamp.

Like all the other inode timestamps in struct inode, i_otime is
assigned to/ from disk or struct inode times or 0.

Hence, i_otime needs to use accessor functions to access inode
timestamps.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/btrfs/btrfs_inode.h | 2 +-
 fs/btrfs/inode.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 61205e3..5200e68 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -190,7 +190,7 @@ struct btrfs_inode {
struct btrfs_delayed_node *delayed_node;
 
/* File creation time. */
-   struct timespec i_otime;
+   struct timespec64 i_otime;
 
/* Hook into fs_info->delayed_iputs */
struct list_head delayed_iput;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 59c0e22..bcd223c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5592,7 +5592,7 @@ static struct inode *new_simple_dir(struct super_block *s,
inode->i_mtime = current_fs_time(inode->i_sb);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
-   BTRFS_I(inode)->i_otime = inode->i_mtime;
+   BTRFS_I(inode)->i_otime = vfs_time_to_timespec64(inode->i_mtime);
 
return inode;
 }
@@ -6164,7 +6164,7 @@ static struct inode *btrfs_new_inode(struct 
btrfs_trans_handle *trans,
inode->i_mtime = current_fs_time(inode->i_sb);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
-   BTRFS_I(inode)->i_otime = inode->i_mtime;
+   BTRFS_I(inode)->i_otime = vfs_time_to_timespec64(inode->i_mtime);
 
inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
  struct btrfs_inode_item);
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2c 3/8] fs: cifs: Change cifs_fattr timestamps data type to timespec64

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use timespec64 and conversion functions here to
access inode times.

This change is safe because cifs_fattr is accessed in following ways:

1. Assigning to/ from/ compared with struct inode timestamps,
   which will match vfs_time alias.
2. Assigned from cifs_NTtimeToUnix(). And, this function does not
   care about the data type sizes of tv_sec and tv_nsec fields.
3. Assigned from current_fs_time(), which will match vfs_time alias.
4. Assigned from cnvrtDosUnixTm(). And, this function does not
   care about the data type sizes of tv_sec and tv_nsec fields.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/cifs/cifsencrypt.c |  4 ++--
 fs/cifs/cifsglob.h|  6 +++---
 fs/cifs/cifsproto.h   |  6 +++---
 fs/cifs/cifssmb.c |  6 +++---
 fs/cifs/inode.c   | 35 ---
 fs/cifs/netmisc.c | 11 ++-
 6 files changed, 37 insertions(+), 31 deletions(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index f86e07d..2917d1d 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -460,7 +460,7 @@ find_timestamp(struct cifs_ses *ses)
unsigned char *blobptr;
unsigned char *blobend;
struct ntlmssp2_name *attrptr;
-   struct timespec ts;
+   struct timespec64 ts;
 
if (!ses->auth_key.len || !ses->auth_key.response)
return 0;
@@ -485,7 +485,7 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */
}
 
-   ktime_get_real_ts();
+   ktime_get_real_ts64();
return cpu_to_le64(cifs_UnixTimeToNT(ts));
 }
 
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index a25b251..7dfb0e2 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1393,9 +1393,9 @@ struct cifs_fattr {
dev_t   cf_rdev;
unsigned intcf_nlink;
unsigned intcf_dtype;
-   struct timespec cf_atime;
-   struct timespec cf_mtime;
-   struct timespec cf_ctime;
+   struct timespec64   cf_atime;
+   struct timespec64   cf_mtime;
+   struct timespec64   cf_ctime;
 };
 
 static inline void free_dfs_info_param(struct dfs_info3_param *param)
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index eed7ff5..2d78814 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -126,9 +126,9 @@ extern enum securityEnum select_sectype(struct 
TCP_Server_Info *server,
enum securityEnum requested);
 extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
  const struct nls_table *nls_cp);
-extern struct timespec cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
-extern u64 cifs_UnixTimeToNT(struct timespec);
-extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
+extern struct timespec64 cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
+extern u64 cifs_UnixTimeToNT(struct timespec64);
+extern struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
  int offset);
 extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
 extern int cifs_get_writer(struct cifsInodeInfo *cinode);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 1a9e43d..db268ff 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -478,8 +478,8 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, 
NEGOTIATE_RSP *pSMBr)
 * this requirement.
 */
int val, seconds, remain, result;
-   struct timespec ts;
-   unsigned long utc = get_seconds();
+   struct timespec64 ts;
+   unsigned long utc = ktime_get_real_seconds();
ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
rsp->SrvTime.Time, 0);
cifs_dbg(FYI, "SrvTime %d sec since 1970 (utc: %d) diff: %d\n",
@@ -4000,7 +4000,7 @@ QInfRetry:
if (rc) {
cifs_dbg(FYI, "Send error in QueryInfo = %d\n", rc);
} else if (data) {
-   struct timespec ts;
+   struct timespec64 ts;
__u32 time = le32_to_cpu(pSMBr->last_write_time);
 
/* decode response */
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index fa72359..1ead483 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -92,6 +92,7 @@ static void
 cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
 {
struct cifsInodeInfo *cifs_i = CIFS_I(inode);
+   struct timespec64 mtime;
 
cifs_dbg(FYI, "%s: revalidating inode %llu\n",
 __func__, cifs_i->uniqueid);
@@ -109,8 +110,9 @@ cifs_revalidat

[Y2038] [RFC v2c 2/8] fs: cifs: Change auxdata to struct timespec64 data type

2016-02-12 Thread Deepa Dinamani
Aux data timestamps are only used to read in inode timestamps for
fscache.

The VFS inode timestamps are not y2038 safe as they use struct timespec.
These will be changed to use struct timespec64 instead and that is y2038
safe. But, since the above data type conversion will break the end file
systems, use accessor functions to access inode times before the vfs
change.

Also convert the timestamp data types in the individual filesystems to
use y2038 safe struct timespec64.

The data type change from struct timespec to struct timespec64 is safe
because
1.Size of auxdata on 64 bit systems already accounts for struct timespec64.
2.Only auxdata length changes(increases) by a maximum of 128 bits
  (data type increase and alignment adjustments).
3.Everything else is the same size as before and possibly less big than on
  64 bit systems.
4.64 bit data is aligned on a 64 bit boundary even on 32 bit systems,
  making the alignment requirements also same as on 64 bit systems,
  except for i386 where alignment requirements pack the struct tighter.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/cifs/cache.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/cifs/cache.c b/fs/cifs/cache.c
index 6c665bf..713055b 100644
--- a/fs/cifs/cache.c
+++ b/fs/cifs/cache.c
@@ -221,8 +221,8 @@ const struct fscache_cookie_def 
cifs_fscache_super_index_def = {
  * Auxiliary data attached to CIFS inode within the cache
  */
 struct cifs_fscache_inode_auxdata {
-   struct timespec last_write_time;
-   struct timespec last_change_time;
+   struct timespec64   last_write_time;
+   struct timespec64   last_change_time;
u64 eof;
 };
 
@@ -259,8 +259,10 @@ cifs_fscache_inode_get_aux(const void *cookie_netfs_data, 
void *buffer,
 
memset(, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof;
-   auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-   auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+   auxdata.last_write_time =
+   vfs_time_to_timespec64(cifsi->vfs_inode.i_mtime);
+   auxdata.last_change_time =
+   vfs_time_to_timespec64(cifsi->vfs_inode.i_ctime);
 
if (maxbuf > sizeof(auxdata))
maxbuf = sizeof(auxdata);
@@ -283,8 +285,10 @@ fscache_checkaux cifs_fscache_inode_check_aux(void 
*cookie_netfs_data,
 
memset(, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof;
-   auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-   auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+   auxdata.last_write_time =
+   vfs_time_to_timespec64(cifsi->vfs_inode.i_mtime);
+   auxdata.last_change_time =
+   vfs_time_to_timespec64(cifsi->vfs_inode.i_ctime);
 
if (memcmp(data, , datalen) != 0)
return FSCACHE_CHECKAUX_OBSOLETE;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2c 4/8] fs: cifs: Make cnvrtDosUnixTm() y2038 safe

2016-02-12 Thread Deepa Dinamani
The seconds calculated from the server(DOS format)
cannot be saved in int data type as this cannot save
seconds since epoch after the year 2038.

Use long long for seconds field in cnvrtDosUnixTm(). This will
help represent 64 bit time even on 32 bit systems.

Note that even though the theoretical max on DOS times is 2107,
its api's only support until the year 2099. This means we can
get away with 32 bit unsigned sec field. But, the sec field uses
long long to maintain uniformity in the kernel, where everyone
uses the theoretical max.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/cifs/netmisc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index bf1b52e..ecbb7162 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -963,7 +963,8 @@ static const int total_days_of_prev_months[] = {
 struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
 {
struct timespec64 ts;
-   int sec, min, days, month, year;
+   long long sec;
+   int min, days, month, year;
u16 date = le16_to_cpu(le_date);
u16 time = le16_to_cpu(le_time);
SMB_TIME *st = (SMB_TIME *)
@@ -974,7 +975,7 @@ struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 
le_time, int offset)
sec = 2 * st->TwoSeconds;
min = st->Minutes;
if ((sec > 59) || (min > 59))
-   cifs_dbg(VFS, "illegal time min %d sec %d\n", min, sec);
+   cifs_dbg(VFS, "illegal time min %d sec %lld\n", min, sec);
sec += (min * 60);
sec += 60 * 60 * st->Hours;
if (st->Hours > 24)
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2c 6/8] fs: btrfs: Use vfs timestamp abstraction helper

2016-02-12 Thread Deepa Dinamani
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the end
file systems, use timespec64 and conversion functions here to
access inode times.

The following needs to switch along with vfs time
representation.

1. inode times set/get.
2. For inode times comparison.
3. getting times from current_fs_time().
4. btrfs_timespec already uses 64 bits to represent seconds in timestamps
   as 64 bits in btrfs_timespec.
5. btrfs_update_time() is a inode_ops callback.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
---
 fs/btrfs/file.c| 7 ---
 fs/btrfs/inode.c   | 2 +-
 fs/btrfs/ioctl.c   | 4 ++--
 fs/btrfs/root-tree.c   | 2 +-
 fs/btrfs/transaction.c | 2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 610f569..a5fb13c 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1732,16 +1732,17 @@ out:
 
 static void update_time_for_write(struct inode *inode)
 {
-   struct timespec now;
+   struct vfs_time now;
 
if (IS_NOCMTIME(inode))
return;
 
now = current_fs_time(inode->i_sb);
-   if (!timespec_equal(>i_mtime, ))
+
+   if (!vfs_time_equal(>i_mtime, ))
inode->i_mtime = now;
 
-   if (!timespec_equal(>i_ctime, ))
+   if (!vfs_time_equal(>i_ctime, ))
inode->i_ctime = now;
 
if (IS_I_VERSION(inode))
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index bcd223c..860e5e6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5942,7 +5942,7 @@ static int btrfs_dirty_inode(struct inode *inode)
  * This is a copy of file_update_time.  We need this so we can return error on
  * ENOSPC for updating the inode in the case of file write and mmap writes.
  */
-static int btrfs_update_time(struct inode *inode, struct timespec *now,
+static int btrfs_update_time(struct inode *inode, struct vfs_time *now,
 int flags)
 {
struct btrfs_root *root = BTRFS_I(inode)->root;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6f35d9c..471037f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -443,7 +443,7 @@ static noinline int create_subvol(struct inode *dir,
struct btrfs_root *root = BTRFS_I(dir)->root;
struct btrfs_root *new_root;
struct btrfs_block_rsv block_rsv;
-   struct timespec cur_time = current_fs_time(dir->i_sb);
+   struct vfs_time cur_time = current_fs_time(dir->i_sb);
struct inode *inode;
int ret;
int err;
@@ -4956,7 +4956,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file 
*file,
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_root_item *root_item = >root_item;
struct btrfs_trans_handle *trans;
-   struct timespec ct = current_fs_time(inode->i_sb);
+   struct vfs_time ct = current_fs_time(inode->i_sb);
int ret = 0;
int received_uuid_changed;
 
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index a25f3b2..0a309f6b 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -488,7 +488,7 @@ void btrfs_update_root_times(struct btrfs_trans_handle 
*trans,
 struct btrfs_root *root)
 {
struct btrfs_root_item *item = >root_item;
-   struct timespec ct = current_fs_time(root->fs_info->sb);
+   struct vfs_time ct = current_fs_time(root->fs_info->sb);
 
spin_lock(>root_item_lock);
btrfs_set_root_ctransid(item, trans->transid);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 37562d6..5481ee0 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1333,7 +1333,7 @@ static noinline int create_pending_snapshot(struct 
btrfs_trans_handle *trans,
struct dentry *dentry;
struct extent_buffer *tmp;
struct extent_buffer *old;
-   struct timespec cur_time;
+   struct vfs_time cur_time;
int ret = 0;
u64 to_reserve = 0;
u64 index = 0;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH 10/10] fs: btrfs: Replace CURRENT_TIME by current_fs_time()

2016-02-05 Thread Deepa Dinamani
The kernel tester found a dereferencing NULL pointer issue with this patch.

I think this is the fix:

--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -488,7 +488,7 @@ void btrfs_update_root_times(struct
btrfs_trans_handle *trans,
 struct btrfs_root *root)
 {
struct btrfs_root_item *item = >root_item;
-   struct timespec ct = current_fs_time(root->ino_cache_inode->i_sb);
+   struct timespec ct = current_fs_time(root->fs_info->sb);


I will test and re-post the patch.

-Deepa

On Thu, Feb 4, 2016 at 6:14 AM, David Sterba <dste...@suse.cz> wrote:
> On Tue, Feb 02, 2016 at 10:07:50PM -0800, Deepa Dinamani wrote:
>> CURRENT_TIME macro is not appropriate for filesystems as it
>> doesn't use the right granularity for filesystem timestamps.
>> Use current_fs_time() instead.
>>
>> Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
>> Cc: Chris Mason <c...@fb.com>
>> Cc: Josef Bacik <jba...@fb.com>
>> Cc: David Sterba <dste...@suse.com>
>> Cc: linux-bt...@vger.kernel.org
>
> Reviewed-by: David Sterba <dste...@suse.com>
>
> There's no actual change for btrfs as it uses granularity 1 which is a
> no-op and equivalent to CURRENT_TIME.
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2] vfs 64 bit time transition proposals

2016-02-13 Thread Deepa Dinamani
Changing a few things and accounting for false positives
(assuming worst case and rounding up for case 2a,
rounding down for 2b)

> * # Changes needed in 2a = row 1 + row 7 + row 8 + row 9 + row 10
> = 34 + 80 + 10 + 3 + 3 = 130
> * # Changes needed in 2b = row 1 + row 4 + row 5 + row 6 + row 7 * (~3)
> = 34 + 80 + 141 + 74 + 85 + 240 = 654
> * # Changes needed in 2c = Changes in 2b + some more

becomes

* # Changes needed in 2a = row 1 + row 4 + row 7 + row 8 + row 9 + row 10
= 34 + 80 + 141 + 10 + 3 + 3 = 271
* # Changes needed in 2b = row 1 + row 4 + row 5 + row 6 + row 7 * (~2)
= 34 + 141 + 74 + 85 + 160 = 494
* # Changes needed in 2c = Changes in 2b + some more

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [RFC v2] vfs 64 bit time transition proposals

2016-02-13 Thread Deepa Dinamani


Changing a few things, accounting for false positives
(assuming worst case and rounding up for case 2a,
rounding down for 2b)

> * # Changes needed in 2a = row 1 + row 7 + row 8 + row 9 + row 10
> = 34 + 80 + 10 + 3 + 3 = 130
> * # Changes needed in 2b = row 1 + row 4 + row 5 + row 6 + row 7 * (~3)
> = 34 + 80 + 141 + 74 + 85 + 240 = 654
> * # Changes needed in 2c = Changes in 2b + some more

becomes

* # Changes needed in 2a = row 1 + row 4 + row 7 + row 8 + row 9 + row 10
= 34 + 80 + 141 + 10 + 3 + 3 = 271
* # Changes needed in 2b = row 1 + row 4 + row 5 + row 6 + row 7 * (~2)
= 34 + 141 + 74 + 85 + 160 = 494
* # Changes needed in 2c = Changes in 2b + some more

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [RFC v2] vfs 64 bit time transition proposals

2016-02-12 Thread Deepa Dinamani
> Regarding the three versions, I think all of them are doable
> doable, and they all have their upsides and downsides but no
> showstoppers.

I agree that all the approaches are doable.

> Let me summarize what I see in the patches:
>
> 2a is the smallest set of changes in number of lines, as you indicated
>in the previous discussion (I was skeptical here initially, but
>you were right). The main downside is that each patch has to
>carefully consider what happens at the point when the type gets
>flipped, so that printk format strings are correct and assignments
>to local variables don't truncate the range. It also requires
>changing the types again after the VFS change, but that is
>something we can automate using coccinelle.

2c has the same downside as this.
It also has to carefully consider what happens when you switch end filesystems
to timespec64, be it for printks or assignments.
I would say that the effort to do this was the same for 2a and 2c.

And, 2c also needs to get rid of the abstraction macros when vfs is transitioned
to using timespec64.

> 2b has the main advantage of not changing behavior with the flip, so
>we can convert all file systems to use vfs_time relatively easily
>and then later make them actually use 64-bit timestamps with
>a patch that each file system developer can do for themselves.
>One downside is that it leads to rather ugly code as discussed
>before, examples are in "[RFC v2b 5/5] fs: xfs: change inode
>times to use vfs_time data type" and "[RFC v2b 3/5] fs: btrfs:
>Use vfs_time accessors".

Here is the breakup of the number of changes required from the table
in the cover letter(https://lkml.org/lkml/2016/2/12/76):

* # Changes needed in 2a = row 1 + row 7 + row 8 + row 9 + row 10
= 34 + 80 + 10 + 3 + 3 = 130
* # Changes needed in 2b = row 1 + row 4 + row 5 + row 6 + row 7 * (~3)
= 34 + 80 + 141 + 74 + 85 + 240 = 654
* # Changes needed in 2c = Changes in 2b + some more

It is clear to see from the above table that number of such changes will be
considerably more for approaches 2b and 2c.

And, 2b is not even close to what we want to achieve and will again confuse
developers even more as there will be 2 sets of abstraction apis now:
1. vfs_time apis
2. timespec64 to timespec/ timespec to timespec64 apis
Since there is no clean up effort here after vfs is switched over, we are just
making all filesystems that use these apis harder to read.

> 2c gets us the furthest along the way for the conversion, close
>to where we want to end up in the long run, so we could do that
>to file systems one by one. The behavior change is immediate,
>so there are fewer possible surprises than with 2a, but it
>also means the most upfront work.

2c abstractions can be used in more than one way.
And, 2c also introduces a new timestamp data type along with
timespec64 in the filesystem code.
The above two factors can make it confusing for the developers
until we transition vfs and remove abstractions from individual
filesystems. And, this is a problem as we want to remove
abstractions in a different kernel release than the one we do the
transition in, as we discussed previously.

2a still seems like the right choice to me.
And, will have the least number of changes.

As Arnd thinks all of them are doable, if anybody else has other
concerns we missed
please comment.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 00/10] Remove CURRENT_TIME and CURRENT_TIME_SEC - PART 1

2016-02-02 Thread Deepa Dinamani
Introduction

This patch series is aimed at getting rid of CURRENT_TIME and CURRENT_TIME_SEC
macros.

The idea for the series evolved from my discussions with Arnd Bergmann.

This was originally part of the RFC series[2]:
https://lkml.org/lkml/2016/1/7/20 (under discussion).

Dave Chinner suggested moving bug fixes out of the feature series to keep the
original series simple.

There are 354 occurrences of the the above macros in the kernel.
The series will be divided into 4 or 5 parts to keep the parts manageable
and so that each part could be reviewed and merged independently.
This is part 1 of the series. 

Motivation

The macros: CURRENT_TIME and CURRENT_TIME_SEC are primarily used for
filesystem timestamps.
But, they are not accurate as they do not perform clamping according to
filesystem timestamps ranges, nor do they truncate the nanoseconds value
to the granularity as required by the filesystem.

The series is also viewed as an ancillary to another upcoming series[2]
that attempts to transition file system timestamps to use 64 bit time to
make these y2038 safe.

There will also be another series[3] to add range checks and clamping to
filesystem time functions that are meant to substitute the above macros.

Solution

CURRENT_TIME macro has an equivalent function:

struct timespec current_fs_time(struct super_block *sb)

These will be the changes to the above function:
1. Function will return the type y2038 safe timespec64 in [2].
2. Function will use y2038 safe 64 bit functions in [2].
3. Function will be extended to perform range checks in [3].

A new function will be added to substitute for CURRENT_TIME_SEC macro
in the current series:

struct timespec current_fs_time_sec(void)

These will be the changes to the above function:
1. Function will return the type y2038 safe timespec64 in [2].
2. Function will use y2038 safe 64 bit functions in [2].
3. Function will be extended to perform range checks in [3].

Any use of these macros outside of filesystem timestamps will
be replaced by function calls to appropriate time functions.

Deepa Dinamani (10):
  fs: Add current_fs_time_sec() function
  vfs: Replace CURRENT_TIME by current_fs_time()
  fs: cifs: Replace CURRENT_TIME with current_fs_time()
  fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()
  fs: cifs: Replace CURRENT_TIME by get_seconds
  fs: ext4: Replace CURRENT_TIME_SEC with current_fs_time_sec()
  fs: ext4: Replace CURRENT_TIME with ext4_current_time()
  fs: ceph: replace CURRENT_TIME by current_fs_time()
  fs: ceph: Replace CURRENT_TIME by ktime_get_real_ts()
  fs: btrfs: Replace CURRENT_TIME by current_fs_time()

 fs/btrfs/file.c|  4 ++--
 fs/btrfs/inode.c   | 25 +
 fs/btrfs/ioctl.c   |  8 
 fs/btrfs/root-tree.c   |  2 +-
 fs/btrfs/transaction.c |  7 +--
 fs/btrfs/xattr.c   |  2 +-
 fs/ceph/file.c |  4 ++--
 fs/ceph/inode.c|  2 +-
 fs/ceph/mds_client.c   |  2 +-
 fs/ceph/xattr.c|  4 ++--
 fs/cifs/cifsencrypt.c  |  4 +++-
 fs/cifs/cifssmb.c  | 10 +-
 fs/cifs/inode.c| 15 +++
 fs/ext4/ext4.h |  2 +-
 fs/ext4/super.c|  2 +-
 fs/libfs.c | 21 +
 fs/nsfs.c  |  3 ++-
 fs/pipe.c  |  3 ++-
 fs/posix_acl.c |  2 +-
 include/linux/fs.h |  5 +
 20 files changed, 72 insertions(+), 55 deletions(-)

-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 01/10] fs: Add current_fs_time_sec() function

2016-02-02 Thread Deepa Dinamani
This is in preparation for the series that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

The function is meant to replace CURRENT_TIME_SEC macro.
The macro CURRENT_TIME_SEC does not represent filesystem times
correctly as it cannot perform range checks.
current_fs_time_sec() will be extended to include these.

CURRENT_TIME_SEC is also not y2038 safe. current_fs_time_sec()
will be transitioned to use 64 bit time along with vfs in a
separate series.

The function is inline for now to maintain similar performance
to that of the macro.

The function takes super block as a parameter to allow for
future range checking of filesystem timestamps.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Alexander Viro <v...@zeniv.linux.org.uk>
Cc: linux-fsde...@vger.kernel.org
---
 include/linux/fs.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6a75571..4af612f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1407,6 +1407,11 @@ struct super_block {
 
 extern struct timespec current_fs_time(struct super_block *sb);
 
+static inline struct timespec current_fs_time_sec(struct super_block *sb)
+{
+   return (struct timespec) { get_seconds(), 0 };
+}
+
 /*
  * Snapshotting support.
  */
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 04/10] fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()

2016-02-02 Thread Deepa Dinamani
This is in preparation for the series that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned series.

Filesystem times will use current_fs_time() instead of
CURRENT_TIME.
Use ktime_get_real_ts() here as this is not filesystem time.
ktime_get_real_ts() returns the timestamp in ns which can
be used to calculate network time for NTLMv2 authentication
timestamp.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Steve French <sfre...@samba.org>
Cc: linux-c...@vger.kernel.org
Cc: samba-techni...@lists.samba.org
---
 fs/cifs/cifsencrypt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index d411654..f86e07d 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -460,6 +460,7 @@ find_timestamp(struct cifs_ses *ses)
unsigned char *blobptr;
unsigned char *blobend;
struct ntlmssp2_name *attrptr;
+   struct timespec ts;
 
if (!ses->auth_key.len || !ses->auth_key.response)
return 0;
@@ -484,7 +485,8 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */
}
 
-   return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+   ktime_get_real_ts();
+   return cpu_to_le64(cifs_UnixTimeToNT(ts));
 }
 
 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 05/10] fs: cifs: Replace CURRENT_TIME by get_seconds

2016-02-02 Thread Deepa Dinamani
This is in preparation for the series that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned series.

Filesystems will use current_fs_time() instead of
CURRENT_TIME.
Use get_seconds() here as this is not filesystem time.
Only the seconds portion of the timestamp is necessary for
timezone calculation using server time.

Assume that the difference between server and client times
lie in the range INT_MIN..INT_MAX. This is valid because
this is the difference between current times between server
and client, and the largest timezone difference is in the
range of one day.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: Steve French <sfre...@samba.org>
Cc: linux-c...@vger.kernel.org
Cc: samba-techni...@lists.samba.org
---
 fs/cifs/cifssmb.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 90b4f9f..1a9e43d 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -478,14 +478,14 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, 
NEGOTIATE_RSP *pSMBr)
 * this requirement.
 */
int val, seconds, remain, result;
-   struct timespec ts, utc;
-   utc = CURRENT_TIME;
+   struct timespec ts;
+   unsigned long utc = get_seconds();
ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
rsp->SrvTime.Time, 0);
cifs_dbg(FYI, "SrvTime %d sec since 1970 (utc: %d) diff: %d\n",
-(int)ts.tv_sec, (int)utc.tv_sec,
-(int)(utc.tv_sec - ts.tv_sec));
-   val = (int)(utc.tv_sec - ts.tv_sec);
+(int)ts.tv_sec, (int)utc,
+(int)(utc - ts.tv_sec));
+   val = (int)(utc - ts.tv_sec);
seconds = abs(val);
result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
remain = seconds % MIN_TZ_ADJ;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 07/10] fs: ext4: Replace CURRENT_TIME with ext4_current_time()

2016-02-02 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use ext4_current_time() instead which is appropriate for ext4
timestamps.

Signed-off-by: Deepa Dinamani <deepa.ker...@gmail.com>
Cc: "Theodore Ts'o" <ty...@mit.edu>
Cc: Andreas Dilger <adilger.ker...@dilger.ca>
Cc: linux-e...@vger.kernel.org
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 3ed01ec..5e6c866 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5139,7 +5139,7 @@ static int ext4_quota_off(struct super_block *sb, int 
type)
handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
if (IS_ERR(handle))
goto out;
-   inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
ext4_mark_inode_dirty(handle, inode);
ext4_journal_stop(handle);
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


  1   2   3   4   5   6   7   >