32 bit systems using 'struct timeval' will break in the year 2038, so we modify the code appropriately.
This patch replaces the use of struct timeval and do_gettimeofday() with ktime_get_real_seconds() which returns a 64 bit value which is safer than struct timeval.
This patch also replaces u32 time storing variables with u64 variables to store the 64 bit seconds value returned by ktime_get_real_seconds()
Signed-off-by: Amitoj Kaur Chawla amitoj1606@gmail.com --- Changes in v2: -Converted u32 type to u64 type
drivers/scsi/bfa/bfa_fcpim.c | 2 +- drivers/scsi/bfa/bfa_fcpim.h | 4 ++-- drivers/scsi/bfa/bfad_bsg.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c index d7385d1..224db4e 100644 --- a/drivers/scsi/bfa/bfa_fcpim.c +++ b/drivers/scsi/bfa/bfa_fcpim.c @@ -468,7 +468,7 @@ bfa_ioim_profile_start(struct bfa_ioim_s *ioim) }
bfa_status_t -bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time) +bfa_fcpim_profile_on(struct bfa_s *bfa, u64 time) { struct bfa_itnim_s *itnim; struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa); diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h index e693af6..274e3af 100644 --- a/drivers/scsi/bfa/bfa_fcpim.h +++ b/drivers/scsi/bfa/bfa_fcpim.h @@ -135,7 +135,7 @@ struct bfa_fcpim_s { struct bfa_fcpim_del_itn_stats_s del_itn_stats; bfa_boolean_t ioredirect; bfa_boolean_t io_profile; - u32 io_profile_start_time; + u64 io_profile_start_time; bfa_fcpim_profile_t profile_comp; bfa_fcpim_profile_t profile_start; }; @@ -309,7 +309,7 @@ bfa_status_t bfa_fcpim_port_iostats(struct bfa_s *bfa, struct bfa_itnim_iostats_s *stats, u8 lp_tag); void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats, struct bfa_itnim_iostats_s *itnim_stats); -bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time); +bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, u64 time); bfa_status_t bfa_fcpim_profile_off(struct bfa_s *bfa);
#define bfa_fcpim_ioredirect_enabled(__bfa) \ diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c index 023b9d4..92f5b0f 100644 --- a/drivers/scsi/bfa/bfad_bsg.c +++ b/drivers/scsi/bfa/bfad_bsg.c @@ -15,6 +15,7 @@ * General Public License for more details. */
+#include <linux/ktime.h> #include <linux/uaccess.h> #include "bfad_drv.h" #include "bfad_im.h" @@ -2093,13 +2094,12 @@ bfad_iocmd_fcpim_cfg_profile(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) { struct bfa_bsg_fcpim_profile_s *iocmd = (struct bfa_bsg_fcpim_profile_s *)cmd; - struct timeval tv; unsigned long flags;
- do_gettimeofday(&tv); spin_lock_irqsave(&bfad->bfad_lock, flags); if (v_cmd == IOCMD_FCPIM_PROFILE_ON) - iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, tv.tv_sec); + iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, + ktime_get_real_seconds()); else if (v_cmd == IOCMD_FCPIM_PROFILE_OFF) iocmd->status = bfa_fcpim_profile_off(&bfad->bfa); spin_unlock_irqrestore(&bfad->bfad_lock, flags);
On Wednesday 04 November 2015 20:26:47 Amitoj Kaur Chawla wrote:
32 bit systems using 'struct timeval' will break in the year 2038, so we modify the code appropriately.
This patch replaces the use of struct timeval and do_gettimeofday() with ktime_get_real_seconds() which returns a 64 bit value which is safer than struct timeval.
This patch also replaces u32 time storing variables with u64 variables to store the 64 bit seconds value returned by ktime_get_real_seconds()
Signed-off-by: Amitoj Kaur Chawla amitoj1606@gmail.com
This version is better, but I think you missed the used of the variable:
#define bfa_io_profile_start_time(_bfa) \ ((_bfa)->modules.fcp_mod.fcpim.io_profile_start_time)
bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim, struct bfa_itnim_ioprofile_s *ioprofile) { ... itnim->ioprofile.io_profile_start_time = bfa_io_profile_start_time(itnim->bfa); ... }
so here it is assigned to another u32. Please try to find out if the ioprofile structure can be changed as well, and then either change it as well, or make document the place where the upper bits are lost, whichever is correct.
Arnd
On Fri, Nov 6, 2015 at 8:53 PM, Arnd Bergmann arnd@arndb.de wrote:
This version is better, but I think you missed the used of the variable:
#define bfa_io_profile_start_time(_bfa) \ ((_bfa)->modules.fcp_mod.fcpim.io_profile_start_time)
bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim, struct bfa_itnim_ioprofile_s *ioprofile) { ... itnim->ioprofile.io_profile_start_time = bfa_io_profile_start_time(itnim->bfa); ... }
so here it is assigned to another u32. Please try to find out if the ioprofile structure can be changed as well, and then either change it as well, or make document the place where the upper bits are lost, whichever is correct.
Arnd
Just to clarify since I'm a little confused here, io_profile_start_time is the u32 you are mentioning?
Because I made the change for that from u32 to u64 in this patch. And I changed the argument for bfa_io_profile_start_time from u32 to u64 as well.
So which u32 needs to be changed?
On Saturday 07 November 2015 00:36:26 Amitoj Kaur Chawla wrote:
On Fri, Nov 6, 2015 at 8:53 PM, Arnd Bergmann arnd@arndb.de wrote:
This version is better, but I think you missed the used of the variable:
#define bfa_io_profile_start_time(_bfa) \ ((_bfa)->modules.fcp_mod.fcpim.io_profile_start_time)
bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim, struct bfa_itnim_ioprofile_s *ioprofile) { ... itnim->ioprofile.io_profile_start_time = bfa_io_profile_start_time(itnim->bfa); ... }
so here it is assigned to another u32. Please try to find out if the ioprofile structure can be changed as well, and then either change it as well, or make document the place where the upper bits are lost, whichever is correct.
Arnd
Just to clarify since I'm a little confused here, io_profile_start_time is the u32 you are mentioning?
Because I made the change for that from u32 to u64 in this patch. And I changed the argument for bfa_io_profile_start_time from u32 to u64 as well.
So which u32 needs to be changed?
There are two structure members named "io_profile_start_time", one in bfa_itnim_s and one in bfa_itnim_ioprofile_s. You changed the former, but the code above assigned from that to the latter.
Arnd